echarts.js 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756
  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__(116);
  51. __webpack_require__(142);
  52. __webpack_require__(149);
  53. __webpack_require__(158);
  54. __webpack_require__(162);
  55. __webpack_require__(172);
  56. __webpack_require__(196);
  57. __webpack_require__(208);
  58. __webpack_require__(229);
  59. __webpack_require__(233);
  60. __webpack_require__(237);
  61. __webpack_require__(254);
  62. __webpack_require__(260);
  63. __webpack_require__(267);
  64. __webpack_require__(273);
  65. __webpack_require__(277);
  66. __webpack_require__(286);
  67. __webpack_require__(290);
  68. __webpack_require__(293);
  69. __webpack_require__(316);
  70. __webpack_require__(322);
  71. __webpack_require__(323);
  72. __webpack_require__(324);
  73. __webpack_require__(334);
  74. __webpack_require__(301);
  75. __webpack_require__(338);
  76. __webpack_require__(351);
  77. __webpack_require__(238);
  78. __webpack_require__(294);
  79. __webpack_require__(354);
  80. __webpack_require__(366);
  81. __webpack_require__(370);
  82. __webpack_require__(371);
  83. __webpack_require__(384);
  84. __webpack_require__(399);
  85. __webpack_require__(405);
  86. __webpack_require__(408);
  87. __webpack_require__(411);
  88. __webpack_require__(420);
  89. __webpack_require__(432);
  90. /***/ }),
  91. /* 1 */
  92. /***/ (function(module, exports, __webpack_require__) {
  93. // Enable DEV mode when using source code without build. which has no __DEV__ variable
  94. // In build process 'typeof __DEV__' will be replace with 'boolean'
  95. // So this code will be removed or disabled anyway after built.
  96. if (false) {
  97. // In browser
  98. if (typeof window !== 'undefined') {
  99. window.__DEV__ = true;
  100. }
  101. // In node
  102. else if (typeof global !== 'undefined') {
  103. global.__DEV__ = true;
  104. }
  105. }
  106. /*!
  107. * ECharts, a javascript interactive chart library.
  108. *
  109. * Copyright (c) 2015, Baidu Inc.
  110. * All rights reserved.
  111. *
  112. * LICENSE
  113. * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt
  114. */
  115. /**
  116. * @module echarts
  117. */
  118. var env = __webpack_require__(2);
  119. var GlobalModel = __webpack_require__(3);
  120. var ExtensionAPI = __webpack_require__(78);
  121. var CoordinateSystemManager = __webpack_require__(79);
  122. var OptionManager = __webpack_require__(80);
  123. var backwardCompat = __webpack_require__(81);
  124. var ComponentModel = __webpack_require__(72);
  125. var SeriesModel = __webpack_require__(83);
  126. var ComponentView = __webpack_require__(84);
  127. var ChartView = __webpack_require__(85);
  128. var graphic = __webpack_require__(20);
  129. var modelUtil = __webpack_require__(5);
  130. var throttle = __webpack_require__(86);
  131. var zrender = __webpack_require__(87);
  132. var zrUtil = __webpack_require__(4);
  133. var colorTool = __webpack_require__(33);
  134. var Eventful = __webpack_require__(27);
  135. var timsort = __webpack_require__(91);
  136. var each = zrUtil.each;
  137. var parseClassType = ComponentModel.parseClassType;
  138. var PRIORITY_PROCESSOR_FILTER = 1000;
  139. var PRIORITY_PROCESSOR_STATISTIC = 5000;
  140. var PRIORITY_VISUAL_LAYOUT = 1000;
  141. var PRIORITY_VISUAL_GLOBAL = 2000;
  142. var PRIORITY_VISUAL_CHART = 3000;
  143. var PRIORITY_VISUAL_COMPONENT = 4000;
  144. // FIXME
  145. // necessary?
  146. var PRIORITY_VISUAL_BRUSH = 5000;
  147. // Main process have three entries: `setOption`, `dispatchAction` and `resize`,
  148. // where they must not be invoked nestedly, except the only case: invoke
  149. // dispatchAction with updateMethod "none" in main process.
  150. // This flag is used to carry out this rule.
  151. // All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]).
  152. var IN_MAIN_PROCESS = '__flagInMainProcess';
  153. var HAS_GRADIENT_OR_PATTERN_BG = '__hasGradientOrPatternBg';
  154. var OPTION_UPDATED = '__optionUpdated';
  155. var ACTION_REG = /^[a-zA-Z0-9_]+$/;
  156. function createRegisterEventWithLowercaseName(method) {
  157. return function (eventName, handler, context) {
  158. // Event name is all lowercase
  159. eventName = eventName && eventName.toLowerCase();
  160. Eventful.prototype[method].call(this, eventName, handler, context);
  161. };
  162. }
  163. /**
  164. * @module echarts~MessageCenter
  165. */
  166. function MessageCenter() {
  167. Eventful.call(this);
  168. }
  169. MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on');
  170. MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off');
  171. MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one');
  172. zrUtil.mixin(MessageCenter, Eventful);
  173. /**
  174. * @module echarts~ECharts
  175. */
  176. function ECharts(dom, theme, opts) {
  177. opts = opts || {};
  178. // Get theme by name
  179. if (typeof theme === 'string') {
  180. theme = themeStorage[theme];
  181. }
  182. /**
  183. * @type {string}
  184. */
  185. this.id;
  186. /**
  187. * Group id
  188. * @type {string}
  189. */
  190. this.group;
  191. /**
  192. * @type {HTMLElement}
  193. * @private
  194. */
  195. this._dom = dom;
  196. /**
  197. * @type {module:zrender/ZRender}
  198. * @private
  199. */
  200. var zr = this._zr = zrender.init(dom, {
  201. renderer: opts.renderer || 'canvas',
  202. devicePixelRatio: opts.devicePixelRatio,
  203. width: opts.width,
  204. height: opts.height
  205. });
  206. /**
  207. * Expect 60 pfs.
  208. * @type {Function}
  209. * @private
  210. */
  211. this._throttledZrFlush = throttle.throttle(zrUtil.bind(zr.flush, zr), 17);
  212. var theme = zrUtil.clone(theme);
  213. theme && backwardCompat(theme, true);
  214. /**
  215. * @type {Object}
  216. * @private
  217. */
  218. this._theme = theme;
  219. /**
  220. * @type {Array.<module:echarts/view/Chart>}
  221. * @private
  222. */
  223. this._chartsViews = [];
  224. /**
  225. * @type {Object.<string, module:echarts/view/Chart>}
  226. * @private
  227. */
  228. this._chartsMap = {};
  229. /**
  230. * @type {Array.<module:echarts/view/Component>}
  231. * @private
  232. */
  233. this._componentsViews = [];
  234. /**
  235. * @type {Object.<string, module:echarts/view/Component>}
  236. * @private
  237. */
  238. this._componentsMap = {};
  239. /**
  240. * @type {module:echarts/CoordinateSystem}
  241. * @private
  242. */
  243. this._coordSysMgr = new CoordinateSystemManager();
  244. /**
  245. * @type {module:echarts/ExtensionAPI}
  246. * @private
  247. */
  248. this._api = createExtensionAPI(this);
  249. Eventful.call(this);
  250. /**
  251. * @type {module:echarts~MessageCenter}
  252. * @private
  253. */
  254. this._messageCenter = new MessageCenter();
  255. // Init mouse events
  256. this._initEvents();
  257. // In case some people write `window.onresize = chart.resize`
  258. this.resize = zrUtil.bind(this.resize, this);
  259. // Can't dispatch action during rendering procedure
  260. this._pendingActions = [];
  261. // Sort on demand
  262. function prioritySortFunc(a, b) {
  263. return a.prio - b.prio;
  264. }
  265. timsort(visualFuncs, prioritySortFunc);
  266. timsort(dataProcessorFuncs, prioritySortFunc);
  267. zr.animation.on('frame', this._onframe, this);
  268. // ECharts instance can be used as value.
  269. zrUtil.setAsPrimitive(this);
  270. }
  271. var echartsProto = ECharts.prototype;
  272. echartsProto._onframe = function () {
  273. // Lazy update
  274. if (this[OPTION_UPDATED]) {
  275. var silent = this[OPTION_UPDATED].silent;
  276. this[IN_MAIN_PROCESS] = true;
  277. updateMethods.prepareAndUpdate.call(this);
  278. this[IN_MAIN_PROCESS] = false;
  279. this[OPTION_UPDATED] = false;
  280. flushPendingActions.call(this, silent);
  281. triggerUpdatedEvent.call(this, silent);
  282. }
  283. };
  284. /**
  285. * @return {HTMLElement}
  286. */
  287. echartsProto.getDom = function () {
  288. return this._dom;
  289. };
  290. /**
  291. * @return {module:zrender~ZRender}
  292. */
  293. echartsProto.getZr = function () {
  294. return this._zr;
  295. };
  296. /**
  297. * Usage:
  298. * chart.setOption(option, notMerge, lazyUpdate);
  299. * chart.setOption(option, {
  300. * notMerge: ...,
  301. * lazyUpdate: ...,
  302. * silent: ...
  303. * });
  304. *
  305. * @param {Object} option
  306. * @param {Object|boolean} [opts] opts or notMerge.
  307. * @param {boolean} [opts.notMerge=false]
  308. * @param {boolean} [opts.lazyUpdate=false] Useful when setOption frequently.
  309. */
  310. echartsProto.setOption = function (option, notMerge, lazyUpdate) {
  311. if (true) {
  312. zrUtil.assert(!this[IN_MAIN_PROCESS], '`setOption` should not be called during main process.');
  313. }
  314. var silent;
  315. if (zrUtil.isObject(notMerge)) {
  316. lazyUpdate = notMerge.lazyUpdate;
  317. silent = notMerge.silent;
  318. notMerge = notMerge.notMerge;
  319. }
  320. this[IN_MAIN_PROCESS] = true;
  321. if (!this._model || notMerge) {
  322. var optionManager = new OptionManager(this._api);
  323. var theme = this._theme;
  324. var ecModel = this._model = new GlobalModel(null, null, theme, optionManager);
  325. ecModel.init(null, null, theme, optionManager);
  326. }
  327. this._model.setOption(option, optionPreprocessorFuncs);
  328. if (lazyUpdate) {
  329. this[OPTION_UPDATED] = {silent: silent};
  330. this[IN_MAIN_PROCESS] = false;
  331. }
  332. else {
  333. updateMethods.prepareAndUpdate.call(this);
  334. // Ensure zr refresh sychronously, and then pixel in canvas can be
  335. // fetched after `setOption`.
  336. this._zr.flush();
  337. this[OPTION_UPDATED] = false;
  338. this[IN_MAIN_PROCESS] = false;
  339. flushPendingActions.call(this, silent);
  340. triggerUpdatedEvent.call(this, silent);
  341. }
  342. };
  343. /**
  344. * @DEPRECATED
  345. */
  346. echartsProto.setTheme = function () {
  347. console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0');
  348. };
  349. /**
  350. * @return {module:echarts/model/Global}
  351. */
  352. echartsProto.getModel = function () {
  353. return this._model;
  354. };
  355. /**
  356. * @return {Object}
  357. */
  358. echartsProto.getOption = function () {
  359. return this._model && this._model.getOption();
  360. };
  361. /**
  362. * @return {number}
  363. */
  364. echartsProto.getWidth = function () {
  365. return this._zr.getWidth();
  366. };
  367. /**
  368. * @return {number}
  369. */
  370. echartsProto.getHeight = function () {
  371. return this._zr.getHeight();
  372. };
  373. /**
  374. * @return {number}
  375. */
  376. echartsProto.getDevicePixelRatio = function () {
  377. return this._zr.painter.dpr || window.devicePixelRatio || 1;
  378. };
  379. /**
  380. * Get canvas which has all thing rendered
  381. * @param {Object} opts
  382. * @param {string} [opts.backgroundColor]
  383. */
  384. echartsProto.getRenderedCanvas = function (opts) {
  385. if (!env.canvasSupported) {
  386. return;
  387. }
  388. opts = opts || {};
  389. opts.pixelRatio = opts.pixelRatio || 1;
  390. opts.backgroundColor = opts.backgroundColor
  391. || this._model.get('backgroundColor');
  392. var zr = this._zr;
  393. var list = zr.storage.getDisplayList();
  394. // Stop animations
  395. zrUtil.each(list, function (el) {
  396. el.stopAnimation(true);
  397. });
  398. return zr.painter.getRenderedCanvas(opts);
  399. };
  400. /**
  401. * @return {string}
  402. * @param {Object} opts
  403. * @param {string} [opts.type='png']
  404. * @param {string} [opts.pixelRatio=1]
  405. * @param {string} [opts.backgroundColor]
  406. * @param {string} [opts.excludeComponents]
  407. */
  408. echartsProto.getDataURL = function (opts) {
  409. opts = opts || {};
  410. var excludeComponents = opts.excludeComponents;
  411. var ecModel = this._model;
  412. var excludesComponentViews = [];
  413. var self = this;
  414. each(excludeComponents, function (componentType) {
  415. ecModel.eachComponent({
  416. mainType: componentType
  417. }, function (component) {
  418. var view = self._componentsMap[component.__viewId];
  419. if (!view.group.ignore) {
  420. excludesComponentViews.push(view);
  421. view.group.ignore = true;
  422. }
  423. });
  424. });
  425. var url = this.getRenderedCanvas(opts).toDataURL(
  426. 'image/' + (opts && opts.type || 'png')
  427. );
  428. each(excludesComponentViews, function (view) {
  429. view.group.ignore = false;
  430. });
  431. return url;
  432. };
  433. /**
  434. * @return {string}
  435. * @param {Object} opts
  436. * @param {string} [opts.type='png']
  437. * @param {string} [opts.pixelRatio=1]
  438. * @param {string} [opts.backgroundColor]
  439. */
  440. echartsProto.getConnectedDataURL = function (opts) {
  441. if (!env.canvasSupported) {
  442. return;
  443. }
  444. var groupId = this.group;
  445. var mathMin = Math.min;
  446. var mathMax = Math.max;
  447. var MAX_NUMBER = Infinity;
  448. if (connectedGroups[groupId]) {
  449. var left = MAX_NUMBER;
  450. var top = MAX_NUMBER;
  451. var right = -MAX_NUMBER;
  452. var bottom = -MAX_NUMBER;
  453. var canvasList = [];
  454. var dpr = (opts && opts.pixelRatio) || 1;
  455. zrUtil.each(instances, function (chart, id) {
  456. if (chart.group === groupId) {
  457. var canvas = chart.getRenderedCanvas(
  458. zrUtil.clone(opts)
  459. );
  460. var boundingRect = chart.getDom().getBoundingClientRect();
  461. left = mathMin(boundingRect.left, left);
  462. top = mathMin(boundingRect.top, top);
  463. right = mathMax(boundingRect.right, right);
  464. bottom = mathMax(boundingRect.bottom, bottom);
  465. canvasList.push({
  466. dom: canvas,
  467. left: boundingRect.left,
  468. top: boundingRect.top
  469. });
  470. }
  471. });
  472. left *= dpr;
  473. top *= dpr;
  474. right *= dpr;
  475. bottom *= dpr;
  476. var width = right - left;
  477. var height = bottom - top;
  478. var targetCanvas = zrUtil.createCanvas();
  479. targetCanvas.width = width;
  480. targetCanvas.height = height;
  481. var zr = zrender.init(targetCanvas);
  482. each(canvasList, function (item) {
  483. var img = new graphic.Image({
  484. style: {
  485. x: item.left * dpr - left,
  486. y: item.top * dpr - top,
  487. image: item.dom
  488. }
  489. });
  490. zr.add(img);
  491. });
  492. zr.refreshImmediately();
  493. return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));
  494. }
  495. else {
  496. return this.getDataURL(opts);
  497. }
  498. };
  499. /**
  500. * Convert from logical coordinate system to pixel coordinate system.
  501. * See CoordinateSystem#convertToPixel.
  502. * @param {string|Object} finder
  503. * If string, e.g., 'geo', means {geoIndex: 0}.
  504. * If Object, could contain some of these properties below:
  505. * {
  506. * seriesIndex / seriesId / seriesName,
  507. * geoIndex / geoId, geoName,
  508. * bmapIndex / bmapId / bmapName,
  509. * xAxisIndex / xAxisId / xAxisName,
  510. * yAxisIndex / yAxisId / yAxisName,
  511. * gridIndex / gridId / gridName,
  512. * ... (can be extended)
  513. * }
  514. * @param {Array|number} value
  515. * @return {Array|number} result
  516. */
  517. echartsProto.convertToPixel = zrUtil.curry(doConvertPixel, 'convertToPixel');
  518. /**
  519. * Convert from pixel coordinate system to logical coordinate system.
  520. * See CoordinateSystem#convertFromPixel.
  521. * @param {string|Object} finder
  522. * If string, e.g., 'geo', means {geoIndex: 0}.
  523. * If Object, could contain some of these properties below:
  524. * {
  525. * seriesIndex / seriesId / seriesName,
  526. * geoIndex / geoId / geoName,
  527. * bmapIndex / bmapId / bmapName,
  528. * xAxisIndex / xAxisId / xAxisName,
  529. * yAxisIndex / yAxisId / yAxisName
  530. * gridIndex / gridId / gridName,
  531. * ... (can be extended)
  532. * }
  533. * @param {Array|number} value
  534. * @return {Array|number} result
  535. */
  536. echartsProto.convertFromPixel = zrUtil.curry(doConvertPixel, 'convertFromPixel');
  537. function doConvertPixel(methodName, finder, value) {
  538. var ecModel = this._model;
  539. var coordSysList = this._coordSysMgr.getCoordinateSystems();
  540. var result;
  541. finder = modelUtil.parseFinder(ecModel, finder);
  542. for (var i = 0; i < coordSysList.length; i++) {
  543. var coordSys = coordSysList[i];
  544. if (coordSys[methodName]
  545. && (result = coordSys[methodName](ecModel, finder, value)) != null
  546. ) {
  547. return result;
  548. }
  549. }
  550. if (true) {
  551. console.warn(
  552. 'No coordinate system that supports ' + methodName + ' found by the given finder.'
  553. );
  554. }
  555. }
  556. /**
  557. * Is the specified coordinate systems or components contain the given pixel point.
  558. * @param {string|Object} finder
  559. * If string, e.g., 'geo', means {geoIndex: 0}.
  560. * If Object, could contain some of these properties below:
  561. * {
  562. * seriesIndex / seriesId / seriesName,
  563. * geoIndex / geoId / geoName,
  564. * bmapIndex / bmapId / bmapName,
  565. * xAxisIndex / xAxisId / xAxisName,
  566. * yAxisIndex / yAxisId / yAxisName,
  567. * gridIndex / gridId / gridName,
  568. * ... (can be extended)
  569. * }
  570. * @param {Array|number} value
  571. * @return {boolean} result
  572. */
  573. echartsProto.containPixel = function (finder, value) {
  574. var ecModel = this._model;
  575. var result;
  576. finder = modelUtil.parseFinder(ecModel, finder);
  577. zrUtil.each(finder, function (models, key) {
  578. key.indexOf('Models') >= 0 && zrUtil.each(models, function (model) {
  579. var coordSys = model.coordinateSystem;
  580. if (coordSys && coordSys.containPoint) {
  581. result |= !!coordSys.containPoint(value);
  582. }
  583. else if (key === 'seriesModels') {
  584. var view = this._chartsMap[model.__viewId];
  585. if (view && view.containPoint) {
  586. result |= view.containPoint(value, model);
  587. }
  588. else {
  589. if (true) {
  590. console.warn(key + ': ' + (view
  591. ? 'The found component do not support containPoint.'
  592. : 'No view mapping to the found component.'
  593. ));
  594. }
  595. }
  596. }
  597. else {
  598. if (true) {
  599. console.warn(key + ': containPoint is not supported');
  600. }
  601. }
  602. }, this);
  603. }, this);
  604. return !!result;
  605. };
  606. /**
  607. * Get visual from series or data.
  608. * @param {string|Object} finder
  609. * If string, e.g., 'series', means {seriesIndex: 0}.
  610. * If Object, could contain some of these properties below:
  611. * {
  612. * seriesIndex / seriesId / seriesName,
  613. * dataIndex / dataIndexInside
  614. * }
  615. * If dataIndex is not specified, series visual will be fetched,
  616. * but not data item visual.
  617. * If all of seriesIndex, seriesId, seriesName are not specified,
  618. * visual will be fetched from first series.
  619. * @param {string} visualType 'color', 'symbol', 'symbolSize'
  620. */
  621. echartsProto.getVisual = function (finder, visualType) {
  622. var ecModel = this._model;
  623. finder = modelUtil.parseFinder(ecModel, finder, {defaultMainType: 'series'});
  624. var seriesModel = finder.seriesModel;
  625. if (true) {
  626. if (!seriesModel) {
  627. console.warn('There is no specified seires model');
  628. }
  629. }
  630. var data = seriesModel.getData();
  631. var dataIndexInside = finder.hasOwnProperty('dataIndexInside')
  632. ? finder.dataIndexInside
  633. : finder.hasOwnProperty('dataIndex')
  634. ? data.indexOfRawIndex(finder.dataIndex)
  635. : null;
  636. return dataIndexInside != null
  637. ? data.getItemVisual(dataIndexInside, visualType)
  638. : data.getVisual(visualType);
  639. };
  640. /**
  641. * Get view of corresponding component model
  642. * @param {module:echarts/model/Component} componentModel
  643. * @return {module:echarts/view/Component}
  644. */
  645. echartsProto.getViewOfComponentModel = function (componentModel) {
  646. return this._componentsMap[componentModel.__viewId];
  647. };
  648. /**
  649. * Get view of corresponding series model
  650. * @param {module:echarts/model/Series} seriesModel
  651. * @return {module:echarts/view/Chart}
  652. */
  653. echartsProto.getViewOfSeriesModel = function (seriesModel) {
  654. return this._chartsMap[seriesModel.__viewId];
  655. };
  656. var updateMethods = {
  657. /**
  658. * @param {Object} payload
  659. * @private
  660. */
  661. update: function (payload) {
  662. // console.profile && console.profile('update');
  663. var ecModel = this._model;
  664. var api = this._api;
  665. var coordSysMgr = this._coordSysMgr;
  666. var zr = this._zr;
  667. // update before setOption
  668. if (!ecModel) {
  669. return;
  670. }
  671. // Fixme First time update ?
  672. ecModel.restoreData();
  673. // TODO
  674. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  675. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  676. // Create new coordinate system each update
  677. // In LineView may save the old coordinate system and use it to get the orignal point
  678. coordSysMgr.create(this._model, this._api);
  679. processData.call(this, ecModel, api);
  680. stackSeriesData.call(this, ecModel);
  681. coordSysMgr.update(ecModel, api);
  682. doVisualEncoding.call(this, ecModel, payload);
  683. doRender.call(this, ecModel, payload);
  684. // Set background
  685. var backgroundColor = ecModel.get('backgroundColor') || 'transparent';
  686. var painter = zr.painter;
  687. // TODO all use clearColor ?
  688. if (painter.isSingleCanvas && painter.isSingleCanvas()) {
  689. zr.configLayer(0, {
  690. clearColor: backgroundColor
  691. });
  692. }
  693. else {
  694. // In IE8
  695. if (!env.canvasSupported) {
  696. var colorArr = colorTool.parse(backgroundColor);
  697. backgroundColor = colorTool.stringify(colorArr, 'rgb');
  698. if (colorArr[3] === 0) {
  699. backgroundColor = 'transparent';
  700. }
  701. }
  702. if (backgroundColor.colorStops || backgroundColor.image) {
  703. // Gradient background
  704. // FIXME Fixed layer?
  705. zr.configLayer(0, {
  706. clearColor: backgroundColor
  707. });
  708. this[HAS_GRADIENT_OR_PATTERN_BG] = true;
  709. this._dom.style.background = 'transparent';
  710. }
  711. else {
  712. if (this[HAS_GRADIENT_OR_PATTERN_BG]) {
  713. zr.configLayer(0, {
  714. clearColor: null
  715. });
  716. }
  717. this[HAS_GRADIENT_OR_PATTERN_BG] = false;
  718. this._dom.style.background = backgroundColor;
  719. }
  720. }
  721. each(postUpdateFuncs, function (func) {
  722. func(ecModel, api);
  723. });
  724. // console.profile && console.profileEnd('update');
  725. },
  726. /**
  727. * @param {Object} payload
  728. * @private
  729. */
  730. updateView: function (payload) {
  731. var ecModel = this._model;
  732. // update before setOption
  733. if (!ecModel) {
  734. return;
  735. }
  736. ecModel.eachSeries(function (seriesModel) {
  737. seriesModel.getData().clearAllVisual();
  738. });
  739. doVisualEncoding.call(this, ecModel, payload);
  740. invokeUpdateMethod.call(this, 'updateView', ecModel, payload);
  741. },
  742. /**
  743. * @param {Object} payload
  744. * @private
  745. */
  746. updateVisual: function (payload) {
  747. var ecModel = this._model;
  748. // update before setOption
  749. if (!ecModel) {
  750. return;
  751. }
  752. ecModel.eachSeries(function (seriesModel) {
  753. seriesModel.getData().clearAllVisual();
  754. });
  755. doVisualEncoding.call(this, ecModel, payload, true);
  756. invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload);
  757. },
  758. /**
  759. * @param {Object} payload
  760. * @private
  761. */
  762. updateLayout: function (payload) {
  763. var ecModel = this._model;
  764. // update before setOption
  765. if (!ecModel) {
  766. return;
  767. }
  768. doLayout.call(this, ecModel, payload);
  769. invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload);
  770. },
  771. /**
  772. * @param {Object} payload
  773. * @private
  774. */
  775. prepareAndUpdate: function (payload) {
  776. var ecModel = this._model;
  777. prepareView.call(this, 'component', ecModel);
  778. prepareView.call(this, 'chart', ecModel);
  779. updateMethods.update.call(this, payload);
  780. }
  781. };
  782. /**
  783. * @private
  784. */
  785. function updateDirectly(ecIns, method, payload, mainType, subType) {
  786. var ecModel = ecIns._model;
  787. // broadcast
  788. if (!mainType) {
  789. each(ecIns._componentsViews.concat(ecIns._chartsViews), callView);
  790. return;
  791. }
  792. var query = {};
  793. query[mainType + 'Id'] = payload[mainType + 'Id'];
  794. query[mainType + 'Index'] = payload[mainType + 'Index'];
  795. query[mainType + 'Name'] = payload[mainType + 'Name'];
  796. var condition = {mainType: mainType, query: query};
  797. subType && (condition.subType = subType); // subType may be '' by parseClassType;
  798. // If dispatchAction before setOption, do nothing.
  799. ecModel && ecModel.eachComponent(condition, function (model, index) {
  800. callView(ecIns[
  801. mainType === 'series' ? '_chartsMap' : '_componentsMap'
  802. ][model.__viewId]);
  803. }, ecIns);
  804. function callView(view) {
  805. view && view.__alive && view[method] && view[method](
  806. view.__model, ecModel, ecIns._api, payload
  807. );
  808. }
  809. }
  810. /**
  811. * Resize the chart
  812. * @param {Object} opts
  813. * @param {number} [opts.width] Can be 'auto' (the same as null/undefined)
  814. * @param {number} [opts.height] Can be 'auto' (the same as null/undefined)
  815. * @param {boolean} [opts.silent=false]
  816. */
  817. echartsProto.resize = function (opts) {
  818. if (true) {
  819. zrUtil.assert(!this[IN_MAIN_PROCESS], '`resize` should not be called during main process.');
  820. }
  821. this[IN_MAIN_PROCESS] = true;
  822. this._zr.resize(opts);
  823. var optionChanged = this._model && this._model.resetOption('media');
  824. var updateMethod = optionChanged ? 'prepareAndUpdate' : 'update';
  825. updateMethods[updateMethod].call(this);
  826. // Resize loading effect
  827. this._loadingFX && this._loadingFX.resize();
  828. this[IN_MAIN_PROCESS] = false;
  829. var silent = opts && opts.silent;
  830. flushPendingActions.call(this, silent);
  831. triggerUpdatedEvent.call(this, silent);
  832. };
  833. /**
  834. * Show loading effect
  835. * @param {string} [name='default']
  836. * @param {Object} [cfg]
  837. */
  838. echartsProto.showLoading = function (name, cfg) {
  839. if (zrUtil.isObject(name)) {
  840. cfg = name;
  841. name = '';
  842. }
  843. name = name || 'default';
  844. this.hideLoading();
  845. if (!loadingEffects[name]) {
  846. if (true) {
  847. console.warn('Loading effects ' + name + ' not exists.');
  848. }
  849. return;
  850. }
  851. var el = loadingEffects[name](this._api, cfg);
  852. var zr = this._zr;
  853. this._loadingFX = el;
  854. zr.add(el);
  855. };
  856. /**
  857. * Hide loading effect
  858. */
  859. echartsProto.hideLoading = function () {
  860. this._loadingFX && this._zr.remove(this._loadingFX);
  861. this._loadingFX = null;
  862. };
  863. /**
  864. * @param {Object} eventObj
  865. * @return {Object}
  866. */
  867. echartsProto.makeActionFromEvent = function (eventObj) {
  868. var payload = zrUtil.extend({}, eventObj);
  869. payload.type = eventActionMap[eventObj.type];
  870. return payload;
  871. };
  872. /**
  873. * @pubilc
  874. * @param {Object} payload
  875. * @param {string} [payload.type] Action type
  876. * @param {Object|boolean} [opt] If pass boolean, means opt.silent
  877. * @param {boolean} [opt.silent=false] Whether trigger events.
  878. * @param {boolean} [opt.flush=undefined]
  879. * true: Flush immediately, and then pixel in canvas can be fetched
  880. * immediately. Caution: it might affect performance.
  881. * false: Not not flush.
  882. * undefined: Auto decide whether perform flush.
  883. */
  884. echartsProto.dispatchAction = function (payload, opt) {
  885. if (!zrUtil.isObject(opt)) {
  886. opt = {silent: !!opt};
  887. }
  888. if (!actions[payload.type]) {
  889. return;
  890. }
  891. // Avoid dispatch action before setOption. Especially in `connect`.
  892. if (!this._model) {
  893. return;
  894. }
  895. // May dispatchAction in rendering procedure
  896. if (this[IN_MAIN_PROCESS]) {
  897. this._pendingActions.push(payload);
  898. return;
  899. }
  900. doDispatchAction.call(this, payload, opt.silent);
  901. if (opt.flush) {
  902. this._zr.flush(true);
  903. }
  904. else if (opt.flush !== false && env.browser.weChat) {
  905. // In WeChat embeded browser, `requestAnimationFrame` and `setInterval`
  906. // hang when sliding page (on touch event), which cause that zr does not
  907. // refresh util user interaction finished, which is not expected.
  908. // But `dispatchAction` may be called too frequently when pan on touch
  909. // screen, which impacts performance if do not throttle them.
  910. this._throttledZrFlush();
  911. }
  912. flushPendingActions.call(this, opt.silent);
  913. triggerUpdatedEvent.call(this, opt.silent);
  914. };
  915. function doDispatchAction(payload, silent) {
  916. var payloadType = payload.type;
  917. var escapeConnect = payload.escapeConnect;
  918. var actionWrap = actions[payloadType];
  919. var actionInfo = actionWrap.actionInfo;
  920. var cptType = (actionInfo.update || 'update').split(':');
  921. var updateMethod = cptType.pop();
  922. cptType = cptType[0] != null && parseClassType(cptType[0]);
  923. this[IN_MAIN_PROCESS] = true;
  924. var payloads = [payload];
  925. var batched = false;
  926. // Batch action
  927. if (payload.batch) {
  928. batched = true;
  929. payloads = zrUtil.map(payload.batch, function (item) {
  930. item = zrUtil.defaults(zrUtil.extend({}, item), payload);
  931. item.batch = null;
  932. return item;
  933. });
  934. }
  935. var eventObjBatch = [];
  936. var eventObj;
  937. var isHighDown = payloadType === 'highlight' || payloadType === 'downplay';
  938. each(payloads, function (batchItem) {
  939. // Action can specify the event by return it.
  940. eventObj = actionWrap.action(batchItem, this._model, this._api);
  941. // Emit event outside
  942. eventObj = eventObj || zrUtil.extend({}, batchItem);
  943. // Convert type to eventType
  944. eventObj.type = actionInfo.event || eventObj.type;
  945. eventObjBatch.push(eventObj);
  946. // light update does not perform data process, layout and visual.
  947. if (isHighDown) {
  948. // method, payload, mainType, subType
  949. updateDirectly(this, updateMethod, batchItem, 'series');
  950. }
  951. else if (cptType) {
  952. updateDirectly(this, updateMethod, batchItem, cptType.main, cptType.sub);
  953. }
  954. }, this);
  955. if (updateMethod !== 'none' && !isHighDown && !cptType) {
  956. // Still dirty
  957. if (this[OPTION_UPDATED]) {
  958. // FIXME Pass payload ?
  959. updateMethods.prepareAndUpdate.call(this, payload);
  960. this[OPTION_UPDATED] = false;
  961. }
  962. else {
  963. updateMethods[updateMethod].call(this, payload);
  964. }
  965. }
  966. // Follow the rule of action batch
  967. if (batched) {
  968. eventObj = {
  969. type: actionInfo.event || payloadType,
  970. escapeConnect: escapeConnect,
  971. batch: eventObjBatch
  972. };
  973. }
  974. else {
  975. eventObj = eventObjBatch[0];
  976. }
  977. this[IN_MAIN_PROCESS] = false;
  978. !silent && this._messageCenter.trigger(eventObj.type, eventObj);
  979. }
  980. function flushPendingActions(silent) {
  981. var pendingActions = this._pendingActions;
  982. while (pendingActions.length) {
  983. var payload = pendingActions.shift();
  984. doDispatchAction.call(this, payload, silent);
  985. }
  986. }
  987. function triggerUpdatedEvent(silent) {
  988. !silent && this.trigger('updated');
  989. }
  990. /**
  991. * Register event
  992. * @method
  993. */
  994. echartsProto.on = createRegisterEventWithLowercaseName('on');
  995. echartsProto.off = createRegisterEventWithLowercaseName('off');
  996. echartsProto.one = createRegisterEventWithLowercaseName('one');
  997. /**
  998. * @param {string} methodName
  999. * @private
  1000. */
  1001. function invokeUpdateMethod(methodName, ecModel, payload) {
  1002. var api = this._api;
  1003. // Update all components
  1004. each(this._componentsViews, function (component) {
  1005. var componentModel = component.__model;
  1006. component[methodName](componentModel, ecModel, api, payload);
  1007. updateZ(componentModel, component);
  1008. }, this);
  1009. // Upate all charts
  1010. ecModel.eachSeries(function (seriesModel, idx) {
  1011. var chart = this._chartsMap[seriesModel.__viewId];
  1012. chart[methodName](seriesModel, ecModel, api, payload);
  1013. updateZ(seriesModel, chart);
  1014. updateProgressiveAndBlend(seriesModel, chart);
  1015. }, this);
  1016. // If use hover layer
  1017. updateHoverLayerStatus(this._zr, ecModel);
  1018. // Post render
  1019. each(postUpdateFuncs, function (func) {
  1020. func(ecModel, api);
  1021. });
  1022. }
  1023. /**
  1024. * Prepare view instances of charts and components
  1025. * @param {module:echarts/model/Global} ecModel
  1026. * @private
  1027. */
  1028. function prepareView(type, ecModel) {
  1029. var isComponent = type === 'component';
  1030. var viewList = isComponent ? this._componentsViews : this._chartsViews;
  1031. var viewMap = isComponent ? this._componentsMap : this._chartsMap;
  1032. var zr = this._zr;
  1033. for (var i = 0; i < viewList.length; i++) {
  1034. viewList[i].__alive = false;
  1035. }
  1036. ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) {
  1037. if (isComponent) {
  1038. if (componentType === 'series') {
  1039. return;
  1040. }
  1041. }
  1042. else {
  1043. model = componentType;
  1044. }
  1045. // Consider: id same and type changed.
  1046. var viewId = '_ec_' + model.id + '_' + model.type;
  1047. var view = viewMap[viewId];
  1048. if (!view) {
  1049. var classType = parseClassType(model.type);
  1050. var Clazz = isComponent
  1051. ? ComponentView.getClass(classType.main, classType.sub)
  1052. : ChartView.getClass(classType.sub);
  1053. if (Clazz) {
  1054. view = new Clazz();
  1055. view.init(ecModel, this._api);
  1056. viewMap[viewId] = view;
  1057. viewList.push(view);
  1058. zr.add(view.group);
  1059. }
  1060. else {
  1061. // Error
  1062. return;
  1063. }
  1064. }
  1065. model.__viewId = view.__id = viewId;
  1066. view.__alive = true;
  1067. view.__model = model;
  1068. view.group.__ecComponentInfo = {
  1069. mainType: model.mainType,
  1070. index: model.componentIndex
  1071. };
  1072. }, this);
  1073. for (var i = 0; i < viewList.length;) {
  1074. var view = viewList[i];
  1075. if (!view.__alive) {
  1076. zr.remove(view.group);
  1077. view.dispose(ecModel, this._api);
  1078. viewList.splice(i, 1);
  1079. delete viewMap[view.__id];
  1080. view.__id = view.group.__ecComponentInfo = null;
  1081. }
  1082. else {
  1083. i++;
  1084. }
  1085. }
  1086. }
  1087. /**
  1088. * Processor data in each series
  1089. *
  1090. * @param {module:echarts/model/Global} ecModel
  1091. * @private
  1092. */
  1093. function processData(ecModel, api) {
  1094. each(dataProcessorFuncs, function (process) {
  1095. process.func(ecModel, api);
  1096. });
  1097. }
  1098. /**
  1099. * @private
  1100. */
  1101. function stackSeriesData(ecModel) {
  1102. var stackedDataMap = {};
  1103. ecModel.eachSeries(function (series) {
  1104. var stack = series.get('stack');
  1105. var data = series.getData();
  1106. if (stack && data.type === 'list') {
  1107. var previousStack = stackedDataMap[stack];
  1108. // Avoid conflict with Object.prototype
  1109. if (stackedDataMap.hasOwnProperty(stack) && previousStack) {
  1110. data.stackedOn = previousStack;
  1111. }
  1112. stackedDataMap[stack] = data;
  1113. }
  1114. });
  1115. }
  1116. /**
  1117. * Layout before each chart render there series, special visual encoding stage
  1118. *
  1119. * @param {module:echarts/model/Global} ecModel
  1120. * @private
  1121. */
  1122. function doLayout(ecModel, payload) {
  1123. var api = this._api;
  1124. each(visualFuncs, function (visual) {
  1125. if (visual.isLayout) {
  1126. visual.func(ecModel, api, payload);
  1127. }
  1128. });
  1129. }
  1130. /**
  1131. * Encode visual infomation from data after data processing
  1132. *
  1133. * @param {module:echarts/model/Global} ecModel
  1134. * @param {object} layout
  1135. * @param {boolean} [excludesLayout]
  1136. * @private
  1137. */
  1138. function doVisualEncoding(ecModel, payload, excludesLayout) {
  1139. var api = this._api;
  1140. ecModel.clearColorPalette();
  1141. ecModel.eachSeries(function (seriesModel) {
  1142. seriesModel.clearColorPalette();
  1143. });
  1144. each(visualFuncs, function (visual) {
  1145. (!excludesLayout || !visual.isLayout)
  1146. && visual.func(ecModel, api, payload);
  1147. });
  1148. }
  1149. /**
  1150. * Render each chart and component
  1151. * @private
  1152. */
  1153. function doRender(ecModel, payload) {
  1154. var api = this._api;
  1155. // Render all components
  1156. each(this._componentsViews, function (componentView) {
  1157. var componentModel = componentView.__model;
  1158. componentView.render(componentModel, ecModel, api, payload);
  1159. updateZ(componentModel, componentView);
  1160. }, this);
  1161. each(this._chartsViews, function (chart) {
  1162. chart.__alive = false;
  1163. }, this);
  1164. // Render all charts
  1165. ecModel.eachSeries(function (seriesModel, idx) {
  1166. var chartView = this._chartsMap[seriesModel.__viewId];
  1167. chartView.__alive = true;
  1168. chartView.render(seriesModel, ecModel, api, payload);
  1169. chartView.group.silent = !!seriesModel.get('silent');
  1170. updateZ(seriesModel, chartView);
  1171. updateProgressiveAndBlend(seriesModel, chartView);
  1172. }, this);
  1173. // If use hover layer
  1174. updateHoverLayerStatus(this._zr, ecModel);
  1175. // Remove groups of unrendered charts
  1176. each(this._chartsViews, function (chart) {
  1177. if (!chart.__alive) {
  1178. chart.remove(ecModel, api);
  1179. }
  1180. }, this);
  1181. }
  1182. var MOUSE_EVENT_NAMES = [
  1183. 'click', 'dblclick', 'mouseover', 'mouseout', 'mousemove',
  1184. 'mousedown', 'mouseup', 'globalout', 'contextmenu'
  1185. ];
  1186. /**
  1187. * @private
  1188. */
  1189. echartsProto._initEvents = function () {
  1190. each(MOUSE_EVENT_NAMES, function (eveName) {
  1191. this._zr.on(eveName, function (e) {
  1192. var ecModel = this.getModel();
  1193. var el = e.target;
  1194. var params;
  1195. // no e.target when 'globalout'.
  1196. if (eveName === 'globalout') {
  1197. params = {};
  1198. }
  1199. else if (el && el.dataIndex != null) {
  1200. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  1201. params = dataModel && dataModel.getDataParams(el.dataIndex, el.dataType) || {};
  1202. }
  1203. // If element has custom eventData of components
  1204. else if (el && el.eventData) {
  1205. params = zrUtil.extend({}, el.eventData);
  1206. }
  1207. if (params) {
  1208. params.event = e;
  1209. params.type = eveName;
  1210. this.trigger(eveName, params);
  1211. }
  1212. }, this);
  1213. }, this);
  1214. each(eventActionMap, function (actionType, eventType) {
  1215. this._messageCenter.on(eventType, function (event) {
  1216. this.trigger(eventType, event);
  1217. }, this);
  1218. }, this);
  1219. };
  1220. /**
  1221. * @return {boolean}
  1222. */
  1223. echartsProto.isDisposed = function () {
  1224. return this._disposed;
  1225. };
  1226. /**
  1227. * Clear
  1228. */
  1229. echartsProto.clear = function () {
  1230. this.setOption({ series: [] }, true);
  1231. };
  1232. /**
  1233. * Dispose instance
  1234. */
  1235. echartsProto.dispose = function () {
  1236. if (this._disposed) {
  1237. if (true) {
  1238. console.warn('Instance ' + this.id + ' has been disposed');
  1239. }
  1240. return;
  1241. }
  1242. this._disposed = true;
  1243. var api = this._api;
  1244. var ecModel = this._model;
  1245. each(this._componentsViews, function (component) {
  1246. component.dispose(ecModel, api);
  1247. });
  1248. each(this._chartsViews, function (chart) {
  1249. chart.dispose(ecModel, api);
  1250. });
  1251. // Dispose after all views disposed
  1252. this._zr.dispose();
  1253. delete instances[this.id];
  1254. };
  1255. zrUtil.mixin(ECharts, Eventful);
  1256. function updateHoverLayerStatus(zr, ecModel) {
  1257. var storage = zr.storage;
  1258. var elCount = 0;
  1259. storage.traverse(function (el) {
  1260. if (!el.isGroup) {
  1261. elCount++;
  1262. }
  1263. });
  1264. if (elCount > ecModel.get('hoverLayerThreshold') && !env.node) {
  1265. storage.traverse(function (el) {
  1266. if (!el.isGroup) {
  1267. el.useHoverLayer = true;
  1268. }
  1269. });
  1270. }
  1271. }
  1272. /**
  1273. * Update chart progressive and blend.
  1274. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  1275. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  1276. */
  1277. function updateProgressiveAndBlend(seriesModel, chartView) {
  1278. // Progressive configuration
  1279. var elCount = 0;
  1280. chartView.group.traverse(function (el) {
  1281. if (el.type !== 'group' && !el.ignore) {
  1282. elCount++;
  1283. }
  1284. });
  1285. var frameDrawNum = +seriesModel.get('progressive');
  1286. var needProgressive = elCount > seriesModel.get('progressiveThreshold') && frameDrawNum && !env.node;
  1287. if (needProgressive) {
  1288. chartView.group.traverse(function (el) {
  1289. // FIXME marker and other components
  1290. if (!el.isGroup) {
  1291. el.progressive = needProgressive ?
  1292. Math.floor(elCount++ / frameDrawNum) : -1;
  1293. if (needProgressive) {
  1294. el.stopAnimation(true);
  1295. }
  1296. }
  1297. });
  1298. }
  1299. // Blend configration
  1300. var blendMode = seriesModel.get('blendMode') || null;
  1301. if (true) {
  1302. if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {
  1303. console.warn('Only canvas support blendMode');
  1304. }
  1305. }
  1306. chartView.group.traverse(function (el) {
  1307. // FIXME marker and other components
  1308. if (!el.isGroup) {
  1309. el.setStyle('blend', blendMode);
  1310. }
  1311. });
  1312. }
  1313. /**
  1314. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  1315. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  1316. */
  1317. function updateZ(model, view) {
  1318. var z = model.get('z');
  1319. var zlevel = model.get('zlevel');
  1320. // Set z and zlevel
  1321. view.group.traverse(function (el) {
  1322. if (el.type !== 'group') {
  1323. z != null && (el.z = z);
  1324. zlevel != null && (el.zlevel = zlevel);
  1325. }
  1326. });
  1327. }
  1328. function createExtensionAPI(ecInstance) {
  1329. var coordSysMgr = ecInstance._coordSysMgr;
  1330. return zrUtil.extend(new ExtensionAPI(ecInstance), {
  1331. // Inject methods
  1332. getCoordinateSystems: zrUtil.bind(
  1333. coordSysMgr.getCoordinateSystems, coordSysMgr
  1334. ),
  1335. getComponentByElement: function (el) {
  1336. while (el) {
  1337. var modelInfo = el.__ecComponentInfo;
  1338. if (modelInfo != null) {
  1339. return ecInstance._model.getComponent(modelInfo.mainType, modelInfo.index);
  1340. }
  1341. el = el.parent;
  1342. }
  1343. }
  1344. });
  1345. }
  1346. /**
  1347. * @type {Object} key: actionType.
  1348. * @inner
  1349. */
  1350. var actions = {};
  1351. /**
  1352. * Map eventType to actionType
  1353. * @type {Object}
  1354. */
  1355. var eventActionMap = {};
  1356. /**
  1357. * Data processor functions of each stage
  1358. * @type {Array.<Object.<string, Function>>}
  1359. * @inner
  1360. */
  1361. var dataProcessorFuncs = [];
  1362. /**
  1363. * @type {Array.<Function>}
  1364. * @inner
  1365. */
  1366. var optionPreprocessorFuncs = [];
  1367. /**
  1368. * @type {Array.<Function>}
  1369. * @inner
  1370. */
  1371. var postUpdateFuncs = [];
  1372. /**
  1373. * Visual encoding functions of each stage
  1374. * @type {Array.<Object.<string, Function>>}
  1375. * @inner
  1376. */
  1377. var visualFuncs = [];
  1378. /**
  1379. * Theme storage
  1380. * @type {Object.<key, Object>}
  1381. */
  1382. var themeStorage = {};
  1383. /**
  1384. * Loading effects
  1385. */
  1386. var loadingEffects = {};
  1387. var instances = {};
  1388. var connectedGroups = {};
  1389. var idBase = new Date() - 0;
  1390. var groupIdBase = new Date() - 0;
  1391. var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
  1392. /**
  1393. * @alias module:echarts
  1394. */
  1395. var echarts = {
  1396. /**
  1397. * @type {number}
  1398. */
  1399. version: '3.7.2',
  1400. dependencies: {
  1401. zrender: '3.6.2'
  1402. }
  1403. };
  1404. function enableConnect(chart) {
  1405. var STATUS_PENDING = 0;
  1406. var STATUS_UPDATING = 1;
  1407. var STATUS_UPDATED = 2;
  1408. var STATUS_KEY = '__connectUpdateStatus';
  1409. function updateConnectedChartsStatus(charts, status) {
  1410. for (var i = 0; i < charts.length; i++) {
  1411. var otherChart = charts[i];
  1412. otherChart[STATUS_KEY] = status;
  1413. }
  1414. }
  1415. zrUtil.each(eventActionMap, function (actionType, eventType) {
  1416. chart._messageCenter.on(eventType, function (event) {
  1417. if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) {
  1418. if (event && event.escapeConnect) {
  1419. return;
  1420. }
  1421. var action = chart.makeActionFromEvent(event);
  1422. var otherCharts = [];
  1423. zrUtil.each(instances, function (otherChart) {
  1424. if (otherChart !== chart && otherChart.group === chart.group) {
  1425. otherCharts.push(otherChart);
  1426. }
  1427. });
  1428. updateConnectedChartsStatus(otherCharts, STATUS_PENDING);
  1429. each(otherCharts, function (otherChart) {
  1430. if (otherChart[STATUS_KEY] !== STATUS_UPDATING) {
  1431. otherChart.dispatchAction(action);
  1432. }
  1433. });
  1434. updateConnectedChartsStatus(otherCharts, STATUS_UPDATED);
  1435. }
  1436. });
  1437. });
  1438. }
  1439. /**
  1440. * @param {HTMLElement} dom
  1441. * @param {Object} [theme]
  1442. * @param {Object} opts
  1443. * @param {number} [opts.devicePixelRatio] Use window.devicePixelRatio by default
  1444. * @param {string} [opts.renderer] Currently only 'canvas' is supported.
  1445. * @param {number} [opts.width] Use clientWidth of the input `dom` by default.
  1446. * Can be 'auto' (the same as null/undefined)
  1447. * @param {number} [opts.height] Use clientHeight of the input `dom` by default.
  1448. * Can be 'auto' (the same as null/undefined)
  1449. */
  1450. echarts.init = function (dom, theme, opts) {
  1451. if (true) {
  1452. // Check version
  1453. if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) {
  1454. throw new Error(
  1455. 'ZRender ' + zrender.version
  1456. + ' is too old for ECharts ' + echarts.version
  1457. + '. Current version need ZRender '
  1458. + echarts.dependencies.zrender + '+'
  1459. );
  1460. }
  1461. if (!dom) {
  1462. throw new Error('Initialize failed: invalid dom.');
  1463. }
  1464. }
  1465. var existInstance = echarts.getInstanceByDom(dom);
  1466. if (existInstance) {
  1467. if (true) {
  1468. console.warn('There is a chart instance already initialized on the dom.');
  1469. }
  1470. return existInstance;
  1471. }
  1472. if (true) {
  1473. if (zrUtil.isDom(dom)
  1474. && dom.nodeName.toUpperCase() !== 'CANVAS'
  1475. && (
  1476. (!dom.clientWidth && (!opts || opts.width == null))
  1477. || (!dom.clientHeight && (!opts || opts.height == null))
  1478. )
  1479. ) {
  1480. console.warn('Can\'t get dom width or height');
  1481. }
  1482. }
  1483. var chart = new ECharts(dom, theme, opts);
  1484. chart.id = 'ec_' + idBase++;
  1485. instances[chart.id] = chart;
  1486. if (dom.setAttribute) {
  1487. dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
  1488. }
  1489. else {
  1490. dom[DOM_ATTRIBUTE_KEY] = chart.id;
  1491. }
  1492. enableConnect(chart);
  1493. return chart;
  1494. };
  1495. /**
  1496. * @return {string|Array.<module:echarts~ECharts>} groupId
  1497. */
  1498. echarts.connect = function (groupId) {
  1499. // Is array of charts
  1500. if (zrUtil.isArray(groupId)) {
  1501. var charts = groupId;
  1502. groupId = null;
  1503. // If any chart has group
  1504. zrUtil.each(charts, function (chart) {
  1505. if (chart.group != null) {
  1506. groupId = chart.group;
  1507. }
  1508. });
  1509. groupId = groupId || ('g_' + groupIdBase++);
  1510. zrUtil.each(charts, function (chart) {
  1511. chart.group = groupId;
  1512. });
  1513. }
  1514. connectedGroups[groupId] = true;
  1515. return groupId;
  1516. };
  1517. /**
  1518. * @DEPRECATED
  1519. * @return {string} groupId
  1520. */
  1521. echarts.disConnect = function (groupId) {
  1522. connectedGroups[groupId] = false;
  1523. };
  1524. /**
  1525. * @return {string} groupId
  1526. */
  1527. echarts.disconnect = echarts.disConnect;
  1528. /**
  1529. * Dispose a chart instance
  1530. * @param {module:echarts~ECharts|HTMLDomElement|string} chart
  1531. */
  1532. echarts.dispose = function (chart) {
  1533. if (typeof chart === 'string') {
  1534. chart = instances[chart];
  1535. }
  1536. else if (!(chart instanceof ECharts)){
  1537. // Try to treat as dom
  1538. chart = echarts.getInstanceByDom(chart);
  1539. }
  1540. if ((chart instanceof ECharts) && !chart.isDisposed()) {
  1541. chart.dispose();
  1542. }
  1543. };
  1544. /**
  1545. * @param {HTMLElement} dom
  1546. * @return {echarts~ECharts}
  1547. */
  1548. echarts.getInstanceByDom = function (dom) {
  1549. var key;
  1550. if (dom.getAttribute) {
  1551. key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
  1552. }
  1553. else {
  1554. key = dom[DOM_ATTRIBUTE_KEY];
  1555. }
  1556. return instances[key];
  1557. };
  1558. /**
  1559. * @param {string} key
  1560. * @return {echarts~ECharts}
  1561. */
  1562. echarts.getInstanceById = function (key) {
  1563. return instances[key];
  1564. };
  1565. /**
  1566. * Register theme
  1567. */
  1568. echarts.registerTheme = function (name, theme) {
  1569. themeStorage[name] = theme;
  1570. };
  1571. /**
  1572. * Register option preprocessor
  1573. * @param {Function} preprocessorFunc
  1574. */
  1575. echarts.registerPreprocessor = function (preprocessorFunc) {
  1576. optionPreprocessorFuncs.push(preprocessorFunc);
  1577. };
  1578. /**
  1579. * @param {number} [priority=1000]
  1580. * @param {Function} processorFunc
  1581. */
  1582. echarts.registerProcessor = function (priority, processorFunc) {
  1583. if (typeof priority === 'function') {
  1584. processorFunc = priority;
  1585. priority = PRIORITY_PROCESSOR_FILTER;
  1586. }
  1587. if (true) {
  1588. if (isNaN(priority)) {
  1589. throw new Error('Unkown processor priority');
  1590. }
  1591. }
  1592. dataProcessorFuncs.push({
  1593. prio: priority,
  1594. func: processorFunc
  1595. });
  1596. };
  1597. /**
  1598. * Register postUpdater
  1599. * @param {Function} postUpdateFunc
  1600. */
  1601. echarts.registerPostUpdate = function (postUpdateFunc) {
  1602. postUpdateFuncs.push(postUpdateFunc);
  1603. };
  1604. /**
  1605. * Usage:
  1606. * registerAction('someAction', 'someEvent', function () { ... });
  1607. * registerAction('someAction', function () { ... });
  1608. * registerAction(
  1609. * {type: 'someAction', event: 'someEvent', update: 'updateView'},
  1610. * function () { ... }
  1611. * );
  1612. *
  1613. * @param {(string|Object)} actionInfo
  1614. * @param {string} actionInfo.type
  1615. * @param {string} [actionInfo.event]
  1616. * @param {string} [actionInfo.update]
  1617. * @param {string} [eventName]
  1618. * @param {Function} action
  1619. */
  1620. echarts.registerAction = function (actionInfo, eventName, action) {
  1621. if (typeof eventName === 'function') {
  1622. action = eventName;
  1623. eventName = '';
  1624. }
  1625. var actionType = zrUtil.isObject(actionInfo)
  1626. ? actionInfo.type
  1627. : ([actionInfo, actionInfo = {
  1628. event: eventName
  1629. }][0]);
  1630. // Event name is all lowercase
  1631. actionInfo.event = (actionInfo.event || actionType).toLowerCase();
  1632. eventName = actionInfo.event;
  1633. // Validate action type and event name.
  1634. zrUtil.assert(ACTION_REG.test(actionType) && ACTION_REG.test(eventName));
  1635. if (!actions[actionType]) {
  1636. actions[actionType] = {action: action, actionInfo: actionInfo};
  1637. }
  1638. eventActionMap[eventName] = actionType;
  1639. };
  1640. /**
  1641. * @param {string} type
  1642. * @param {*} CoordinateSystem
  1643. */
  1644. echarts.registerCoordinateSystem = function (type, CoordinateSystem) {
  1645. CoordinateSystemManager.register(type, CoordinateSystem);
  1646. };
  1647. /**
  1648. * Get dimensions of specified coordinate system.
  1649. * @param {string} type
  1650. * @return {Array.<string|Object>}
  1651. */
  1652. echarts.getCoordinateSystemDimensions = function (type) {
  1653. var coordSysCreator = CoordinateSystemManager.get(type);
  1654. if (coordSysCreator) {
  1655. return coordSysCreator.getDimensionsInfo
  1656. ? coordSysCreator.getDimensionsInfo()
  1657. : coordSysCreator.dimensions.slice();
  1658. }
  1659. };
  1660. /**
  1661. * Layout is a special stage of visual encoding
  1662. * Most visual encoding like color are common for different chart
  1663. * But each chart has it's own layout algorithm
  1664. *
  1665. * @param {number} [priority=1000]
  1666. * @param {Function} layoutFunc
  1667. */
  1668. echarts.registerLayout = function (priority, layoutFunc) {
  1669. if (typeof priority === 'function') {
  1670. layoutFunc = priority;
  1671. priority = PRIORITY_VISUAL_LAYOUT;
  1672. }
  1673. if (true) {
  1674. if (isNaN(priority)) {
  1675. throw new Error('Unkown layout priority');
  1676. }
  1677. }
  1678. visualFuncs.push({
  1679. prio: priority,
  1680. func: layoutFunc,
  1681. isLayout: true
  1682. });
  1683. };
  1684. /**
  1685. * @param {number} [priority=3000]
  1686. * @param {Function} visualFunc
  1687. */
  1688. echarts.registerVisual = function (priority, visualFunc) {
  1689. if (typeof priority === 'function') {
  1690. visualFunc = priority;
  1691. priority = PRIORITY_VISUAL_CHART;
  1692. }
  1693. if (true) {
  1694. if (isNaN(priority)) {
  1695. throw new Error('Unkown visual priority');
  1696. }
  1697. }
  1698. visualFuncs.push({
  1699. prio: priority,
  1700. func: visualFunc
  1701. });
  1702. };
  1703. /**
  1704. * @param {string} name
  1705. */
  1706. echarts.registerLoading = function (name, loadingFx) {
  1707. loadingEffects[name] = loadingFx;
  1708. };
  1709. /**
  1710. * @param {Object} opts
  1711. * @param {string} [superClass]
  1712. */
  1713. echarts.extendComponentModel = function (opts/*, superClass*/) {
  1714. // var Clazz = ComponentModel;
  1715. // if (superClass) {
  1716. // var classType = parseClassType(superClass);
  1717. // Clazz = ComponentModel.getClass(classType.main, classType.sub, true);
  1718. // }
  1719. return ComponentModel.extend(opts);
  1720. };
  1721. /**
  1722. * @param {Object} opts
  1723. * @param {string} [superClass]
  1724. */
  1725. echarts.extendComponentView = function (opts/*, superClass*/) {
  1726. // var Clazz = ComponentView;
  1727. // if (superClass) {
  1728. // var classType = parseClassType(superClass);
  1729. // Clazz = ComponentView.getClass(classType.main, classType.sub, true);
  1730. // }
  1731. return ComponentView.extend(opts);
  1732. };
  1733. /**
  1734. * @param {Object} opts
  1735. * @param {string} [superClass]
  1736. */
  1737. echarts.extendSeriesModel = function (opts/*, superClass*/) {
  1738. // var Clazz = SeriesModel;
  1739. // if (superClass) {
  1740. // superClass = 'series.' + superClass.replace('series.', '');
  1741. // var classType = parseClassType(superClass);
  1742. // Clazz = ComponentModel.getClass(classType.main, classType.sub, true);
  1743. // }
  1744. return SeriesModel.extend(opts);
  1745. };
  1746. /**
  1747. * @param {Object} opts
  1748. * @param {string} [superClass]
  1749. */
  1750. echarts.extendChartView = function (opts/*, superClass*/) {
  1751. // var Clazz = ChartView;
  1752. // if (superClass) {
  1753. // superClass = superClass.replace('series.', '');
  1754. // var classType = parseClassType(superClass);
  1755. // Clazz = ChartView.getClass(classType.main, true);
  1756. // }
  1757. return ChartView.extend(opts);
  1758. };
  1759. /**
  1760. * ZRender need a canvas context to do measureText.
  1761. * But in node environment canvas may be created by node-canvas.
  1762. * So we need to specify how to create a canvas instead of using document.createElement('canvas')
  1763. *
  1764. * Be careful of using it in the browser.
  1765. *
  1766. * @param {Function} creator
  1767. * @example
  1768. * var Canvas = require('canvas');
  1769. * var echarts = require('echarts');
  1770. * echarts.setCanvasCreator(function () {
  1771. * // Small size is enough.
  1772. * return new Canvas(32, 32);
  1773. * });
  1774. */
  1775. echarts.setCanvasCreator = function (creator) {
  1776. zrUtil.createCanvas = creator;
  1777. };
  1778. echarts.registerVisual(PRIORITY_VISUAL_GLOBAL, __webpack_require__(99));
  1779. echarts.registerPreprocessor(backwardCompat);
  1780. echarts.registerLoading('default', __webpack_require__(100));
  1781. // Default action
  1782. echarts.registerAction({
  1783. type: 'highlight',
  1784. event: 'highlight',
  1785. update: 'highlight'
  1786. }, zrUtil.noop);
  1787. echarts.registerAction({
  1788. type: 'downplay',
  1789. event: 'downplay',
  1790. update: 'downplay'
  1791. }, zrUtil.noop);
  1792. // --------
  1793. // Exports
  1794. // --------
  1795. echarts.zrender = zrender;
  1796. echarts.List = __webpack_require__(101);
  1797. echarts.Model = __webpack_require__(14);
  1798. echarts.Axis = __webpack_require__(103);
  1799. echarts.graphic = __webpack_require__(20);
  1800. echarts.number = __webpack_require__(7);
  1801. echarts.format = __webpack_require__(6);
  1802. echarts.throttle = throttle.throttle;
  1803. echarts.matrix = __webpack_require__(11);
  1804. echarts.vector = __webpack_require__(10);
  1805. echarts.color = __webpack_require__(33);
  1806. echarts.util = {};
  1807. each([
  1808. 'map', 'each', 'filter', 'indexOf', 'inherits', 'reduce', 'filter',
  1809. 'bind', 'curry', 'isArray', 'isString', 'isObject', 'isFunction',
  1810. 'extend', 'defaults', 'clone', 'merge'
  1811. ],
  1812. function (name) {
  1813. echarts.util[name] = zrUtil[name];
  1814. }
  1815. );
  1816. echarts.helper = __webpack_require__(111);
  1817. // PRIORITY
  1818. echarts.PRIORITY = {
  1819. PROCESSOR: {
  1820. FILTER: PRIORITY_PROCESSOR_FILTER,
  1821. STATISTIC: PRIORITY_PROCESSOR_STATISTIC
  1822. },
  1823. VISUAL: {
  1824. LAYOUT: PRIORITY_VISUAL_LAYOUT,
  1825. GLOBAL: PRIORITY_VISUAL_GLOBAL,
  1826. CHART: PRIORITY_VISUAL_CHART,
  1827. COMPONENT: PRIORITY_VISUAL_COMPONENT,
  1828. BRUSH: PRIORITY_VISUAL_BRUSH
  1829. }
  1830. };
  1831. module.exports = echarts;
  1832. /***/ }),
  1833. /* 2 */
  1834. /***/ (function(module, exports) {
  1835. /**
  1836. * echarts设备环境识别
  1837. *
  1838. * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
  1839. * @author firede[firede@firede.us]
  1840. * @desc thanks zepto.
  1841. */
  1842. var env = {};
  1843. if (typeof navigator === 'undefined') {
  1844. // In node
  1845. env = {
  1846. browser: {},
  1847. os: {},
  1848. node: true,
  1849. // Assume canvas is supported
  1850. canvasSupported: true
  1851. };
  1852. }
  1853. else {
  1854. env = detect(navigator.userAgent);
  1855. }
  1856. module.exports = env;
  1857. // Zepto.js
  1858. // (c) 2010-2013 Thomas Fuchs
  1859. // Zepto.js may be freely distributed under the MIT license.
  1860. function detect(ua) {
  1861. var os = {};
  1862. var browser = {};
  1863. // var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
  1864. // var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  1865. // var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  1866. // var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  1867. // var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  1868. // var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
  1869. // var touchpad = webos && ua.match(/TouchPad/);
  1870. // var kindle = ua.match(/Kindle\/([\d.]+)/);
  1871. // var silk = ua.match(/Silk\/([\d._]+)/);
  1872. // var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  1873. // var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  1874. // var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  1875. // var playbook = ua.match(/PlayBook/);
  1876. // var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  1877. var firefox = ua.match(/Firefox\/([\d.]+)/);
  1878. // var safari = webkit && ua.match(/Mobile\//) && !chrome;
  1879. // var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
  1880. var ie = ua.match(/MSIE\s([\d.]+)/)
  1881. // IE 11 Trident/7.0; rv:11.0
  1882. || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  1883. var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
  1884. var weChat = (/micromessenger/i).test(ua);
  1885. // Todo: clean this up with a better OS/browser seperation:
  1886. // - discern (more) between multiple browsers on android
  1887. // - decide if kindle fire in silk mode is android or not
  1888. // - Firefox on Android doesn't specify the Android version
  1889. // - possibly devide in os, device and browser hashes
  1890. // if (browser.webkit = !!webkit) browser.version = webkit[1];
  1891. // if (android) os.android = true, os.version = android[2];
  1892. // if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
  1893. // if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
  1894. // if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  1895. // if (webos) os.webos = true, os.version = webos[2];
  1896. // if (touchpad) os.touchpad = true;
  1897. // if (blackberry) os.blackberry = true, os.version = blackberry[2];
  1898. // if (bb10) os.bb10 = true, os.version = bb10[2];
  1899. // if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
  1900. // if (playbook) browser.playbook = true;
  1901. // if (kindle) os.kindle = true, os.version = kindle[1];
  1902. // if (silk) browser.silk = true, browser.version = silk[1];
  1903. // if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
  1904. // if (chrome) browser.chrome = true, browser.version = chrome[1];
  1905. if (firefox) {
  1906. browser.firefox = true;
  1907. browser.version = firefox[1];
  1908. }
  1909. // if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
  1910. // if (webview) browser.webview = true;
  1911. if (ie) {
  1912. browser.ie = true;
  1913. browser.version = ie[1];
  1914. }
  1915. if (edge) {
  1916. browser.edge = true;
  1917. browser.version = edge[1];
  1918. }
  1919. // It is difficult to detect WeChat in Win Phone precisely, because ua can
  1920. // not be set on win phone. So we do not consider Win Phone.
  1921. if (weChat) {
  1922. browser.weChat = true;
  1923. }
  1924. // os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
  1925. // (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
  1926. // os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos ||
  1927. // (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
  1928. // (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
  1929. return {
  1930. browser: browser,
  1931. os: os,
  1932. node: false,
  1933. // 原生canvas支持,改极端点了
  1934. // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
  1935. canvasSupported : document.createElement('canvas').getContext ? true : false,
  1936. // @see <http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript>
  1937. // works on most browsers
  1938. // IE10/11 does not support touch event, and MS Edge supports them but not by
  1939. // default, so we dont check navigator.maxTouchPoints for them here.
  1940. touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
  1941. // <http://caniuse.com/#search=pointer%20event>.
  1942. pointerEventsSupported: 'onpointerdown' in window
  1943. // Firefox supports pointer but not by default, only MS browsers are reliable on pointer
  1944. // events currently. So we dont use that on other browsers unless tested sufficiently.
  1945. // Although IE 10 supports pointer event, it use old style and is different from the
  1946. // standard. So we exclude that. (IE 10 is hardly used on touch device)
  1947. && (browser.edge || (browser.ie && browser.version >= 11))
  1948. };
  1949. }
  1950. /***/ }),
  1951. /* 3 */
  1952. /***/ (function(module, exports, __webpack_require__) {
  1953. /**
  1954. * ECharts global model
  1955. *
  1956. * @module {echarts/model/Global}
  1957. */
  1958. /**
  1959. * Caution: If the mechanism should be changed some day, these cases
  1960. * should be considered:
  1961. *
  1962. * (1) In `merge option` mode, if using the same option to call `setOption`
  1963. * many times, the result should be the same (try our best to ensure that).
  1964. * (2) In `merge option` mode, if a component has no id/name specified, it
  1965. * will be merged by index, and the result sequence of the components is
  1966. * consistent to the original sequence.
  1967. * (3) `reset` feature (in toolbox). Find detailed info in comments about
  1968. * `mergeOption` in module:echarts/model/OptionManager.
  1969. */
  1970. var zrUtil = __webpack_require__(4);
  1971. var modelUtil = __webpack_require__(5);
  1972. var Model = __webpack_require__(14);
  1973. var each = zrUtil.each;
  1974. var filter = zrUtil.filter;
  1975. var map = zrUtil.map;
  1976. var isArray = zrUtil.isArray;
  1977. var indexOf = zrUtil.indexOf;
  1978. var isObject = zrUtil.isObject;
  1979. var ComponentModel = __webpack_require__(72);
  1980. var globalDefault = __webpack_require__(76);
  1981. var OPTION_INNER_KEY = '\0_ec_inner';
  1982. /**
  1983. * @alias module:echarts/model/Global
  1984. *
  1985. * @param {Object} option
  1986. * @param {module:echarts/model/Model} parentModel
  1987. * @param {Object} theme
  1988. */
  1989. var GlobalModel = Model.extend({
  1990. constructor: GlobalModel,
  1991. init: function (option, parentModel, theme, optionManager) {
  1992. theme = theme || {};
  1993. this.option = null; // Mark as not initialized.
  1994. /**
  1995. * @type {module:echarts/model/Model}
  1996. * @private
  1997. */
  1998. this._theme = new Model(theme);
  1999. /**
  2000. * @type {module:echarts/model/OptionManager}
  2001. */
  2002. this._optionManager = optionManager;
  2003. },
  2004. setOption: function (option, optionPreprocessorFuncs) {
  2005. zrUtil.assert(
  2006. !(OPTION_INNER_KEY in option),
  2007. 'please use chart.getOption()'
  2008. );
  2009. this._optionManager.setOption(option, optionPreprocessorFuncs);
  2010. this.resetOption(null);
  2011. },
  2012. /**
  2013. * @param {string} type null/undefined: reset all.
  2014. * 'recreate': force recreate all.
  2015. * 'timeline': only reset timeline option
  2016. * 'media': only reset media query option
  2017. * @return {boolean} Whether option changed.
  2018. */
  2019. resetOption: function (type) {
  2020. var optionChanged = false;
  2021. var optionManager = this._optionManager;
  2022. if (!type || type === 'recreate') {
  2023. var baseOption = optionManager.mountOption(type === 'recreate');
  2024. if (!this.option || type === 'recreate') {
  2025. initBase.call(this, baseOption);
  2026. }
  2027. else {
  2028. this.restoreData();
  2029. this.mergeOption(baseOption);
  2030. }
  2031. optionChanged = true;
  2032. }
  2033. if (type === 'timeline' || type === 'media') {
  2034. this.restoreData();
  2035. }
  2036. if (!type || type === 'recreate' || type === 'timeline') {
  2037. var timelineOption = optionManager.getTimelineOption(this);
  2038. timelineOption && (this.mergeOption(timelineOption), optionChanged = true);
  2039. }
  2040. if (!type || type === 'recreate' || type === 'media') {
  2041. var mediaOptions = optionManager.getMediaOption(this, this._api);
  2042. if (mediaOptions.length) {
  2043. each(mediaOptions, function (mediaOption) {
  2044. this.mergeOption(mediaOption, optionChanged = true);
  2045. }, this);
  2046. }
  2047. }
  2048. return optionChanged;
  2049. },
  2050. /**
  2051. * @protected
  2052. */
  2053. mergeOption: function (newOption) {
  2054. var option = this.option;
  2055. var componentsMap = this._componentsMap;
  2056. var newCptTypes = [];
  2057. // 如果不存在对应的 component model 则直接 merge
  2058. each(newOption, function (componentOption, mainType) {
  2059. if (componentOption == null) {
  2060. return;
  2061. }
  2062. if (!ComponentModel.hasClass(mainType)) {
  2063. option[mainType] = option[mainType] == null
  2064. ? zrUtil.clone(componentOption)
  2065. : zrUtil.merge(option[mainType], componentOption, true);
  2066. }
  2067. else {
  2068. newCptTypes.push(mainType);
  2069. }
  2070. });
  2071. // FIXME OPTION 同步是否要改回原来的
  2072. ComponentModel.topologicalTravel(
  2073. newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this
  2074. );
  2075. this._seriesIndices = this._seriesIndices || [];
  2076. function visitComponent(mainType, dependencies) {
  2077. var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
  2078. var mapResult = modelUtil.mappingToExists(
  2079. componentsMap.get(mainType), newCptOptionList
  2080. );
  2081. modelUtil.makeIdAndName(mapResult);
  2082. // Set mainType and complete subType.
  2083. each(mapResult, function (item, index) {
  2084. var opt = item.option;
  2085. if (isObject(opt)) {
  2086. item.keyInfo.mainType = mainType;
  2087. item.keyInfo.subType = determineSubType(mainType, opt, item.exist);
  2088. }
  2089. });
  2090. var dependentModels = getComponentsByTypes(
  2091. componentsMap, dependencies
  2092. );
  2093. option[mainType] = [];
  2094. componentsMap.set(mainType, []);
  2095. each(mapResult, function (resultItem, index) {
  2096. var componentModel = resultItem.exist;
  2097. var newCptOption = resultItem.option;
  2098. zrUtil.assert(
  2099. isObject(newCptOption) || componentModel,
  2100. 'Empty component definition'
  2101. );
  2102. // Consider where is no new option and should be merged using {},
  2103. // see removeEdgeAndAdd in topologicalTravel and
  2104. // ComponentModel.getAllClassMainTypes.
  2105. if (!newCptOption) {
  2106. componentModel.mergeOption({}, this);
  2107. componentModel.optionUpdated({}, false);
  2108. }
  2109. else {
  2110. var ComponentModelClass = ComponentModel.getClass(
  2111. mainType, resultItem.keyInfo.subType, true
  2112. );
  2113. if (componentModel && componentModel instanceof ComponentModelClass) {
  2114. componentModel.name = resultItem.keyInfo.name;
  2115. componentModel.mergeOption(newCptOption, this);
  2116. componentModel.optionUpdated(newCptOption, false);
  2117. }
  2118. else {
  2119. // PENDING Global as parent ?
  2120. var extraOpt = zrUtil.extend(
  2121. {
  2122. dependentModels: dependentModels,
  2123. componentIndex: index
  2124. },
  2125. resultItem.keyInfo
  2126. );
  2127. componentModel = new ComponentModelClass(
  2128. newCptOption, this, this, extraOpt
  2129. );
  2130. zrUtil.extend(componentModel, extraOpt);
  2131. componentModel.init(newCptOption, this, this, extraOpt);
  2132. // Call optionUpdated after init.
  2133. // newCptOption has been used as componentModel.option
  2134. // and may be merged with theme and default, so pass null
  2135. // to avoid confusion.
  2136. componentModel.optionUpdated(null, true);
  2137. }
  2138. }
  2139. componentsMap.get(mainType)[index] = componentModel;
  2140. option[mainType][index] = componentModel.option;
  2141. }, this);
  2142. // Backup series for filtering.
  2143. if (mainType === 'series') {
  2144. this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
  2145. }
  2146. }
  2147. },
  2148. /**
  2149. * Get option for output (cloned option and inner info removed)
  2150. * @public
  2151. * @return {Object}
  2152. */
  2153. getOption: function () {
  2154. var option = zrUtil.clone(this.option);
  2155. each(option, function (opts, mainType) {
  2156. if (ComponentModel.hasClass(mainType)) {
  2157. var opts = modelUtil.normalizeToArray(opts);
  2158. for (var i = opts.length - 1; i >= 0; i--) {
  2159. // Remove options with inner id.
  2160. if (modelUtil.isIdInner(opts[i])) {
  2161. opts.splice(i, 1);
  2162. }
  2163. }
  2164. option[mainType] = opts;
  2165. }
  2166. });
  2167. delete option[OPTION_INNER_KEY];
  2168. return option;
  2169. },
  2170. /**
  2171. * @return {module:echarts/model/Model}
  2172. */
  2173. getTheme: function () {
  2174. return this._theme;
  2175. },
  2176. /**
  2177. * @param {string} mainType
  2178. * @param {number} [idx=0]
  2179. * @return {module:echarts/model/Component}
  2180. */
  2181. getComponent: function (mainType, idx) {
  2182. var list = this._componentsMap.get(mainType);
  2183. if (list) {
  2184. return list[idx || 0];
  2185. }
  2186. },
  2187. /**
  2188. * If none of index and id and name used, return all components with mainType.
  2189. * @param {Object} condition
  2190. * @param {string} condition.mainType
  2191. * @param {string} [condition.subType] If ignore, only query by mainType
  2192. * @param {number|Array.<number>} [condition.index] Either input index or id or name.
  2193. * @param {string|Array.<string>} [condition.id] Either input index or id or name.
  2194. * @param {string|Array.<string>} [condition.name] Either input index or id or name.
  2195. * @return {Array.<module:echarts/model/Component>}
  2196. */
  2197. queryComponents: function (condition) {
  2198. var mainType = condition.mainType;
  2199. if (!mainType) {
  2200. return [];
  2201. }
  2202. var index = condition.index;
  2203. var id = condition.id;
  2204. var name = condition.name;
  2205. var cpts = this._componentsMap.get(mainType);
  2206. if (!cpts || !cpts.length) {
  2207. return [];
  2208. }
  2209. var result;
  2210. if (index != null) {
  2211. if (!isArray(index)) {
  2212. index = [index];
  2213. }
  2214. result = filter(map(index, function (idx) {
  2215. return cpts[idx];
  2216. }), function (val) {
  2217. return !!val;
  2218. });
  2219. }
  2220. else if (id != null) {
  2221. var isIdArray = isArray(id);
  2222. result = filter(cpts, function (cpt) {
  2223. return (isIdArray && indexOf(id, cpt.id) >= 0)
  2224. || (!isIdArray && cpt.id === id);
  2225. });
  2226. }
  2227. else if (name != null) {
  2228. var isNameArray = isArray(name);
  2229. result = filter(cpts, function (cpt) {
  2230. return (isNameArray && indexOf(name, cpt.name) >= 0)
  2231. || (!isNameArray && cpt.name === name);
  2232. });
  2233. }
  2234. else {
  2235. // Return all components with mainType
  2236. result = cpts.slice();
  2237. }
  2238. return filterBySubType(result, condition);
  2239. },
  2240. /**
  2241. * The interface is different from queryComponents,
  2242. * which is convenient for inner usage.
  2243. *
  2244. * @usage
  2245. * var result = findComponents(
  2246. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  2247. * );
  2248. * var result = findComponents(
  2249. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  2250. * );
  2251. * var result = findComponents(
  2252. * {mainType: 'series'},
  2253. * function (model, index) {...}
  2254. * );
  2255. * // result like [component0, componnet1, ...]
  2256. *
  2257. * @param {Object} condition
  2258. * @param {string} condition.mainType Mandatory.
  2259. * @param {string} [condition.subType] Optional.
  2260. * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName},
  2261. * where xxx is mainType.
  2262. * If query attribute is null/undefined or has no index/id/name,
  2263. * do not filtering by query conditions, which is convenient for
  2264. * no-payload situations or when target of action is global.
  2265. * @param {Function} [condition.filter] parameter: component, return boolean.
  2266. * @return {Array.<module:echarts/model/Component>}
  2267. */
  2268. findComponents: function (condition) {
  2269. var query = condition.query;
  2270. var mainType = condition.mainType;
  2271. var queryCond = getQueryCond(query);
  2272. var result = queryCond
  2273. ? this.queryComponents(queryCond)
  2274. : this._componentsMap.get(mainType);
  2275. return doFilter(filterBySubType(result, condition));
  2276. function getQueryCond(q) {
  2277. var indexAttr = mainType + 'Index';
  2278. var idAttr = mainType + 'Id';
  2279. var nameAttr = mainType + 'Name';
  2280. return q && (
  2281. q[indexAttr] != null
  2282. || q[idAttr] != null
  2283. || q[nameAttr] != null
  2284. )
  2285. ? {
  2286. mainType: mainType,
  2287. // subType will be filtered finally.
  2288. index: q[indexAttr],
  2289. id: q[idAttr],
  2290. name: q[nameAttr]
  2291. }
  2292. : null;
  2293. }
  2294. function doFilter(res) {
  2295. return condition.filter
  2296. ? filter(res, condition.filter)
  2297. : res;
  2298. }
  2299. },
  2300. /**
  2301. * @usage
  2302. * eachComponent('legend', function (legendModel, index) {
  2303. * ...
  2304. * });
  2305. * eachComponent(function (componentType, model, index) {
  2306. * // componentType does not include subType
  2307. * // (componentType is 'xxx' but not 'xxx.aa')
  2308. * });
  2309. * eachComponent(
  2310. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
  2311. * function (model, index) {...}
  2312. * );
  2313. * eachComponent(
  2314. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
  2315. * function (model, index) {...}
  2316. * );
  2317. *
  2318. * @param {string|Object=} mainType When mainType is object, the definition
  2319. * is the same as the method 'findComponents'.
  2320. * @param {Function} cb
  2321. * @param {*} context
  2322. */
  2323. eachComponent: function (mainType, cb, context) {
  2324. var componentsMap = this._componentsMap;
  2325. if (typeof mainType === 'function') {
  2326. context = cb;
  2327. cb = mainType;
  2328. componentsMap.each(function (components, componentType) {
  2329. each(components, function (component, index) {
  2330. cb.call(context, componentType, component, index);
  2331. });
  2332. });
  2333. }
  2334. else if (zrUtil.isString(mainType)) {
  2335. each(componentsMap.get(mainType), cb, context);
  2336. }
  2337. else if (isObject(mainType)) {
  2338. var queryResult = this.findComponents(mainType);
  2339. each(queryResult, cb, context);
  2340. }
  2341. },
  2342. /**
  2343. * @param {string} name
  2344. * @return {Array.<module:echarts/model/Series>}
  2345. */
  2346. getSeriesByName: function (name) {
  2347. var series = this._componentsMap.get('series');
  2348. return filter(series, function (oneSeries) {
  2349. return oneSeries.name === name;
  2350. });
  2351. },
  2352. /**
  2353. * @param {number} seriesIndex
  2354. * @return {module:echarts/model/Series}
  2355. */
  2356. getSeriesByIndex: function (seriesIndex) {
  2357. return this._componentsMap.get('series')[seriesIndex];
  2358. },
  2359. /**
  2360. * @param {string} subType
  2361. * @return {Array.<module:echarts/model/Series>}
  2362. */
  2363. getSeriesByType: function (subType) {
  2364. var series = this._componentsMap.get('series');
  2365. return filter(series, function (oneSeries) {
  2366. return oneSeries.subType === subType;
  2367. });
  2368. },
  2369. /**
  2370. * @return {Array.<module:echarts/model/Series>}
  2371. */
  2372. getSeries: function () {
  2373. return this._componentsMap.get('series').slice();
  2374. },
  2375. /**
  2376. * After filtering, series may be different
  2377. * frome raw series.
  2378. *
  2379. * @param {Function} cb
  2380. * @param {*} context
  2381. */
  2382. eachSeries: function (cb, context) {
  2383. assertSeriesInitialized(this);
  2384. each(this._seriesIndices, function (rawSeriesIndex) {
  2385. var series = this._componentsMap.get('series')[rawSeriesIndex];
  2386. cb.call(context, series, rawSeriesIndex);
  2387. }, this);
  2388. },
  2389. /**
  2390. * Iterate raw series before filtered.
  2391. *
  2392. * @param {Function} cb
  2393. * @param {*} context
  2394. */
  2395. eachRawSeries: function (cb, context) {
  2396. each(this._componentsMap.get('series'), cb, context);
  2397. },
  2398. /**
  2399. * After filtering, series may be different.
  2400. * frome raw series.
  2401. *
  2402. * @parma {string} subType
  2403. * @param {Function} cb
  2404. * @param {*} context
  2405. */
  2406. eachSeriesByType: function (subType, cb, context) {
  2407. assertSeriesInitialized(this);
  2408. each(this._seriesIndices, function (rawSeriesIndex) {
  2409. var series = this._componentsMap.get('series')[rawSeriesIndex];
  2410. if (series.subType === subType) {
  2411. cb.call(context, series, rawSeriesIndex);
  2412. }
  2413. }, this);
  2414. },
  2415. /**
  2416. * Iterate raw series before filtered of given type.
  2417. *
  2418. * @parma {string} subType
  2419. * @param {Function} cb
  2420. * @param {*} context
  2421. */
  2422. eachRawSeriesByType: function (subType, cb, context) {
  2423. return each(this.getSeriesByType(subType), cb, context);
  2424. },
  2425. /**
  2426. * @param {module:echarts/model/Series} seriesModel
  2427. */
  2428. isSeriesFiltered: function (seriesModel) {
  2429. assertSeriesInitialized(this);
  2430. return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
  2431. },
  2432. /**
  2433. * @return {Array.<number>}
  2434. */
  2435. getCurrentSeriesIndices: function () {
  2436. return (this._seriesIndices || []).slice();
  2437. },
  2438. /**
  2439. * @param {Function} cb
  2440. * @param {*} context
  2441. */
  2442. filterSeries: function (cb, context) {
  2443. assertSeriesInitialized(this);
  2444. var filteredSeries = filter(
  2445. this._componentsMap.get('series'), cb, context
  2446. );
  2447. this._seriesIndices = createSeriesIndices(filteredSeries);
  2448. },
  2449. restoreData: function () {
  2450. var componentsMap = this._componentsMap;
  2451. this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
  2452. var componentTypes = [];
  2453. componentsMap.each(function (components, componentType) {
  2454. componentTypes.push(componentType);
  2455. });
  2456. ComponentModel.topologicalTravel(
  2457. componentTypes,
  2458. ComponentModel.getAllClassMainTypes(),
  2459. function (componentType, dependencies) {
  2460. each(componentsMap.get(componentType), function (component) {
  2461. component.restoreData();
  2462. });
  2463. }
  2464. );
  2465. }
  2466. });
  2467. /**
  2468. * @inner
  2469. */
  2470. function mergeTheme(option, theme) {
  2471. zrUtil.each(theme, function (themeItem, name) {
  2472. // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理
  2473. if (!ComponentModel.hasClass(name)) {
  2474. if (typeof themeItem === 'object') {
  2475. option[name] = !option[name]
  2476. ? zrUtil.clone(themeItem)
  2477. : zrUtil.merge(option[name], themeItem, false);
  2478. }
  2479. else {
  2480. if (option[name] == null) {
  2481. option[name] = themeItem;
  2482. }
  2483. }
  2484. }
  2485. });
  2486. }
  2487. function initBase(baseOption) {
  2488. baseOption = baseOption;
  2489. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  2490. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  2491. this.option = {};
  2492. this.option[OPTION_INNER_KEY] = 1;
  2493. /**
  2494. * Init with series: [], in case of calling findSeries method
  2495. * before series initialized.
  2496. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  2497. * @private
  2498. */
  2499. this._componentsMap = zrUtil.createHashMap({series: []});
  2500. /**
  2501. * Mapping between filtered series list and raw series list.
  2502. * key: filtered series indices, value: raw series indices.
  2503. * @type {Array.<nubmer>}
  2504. * @private
  2505. */
  2506. this._seriesIndices = null;
  2507. mergeTheme(baseOption, this._theme.option);
  2508. // TODO Needs clone when merging to the unexisted property
  2509. zrUtil.merge(baseOption, globalDefault, false);
  2510. this.mergeOption(baseOption);
  2511. }
  2512. /**
  2513. * @inner
  2514. * @param {Array.<string>|string} types model types
  2515. * @return {Object} key: {string} type, value: {Array.<Object>} models
  2516. */
  2517. function getComponentsByTypes(componentsMap, types) {
  2518. if (!zrUtil.isArray(types)) {
  2519. types = types ? [types] : [];
  2520. }
  2521. var ret = {};
  2522. each(types, function (type) {
  2523. ret[type] = (componentsMap.get(type) || []).slice();
  2524. });
  2525. return ret;
  2526. }
  2527. /**
  2528. * @inner
  2529. */
  2530. function determineSubType(mainType, newCptOption, existComponent) {
  2531. var subType = newCptOption.type
  2532. ? newCptOption.type
  2533. : existComponent
  2534. ? existComponent.subType
  2535. // Use determineSubType only when there is no existComponent.
  2536. : ComponentModel.determineSubType(mainType, newCptOption);
  2537. // tooltip, markline, markpoint may always has no subType
  2538. return subType;
  2539. }
  2540. /**
  2541. * @inner
  2542. */
  2543. function createSeriesIndices(seriesModels) {
  2544. return map(seriesModels, function (series) {
  2545. return series.componentIndex;
  2546. }) || [];
  2547. }
  2548. /**
  2549. * @inner
  2550. */
  2551. function filterBySubType(components, condition) {
  2552. // Using hasOwnProperty for restrict. Consider
  2553. // subType is undefined in user payload.
  2554. return condition.hasOwnProperty('subType')
  2555. ? filter(components, function (cpt) {
  2556. return cpt.subType === condition.subType;
  2557. })
  2558. : components;
  2559. }
  2560. /**
  2561. * @inner
  2562. */
  2563. function assertSeriesInitialized(ecModel) {
  2564. // Components that use _seriesIndices should depends on series component,
  2565. // which make sure that their initialization is after series.
  2566. if (true) {
  2567. if (!ecModel._seriesIndices) {
  2568. throw new Error('Option should contains series.');
  2569. }
  2570. }
  2571. }
  2572. zrUtil.mixin(GlobalModel, __webpack_require__(77));
  2573. module.exports = GlobalModel;
  2574. /***/ }),
  2575. /* 4 */
  2576. /***/ (function(module, exports) {
  2577. /**
  2578. * @module zrender/core/util
  2579. */
  2580. // 用于处理merge时无法遍历Date等对象的问题
  2581. var BUILTIN_OBJECT = {
  2582. '[object Function]': 1,
  2583. '[object RegExp]': 1,
  2584. '[object Date]': 1,
  2585. '[object Error]': 1,
  2586. '[object CanvasGradient]': 1,
  2587. '[object CanvasPattern]': 1,
  2588. // For node-canvas
  2589. '[object Image]': 1,
  2590. '[object Canvas]': 1
  2591. };
  2592. var TYPED_ARRAY = {
  2593. '[object Int8Array]': 1,
  2594. '[object Uint8Array]': 1,
  2595. '[object Uint8ClampedArray]': 1,
  2596. '[object Int16Array]': 1,
  2597. '[object Uint16Array]': 1,
  2598. '[object Int32Array]': 1,
  2599. '[object Uint32Array]': 1,
  2600. '[object Float32Array]': 1,
  2601. '[object Float64Array]': 1
  2602. };
  2603. var objToString = Object.prototype.toString;
  2604. var arrayProto = Array.prototype;
  2605. var nativeForEach = arrayProto.forEach;
  2606. var nativeFilter = arrayProto.filter;
  2607. var nativeSlice = arrayProto.slice;
  2608. var nativeMap = arrayProto.map;
  2609. var nativeReduce = arrayProto.reduce;
  2610. /**
  2611. * Those data types can be cloned:
  2612. * Plain object, Array, TypedArray, number, string, null, undefined.
  2613. * Those data types will be assgined using the orginal data:
  2614. * BUILTIN_OBJECT
  2615. * Instance of user defined class will be cloned to a plain object, without
  2616. * properties in prototype.
  2617. * Other data types is not supported (not sure what will happen).
  2618. *
  2619. * Caution: do not support clone Date, for performance consideration.
  2620. * (There might be a large number of date in `series.data`).
  2621. * So date should not be modified in and out of echarts.
  2622. *
  2623. * @param {*} source
  2624. * @return {*} new
  2625. */
  2626. function clone(source) {
  2627. if (source == null || typeof source != 'object') {
  2628. return source;
  2629. }
  2630. var result = source;
  2631. var typeStr = objToString.call(source);
  2632. if (typeStr === '[object Array]') {
  2633. result = [];
  2634. for (var i = 0, len = source.length; i < len; i++) {
  2635. result[i] = clone(source[i]);
  2636. }
  2637. }
  2638. else if (TYPED_ARRAY[typeStr]) {
  2639. var Ctor = source.constructor;
  2640. if (source.constructor.from) {
  2641. result = Ctor.from(source);
  2642. }
  2643. else {
  2644. result = new Ctor(source.length);
  2645. for (var i = 0, len = source.length; i < len; i++) {
  2646. result[i] = clone(source[i]);
  2647. }
  2648. }
  2649. }
  2650. else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
  2651. result = {};
  2652. for (var key in source) {
  2653. if (source.hasOwnProperty(key)) {
  2654. result[key] = clone(source[key]);
  2655. }
  2656. }
  2657. }
  2658. return result;
  2659. }
  2660. /**
  2661. * @memberOf module:zrender/core/util
  2662. * @param {*} target
  2663. * @param {*} source
  2664. * @param {boolean} [overwrite=false]
  2665. */
  2666. function merge(target, source, overwrite) {
  2667. // We should escapse that source is string
  2668. // and enter for ... in ...
  2669. if (!isObject(source) || !isObject(target)) {
  2670. return overwrite ? clone(source) : target;
  2671. }
  2672. for (var key in source) {
  2673. if (source.hasOwnProperty(key)) {
  2674. var targetProp = target[key];
  2675. var sourceProp = source[key];
  2676. if (isObject(sourceProp)
  2677. && isObject(targetProp)
  2678. && !isArray(sourceProp)
  2679. && !isArray(targetProp)
  2680. && !isDom(sourceProp)
  2681. && !isDom(targetProp)
  2682. && !isBuiltInObject(sourceProp)
  2683. && !isBuiltInObject(targetProp)
  2684. && !isPrimitive(sourceProp)
  2685. && !isPrimitive(targetProp)
  2686. ) {
  2687. // 如果需要递归覆盖,就递归调用merge
  2688. merge(targetProp, sourceProp, overwrite);
  2689. }
  2690. else if (overwrite || !(key in target)) {
  2691. // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
  2692. // NOTE,在 target[key] 不存在的时候也是直接覆盖
  2693. target[key] = clone(source[key], true);
  2694. }
  2695. }
  2696. }
  2697. return target;
  2698. }
  2699. /**
  2700. * @param {Array} targetAndSources The first item is target, and the rests are source.
  2701. * @param {boolean} [overwrite=false]
  2702. * @return {*} target
  2703. */
  2704. function mergeAll(targetAndSources, overwrite) {
  2705. var result = targetAndSources[0];
  2706. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  2707. result = merge(result, targetAndSources[i], overwrite);
  2708. }
  2709. return result;
  2710. }
  2711. /**
  2712. * @param {*} target
  2713. * @param {*} source
  2714. * @memberOf module:zrender/core/util
  2715. */
  2716. function extend(target, source) {
  2717. for (var key in source) {
  2718. if (source.hasOwnProperty(key)) {
  2719. target[key] = source[key];
  2720. }
  2721. }
  2722. return target;
  2723. }
  2724. /**
  2725. * @param {*} target
  2726. * @param {*} source
  2727. * @param {boolean} [overlay=false]
  2728. * @memberOf module:zrender/core/util
  2729. */
  2730. function defaults(target, source, overlay) {
  2731. for (var key in source) {
  2732. if (source.hasOwnProperty(key)
  2733. && (overlay ? source[key] != null : target[key] == null)
  2734. ) {
  2735. target[key] = source[key];
  2736. }
  2737. }
  2738. return target;
  2739. }
  2740. function createCanvas() {
  2741. return document.createElement('canvas');
  2742. }
  2743. // FIXME
  2744. var _ctx;
  2745. function getContext() {
  2746. if (!_ctx) {
  2747. // Use util.createCanvas instead of createCanvas
  2748. // because createCanvas may be overwritten in different environment
  2749. _ctx = util.createCanvas().getContext('2d');
  2750. }
  2751. return _ctx;
  2752. }
  2753. /**
  2754. * 查询数组中元素的index
  2755. * @memberOf module:zrender/core/util
  2756. */
  2757. function indexOf(array, value) {
  2758. if (array) {
  2759. if (array.indexOf) {
  2760. return array.indexOf(value);
  2761. }
  2762. for (var i = 0, len = array.length; i < len; i++) {
  2763. if (array[i] === value) {
  2764. return i;
  2765. }
  2766. }
  2767. }
  2768. return -1;
  2769. }
  2770. /**
  2771. * 构造类继承关系
  2772. *
  2773. * @memberOf module:zrender/core/util
  2774. * @param {Function} clazz 源类
  2775. * @param {Function} baseClazz 基类
  2776. */
  2777. function inherits(clazz, baseClazz) {
  2778. var clazzPrototype = clazz.prototype;
  2779. function F() {}
  2780. F.prototype = baseClazz.prototype;
  2781. clazz.prototype = new F();
  2782. for (var prop in clazzPrototype) {
  2783. clazz.prototype[prop] = clazzPrototype[prop];
  2784. }
  2785. clazz.prototype.constructor = clazz;
  2786. clazz.superClass = baseClazz;
  2787. }
  2788. /**
  2789. * @memberOf module:zrender/core/util
  2790. * @param {Object|Function} target
  2791. * @param {Object|Function} sorce
  2792. * @param {boolean} overlay
  2793. */
  2794. function mixin(target, source, overlay) {
  2795. target = 'prototype' in target ? target.prototype : target;
  2796. source = 'prototype' in source ? source.prototype : source;
  2797. defaults(target, source, overlay);
  2798. }
  2799. /**
  2800. * Consider typed array.
  2801. * @param {Array|TypedArray} data
  2802. */
  2803. function isArrayLike(data) {
  2804. if (! data) {
  2805. return;
  2806. }
  2807. if (typeof data == 'string') {
  2808. return false;
  2809. }
  2810. return typeof data.length == 'number';
  2811. }
  2812. /**
  2813. * 数组或对象遍历
  2814. * @memberOf module:zrender/core/util
  2815. * @param {Object|Array} obj
  2816. * @param {Function} cb
  2817. * @param {*} [context]
  2818. */
  2819. function each(obj, cb, context) {
  2820. if (!(obj && cb)) {
  2821. return;
  2822. }
  2823. if (obj.forEach && obj.forEach === nativeForEach) {
  2824. obj.forEach(cb, context);
  2825. }
  2826. else if (obj.length === +obj.length) {
  2827. for (var i = 0, len = obj.length; i < len; i++) {
  2828. cb.call(context, obj[i], i, obj);
  2829. }
  2830. }
  2831. else {
  2832. for (var key in obj) {
  2833. if (obj.hasOwnProperty(key)) {
  2834. cb.call(context, obj[key], key, obj);
  2835. }
  2836. }
  2837. }
  2838. }
  2839. /**
  2840. * 数组映射
  2841. * @memberOf module:zrender/core/util
  2842. * @param {Array} obj
  2843. * @param {Function} cb
  2844. * @param {*} [context]
  2845. * @return {Array}
  2846. */
  2847. function map(obj, cb, context) {
  2848. if (!(obj && cb)) {
  2849. return;
  2850. }
  2851. if (obj.map && obj.map === nativeMap) {
  2852. return obj.map(cb, context);
  2853. }
  2854. else {
  2855. var result = [];
  2856. for (var i = 0, len = obj.length; i < len; i++) {
  2857. result.push(cb.call(context, obj[i], i, obj));
  2858. }
  2859. return result;
  2860. }
  2861. }
  2862. /**
  2863. * @memberOf module:zrender/core/util
  2864. * @param {Array} obj
  2865. * @param {Function} cb
  2866. * @param {Object} [memo]
  2867. * @param {*} [context]
  2868. * @return {Array}
  2869. */
  2870. function reduce(obj, cb, memo, context) {
  2871. if (!(obj && cb)) {
  2872. return;
  2873. }
  2874. if (obj.reduce && obj.reduce === nativeReduce) {
  2875. return obj.reduce(cb, memo, context);
  2876. }
  2877. else {
  2878. for (var i = 0, len = obj.length; i < len; i++) {
  2879. memo = cb.call(context, memo, obj[i], i, obj);
  2880. }
  2881. return memo;
  2882. }
  2883. }
  2884. /**
  2885. * 数组过滤
  2886. * @memberOf module:zrender/core/util
  2887. * @param {Array} obj
  2888. * @param {Function} cb
  2889. * @param {*} [context]
  2890. * @return {Array}
  2891. */
  2892. function filter(obj, cb, context) {
  2893. if (!(obj && cb)) {
  2894. return;
  2895. }
  2896. if (obj.filter && obj.filter === nativeFilter) {
  2897. return obj.filter(cb, context);
  2898. }
  2899. else {
  2900. var result = [];
  2901. for (var i = 0, len = obj.length; i < len; i++) {
  2902. if (cb.call(context, obj[i], i, obj)) {
  2903. result.push(obj[i]);
  2904. }
  2905. }
  2906. return result;
  2907. }
  2908. }
  2909. /**
  2910. * 数组项查找
  2911. * @memberOf module:zrender/core/util
  2912. * @param {Array} obj
  2913. * @param {Function} cb
  2914. * @param {*} [context]
  2915. * @return {Array}
  2916. */
  2917. function find(obj, cb, context) {
  2918. if (!(obj && cb)) {
  2919. return;
  2920. }
  2921. for (var i = 0, len = obj.length; i < len; i++) {
  2922. if (cb.call(context, obj[i], i, obj)) {
  2923. return obj[i];
  2924. }
  2925. }
  2926. }
  2927. /**
  2928. * @memberOf module:zrender/core/util
  2929. * @param {Function} func
  2930. * @param {*} context
  2931. * @return {Function}
  2932. */
  2933. function bind(func, context) {
  2934. var args = nativeSlice.call(arguments, 2);
  2935. return function () {
  2936. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  2937. };
  2938. }
  2939. /**
  2940. * @memberOf module:zrender/core/util
  2941. * @param {Function} func
  2942. * @return {Function}
  2943. */
  2944. function curry(func) {
  2945. var args = nativeSlice.call(arguments, 1);
  2946. return function () {
  2947. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  2948. };
  2949. }
  2950. /**
  2951. * @memberOf module:zrender/core/util
  2952. * @param {*} value
  2953. * @return {boolean}
  2954. */
  2955. function isArray(value) {
  2956. return objToString.call(value) === '[object Array]';
  2957. }
  2958. /**
  2959. * @memberOf module:zrender/core/util
  2960. * @param {*} value
  2961. * @return {boolean}
  2962. */
  2963. function isFunction(value) {
  2964. return typeof value === 'function';
  2965. }
  2966. /**
  2967. * @memberOf module:zrender/core/util
  2968. * @param {*} value
  2969. * @return {boolean}
  2970. */
  2971. function isString(value) {
  2972. return objToString.call(value) === '[object String]';
  2973. }
  2974. /**
  2975. * @memberOf module:zrender/core/util
  2976. * @param {*} value
  2977. * @return {boolean}
  2978. */
  2979. function isObject(value) {
  2980. // Avoid a V8 JIT bug in Chrome 19-20.
  2981. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  2982. var type = typeof value;
  2983. return type === 'function' || (!!value && type == 'object');
  2984. }
  2985. /**
  2986. * @memberOf module:zrender/core/util
  2987. * @param {*} value
  2988. * @return {boolean}
  2989. */
  2990. function isBuiltInObject(value) {
  2991. return !!BUILTIN_OBJECT[objToString.call(value)];
  2992. }
  2993. /**
  2994. * @memberOf module:zrender/core/util
  2995. * @param {*} value
  2996. * @return {boolean}
  2997. */
  2998. function isDom(value) {
  2999. return typeof value === 'object'
  3000. && typeof value.nodeType === 'number'
  3001. && typeof value.ownerDocument === 'object';
  3002. }
  3003. /**
  3004. * Whether is exactly NaN. Notice isNaN('a') returns true.
  3005. * @param {*} value
  3006. * @return {boolean}
  3007. */
  3008. function eqNaN(value) {
  3009. return value !== value;
  3010. }
  3011. /**
  3012. * If value1 is not null, then return value1, otherwise judget rest of values.
  3013. * Low performance.
  3014. * @memberOf module:zrender/core/util
  3015. * @return {*} Final value
  3016. */
  3017. function retrieve(values) {
  3018. for (var i = 0, len = arguments.length; i < len; i++) {
  3019. if (arguments[i] != null) {
  3020. return arguments[i];
  3021. }
  3022. }
  3023. }
  3024. function retrieve2(value0, value1) {
  3025. return value0 != null
  3026. ? value0
  3027. : value1;
  3028. }
  3029. function retrieve3(value0, value1, value2) {
  3030. return value0 != null
  3031. ? value0
  3032. : value1 != null
  3033. ? value1
  3034. : value2;
  3035. }
  3036. /**
  3037. * @memberOf module:zrender/core/util
  3038. * @param {Array} arr
  3039. * @param {number} startIndex
  3040. * @param {number} endIndex
  3041. * @return {Array}
  3042. */
  3043. function slice() {
  3044. return Function.call.apply(nativeSlice, arguments);
  3045. }
  3046. /**
  3047. * Normalize css liked array configuration
  3048. * e.g.
  3049. * 3 => [3, 3, 3, 3]
  3050. * [4, 2] => [4, 2, 4, 2]
  3051. * [4, 3, 2] => [4, 3, 2, 3]
  3052. * @param {number|Array.<number>} val
  3053. * @return {Array.<number>}
  3054. */
  3055. function normalizeCssArray(val) {
  3056. if (typeof (val) === 'number') {
  3057. return [val, val, val, val];
  3058. }
  3059. var len = val.length;
  3060. if (len === 2) {
  3061. // vertical | horizontal
  3062. return [val[0], val[1], val[0], val[1]];
  3063. }
  3064. else if (len === 3) {
  3065. // top | horizontal | bottom
  3066. return [val[0], val[1], val[2], val[1]];
  3067. }
  3068. return val;
  3069. }
  3070. /**
  3071. * @memberOf module:zrender/core/util
  3072. * @param {boolean} condition
  3073. * @param {string} message
  3074. */
  3075. function assert(condition, message) {
  3076. if (!condition) {
  3077. throw new Error(message);
  3078. }
  3079. }
  3080. var primitiveKey = '__ec_primitive__';
  3081. /**
  3082. * Set an object as primitive to be ignored traversing children in clone or merge
  3083. */
  3084. function setAsPrimitive(obj) {
  3085. obj[primitiveKey] = true;
  3086. }
  3087. function isPrimitive(obj) {
  3088. return obj[primitiveKey];
  3089. }
  3090. /**
  3091. * @constructor
  3092. * @param {Object} obj Only apply `ownProperty`.
  3093. */
  3094. function HashMap(obj) {
  3095. obj && each(obj, function (value, key) {
  3096. this.set(key, value);
  3097. }, this);
  3098. }
  3099. // Add prefix to avoid conflict with Object.prototype.
  3100. var HASH_MAP_PREFIX = '_ec_';
  3101. var HASH_MAP_PREFIX_LENGTH = 4;
  3102. HashMap.prototype = {
  3103. constructor: HashMap,
  3104. // Do not provide `has` method to avoid defining what is `has`.
  3105. // (We usually treat `null` and `undefined` as the same, different
  3106. // from ES6 Map).
  3107. get: function (key) {
  3108. return this[HASH_MAP_PREFIX + key];
  3109. },
  3110. set: function (key, value) {
  3111. this[HASH_MAP_PREFIX + key] = value;
  3112. // Comparing with invocation chaining, `return value` is more commonly
  3113. // used in this case: `var someVal = map.set('a', genVal());`
  3114. return value;
  3115. },
  3116. // Although util.each can be performed on this hashMap directly, user
  3117. // should not use the exposed keys, who are prefixed.
  3118. each: function (cb, context) {
  3119. context !== void 0 && (cb = bind(cb, context));
  3120. for (var prefixedKey in this) {
  3121. this.hasOwnProperty(prefixedKey)
  3122. && cb(this[prefixedKey], prefixedKey.slice(HASH_MAP_PREFIX_LENGTH));
  3123. }
  3124. },
  3125. // Do not use this method if performance sensitive.
  3126. removeKey: function (key) {
  3127. delete this[HASH_MAP_PREFIX + key];
  3128. }
  3129. };
  3130. function createHashMap(obj) {
  3131. return new HashMap(obj);
  3132. }
  3133. var util = {
  3134. inherits: inherits,
  3135. mixin: mixin,
  3136. clone: clone,
  3137. merge: merge,
  3138. mergeAll: mergeAll,
  3139. extend: extend,
  3140. defaults: defaults,
  3141. getContext: getContext,
  3142. createCanvas: createCanvas,
  3143. indexOf: indexOf,
  3144. slice: slice,
  3145. find: find,
  3146. isArrayLike: isArrayLike,
  3147. each: each,
  3148. map: map,
  3149. reduce: reduce,
  3150. filter: filter,
  3151. bind: bind,
  3152. curry: curry,
  3153. isArray: isArray,
  3154. isString: isString,
  3155. isObject: isObject,
  3156. isFunction: isFunction,
  3157. isBuiltInObject: isBuiltInObject,
  3158. isDom: isDom,
  3159. eqNaN: eqNaN,
  3160. retrieve: retrieve,
  3161. retrieve2: retrieve2,
  3162. retrieve3: retrieve3,
  3163. assert: assert,
  3164. setAsPrimitive: setAsPrimitive,
  3165. createHashMap: createHashMap,
  3166. normalizeCssArray: normalizeCssArray,
  3167. noop: function () {}
  3168. };
  3169. module.exports = util;
  3170. /***/ }),
  3171. /* 5 */
  3172. /***/ (function(module, exports, __webpack_require__) {
  3173. var formatUtil = __webpack_require__(6);
  3174. var nubmerUtil = __webpack_require__(7);
  3175. var Model = __webpack_require__(14);
  3176. var zrUtil = __webpack_require__(4);
  3177. var each = zrUtil.each;
  3178. var isObject = zrUtil.isObject;
  3179. var modelUtil = {};
  3180. /**
  3181. * If value is not array, then translate it to array.
  3182. * @param {*} value
  3183. * @return {Array} [value] or value
  3184. */
  3185. modelUtil.normalizeToArray = function (value) {
  3186. return value instanceof Array
  3187. ? value
  3188. : value == null
  3189. ? []
  3190. : [value];
  3191. };
  3192. /**
  3193. * Sync default option between normal and emphasis like `position` and `show`
  3194. * In case some one will write code like
  3195. * label: {
  3196. * normal: {
  3197. * show: false,
  3198. * position: 'outside',
  3199. * fontSize: 18
  3200. * },
  3201. * emphasis: {
  3202. * show: true
  3203. * }
  3204. * }
  3205. * @param {Object} opt
  3206. * @param {Array.<string>} subOpts
  3207. */
  3208. modelUtil.defaultEmphasis = function (opt, subOpts) {
  3209. if (opt) {
  3210. var emphasisOpt = opt.emphasis = opt.emphasis || {};
  3211. var normalOpt = opt.normal = opt.normal || {};
  3212. // Default emphasis option from normal
  3213. for (var i = 0, len = subOpts.length; i < len; i++) {
  3214. var subOptName = subOpts[i];
  3215. if (!emphasisOpt.hasOwnProperty(subOptName)
  3216. && normalOpt.hasOwnProperty(subOptName)
  3217. ) {
  3218. emphasisOpt[subOptName] = normalOpt[subOptName];
  3219. }
  3220. }
  3221. }
  3222. };
  3223. modelUtil.TEXT_STYLE_OPTIONS = [
  3224. 'fontStyle', 'fontWeight', 'fontSize', 'fontFamily',
  3225. 'rich', 'tag', 'color', 'textBorderColor', 'textBorderWidth',
  3226. 'width', 'height', 'lineHeight', 'align', 'verticalAlign', 'baseline',
  3227. 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY',
  3228. 'textShadowColor', 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY',
  3229. 'backgroundColor', 'borderColor', 'borderWidth', 'borderRadius', 'padding'
  3230. ];
  3231. // modelUtil.LABEL_OPTIONS = modelUtil.TEXT_STYLE_OPTIONS.concat([
  3232. // 'position', 'offset', 'rotate', 'origin', 'show', 'distance', 'formatter',
  3233. // 'fontStyle', 'fontWeight', 'fontSize', 'fontFamily',
  3234. // // FIXME: deprecated, check and remove it.
  3235. // 'textStyle'
  3236. // ]);
  3237. /**
  3238. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  3239. * This helper method retieves value from data.
  3240. * @param {string|number|Date|Array|Object} dataItem
  3241. * @return {number|string|Date|Array.<number|string|Date>}
  3242. */
  3243. modelUtil.getDataItemValue = function (dataItem) {
  3244. // Performance sensitive.
  3245. return dataItem && (dataItem.value == null ? dataItem : dataItem.value);
  3246. };
  3247. /**
  3248. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  3249. * This helper method determine if dataItem has extra option besides value
  3250. * @param {string|number|Date|Array|Object} dataItem
  3251. */
  3252. modelUtil.isDataItemOption = function (dataItem) {
  3253. return isObject(dataItem)
  3254. && !(dataItem instanceof Array);
  3255. // // markLine data can be array
  3256. // && !(dataItem[0] && isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
  3257. };
  3258. /**
  3259. * This helper method convert value in data.
  3260. * @param {string|number|Date} value
  3261. * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'.
  3262. */
  3263. modelUtil.converDataValue = function (value, dimInfo) {
  3264. // Performance sensitive.
  3265. var dimType = dimInfo && dimInfo.type;
  3266. if (dimType === 'ordinal') {
  3267. return value;
  3268. }
  3269. if (dimType === 'time'
  3270. // spead up when using timestamp
  3271. && typeof value !== 'number'
  3272. && value != null
  3273. && value !== '-'
  3274. ) {
  3275. value = +nubmerUtil.parseDate(value);
  3276. }
  3277. // dimType defaults 'number'.
  3278. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  3279. // parse to NaN.
  3280. return (value == null || value === '')
  3281. ? NaN : +value; // If string (like '-'), using '+' parse to NaN
  3282. };
  3283. /**
  3284. * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data.
  3285. * @param {module:echarts/data/List} data
  3286. * @param {Object} opt
  3287. * @param {string} [opt.seriesIndex]
  3288. * @param {Object} [opt.name]
  3289. * @param {Object} [opt.mainType]
  3290. * @param {Object} [opt.subType]
  3291. */
  3292. modelUtil.createDataFormatModel = function (data, opt) {
  3293. var model = new Model();
  3294. zrUtil.mixin(model, modelUtil.dataFormatMixin);
  3295. model.seriesIndex = opt.seriesIndex;
  3296. model.name = opt.name || '';
  3297. model.mainType = opt.mainType;
  3298. model.subType = opt.subType;
  3299. model.getData = function () {
  3300. return data;
  3301. };
  3302. return model;
  3303. };
  3304. // PENDING A little ugly
  3305. modelUtil.dataFormatMixin = {
  3306. /**
  3307. * Get params for formatter
  3308. * @param {number} dataIndex
  3309. * @param {string} [dataType]
  3310. * @return {Object}
  3311. */
  3312. getDataParams: function (dataIndex, dataType) {
  3313. var data = this.getData(dataType);
  3314. var rawValue = this.getRawValue(dataIndex, dataType);
  3315. var rawDataIndex = data.getRawIndex(dataIndex);
  3316. var name = data.getName(dataIndex, true);
  3317. var itemOpt = data.getRawDataItem(dataIndex);
  3318. var color = data.getItemVisual(dataIndex, 'color');
  3319. return {
  3320. componentType: this.mainType,
  3321. componentSubType: this.subType,
  3322. seriesType: this.mainType === 'series' ? this.subType : null,
  3323. seriesIndex: this.seriesIndex,
  3324. seriesId: this.id,
  3325. seriesName: this.name,
  3326. name: name,
  3327. dataIndex: rawDataIndex,
  3328. data: itemOpt,
  3329. dataType: dataType,
  3330. value: rawValue,
  3331. color: color,
  3332. marker: formatUtil.getTooltipMarker(color),
  3333. // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  3334. $vars: ['seriesName', 'name', 'value']
  3335. };
  3336. },
  3337. /**
  3338. * Format label
  3339. * @param {number} dataIndex
  3340. * @param {string} [status='normal'] 'normal' or 'emphasis'
  3341. * @param {string} [dataType]
  3342. * @param {number} [dimIndex]
  3343. * @param {string} [labelProp='label']
  3344. * @return {string}
  3345. */
  3346. getFormattedLabel: function (dataIndex, status, dataType, dimIndex, labelProp) {
  3347. status = status || 'normal';
  3348. var data = this.getData(dataType);
  3349. var itemModel = data.getItemModel(dataIndex);
  3350. var params = this.getDataParams(dataIndex, dataType);
  3351. if (dimIndex != null && (params.value instanceof Array)) {
  3352. params.value = params.value[dimIndex];
  3353. }
  3354. var formatter = itemModel.get([labelProp || 'label', status, 'formatter']);
  3355. if (typeof formatter === 'function') {
  3356. params.status = status;
  3357. return formatter(params);
  3358. }
  3359. else if (typeof formatter === 'string') {
  3360. return formatUtil.formatTpl(formatter, params);
  3361. }
  3362. },
  3363. /**
  3364. * Get raw value in option
  3365. * @param {number} idx
  3366. * @param {string} [dataType]
  3367. * @return {Object}
  3368. */
  3369. getRawValue: function (idx, dataType) {
  3370. var data = this.getData(dataType);
  3371. var dataItem = data.getRawDataItem(idx);
  3372. if (dataItem != null) {
  3373. return (isObject(dataItem) && !(dataItem instanceof Array))
  3374. ? dataItem.value : dataItem;
  3375. }
  3376. },
  3377. /**
  3378. * Should be implemented.
  3379. * @param {number} dataIndex
  3380. * @param {boolean} [multipleSeries=false]
  3381. * @param {number} [dataType]
  3382. * @return {string} tooltip string
  3383. */
  3384. formatTooltip: zrUtil.noop
  3385. };
  3386. /**
  3387. * Mapping to exists for merge.
  3388. *
  3389. * @public
  3390. * @param {Array.<Object>|Array.<module:echarts/model/Component>} exists
  3391. * @param {Object|Array.<Object>} newCptOptions
  3392. * @return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3393. * index of which is the same as exists.
  3394. */
  3395. modelUtil.mappingToExists = function (exists, newCptOptions) {
  3396. // Mapping by the order by original option (but not order of
  3397. // new option) in merge mode. Because we should ensure
  3398. // some specified index (like xAxisIndex) is consistent with
  3399. // original option, which is easy to understand, espatially in
  3400. // media query. And in most case, merge option is used to
  3401. // update partial option but not be expected to change order.
  3402. newCptOptions = (newCptOptions || []).slice();
  3403. var result = zrUtil.map(exists || [], function (obj, index) {
  3404. return {exist: obj};
  3405. });
  3406. // Mapping by id or name if specified.
  3407. each(newCptOptions, function (cptOption, index) {
  3408. if (!isObject(cptOption)) {
  3409. return;
  3410. }
  3411. // id has highest priority.
  3412. for (var i = 0; i < result.length; i++) {
  3413. if (!result[i].option // Consider name: two map to one.
  3414. && cptOption.id != null
  3415. && result[i].exist.id === cptOption.id + ''
  3416. ) {
  3417. result[i].option = cptOption;
  3418. newCptOptions[index] = null;
  3419. return;
  3420. }
  3421. }
  3422. for (var i = 0; i < result.length; i++) {
  3423. var exist = result[i].exist;
  3424. if (!result[i].option // Consider name: two map to one.
  3425. // Can not match when both ids exist but different.
  3426. && (exist.id == null || cptOption.id == null)
  3427. && cptOption.name != null
  3428. && !modelUtil.isIdInner(cptOption)
  3429. && !modelUtil.isIdInner(exist)
  3430. && exist.name === cptOption.name + ''
  3431. ) {
  3432. result[i].option = cptOption;
  3433. newCptOptions[index] = null;
  3434. return;
  3435. }
  3436. }
  3437. });
  3438. // Otherwise mapping by index.
  3439. each(newCptOptions, function (cptOption, index) {
  3440. if (!isObject(cptOption)) {
  3441. return;
  3442. }
  3443. var i = 0;
  3444. for (; i < result.length; i++) {
  3445. var exist = result[i].exist;
  3446. if (!result[i].option
  3447. // Existing model that already has id should be able to
  3448. // mapped to (because after mapping performed model may
  3449. // be assigned with a id, whish should not affect next
  3450. // mapping), except those has inner id.
  3451. && !modelUtil.isIdInner(exist)
  3452. // Caution:
  3453. // Do not overwrite id. But name can be overwritten,
  3454. // because axis use name as 'show label text'.
  3455. // 'exist' always has id and name and we dont
  3456. // need to check it.
  3457. && cptOption.id == null
  3458. ) {
  3459. result[i].option = cptOption;
  3460. break;
  3461. }
  3462. }
  3463. if (i >= result.length) {
  3464. result.push({option: cptOption});
  3465. }
  3466. });
  3467. return result;
  3468. };
  3469. /**
  3470. * Make id and name for mapping result (result of mappingToExists)
  3471. * into `keyInfo` field.
  3472. *
  3473. * @public
  3474. * @param {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3475. * which order is the same as exists.
  3476. * @return {Array.<Object>} The input.
  3477. */
  3478. modelUtil.makeIdAndName = function (mapResult) {
  3479. // We use this id to hash component models and view instances
  3480. // in echarts. id can be specified by user, or auto generated.
  3481. // The id generation rule ensures new view instance are able
  3482. // to mapped to old instance when setOption are called in
  3483. // no-merge mode. So we generate model id by name and plus
  3484. // type in view id.
  3485. // name can be duplicated among components, which is convenient
  3486. // to specify multi components (like series) by one name.
  3487. // Ensure that each id is distinct.
  3488. var idMap = zrUtil.createHashMap();
  3489. each(mapResult, function (item, index) {
  3490. var existCpt = item.exist;
  3491. existCpt && idMap.set(existCpt.id, item);
  3492. });
  3493. each(mapResult, function (item, index) {
  3494. var opt = item.option;
  3495. zrUtil.assert(
  3496. !opt || opt.id == null || !idMap.get(opt.id) || idMap.get(opt.id) === item,
  3497. 'id duplicates: ' + (opt && opt.id)
  3498. );
  3499. opt && opt.id != null && idMap.set(opt.id, item);
  3500. !item.keyInfo && (item.keyInfo = {});
  3501. });
  3502. // Make name and id.
  3503. each(mapResult, function (item, index) {
  3504. var existCpt = item.exist;
  3505. var opt = item.option;
  3506. var keyInfo = item.keyInfo;
  3507. if (!isObject(opt)) {
  3508. return;
  3509. }
  3510. // name can be overwitten. Consider case: axis.name = '20km'.
  3511. // But id generated by name will not be changed, which affect
  3512. // only in that case: setOption with 'not merge mode' and view
  3513. // instance will be recreated, which can be accepted.
  3514. keyInfo.name = opt.name != null
  3515. ? opt.name + ''
  3516. : existCpt
  3517. ? existCpt.name
  3518. : '\0-'; // name may be displayed on screen, so use '-'.
  3519. if (existCpt) {
  3520. keyInfo.id = existCpt.id;
  3521. }
  3522. else if (opt.id != null) {
  3523. keyInfo.id = opt.id + '';
  3524. }
  3525. else {
  3526. // Consider this situatoin:
  3527. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  3528. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  3529. // Series with the same name between optionA and optionB
  3530. // should be mapped.
  3531. var idNum = 0;
  3532. do {
  3533. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  3534. }
  3535. while (idMap.get(keyInfo.id));
  3536. }
  3537. idMap.set(keyInfo.id, item);
  3538. });
  3539. };
  3540. /**
  3541. * @public
  3542. * @param {Object} cptOption
  3543. * @return {boolean}
  3544. */
  3545. modelUtil.isIdInner = function (cptOption) {
  3546. return isObject(cptOption)
  3547. && cptOption.id
  3548. && (cptOption.id + '').indexOf('\0_ec_\0') === 0;
  3549. };
  3550. /**
  3551. * A helper for removing duplicate items between batchA and batchB,
  3552. * and in themselves, and categorize by series.
  3553. *
  3554. * @param {Array.<Object>} batchA Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3555. * @param {Array.<Object>} batchB Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3556. * @return {Array.<Array.<Object>, Array.<Object>>} result: [resultBatchA, resultBatchB]
  3557. */
  3558. modelUtil.compressBatches = function (batchA, batchB) {
  3559. var mapA = {};
  3560. var mapB = {};
  3561. makeMap(batchA || [], mapA);
  3562. makeMap(batchB || [], mapB, mapA);
  3563. return [mapToArray(mapA), mapToArray(mapB)];
  3564. function makeMap(sourceBatch, map, otherMap) {
  3565. for (var i = 0, len = sourceBatch.length; i < len; i++) {
  3566. var seriesId = sourceBatch[i].seriesId;
  3567. var dataIndices = modelUtil.normalizeToArray(sourceBatch[i].dataIndex);
  3568. var otherDataIndices = otherMap && otherMap[seriesId];
  3569. for (var j = 0, lenj = dataIndices.length; j < lenj; j++) {
  3570. var dataIndex = dataIndices[j];
  3571. if (otherDataIndices && otherDataIndices[dataIndex]) {
  3572. otherDataIndices[dataIndex] = null;
  3573. }
  3574. else {
  3575. (map[seriesId] || (map[seriesId] = {}))[dataIndex] = 1;
  3576. }
  3577. }
  3578. }
  3579. }
  3580. function mapToArray(map, isData) {
  3581. var result = [];
  3582. for (var i in map) {
  3583. if (map.hasOwnProperty(i) && map[i] != null) {
  3584. if (isData) {
  3585. result.push(+i);
  3586. }
  3587. else {
  3588. var dataIndices = mapToArray(map[i], true);
  3589. dataIndices.length && result.push({seriesId: i, dataIndex: dataIndices});
  3590. }
  3591. }
  3592. }
  3593. return result;
  3594. }
  3595. };
  3596. /**
  3597. * @param {module:echarts/data/List} data
  3598. * @param {Object} payload Contains dataIndex (means rawIndex) / dataIndexInside / name
  3599. * each of which can be Array or primary type.
  3600. * @return {number|Array.<number>} dataIndex If not found, return undefined/null.
  3601. */
  3602. modelUtil.queryDataIndex = function (data, payload) {
  3603. if (payload.dataIndexInside != null) {
  3604. return payload.dataIndexInside;
  3605. }
  3606. else if (payload.dataIndex != null) {
  3607. return zrUtil.isArray(payload.dataIndex)
  3608. ? zrUtil.map(payload.dataIndex, function (value) {
  3609. return data.indexOfRawIndex(value);
  3610. })
  3611. : data.indexOfRawIndex(payload.dataIndex);
  3612. }
  3613. else if (payload.name != null) {
  3614. return zrUtil.isArray(payload.name)
  3615. ? zrUtil.map(payload.name, function (value) {
  3616. return data.indexOfName(value);
  3617. })
  3618. : data.indexOfName(payload.name);
  3619. }
  3620. };
  3621. /**
  3622. * Enable property storage to any host object.
  3623. * Notice: Serialization is not supported.
  3624. *
  3625. * For example:
  3626. * var get = modelUitl.makeGetter();
  3627. *
  3628. * function some(hostObj) {
  3629. * get(hostObj)._someProperty = 1212;
  3630. * ...
  3631. * }
  3632. *
  3633. * @return {Function}
  3634. */
  3635. modelUtil.makeGetter = (function () {
  3636. var index = 0;
  3637. return function () {
  3638. var key = '\0__ec_prop_getter_' + index++;
  3639. return function (hostObj) {
  3640. return hostObj[key] || (hostObj[key] = {});
  3641. };
  3642. };
  3643. })();
  3644. /**
  3645. * @param {module:echarts/model/Global} ecModel
  3646. * @param {string|Object} finder
  3647. * If string, e.g., 'geo', means {geoIndex: 0}.
  3648. * If Object, could contain some of these properties below:
  3649. * {
  3650. * seriesIndex, seriesId, seriesName,
  3651. * geoIndex, geoId, geoName,
  3652. * bmapIndex, bmapId, bmapName,
  3653. * xAxisIndex, xAxisId, xAxisName,
  3654. * yAxisIndex, yAxisId, yAxisName,
  3655. * gridIndex, gridId, gridName,
  3656. * ... (can be extended)
  3657. * }
  3658. * Each properties can be number|string|Array.<number>|Array.<string>
  3659. * For example, a finder could be
  3660. * {
  3661. * seriesIndex: 3,
  3662. * geoId: ['aa', 'cc'],
  3663. * gridName: ['xx', 'rr']
  3664. * }
  3665. * xxxIndex can be set as 'all' (means all xxx) or 'none' (means not specify)
  3666. * If nothing or null/undefined specified, return nothing.
  3667. * @param {Object} [opt]
  3668. * @param {string} [opt.defaultMainType]
  3669. * @param {Array.<string>} [opt.includeMainTypes]
  3670. * @return {Object} result like:
  3671. * {
  3672. * seriesModels: [seriesModel1, seriesModel2],
  3673. * seriesModel: seriesModel1, // The first model
  3674. * geoModels: [geoModel1, geoModel2],
  3675. * geoModel: geoModel1, // The first model
  3676. * ...
  3677. * }
  3678. */
  3679. modelUtil.parseFinder = function (ecModel, finder, opt) {
  3680. if (zrUtil.isString(finder)) {
  3681. var obj = {};
  3682. obj[finder + 'Index'] = 0;
  3683. finder = obj;
  3684. }
  3685. var defaultMainType = opt && opt.defaultMainType;
  3686. if (defaultMainType
  3687. && !has(finder, defaultMainType + 'Index')
  3688. && !has(finder, defaultMainType + 'Id')
  3689. && !has(finder, defaultMainType + 'Name')
  3690. ) {
  3691. finder[defaultMainType + 'Index'] = 0;
  3692. }
  3693. var result = {};
  3694. each(finder, function (value, key) {
  3695. var value = finder[key];
  3696. // Exclude 'dataIndex' and other illgal keys.
  3697. if (key === 'dataIndex' || key === 'dataIndexInside') {
  3698. result[key] = value;
  3699. return;
  3700. }
  3701. var parsedKey = key.match(/^(\w+)(Index|Id|Name)$/) || [];
  3702. var mainType = parsedKey[1];
  3703. var queryType = (parsedKey[2] || '').toLowerCase();
  3704. if (!mainType
  3705. || !queryType
  3706. || value == null
  3707. || (queryType === 'index' && value === 'none')
  3708. || (opt && opt.includeMainTypes && zrUtil.indexOf(opt.includeMainTypes, mainType) < 0)
  3709. ) {
  3710. return;
  3711. }
  3712. var queryParam = {mainType: mainType};
  3713. if (queryType !== 'index' || value !== 'all') {
  3714. queryParam[queryType] = value;
  3715. }
  3716. var models = ecModel.queryComponents(queryParam);
  3717. result[mainType + 'Models'] = models;
  3718. result[mainType + 'Model'] = models[0];
  3719. });
  3720. return result;
  3721. };
  3722. /**
  3723. * @see {module:echarts/data/helper/completeDimensions}
  3724. * @param {module:echarts/data/List} data
  3725. * @param {string|number} dataDim
  3726. * @return {string}
  3727. */
  3728. modelUtil.dataDimToCoordDim = function (data, dataDim) {
  3729. var dimensions = data.dimensions;
  3730. dataDim = data.getDimension(dataDim);
  3731. for (var i = 0; i < dimensions.length; i++) {
  3732. var dimItem = data.getDimensionInfo(dimensions[i]);
  3733. if (dimItem.name === dataDim) {
  3734. return dimItem.coordDim;
  3735. }
  3736. }
  3737. };
  3738. /**
  3739. * @see {module:echarts/data/helper/completeDimensions}
  3740. * @param {module:echarts/data/List} data
  3741. * @param {string} coordDim
  3742. * @return {Array.<string>} data dimensions on the coordDim.
  3743. */
  3744. modelUtil.coordDimToDataDim = function (data, coordDim) {
  3745. var dataDim = [];
  3746. each(data.dimensions, function (dimName) {
  3747. var dimItem = data.getDimensionInfo(dimName);
  3748. if (dimItem.coordDim === coordDim) {
  3749. dataDim[dimItem.coordDimIndex] = dimItem.name;
  3750. }
  3751. });
  3752. return dataDim;
  3753. };
  3754. /**
  3755. * @see {module:echarts/data/helper/completeDimensions}
  3756. * @param {module:echarts/data/List} data
  3757. * @param {string} otherDim Can be `otherDims`
  3758. * like 'label' or 'tooltip'.
  3759. * @return {Array.<string>} data dimensions on the otherDim.
  3760. */
  3761. modelUtil.otherDimToDataDim = function (data, otherDim) {
  3762. var dataDim = [];
  3763. each(data.dimensions, function (dimName) {
  3764. var dimItem = data.getDimensionInfo(dimName);
  3765. var otherDims = dimItem.otherDims;
  3766. var dimIndex = otherDims[otherDim];
  3767. if (dimIndex != null && dimIndex !== false) {
  3768. dataDim[dimIndex] = dimItem.name;
  3769. }
  3770. });
  3771. return dataDim;
  3772. };
  3773. function has(obj, prop) {
  3774. return obj && obj.hasOwnProperty(prop);
  3775. }
  3776. module.exports = modelUtil;
  3777. /***/ }),
  3778. /* 6 */
  3779. /***/ (function(module, exports, __webpack_require__) {
  3780. var zrUtil = __webpack_require__(4);
  3781. var numberUtil = __webpack_require__(7);
  3782. var textContain = __webpack_require__(8);
  3783. var formatUtil = {};
  3784. /**
  3785. * 每三位默认加,格式化
  3786. * @param {string|number} x
  3787. * @return {string}
  3788. */
  3789. formatUtil.addCommas = function (x) {
  3790. if (isNaN(x)) {
  3791. return '-';
  3792. }
  3793. x = (x + '').split('.');
  3794. return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,')
  3795. + (x.length > 1 ? ('.' + x[1]) : '');
  3796. };
  3797. /**
  3798. * @param {string} str
  3799. * @param {boolean} [upperCaseFirst=false]
  3800. * @return {string} str
  3801. */
  3802. formatUtil.toCamelCase = function (str, upperCaseFirst) {
  3803. str = (str || '').toLowerCase().replace(/-(.)/g, function(match, group1) {
  3804. return group1.toUpperCase();
  3805. });
  3806. if (upperCaseFirst && str) {
  3807. str = str.charAt(0).toUpperCase() + str.slice(1);
  3808. }
  3809. return str;
  3810. };
  3811. formatUtil.normalizeCssArray = zrUtil.normalizeCssArray;
  3812. var encodeHTML = formatUtil.encodeHTML = function (source) {
  3813. return String(source)
  3814. .replace(/&/g, '&amp;')
  3815. .replace(/</g, '&lt;')
  3816. .replace(/>/g, '&gt;')
  3817. .replace(/"/g, '&quot;')
  3818. .replace(/'/g, '&#39;');
  3819. };
  3820. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
  3821. var wrapVar = function (varName, seriesIdx) {
  3822. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
  3823. };
  3824. /**
  3825. * Template formatter
  3826. * @param {string} tpl
  3827. * @param {Array.<Object>|Object} paramsList
  3828. * @param {boolean} [encode=false]
  3829. * @return {string}
  3830. */
  3831. formatUtil.formatTpl = function (tpl, paramsList, encode) {
  3832. if (!zrUtil.isArray(paramsList)) {
  3833. paramsList = [paramsList];
  3834. }
  3835. var seriesLen = paramsList.length;
  3836. if (!seriesLen) {
  3837. return '';
  3838. }
  3839. var $vars = paramsList[0].$vars || [];
  3840. for (var i = 0; i < $vars.length; i++) {
  3841. var alias = TPL_VAR_ALIAS[i];
  3842. var val = wrapVar(alias, 0);
  3843. tpl = tpl.replace(wrapVar(alias), encode ? encodeHTML(val) : val);
  3844. }
  3845. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  3846. for (var k = 0; k < $vars.length; k++) {
  3847. var val = paramsList[seriesIdx][$vars[k]];
  3848. tpl = tpl.replace(
  3849. wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
  3850. encode ? encodeHTML(val) : val
  3851. );
  3852. }
  3853. }
  3854. return tpl;
  3855. };
  3856. /**
  3857. * simple Template formatter
  3858. *
  3859. * @param {string} tpl
  3860. * @param {Object} param
  3861. * @param {boolean} [encode=false]
  3862. * @return {string}
  3863. */
  3864. formatUtil.formatTplSimple = function (tpl, param, encode) {
  3865. zrUtil.each(param, function (value, key) {
  3866. tpl = tpl.replace(
  3867. '{' + key + '}',
  3868. encode ? encodeHTML(value) : value
  3869. );
  3870. });
  3871. return tpl;
  3872. };
  3873. /**
  3874. * @param {string} color
  3875. * @param {string} [extraCssText]
  3876. * @return {string}
  3877. */
  3878. formatUtil.getTooltipMarker = function (color, extraCssText) {
  3879. return color
  3880. ? '<span style="display:inline-block;margin-right:5px;'
  3881. + 'border-radius:10px;width:9px;height:9px;background-color:'
  3882. + formatUtil.encodeHTML(color) + ';' + (extraCssText || '') + '"></span>'
  3883. : '';
  3884. };
  3885. /**
  3886. * @param {string} str
  3887. * @return {string}
  3888. * @inner
  3889. */
  3890. var s2d = function (str) {
  3891. return str < 10 ? ('0' + str) : str;
  3892. };
  3893. /**
  3894. * ISO Date format
  3895. * @param {string} tpl
  3896. * @param {number} value
  3897. * @param {boolean} [isUTC=false] Default in local time.
  3898. * see `module:echarts/scale/Time`
  3899. * and `module:echarts/util/number#parseDate`.
  3900. * @inner
  3901. */
  3902. formatUtil.formatTime = function (tpl, value, isUTC) {
  3903. if (tpl === 'week'
  3904. || tpl === 'month'
  3905. || tpl === 'quarter'
  3906. || tpl === 'half-year'
  3907. || tpl === 'year'
  3908. ) {
  3909. tpl = 'MM-dd\nyyyy';
  3910. }
  3911. var date = numberUtil.parseDate(value);
  3912. var utc = isUTC ? 'UTC' : '';
  3913. var y = date['get' + utc + 'FullYear']();
  3914. var M = date['get' + utc + 'Month']() + 1;
  3915. var d = date['get' + utc + 'Date']();
  3916. var h = date['get' + utc + 'Hours']();
  3917. var m = date['get' + utc + 'Minutes']();
  3918. var s = date['get' + utc + 'Seconds']();
  3919. tpl = tpl.replace('MM', s2d(M))
  3920. .replace('M', M)
  3921. .replace('yyyy', y)
  3922. .replace('yy', y % 100)
  3923. .replace('dd', s2d(d))
  3924. .replace('d', d)
  3925. .replace('hh', s2d(h))
  3926. .replace('h', h)
  3927. .replace('mm', s2d(m))
  3928. .replace('m', m)
  3929. .replace('ss', s2d(s))
  3930. .replace('s', s);
  3931. return tpl;
  3932. };
  3933. /**
  3934. * Capital first
  3935. * @param {string} str
  3936. * @return {string}
  3937. */
  3938. formatUtil.capitalFirst = function (str) {
  3939. return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
  3940. };
  3941. formatUtil.truncateText = textContain.truncateText;
  3942. formatUtil.getTextRect = textContain.getBoundingRect;
  3943. module.exports = formatUtil;
  3944. /***/ }),
  3945. /* 7 */
  3946. /***/ (function(module, exports, __webpack_require__) {
  3947. /**
  3948. * 数值处理模块
  3949. * @module echarts/util/number
  3950. */
  3951. var zrUtil = __webpack_require__(4);
  3952. var number = {};
  3953. var RADIAN_EPSILON = 1e-4;
  3954. function _trim(str) {
  3955. return str.replace(/^\s+/, '').replace(/\s+$/, '');
  3956. }
  3957. /**
  3958. * Linear mapping a value from domain to range
  3959. * @memberOf module:echarts/util/number
  3960. * @param {(number|Array.<number>)} val
  3961. * @param {Array.<number>} domain Domain extent domain[0] can be bigger than domain[1]
  3962. * @param {Array.<number>} range Range extent range[0] can be bigger than range[1]
  3963. * @param {boolean} clamp
  3964. * @return {(number|Array.<number>}
  3965. */
  3966. number.linearMap = function (val, domain, range, clamp) {
  3967. var subDomain = domain[1] - domain[0];
  3968. var subRange = range[1] - range[0];
  3969. if (subDomain === 0) {
  3970. return subRange === 0
  3971. ? range[0]
  3972. : (range[0] + range[1]) / 2;
  3973. }
  3974. // Avoid accuracy problem in edge, such as
  3975. // 146.39 - 62.83 === 83.55999999999999.
  3976. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  3977. // It is a little verbose for efficiency considering this method
  3978. // is a hotspot.
  3979. if (clamp) {
  3980. if (subDomain > 0) {
  3981. if (val <= domain[0]) {
  3982. return range[0];
  3983. }
  3984. else if (val >= domain[1]) {
  3985. return range[1];
  3986. }
  3987. }
  3988. else {
  3989. if (val >= domain[0]) {
  3990. return range[0];
  3991. }
  3992. else if (val <= domain[1]) {
  3993. return range[1];
  3994. }
  3995. }
  3996. }
  3997. else {
  3998. if (val === domain[0]) {
  3999. return range[0];
  4000. }
  4001. if (val === domain[1]) {
  4002. return range[1];
  4003. }
  4004. }
  4005. return (val - domain[0]) / subDomain * subRange + range[0];
  4006. };
  4007. /**
  4008. * Convert a percent string to absolute number.
  4009. * Returns NaN if percent is not a valid string or number
  4010. * @memberOf module:echarts/util/number
  4011. * @param {string|number} percent
  4012. * @param {number} all
  4013. * @return {number}
  4014. */
  4015. number.parsePercent = function(percent, all) {
  4016. switch (percent) {
  4017. case 'center':
  4018. case 'middle':
  4019. percent = '50%';
  4020. break;
  4021. case 'left':
  4022. case 'top':
  4023. percent = '0%';
  4024. break;
  4025. case 'right':
  4026. case 'bottom':
  4027. percent = '100%';
  4028. break;
  4029. }
  4030. if (typeof percent === 'string') {
  4031. if (_trim(percent).match(/%$/)) {
  4032. return parseFloat(percent) / 100 * all;
  4033. }
  4034. return parseFloat(percent);
  4035. }
  4036. return percent == null ? NaN : +percent;
  4037. };
  4038. /**
  4039. * (1) Fix rounding error of float numbers.
  4040. * (2) Support return string to avoid scientific notation like '3.5e-7'.
  4041. *
  4042. * @param {number} x
  4043. * @param {number} [precision]
  4044. * @param {boolean} [returnStr]
  4045. * @return {number|string}
  4046. */
  4047. number.round = function (x, precision, returnStr) {
  4048. if (precision == null) {
  4049. precision = 10;
  4050. }
  4051. // Avoid range error
  4052. precision = Math.min(Math.max(0, precision), 20);
  4053. x = (+x).toFixed(precision);
  4054. return returnStr ? x : +x;
  4055. };
  4056. number.asc = function (arr) {
  4057. arr.sort(function (a, b) {
  4058. return a - b;
  4059. });
  4060. return arr;
  4061. };
  4062. /**
  4063. * Get precision
  4064. * @param {number} val
  4065. */
  4066. number.getPrecision = function (val) {
  4067. val = +val;
  4068. if (isNaN(val)) {
  4069. return 0;
  4070. }
  4071. // It is much faster than methods converting number to string as follows
  4072. // var tmp = val.toString();
  4073. // return tmp.length - 1 - tmp.indexOf('.');
  4074. // especially when precision is low
  4075. var e = 1;
  4076. var count = 0;
  4077. while (Math.round(val * e) / e !== val) {
  4078. e *= 10;
  4079. count++;
  4080. }
  4081. return count;
  4082. };
  4083. /**
  4084. * @param {string|number} val
  4085. * @return {number}
  4086. */
  4087. number.getPrecisionSafe = function (val) {
  4088. var str = val.toString();
  4089. // Consider scientific notation: '3.4e-12' '3.4e+12'
  4090. var eIndex = str.indexOf('e');
  4091. if (eIndex > 0) {
  4092. var precision = +str.slice(eIndex + 1);
  4093. return precision < 0 ? -precision : 0;
  4094. }
  4095. else {
  4096. var dotIndex = str.indexOf('.');
  4097. return dotIndex < 0 ? 0 : str.length - 1 - dotIndex;
  4098. }
  4099. };
  4100. /**
  4101. * Minimal dicernible data precisioin according to a single pixel.
  4102. *
  4103. * @param {Array.<number>} dataExtent
  4104. * @param {Array.<number>} pixelExtent
  4105. * @return {number} precision
  4106. */
  4107. number.getPixelPrecision = function (dataExtent, pixelExtent) {
  4108. var log = Math.log;
  4109. var LN10 = Math.LN10;
  4110. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  4111. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
  4112. // toFixed() digits argument must be between 0 and 20.
  4113. var precision = Math.min(Math.max(-dataQuantity + sizeQuantity, 0), 20);
  4114. return !isFinite(precision) ? 20 : precision;
  4115. };
  4116. /**
  4117. * Get a data of given precision, assuring the sum of percentages
  4118. * in valueList is 1.
  4119. * The largest remainer method is used.
  4120. * https://en.wikipedia.org/wiki/Largest_remainder_method
  4121. *
  4122. * @param {Array.<number>} valueList a list of all data
  4123. * @param {number} idx index of the data to be processed in valueList
  4124. * @param {number} precision integer number showing digits of precision
  4125. * @return {number} percent ranging from 0 to 100
  4126. */
  4127. number.getPercentWithPrecision = function (valueList, idx, precision) {
  4128. if (!valueList[idx]) {
  4129. return 0;
  4130. }
  4131. var sum = zrUtil.reduce(valueList, function (acc, val) {
  4132. return acc + (isNaN(val) ? 0 : val);
  4133. }, 0);
  4134. if (sum === 0) {
  4135. return 0;
  4136. }
  4137. var digits = Math.pow(10, precision);
  4138. var votesPerQuota = zrUtil.map(valueList, function (val) {
  4139. return (isNaN(val) ? 0 : val) / sum * digits * 100;
  4140. });
  4141. var targetSeats = digits * 100;
  4142. var seats = zrUtil.map(votesPerQuota, function (votes) {
  4143. // Assign automatic seats.
  4144. return Math.floor(votes);
  4145. });
  4146. var currentSum = zrUtil.reduce(seats, function (acc, val) {
  4147. return acc + val;
  4148. }, 0);
  4149. var remainder = zrUtil.map(votesPerQuota, function (votes, idx) {
  4150. return votes - seats[idx];
  4151. });
  4152. // Has remainding votes.
  4153. while (currentSum < targetSeats) {
  4154. // Find next largest remainder.
  4155. var max = Number.NEGATIVE_INFINITY;
  4156. var maxId = null;
  4157. for (var i = 0, len = remainder.length; i < len; ++i) {
  4158. if (remainder[i] > max) {
  4159. max = remainder[i];
  4160. maxId = i;
  4161. }
  4162. }
  4163. // Add a vote to max remainder.
  4164. ++seats[maxId];
  4165. remainder[maxId] = 0;
  4166. ++currentSum;
  4167. }
  4168. return seats[idx] / digits;
  4169. };
  4170. // Number.MAX_SAFE_INTEGER, ie do not support.
  4171. number.MAX_SAFE_INTEGER = 9007199254740991;
  4172. /**
  4173. * To 0 - 2 * PI, considering negative radian.
  4174. * @param {number} radian
  4175. * @return {number}
  4176. */
  4177. number.remRadian = function (radian) {
  4178. var pi2 = Math.PI * 2;
  4179. return (radian % pi2 + pi2) % pi2;
  4180. };
  4181. /**
  4182. * @param {type} radian
  4183. * @return {boolean}
  4184. */
  4185. number.isRadianAroundZero = function (val) {
  4186. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  4187. };
  4188. var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line
  4189. /**
  4190. * Consider DST, it is incorrect to provide a method `getTimezoneOffset`
  4191. * without time specified. So this method is removed.
  4192. *
  4193. * @return {number} in minutes
  4194. */
  4195. // number.getTimezoneOffset = function () {
  4196. // return (new Date()).getTimezoneOffset();
  4197. // };
  4198. /**
  4199. * @param {string|Date|number} value These values can be accepted:
  4200. * + An instance of Date, represent a time in its own time zone.
  4201. * + Or string in a subset of ISO 8601, only including:
  4202. * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
  4203. * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
  4204. * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
  4205. * all of which will be treated as local time if time zone is not specified
  4206. * (see <https://momentjs.com/>).
  4207. * + Or other string format, including (all of which will be treated as loacal time):
  4208. * '2012', '2012-3-1', '2012/3/1', '2012/03/01',
  4209. * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
  4210. * + a timestamp, which represent a time in UTC.
  4211. * @return {Date} date
  4212. */
  4213. number.parseDate = function (value) {
  4214. if (value instanceof Date) {
  4215. return value;
  4216. }
  4217. else if (typeof value === 'string') {
  4218. // Different browsers parse date in different way, so we parse it manually.
  4219. // Some other issues:
  4220. // new Date('1970-01-01') is UTC,
  4221. // new Date('1970/01/01') and new Date('1970-1-01') is local.
  4222. // See issue #3623
  4223. var match = TIME_REG.exec(value);
  4224. if (!match) {
  4225. // return Invalid Date.
  4226. return new Date(NaN);
  4227. }
  4228. // Use local time when no timezone offset specifed.
  4229. if (!match[8]) {
  4230. // match[n] can only be string or undefined.
  4231. // But take care of '12' + 1 => '121'.
  4232. return new Date(
  4233. +match[1],
  4234. +(match[2] || 1) - 1,
  4235. +match[3] || 1,
  4236. +match[4] || 0,
  4237. +(match[5] || 0),
  4238. +match[6] || 0,
  4239. +match[7] || 0
  4240. );
  4241. }
  4242. // Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time,
  4243. // https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment).
  4244. // For example, system timezone is set as "Time Zone: America/Toronto",
  4245. // then these code will get different result:
  4246. // `new Date(1478411999999).getTimezoneOffset(); // get 240`
  4247. // `new Date(1478412000000).getTimezoneOffset(); // get 300`
  4248. // So we should not use `new Date`, but use `Date.UTC`.
  4249. else {
  4250. var hour = +match[4] || 0;
  4251. if (match[8].toUpperCase() !== 'Z') {
  4252. hour -= match[8].slice(0, 3);
  4253. }
  4254. return new Date(Date.UTC(
  4255. +match[1],
  4256. +(match[2] || 1) - 1,
  4257. +match[3] || 1,
  4258. hour,
  4259. +(match[5] || 0),
  4260. +match[6] || 0,
  4261. +match[7] || 0
  4262. ));
  4263. }
  4264. }
  4265. else if (value == null) {
  4266. return new Date(NaN);
  4267. }
  4268. return new Date(Math.round(value));
  4269. };
  4270. /**
  4271. * Quantity of a number. e.g. 0.1, 1, 10, 100
  4272. *
  4273. * @param {number} val
  4274. * @return {number}
  4275. */
  4276. number.quantity = function (val) {
  4277. return Math.pow(10, quantityExponent(val));
  4278. };
  4279. function quantityExponent(val) {
  4280. return Math.floor(Math.log(val) / Math.LN10);
  4281. }
  4282. /**
  4283. * find a “nice” number approximately equal to x. Round the number if round = true,
  4284. * take ceiling if round = false. The primary observation is that the “nicest”
  4285. * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  4286. *
  4287. * See "Nice Numbers for Graph Labels" of Graphic Gems.
  4288. *
  4289. * @param {number} val Non-negative value.
  4290. * @param {boolean} round
  4291. * @return {number}
  4292. */
  4293. number.nice = function (val, round) {
  4294. var exponent = quantityExponent(val);
  4295. var exp10 = Math.pow(10, exponent);
  4296. var f = val / exp10; // 1 <= f < 10
  4297. var nf;
  4298. if (round) {
  4299. if (f < 1.5) { nf = 1; }
  4300. else if (f < 2.5) { nf = 2; }
  4301. else if (f < 4) { nf = 3; }
  4302. else if (f < 7) { nf = 5; }
  4303. else { nf = 10; }
  4304. }
  4305. else {
  4306. if (f < 1) { nf = 1; }
  4307. else if (f < 2) { nf = 2; }
  4308. else if (f < 3) { nf = 3; }
  4309. else if (f < 5) { nf = 5; }
  4310. else { nf = 10; }
  4311. }
  4312. val = nf * exp10;
  4313. // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754).
  4314. // 20 is the uppper bound of toFixed.
  4315. return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
  4316. };
  4317. /**
  4318. * Order intervals asc, and split them when overlap.
  4319. * expect(numberUtil.reformIntervals([
  4320. * {interval: [18, 62], close: [1, 1]},
  4321. * {interval: [-Infinity, -70], close: [0, 0]},
  4322. * {interval: [-70, -26], close: [1, 1]},
  4323. * {interval: [-26, 18], close: [1, 1]},
  4324. * {interval: [62, 150], close: [1, 1]},
  4325. * {interval: [106, 150], close: [1, 1]},
  4326. * {interval: [150, Infinity], close: [0, 0]}
  4327. * ])).toEqual([
  4328. * {interval: [-Infinity, -70], close: [0, 0]},
  4329. * {interval: [-70, -26], close: [1, 1]},
  4330. * {interval: [-26, 18], close: [0, 1]},
  4331. * {interval: [18, 62], close: [0, 1]},
  4332. * {interval: [62, 150], close: [0, 1]},
  4333. * {interval: [150, Infinity], close: [0, 0]}
  4334. * ]);
  4335. * @param {Array.<Object>} list, where `close` mean open or close
  4336. * of the interval, and Infinity can be used.
  4337. * @return {Array.<Object>} The origin list, which has been reformed.
  4338. */
  4339. number.reformIntervals = function (list) {
  4340. list.sort(function (a, b) {
  4341. return littleThan(a, b, 0) ? -1 : 1;
  4342. });
  4343. var curr = -Infinity;
  4344. var currClose = 1;
  4345. for (var i = 0; i < list.length;) {
  4346. var interval = list[i].interval;
  4347. var close = list[i].close;
  4348. for (var lg = 0; lg < 2; lg++) {
  4349. if (interval[lg] <= curr) {
  4350. interval[lg] = curr;
  4351. close[lg] = !lg ? 1 - currClose : 1;
  4352. }
  4353. curr = interval[lg];
  4354. currClose = close[lg];
  4355. }
  4356. if (interval[0] === interval[1] && close[0] * close[1] !== 1) {
  4357. list.splice(i, 1);
  4358. }
  4359. else {
  4360. i++;
  4361. }
  4362. }
  4363. return list;
  4364. function littleThan(a, b, lg) {
  4365. return a.interval[lg] < b.interval[lg]
  4366. || (
  4367. a.interval[lg] === b.interval[lg]
  4368. && (
  4369. (a.close[lg] - b.close[lg] === (!lg ? 1 : -1))
  4370. || (!lg && littleThan(a, b, 1))
  4371. )
  4372. );
  4373. }
  4374. };
  4375. /**
  4376. * parseFloat NaNs numeric-cast false positives (null|true|false|"")
  4377. * ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  4378. * subtraction forces infinities to NaN
  4379. *
  4380. * @param {*} v
  4381. * @return {boolean}
  4382. */
  4383. number.isNumeric = function (v) {
  4384. return v - parseFloat(v) >= 0;
  4385. };
  4386. module.exports = number;
  4387. /***/ }),
  4388. /* 8 */
  4389. /***/ (function(module, exports, __webpack_require__) {
  4390. var util = __webpack_require__(4);
  4391. var BoundingRect = __webpack_require__(9);
  4392. var imageHelper = __webpack_require__(12);
  4393. var textWidthCache = {};
  4394. var textWidthCacheCounter = 0;
  4395. var TEXT_CACHE_MAX = 5000;
  4396. var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;
  4397. var DEFAULT_FONT = '12px sans-serif';
  4398. var retrieve2 = util.retrieve2;
  4399. var retrieve3 = util.retrieve3;
  4400. /**
  4401. * @public
  4402. * @param {string} text
  4403. * @param {string} font
  4404. * @return {number} width
  4405. */
  4406. function getTextWidth(text, font) {
  4407. font = font || DEFAULT_FONT;
  4408. var key = text + ':' + font;
  4409. if (textWidthCache[key]) {
  4410. return textWidthCache[key];
  4411. }
  4412. var textLines = (text + '').split('\n');
  4413. var width = 0;
  4414. for (var i = 0, l = textLines.length; i < l; i++) {
  4415. // textContain.measureText may be overrided in SVG or VML
  4416. width = Math.max(textContain.measureText(textLines[i], font).width, width);
  4417. }
  4418. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  4419. textWidthCacheCounter = 0;
  4420. textWidthCache = {};
  4421. }
  4422. textWidthCacheCounter++;
  4423. textWidthCache[key] = width;
  4424. return width;
  4425. }
  4426. /**
  4427. * @public
  4428. * @param {string} text
  4429. * @param {string} font
  4430. * @param {string} [textAlign='left']
  4431. * @param {string} [textVerticalAlign='top']
  4432. * @param {Array.<number>} [textPadding]
  4433. * @param {Object} [rich]
  4434. * @param {Object} [truncate]
  4435. * @return {Object} {x, y, width, height, lineHeight}
  4436. */
  4437. function getTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) {
  4438. return rich
  4439. ? getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate)
  4440. : getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, truncate);
  4441. }
  4442. function getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, truncate) {
  4443. var contentBlock = parsePlainText(text, font, textPadding, truncate);
  4444. var outerWidth = getTextWidth(text, font);
  4445. if (textPadding) {
  4446. outerWidth += textPadding[1] + textPadding[3];
  4447. }
  4448. var outerHeight = contentBlock.outerHeight;
  4449. var x = adjustTextX(0, outerWidth, textAlign);
  4450. var y = adjustTextY(0, outerHeight, textVerticalAlign);
  4451. var rect = new BoundingRect(x, y, outerWidth, outerHeight);
  4452. rect.lineHeight = contentBlock.lineHeight;
  4453. return rect;
  4454. }
  4455. function getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) {
  4456. var contentBlock = parseRichText(text, {
  4457. rich: rich,
  4458. truncate: truncate,
  4459. font: font,
  4460. textAlign: textAlign,
  4461. textPadding: textPadding
  4462. });
  4463. var outerWidth = contentBlock.outerWidth;
  4464. var outerHeight = contentBlock.outerHeight;
  4465. var x = adjustTextX(0, outerWidth, textAlign);
  4466. var y = adjustTextY(0, outerHeight, textVerticalAlign);
  4467. return new BoundingRect(x, y, outerWidth, outerHeight);
  4468. }
  4469. /**
  4470. * @public
  4471. * @param {number} x
  4472. * @param {number} width
  4473. * @param {string} [textAlign='left']
  4474. * @return {number} Adjusted x.
  4475. */
  4476. function adjustTextX(x, width, textAlign) {
  4477. // FIXME Right to left language
  4478. if (textAlign === 'right') {
  4479. x -= width;
  4480. }
  4481. else if (textAlign === 'center') {
  4482. x -= width / 2;
  4483. }
  4484. return x;
  4485. }
  4486. /**
  4487. * @public
  4488. * @param {number} y
  4489. * @param {number} height
  4490. * @param {string} [textVerticalAlign='top']
  4491. * @return {number} Adjusted y.
  4492. */
  4493. function adjustTextY(y, height, textVerticalAlign) {
  4494. if (textVerticalAlign === 'middle') {
  4495. y -= height / 2;
  4496. }
  4497. else if (textVerticalAlign === 'bottom') {
  4498. y -= height;
  4499. }
  4500. return y;
  4501. }
  4502. /**
  4503. * @public
  4504. * @param {stirng} textPosition
  4505. * @param {Object} rect {x, y, width, height}
  4506. * @param {number} distance
  4507. * @return {Object} {x, y, textAlign, textVerticalAlign}
  4508. */
  4509. function adjustTextPositionOnRect(textPosition, rect, distance) {
  4510. var x = rect.x;
  4511. var y = rect.y;
  4512. var height = rect.height;
  4513. var width = rect.width;
  4514. var halfHeight = height / 2;
  4515. var textAlign = 'left';
  4516. var textVerticalAlign = 'top';
  4517. switch (textPosition) {
  4518. case 'left':
  4519. x -= distance;
  4520. y += halfHeight;
  4521. textAlign = 'right';
  4522. textVerticalAlign = 'middle';
  4523. break;
  4524. case 'right':
  4525. x += distance + width;
  4526. y += halfHeight;
  4527. textVerticalAlign = 'middle';
  4528. break;
  4529. case 'top':
  4530. x += width / 2;
  4531. y -= distance;
  4532. textAlign = 'center';
  4533. textVerticalAlign = 'bottom';
  4534. break;
  4535. case 'bottom':
  4536. x += width / 2;
  4537. y += height + distance;
  4538. textAlign = 'center';
  4539. break;
  4540. case 'inside':
  4541. x += width / 2;
  4542. y += halfHeight;
  4543. textAlign = 'center';
  4544. textVerticalAlign = 'middle';
  4545. break;
  4546. case 'insideLeft':
  4547. x += distance;
  4548. y += halfHeight;
  4549. textVerticalAlign = 'middle';
  4550. break;
  4551. case 'insideRight':
  4552. x += width - distance;
  4553. y += halfHeight;
  4554. textAlign = 'right';
  4555. textVerticalAlign = 'middle';
  4556. break;
  4557. case 'insideTop':
  4558. x += width / 2;
  4559. y += distance;
  4560. textAlign = 'center';
  4561. break;
  4562. case 'insideBottom':
  4563. x += width / 2;
  4564. y += height - distance;
  4565. textAlign = 'center';
  4566. textVerticalAlign = 'bottom';
  4567. break;
  4568. case 'insideTopLeft':
  4569. x += distance;
  4570. y += distance;
  4571. break;
  4572. case 'insideTopRight':
  4573. x += width - distance;
  4574. y += distance;
  4575. textAlign = 'right';
  4576. break;
  4577. case 'insideBottomLeft':
  4578. x += distance;
  4579. y += height - distance;
  4580. textVerticalAlign = 'bottom';
  4581. break;
  4582. case 'insideBottomRight':
  4583. x += width - distance;
  4584. y += height - distance;
  4585. textAlign = 'right';
  4586. textVerticalAlign = 'bottom';
  4587. break;
  4588. }
  4589. return {
  4590. x: x,
  4591. y: y,
  4592. textAlign: textAlign,
  4593. textVerticalAlign: textVerticalAlign
  4594. };
  4595. }
  4596. /**
  4597. * Show ellipsis if overflow.
  4598. *
  4599. * @public
  4600. * @param {string} text
  4601. * @param {string} containerWidth
  4602. * @param {string} font
  4603. * @param {number} [ellipsis='...']
  4604. * @param {Object} [options]
  4605. * @param {number} [options.maxIterations=3]
  4606. * @param {number} [options.minChar=0] If truncate result are less
  4607. * then minChar, ellipsis will not show, which is
  4608. * better for user hint in some cases.
  4609. * @param {number} [options.placeholder=''] When all truncated, use the placeholder.
  4610. * @return {string}
  4611. */
  4612. function truncateText(text, containerWidth, font, ellipsis, options) {
  4613. if (!containerWidth) {
  4614. return '';
  4615. }
  4616. var textLines = (text + '').split('\n');
  4617. options = prepareTruncateOptions(containerWidth, font, ellipsis, options);
  4618. // FIXME
  4619. // It is not appropriate that every line has '...' when truncate multiple lines.
  4620. for (var i = 0, len = textLines.length; i < len; i++) {
  4621. textLines[i] = truncateSingleLine(textLines[i], options);
  4622. }
  4623. return textLines.join('\n');
  4624. }
  4625. function prepareTruncateOptions(containerWidth, font, ellipsis, options) {
  4626. options = util.extend({}, options);
  4627. options.font = font;
  4628. var ellipsis = retrieve2(ellipsis, '...');
  4629. options.maxIterations = retrieve2(options.maxIterations, 2);
  4630. var minChar = options.minChar = retrieve2(options.minChar, 0);
  4631. // FIXME
  4632. // Other languages?
  4633. options.cnCharWidth = getTextWidth('国', font);
  4634. // FIXME
  4635. // Consider proportional font?
  4636. var ascCharWidth = options.ascCharWidth = getTextWidth('a', font);
  4637. options.placeholder = retrieve2(options.placeholder, '');
  4638. // Example 1: minChar: 3, text: 'asdfzxcv', truncate result: 'asdf', but not: 'a...'.
  4639. // Example 2: minChar: 3, text: '维度', truncate result: '维', but not: '...'.
  4640. var contentWidth = containerWidth = Math.max(0, containerWidth - 1); // Reserve some gap.
  4641. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  4642. contentWidth -= ascCharWidth;
  4643. }
  4644. var ellipsisWidth = getTextWidth(ellipsis);
  4645. if (ellipsisWidth > contentWidth) {
  4646. ellipsis = '';
  4647. ellipsisWidth = 0;
  4648. }
  4649. contentWidth = containerWidth - ellipsisWidth;
  4650. options.ellipsis = ellipsis;
  4651. options.ellipsisWidth = ellipsisWidth;
  4652. options.contentWidth = contentWidth;
  4653. options.containerWidth = containerWidth;
  4654. return options;
  4655. }
  4656. function truncateSingleLine(textLine, options) {
  4657. var containerWidth = options.containerWidth;
  4658. var font = options.font;
  4659. var contentWidth = options.contentWidth;
  4660. if (!containerWidth) {
  4661. return '';
  4662. }
  4663. var lineWidth = getTextWidth(textLine, font);
  4664. if (lineWidth <= containerWidth) {
  4665. return textLine;
  4666. }
  4667. for (var j = 0;; j++) {
  4668. if (lineWidth <= contentWidth || j >= options.maxIterations) {
  4669. textLine += options.ellipsis;
  4670. break;
  4671. }
  4672. var subLength = j === 0
  4673. ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth)
  4674. : lineWidth > 0
  4675. ? Math.floor(textLine.length * contentWidth / lineWidth)
  4676. : 0;
  4677. textLine = textLine.substr(0, subLength);
  4678. lineWidth = getTextWidth(textLine, font);
  4679. }
  4680. if (textLine === '') {
  4681. textLine = options.placeholder;
  4682. }
  4683. return textLine;
  4684. }
  4685. function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
  4686. var width = 0;
  4687. var i = 0;
  4688. for (var len = text.length; i < len && width < contentWidth; i++) {
  4689. var charCode = text.charCodeAt(i);
  4690. width += (0 <= charCode && charCode <= 127) ? ascCharWidth : cnCharWidth;
  4691. }
  4692. return i;
  4693. }
  4694. /**
  4695. * @public
  4696. * @param {string} font
  4697. * @return {number} line height
  4698. */
  4699. function getLineHeight(font) {
  4700. // FIXME A rough approach.
  4701. return getTextWidth('国', font);
  4702. }
  4703. /**
  4704. * @public
  4705. * @param {string} text
  4706. * @param {string} font
  4707. * @return {Object} width
  4708. */
  4709. function measureText(text, font) {
  4710. var ctx = util.getContext();
  4711. ctx.font = font || DEFAULT_FONT;
  4712. return ctx.measureText(text);
  4713. }
  4714. /**
  4715. * @public
  4716. * @param {string} text
  4717. * @param {string} font
  4718. * @param {Object} [truncate]
  4719. * @return {Object} block: {lineHeight, lines, height, outerHeight}
  4720. * Notice: for performance, do not calculate outerWidth util needed.
  4721. */
  4722. function parsePlainText(text, font, padding, truncate) {
  4723. text != null && (text += '');
  4724. var lineHeight = getLineHeight(font);
  4725. var lines = text ? text.split('\n') : [];
  4726. var height = lines.length * lineHeight;
  4727. var outerHeight = height;
  4728. if (padding) {
  4729. outerHeight += padding[0] + padding[2];
  4730. }
  4731. if (text && truncate) {
  4732. var truncOuterHeight = truncate.outerHeight;
  4733. var truncOuterWidth = truncate.outerWidth;
  4734. if (truncOuterHeight != null && outerHeight > truncOuterHeight) {
  4735. text = '';
  4736. lines = [];
  4737. }
  4738. else if (truncOuterWidth != null) {
  4739. var options = prepareTruncateOptions(
  4740. truncOuterWidth - (padding ? padding[1] + padding[3] : 0),
  4741. font,
  4742. truncate.ellipsis,
  4743. {minChar: truncate.minChar, placeholder: truncate.placeholder}
  4744. );
  4745. // FIXME
  4746. // It is not appropriate that every line has '...' when truncate multiple lines.
  4747. for (var i = 0, len = lines.length; i < len; i++) {
  4748. lines[i] = truncateSingleLine(lines[i], options);
  4749. }
  4750. }
  4751. }
  4752. return {
  4753. lines: lines,
  4754. height: height,
  4755. outerHeight: outerHeight,
  4756. lineHeight: lineHeight
  4757. };
  4758. }
  4759. /**
  4760. * For example: 'some text {a|some text}other text{b|some text}xxx{c|}xxx'
  4761. * Also consider 'bbbb{a|xxx\nzzz}xxxx\naaaa'.
  4762. *
  4763. * @public
  4764. * @param {string} text
  4765. * @param {Object} style
  4766. * @return {Object} block
  4767. * {
  4768. * width,
  4769. * height,
  4770. * lines: [{
  4771. * lineHeight,
  4772. * width,
  4773. * tokens: [[{
  4774. * styleName,
  4775. * text,
  4776. * width, // include textPadding
  4777. * height, // include textPadding
  4778. * textWidth, // pure text width
  4779. * textHeight, // pure text height
  4780. * lineHeihgt,
  4781. * font,
  4782. * textAlign,
  4783. * textVerticalAlign
  4784. * }], [...], ...]
  4785. * }, ...]
  4786. * }
  4787. * If styleName is undefined, it is plain text.
  4788. */
  4789. function parseRichText(text, style) {
  4790. var contentBlock = {lines: [], width: 0, height: 0};
  4791. text != null && (text += '');
  4792. if (!text) {
  4793. return contentBlock;
  4794. }
  4795. var lastIndex = STYLE_REG.lastIndex = 0;
  4796. var result;
  4797. while ((result = STYLE_REG.exec(text)) != null)  {
  4798. var matchedIndex = result.index;
  4799. if (matchedIndex > lastIndex) {
  4800. pushTokens(contentBlock, text.substring(lastIndex, matchedIndex));
  4801. }
  4802. pushTokens(contentBlock, result[2], result[1]);
  4803. lastIndex = STYLE_REG.lastIndex;
  4804. }
  4805. if (lastIndex < text.length) {
  4806. pushTokens(contentBlock, text.substring(lastIndex, text.length));
  4807. }
  4808. var lines = contentBlock.lines;
  4809. var contentHeight = 0;
  4810. var contentWidth = 0;
  4811. // For `textWidth: 100%`
  4812. var pendingList = [];
  4813. var stlPadding = style.textPadding;
  4814. var truncate = style.truncate;
  4815. var truncateWidth = truncate && truncate.outerWidth;
  4816. var truncateHeight = truncate && truncate.outerHeight;
  4817. if (stlPadding) {
  4818. truncateWidth != null && (truncateWidth -= stlPadding[1] + stlPadding[3]);
  4819. truncateHeight != null && (truncateHeight -= stlPadding[0] + stlPadding[2]);
  4820. }
  4821. // Calculate layout info of tokens.
  4822. for (var i = 0; i < lines.length; i++) {
  4823. var line = lines[i];
  4824. var lineHeight = 0;
  4825. var lineWidth = 0;
  4826. for (var j = 0; j < line.tokens.length; j++) {
  4827. var token = line.tokens[j];
  4828. var tokenStyle = token.styleName && style.rich[token.styleName] || {};
  4829. // textPadding should not inherit from style.
  4830. var textPadding = token.textPadding = tokenStyle.textPadding;
  4831. // textFont has been asigned to font by `normalizeStyle`.
  4832. var font = token.font = tokenStyle.font || style.font;
  4833. // textHeight can be used when textVerticalAlign is specified in token.
  4834. var tokenHeight = token.textHeight = retrieve2(
  4835. // textHeight should not be inherited, consider it can be specified
  4836. // as box height of the block.
  4837. tokenStyle.textHeight, textContain.getLineHeight(font)
  4838. );
  4839. textPadding && (tokenHeight += textPadding[0] + textPadding[2]);
  4840. token.height = tokenHeight;
  4841. token.lineHeight = retrieve3(
  4842. tokenStyle.textLineHeight, style.textLineHeight, tokenHeight
  4843. );
  4844. token.textAlign = tokenStyle && tokenStyle.textAlign || style.textAlign;
  4845. token.textVerticalAlign = tokenStyle && tokenStyle.textVerticalAlign || 'middle';
  4846. if (truncateHeight != null && contentHeight + token.lineHeight > truncateHeight) {
  4847. return {lines: [], width: 0, height: 0};
  4848. }
  4849. token.textWidth = textContain.getWidth(token.text, font);
  4850. var tokenWidth = tokenStyle.textWidth;
  4851. var tokenWidthNotSpecified = tokenWidth == null || tokenWidth === 'auto';
  4852. // Percent width, can be `100%`, can be used in drawing separate
  4853. // line when box width is needed to be auto.
  4854. if (typeof tokenWidth === 'string' && tokenWidth.charAt(tokenWidth.length - 1) === '%') {
  4855. token.percentWidth = tokenWidth;
  4856. pendingList.push(token);
  4857. tokenWidth = 0;
  4858. // Do not truncate in this case, because there is no user case
  4859. // and it is too complicated.
  4860. }
  4861. else {
  4862. if (tokenWidthNotSpecified) {
  4863. tokenWidth = token.textWidth;
  4864. // FIXME: If image is not loaded and textWidth is not specified, calling
  4865. // `getBoundingRect()` will not get correct result.
  4866. var textBackgroundColor = tokenStyle.textBackgroundColor;
  4867. var bgImg = textBackgroundColor && textBackgroundColor.image;
  4868. // Use cases:
  4869. // (1) If image is not loaded, it will be loaded at render phase and call
  4870. // `dirty()` and `textBackgroundColor.image` will be replaced with the loaded
  4871. // image, and then the right size will be calculated here at the next tick.
  4872. // See `graphic/helper/text.js`.
  4873. // (2) If image loaded, and `textBackgroundColor.image` is image src string,
  4874. // use `imageHelper.findExistImage` to find cached image.
  4875. // `imageHelper.findExistImage` will always be called here before
  4876. // `imageHelper.createOrUpdateImage` in `graphic/helper/text.js#renderRichText`
  4877. // which ensures that image will not be rendered before correct size calcualted.
  4878. if (bgImg) {
  4879. bgImg = imageHelper.findExistImage(bgImg);
  4880. if (imageHelper.isImageReady(bgImg)) {
  4881. tokenWidth = Math.max(tokenWidth, bgImg.width * tokenHeight / bgImg.height);
  4882. }
  4883. }
  4884. }
  4885. var paddingW = textPadding ? textPadding[1] + textPadding[3] : 0;
  4886. tokenWidth += paddingW;
  4887. var remianTruncWidth = truncateWidth != null ? truncateWidth - lineWidth : null;
  4888. if (remianTruncWidth != null && remianTruncWidth < tokenWidth) {
  4889. if (!tokenWidthNotSpecified || remianTruncWidth < paddingW) {
  4890. token.text = '';
  4891. token.textWidth = tokenWidth = 0;
  4892. }
  4893. else {
  4894. token.text = truncateText(
  4895. token.text, remianTruncWidth - paddingW, font, truncate.ellipsis,
  4896. {minChar: truncate.minChar}
  4897. );
  4898. token.textWidth = textContain.getWidth(token.text, font);
  4899. tokenWidth = token.textWidth + paddingW;
  4900. }
  4901. }
  4902. }
  4903. lineWidth += (token.width = tokenWidth);
  4904. tokenStyle && (lineHeight = Math.max(lineHeight, token.lineHeight));
  4905. }
  4906. line.width = lineWidth;
  4907. line.lineHeight = lineHeight;
  4908. contentHeight += lineHeight;
  4909. contentWidth = Math.max(contentWidth, lineWidth);
  4910. }
  4911. contentBlock.outerWidth = contentBlock.width = retrieve2(style.textWidth, contentWidth);
  4912. contentBlock.outerHeight = contentBlock.height = retrieve2(style.textHeight, contentHeight);
  4913. if (stlPadding) {
  4914. contentBlock.outerWidth += stlPadding[1] + stlPadding[3];
  4915. contentBlock.outerHeight += stlPadding[0] + stlPadding[2];
  4916. }
  4917. for (var i = 0; i < pendingList.length; i++) {
  4918. var token = pendingList[i];
  4919. var percentWidth = token.percentWidth;
  4920. // Should not base on outerWidth, because token can not be placed out of padding.
  4921. token.width = parseInt(percentWidth, 10) / 100 * contentWidth;
  4922. }
  4923. return contentBlock;
  4924. }
  4925. function pushTokens(block, str, styleName) {
  4926. var isEmptyStr = str === '';
  4927. var strs = str.split('\n');
  4928. var lines = block.lines;
  4929. for (var i = 0; i < strs.length; i++) {
  4930. var text = strs[i];
  4931. var token = {
  4932. styleName: styleName,
  4933. text: text,
  4934. isLineHolder: !text && !isEmptyStr
  4935. };
  4936. // The first token should be appended to the last line.
  4937. if (!i) {
  4938. var tokens = (lines[lines.length - 1] || (lines[0] = {tokens: []})).tokens;
  4939. // Consider cases:
  4940. // (1) ''.split('\n') => ['', '\n', ''], the '' at the first item
  4941. // (which is a placeholder) should be replaced by new token.
  4942. // (2) A image backage, where token likes {a|}.
  4943. // (3) A redundant '' will affect textAlign in line.
  4944. // (4) tokens with the same tplName should not be merged, because
  4945. // they should be displayed in different box (with border and padding).
  4946. var tokensLen = tokens.length;
  4947. (tokensLen === 1 && tokens[0].isLineHolder)
  4948. ? (tokens[0] = token)
  4949. // Consider text is '', only insert when it is the "lineHolder" or
  4950. // "emptyStr". Otherwise a redundant '' will affect textAlign in line.
  4951. : ((text || !tokensLen || isEmptyStr) && tokens.push(token));
  4952. }
  4953. // Other tokens always start a new line.
  4954. else {
  4955. // If there is '', insert it as a placeholder.
  4956. lines.push({tokens: [token]});
  4957. }
  4958. }
  4959. }
  4960. function makeFont(style) {
  4961. // FIXME in node-canvas fontWeight is before fontStyle
  4962. // Use `fontSize` `fontFamily` to check whether font properties are defined.
  4963. return (style.fontSize || style.fontFamily) && [
  4964. style.fontStyle,
  4965. style.fontWeight,
  4966. (style.fontSize || 12) + 'px',
  4967. // If font properties are defined, `fontFamily` should not be ignored.
  4968. style.fontFamily || 'sans-serif'
  4969. ].join(' ') || style.textFont || style.font;
  4970. }
  4971. var textContain = {
  4972. getWidth: getTextWidth,
  4973. getBoundingRect: getTextRect,
  4974. adjustTextPositionOnRect: adjustTextPositionOnRect,
  4975. truncateText: truncateText,
  4976. measureText: measureText,
  4977. getLineHeight: getLineHeight,
  4978. parsePlainText: parsePlainText,
  4979. parseRichText: parseRichText,
  4980. adjustTextX: adjustTextX,
  4981. adjustTextY: adjustTextY,
  4982. makeFont: makeFont,
  4983. DEFAULT_FONT: DEFAULT_FONT
  4984. };
  4985. module.exports = textContain;
  4986. /***/ }),
  4987. /* 9 */
  4988. /***/ (function(module, exports, __webpack_require__) {
  4989. 'use strict';
  4990. /**
  4991. * @module echarts/core/BoundingRect
  4992. */
  4993. var vec2 = __webpack_require__(10);
  4994. var matrix = __webpack_require__(11);
  4995. var v2ApplyTransform = vec2.applyTransform;
  4996. var mathMin = Math.min;
  4997. var mathMax = Math.max;
  4998. /**
  4999. * @alias module:echarts/core/BoundingRect
  5000. */
  5001. function BoundingRect(x, y, width, height) {
  5002. if (width < 0) {
  5003. x = x + width;
  5004. width = -width;
  5005. }
  5006. if (height < 0) {
  5007. y = y + height;
  5008. height = -height;
  5009. }
  5010. /**
  5011. * @type {number}
  5012. */
  5013. this.x = x;
  5014. /**
  5015. * @type {number}
  5016. */
  5017. this.y = y;
  5018. /**
  5019. * @type {number}
  5020. */
  5021. this.width = width;
  5022. /**
  5023. * @type {number}
  5024. */
  5025. this.height = height;
  5026. }
  5027. BoundingRect.prototype = {
  5028. constructor: BoundingRect,
  5029. /**
  5030. * @param {module:echarts/core/BoundingRect} other
  5031. */
  5032. union: function (other) {
  5033. var x = mathMin(other.x, this.x);
  5034. var y = mathMin(other.y, this.y);
  5035. this.width = mathMax(
  5036. other.x + other.width,
  5037. this.x + this.width
  5038. ) - x;
  5039. this.height = mathMax(
  5040. other.y + other.height,
  5041. this.y + this.height
  5042. ) - y;
  5043. this.x = x;
  5044. this.y = y;
  5045. },
  5046. /**
  5047. * @param {Array.<number>} m
  5048. * @methods
  5049. */
  5050. applyTransform: (function () {
  5051. var lt = [];
  5052. var rb = [];
  5053. var lb = [];
  5054. var rt = [];
  5055. return function (m) {
  5056. // In case usage like this
  5057. // el.getBoundingRect().applyTransform(el.transform)
  5058. // And element has no transform
  5059. if (!m) {
  5060. return;
  5061. }
  5062. lt[0] = lb[0] = this.x;
  5063. lt[1] = rt[1] = this.y;
  5064. rb[0] = rt[0] = this.x + this.width;
  5065. rb[1] = lb[1] = this.y + this.height;
  5066. v2ApplyTransform(lt, lt, m);
  5067. v2ApplyTransform(rb, rb, m);
  5068. v2ApplyTransform(lb, lb, m);
  5069. v2ApplyTransform(rt, rt, m);
  5070. this.x = mathMin(lt[0], rb[0], lb[0], rt[0]);
  5071. this.y = mathMin(lt[1], rb[1], lb[1], rt[1]);
  5072. var maxX = mathMax(lt[0], rb[0], lb[0], rt[0]);
  5073. var maxY = mathMax(lt[1], rb[1], lb[1], rt[1]);
  5074. this.width = maxX - this.x;
  5075. this.height = maxY - this.y;
  5076. };
  5077. })(),
  5078. /**
  5079. * Calculate matrix of transforming from self to target rect
  5080. * @param {module:zrender/core/BoundingRect} b
  5081. * @return {Array.<number>}
  5082. */
  5083. calculateTransform: function (b) {
  5084. var a = this;
  5085. var sx = b.width / a.width;
  5086. var sy = b.height / a.height;
  5087. var m = matrix.create();
  5088. // 矩阵右乘
  5089. matrix.translate(m, m, [-a.x, -a.y]);
  5090. matrix.scale(m, m, [sx, sy]);
  5091. matrix.translate(m, m, [b.x, b.y]);
  5092. return m;
  5093. },
  5094. /**
  5095. * @param {(module:echarts/core/BoundingRect|Object)} b
  5096. * @return {boolean}
  5097. */
  5098. intersect: function (b) {
  5099. if (!b) {
  5100. return false;
  5101. }
  5102. if (!(b instanceof BoundingRect)) {
  5103. // Normalize negative width/height.
  5104. b = BoundingRect.create(b);
  5105. }
  5106. var a = this;
  5107. var ax0 = a.x;
  5108. var ax1 = a.x + a.width;
  5109. var ay0 = a.y;
  5110. var ay1 = a.y + a.height;
  5111. var bx0 = b.x;
  5112. var bx1 = b.x + b.width;
  5113. var by0 = b.y;
  5114. var by1 = b.y + b.height;
  5115. return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  5116. },
  5117. contain: function (x, y) {
  5118. var rect = this;
  5119. return x >= rect.x
  5120. && x <= (rect.x + rect.width)
  5121. && y >= rect.y
  5122. && y <= (rect.y + rect.height);
  5123. },
  5124. /**
  5125. * @return {module:echarts/core/BoundingRect}
  5126. */
  5127. clone: function () {
  5128. return new BoundingRect(this.x, this.y, this.width, this.height);
  5129. },
  5130. /**
  5131. * Copy from another rect
  5132. */
  5133. copy: function (other) {
  5134. this.x = other.x;
  5135. this.y = other.y;
  5136. this.width = other.width;
  5137. this.height = other.height;
  5138. },
  5139. plain: function () {
  5140. return {
  5141. x: this.x,
  5142. y: this.y,
  5143. width: this.width,
  5144. height: this.height
  5145. };
  5146. }
  5147. };
  5148. /**
  5149. * @param {Object|module:zrender/core/BoundingRect} rect
  5150. * @param {number} rect.x
  5151. * @param {number} rect.y
  5152. * @param {number} rect.width
  5153. * @param {number} rect.height
  5154. * @return {module:zrender/core/BoundingRect}
  5155. */
  5156. BoundingRect.create = function (rect) {
  5157. return new BoundingRect(rect.x, rect.y, rect.width, rect.height);
  5158. };
  5159. module.exports = BoundingRect;
  5160. /***/ }),
  5161. /* 10 */
  5162. /***/ (function(module, exports) {
  5163. var ArrayCtor = typeof Float32Array === 'undefined'
  5164. ? Array
  5165. : Float32Array;
  5166. /**
  5167. * @typedef {Float32Array|Array.<number>} Vector2
  5168. */
  5169. /**
  5170. * 二维向量类
  5171. * @exports zrender/tool/vector
  5172. */
  5173. var vector = {
  5174. /**
  5175. * 创建一个向量
  5176. * @param {number} [x=0]
  5177. * @param {number} [y=0]
  5178. * @return {Vector2}
  5179. */
  5180. create: function (x, y) {
  5181. var out = new ArrayCtor(2);
  5182. if (x == null) {
  5183. x = 0;
  5184. }
  5185. if (y == null) {
  5186. y = 0;
  5187. }
  5188. out[0] = x;
  5189. out[1] = y;
  5190. return out;
  5191. },
  5192. /**
  5193. * 复制向量数据
  5194. * @param {Vector2} out
  5195. * @param {Vector2} v
  5196. * @return {Vector2}
  5197. */
  5198. copy: function (out, v) {
  5199. out[0] = v[0];
  5200. out[1] = v[1];
  5201. return out;
  5202. },
  5203. /**
  5204. * 克隆一个向量
  5205. * @param {Vector2} v
  5206. * @return {Vector2}
  5207. */
  5208. clone: function (v) {
  5209. var out = new ArrayCtor(2);
  5210. out[0] = v[0];
  5211. out[1] = v[1];
  5212. return out;
  5213. },
  5214. /**
  5215. * 设置向量的两个项
  5216. * @param {Vector2} out
  5217. * @param {number} a
  5218. * @param {number} b
  5219. * @return {Vector2} 结果
  5220. */
  5221. set: function (out, a, b) {
  5222. out[0] = a;
  5223. out[1] = b;
  5224. return out;
  5225. },
  5226. /**
  5227. * 向量相加
  5228. * @param {Vector2} out
  5229. * @param {Vector2} v1
  5230. * @param {Vector2} v2
  5231. */
  5232. add: function (out, v1, v2) {
  5233. out[0] = v1[0] + v2[0];
  5234. out[1] = v1[1] + v2[1];
  5235. return out;
  5236. },
  5237. /**
  5238. * 向量缩放后相加
  5239. * @param {Vector2} out
  5240. * @param {Vector2} v1
  5241. * @param {Vector2} v2
  5242. * @param {number} a
  5243. */
  5244. scaleAndAdd: function (out, v1, v2, a) {
  5245. out[0] = v1[0] + v2[0] * a;
  5246. out[1] = v1[1] + v2[1] * a;
  5247. return out;
  5248. },
  5249. /**
  5250. * 向量相减
  5251. * @param {Vector2} out
  5252. * @param {Vector2} v1
  5253. * @param {Vector2} v2
  5254. */
  5255. sub: function (out, v1, v2) {
  5256. out[0] = v1[0] - v2[0];
  5257. out[1] = v1[1] - v2[1];
  5258. return out;
  5259. },
  5260. /**
  5261. * 向量长度
  5262. * @param {Vector2} v
  5263. * @return {number}
  5264. */
  5265. len: function (v) {
  5266. return Math.sqrt(this.lenSquare(v));
  5267. },
  5268. /**
  5269. * 向量长度平方
  5270. * @param {Vector2} v
  5271. * @return {number}
  5272. */
  5273. lenSquare: function (v) {
  5274. return v[0] * v[0] + v[1] * v[1];
  5275. },
  5276. /**
  5277. * 向量乘法
  5278. * @param {Vector2} out
  5279. * @param {Vector2} v1
  5280. * @param {Vector2} v2
  5281. */
  5282. mul: function (out, v1, v2) {
  5283. out[0] = v1[0] * v2[0];
  5284. out[1] = v1[1] * v2[1];
  5285. return out;
  5286. },
  5287. /**
  5288. * 向量除法
  5289. * @param {Vector2} out
  5290. * @param {Vector2} v1
  5291. * @param {Vector2} v2
  5292. */
  5293. div: function (out, v1, v2) {
  5294. out[0] = v1[0] / v2[0];
  5295. out[1] = v1[1] / v2[1];
  5296. return out;
  5297. },
  5298. /**
  5299. * 向量点乘
  5300. * @param {Vector2} v1
  5301. * @param {Vector2} v2
  5302. * @return {number}
  5303. */
  5304. dot: function (v1, v2) {
  5305. return v1[0] * v2[0] + v1[1] * v2[1];
  5306. },
  5307. /**
  5308. * 向量缩放
  5309. * @param {Vector2} out
  5310. * @param {Vector2} v
  5311. * @param {number} s
  5312. */
  5313. scale: function (out, v, s) {
  5314. out[0] = v[0] * s;
  5315. out[1] = v[1] * s;
  5316. return out;
  5317. },
  5318. /**
  5319. * 向量归一化
  5320. * @param {Vector2} out
  5321. * @param {Vector2} v
  5322. */
  5323. normalize: function (out, v) {
  5324. var d = vector.len(v);
  5325. if (d === 0) {
  5326. out[0] = 0;
  5327. out[1] = 0;
  5328. }
  5329. else {
  5330. out[0] = v[0] / d;
  5331. out[1] = v[1] / d;
  5332. }
  5333. return out;
  5334. },
  5335. /**
  5336. * 计算向量间距离
  5337. * @param {Vector2} v1
  5338. * @param {Vector2} v2
  5339. * @return {number}
  5340. */
  5341. distance: function (v1, v2) {
  5342. return Math.sqrt(
  5343. (v1[0] - v2[0]) * (v1[0] - v2[0])
  5344. + (v1[1] - v2[1]) * (v1[1] - v2[1])
  5345. );
  5346. },
  5347. /**
  5348. * 向量距离平方
  5349. * @param {Vector2} v1
  5350. * @param {Vector2} v2
  5351. * @return {number}
  5352. */
  5353. distanceSquare: function (v1, v2) {
  5354. return (v1[0] - v2[0]) * (v1[0] - v2[0])
  5355. + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  5356. },
  5357. /**
  5358. * 求负向量
  5359. * @param {Vector2} out
  5360. * @param {Vector2} v
  5361. */
  5362. negate: function (out, v) {
  5363. out[0] = -v[0];
  5364. out[1] = -v[1];
  5365. return out;
  5366. },
  5367. /**
  5368. * 插值两个点
  5369. * @param {Vector2} out
  5370. * @param {Vector2} v1
  5371. * @param {Vector2} v2
  5372. * @param {number} t
  5373. */
  5374. lerp: function (out, v1, v2, t) {
  5375. out[0] = v1[0] + t * (v2[0] - v1[0]);
  5376. out[1] = v1[1] + t * (v2[1] - v1[1]);
  5377. return out;
  5378. },
  5379. /**
  5380. * 矩阵左乘向量
  5381. * @param {Vector2} out
  5382. * @param {Vector2} v
  5383. * @param {Vector2} m
  5384. */
  5385. applyTransform: function (out, v, m) {
  5386. var x = v[0];
  5387. var y = v[1];
  5388. out[0] = m[0] * x + m[2] * y + m[4];
  5389. out[1] = m[1] * x + m[3] * y + m[5];
  5390. return out;
  5391. },
  5392. /**
  5393. * 求两个向量最小值
  5394. * @param {Vector2} out
  5395. * @param {Vector2} v1
  5396. * @param {Vector2} v2
  5397. */
  5398. min: function (out, v1, v2) {
  5399. out[0] = Math.min(v1[0], v2[0]);
  5400. out[1] = Math.min(v1[1], v2[1]);
  5401. return out;
  5402. },
  5403. /**
  5404. * 求两个向量最大值
  5405. * @param {Vector2} out
  5406. * @param {Vector2} v1
  5407. * @param {Vector2} v2
  5408. */
  5409. max: function (out, v1, v2) {
  5410. out[0] = Math.max(v1[0], v2[0]);
  5411. out[1] = Math.max(v1[1], v2[1]);
  5412. return out;
  5413. }
  5414. };
  5415. vector.length = vector.len;
  5416. vector.lengthSquare = vector.lenSquare;
  5417. vector.dist = vector.distance;
  5418. vector.distSquare = vector.distanceSquare;
  5419. module.exports = vector;
  5420. /***/ }),
  5421. /* 11 */
  5422. /***/ (function(module, exports) {
  5423. var ArrayCtor = typeof Float32Array === 'undefined'
  5424. ? Array
  5425. : Float32Array;
  5426. /**
  5427. * 3x2矩阵操作类
  5428. * @exports zrender/tool/matrix
  5429. */
  5430. var matrix = {
  5431. /**
  5432. * 创建一个单位矩阵
  5433. * @return {Float32Array|Array.<number>}
  5434. */
  5435. create : function() {
  5436. var out = new ArrayCtor(6);
  5437. matrix.identity(out);
  5438. return out;
  5439. },
  5440. /**
  5441. * 设置矩阵为单位矩阵
  5442. * @param {Float32Array|Array.<number>} out
  5443. */
  5444. identity : function(out) {
  5445. out[0] = 1;
  5446. out[1] = 0;
  5447. out[2] = 0;
  5448. out[3] = 1;
  5449. out[4] = 0;
  5450. out[5] = 0;
  5451. return out;
  5452. },
  5453. /**
  5454. * 复制矩阵
  5455. * @param {Float32Array|Array.<number>} out
  5456. * @param {Float32Array|Array.<number>} m
  5457. */
  5458. copy: function(out, m) {
  5459. out[0] = m[0];
  5460. out[1] = m[1];
  5461. out[2] = m[2];
  5462. out[3] = m[3];
  5463. out[4] = m[4];
  5464. out[5] = m[5];
  5465. return out;
  5466. },
  5467. /**
  5468. * 矩阵相乘
  5469. * @param {Float32Array|Array.<number>} out
  5470. * @param {Float32Array|Array.<number>} m1
  5471. * @param {Float32Array|Array.<number>} m2
  5472. */
  5473. mul : function (out, m1, m2) {
  5474. // Consider matrix.mul(m, m2, m);
  5475. // where out is the same as m2.
  5476. // So use temp variable to escape error.
  5477. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  5478. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  5479. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  5480. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  5481. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  5482. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  5483. out[0] = out0;
  5484. out[1] = out1;
  5485. out[2] = out2;
  5486. out[3] = out3;
  5487. out[4] = out4;
  5488. out[5] = out5;
  5489. return out;
  5490. },
  5491. /**
  5492. * 平移变换
  5493. * @param {Float32Array|Array.<number>} out
  5494. * @param {Float32Array|Array.<number>} a
  5495. * @param {Float32Array|Array.<number>} v
  5496. */
  5497. translate : function(out, a, v) {
  5498. out[0] = a[0];
  5499. out[1] = a[1];
  5500. out[2] = a[2];
  5501. out[3] = a[3];
  5502. out[4] = a[4] + v[0];
  5503. out[5] = a[5] + v[1];
  5504. return out;
  5505. },
  5506. /**
  5507. * 旋转变换
  5508. * @param {Float32Array|Array.<number>} out
  5509. * @param {Float32Array|Array.<number>} a
  5510. * @param {number} rad
  5511. */
  5512. rotate : function(out, a, rad) {
  5513. var aa = a[0];
  5514. var ac = a[2];
  5515. var atx = a[4];
  5516. var ab = a[1];
  5517. var ad = a[3];
  5518. var aty = a[5];
  5519. var st = Math.sin(rad);
  5520. var ct = Math.cos(rad);
  5521. out[0] = aa * ct + ab * st;
  5522. out[1] = -aa * st + ab * ct;
  5523. out[2] = ac * ct + ad * st;
  5524. out[3] = -ac * st + ct * ad;
  5525. out[4] = ct * atx + st * aty;
  5526. out[5] = ct * aty - st * atx;
  5527. return out;
  5528. },
  5529. /**
  5530. * 缩放变换
  5531. * @param {Float32Array|Array.<number>} out
  5532. * @param {Float32Array|Array.<number>} a
  5533. * @param {Float32Array|Array.<number>} v
  5534. */
  5535. scale : function(out, a, v) {
  5536. var vx = v[0];
  5537. var vy = v[1];
  5538. out[0] = a[0] * vx;
  5539. out[1] = a[1] * vy;
  5540. out[2] = a[2] * vx;
  5541. out[3] = a[3] * vy;
  5542. out[4] = a[4] * vx;
  5543. out[5] = a[5] * vy;
  5544. return out;
  5545. },
  5546. /**
  5547. * 求逆矩阵
  5548. * @param {Float32Array|Array.<number>} out
  5549. * @param {Float32Array|Array.<number>} a
  5550. */
  5551. invert : function(out, a) {
  5552. var aa = a[0];
  5553. var ac = a[2];
  5554. var atx = a[4];
  5555. var ab = a[1];
  5556. var ad = a[3];
  5557. var aty = a[5];
  5558. var det = aa * ad - ab * ac;
  5559. if (!det) {
  5560. return null;
  5561. }
  5562. det = 1.0 / det;
  5563. out[0] = ad * det;
  5564. out[1] = -ab * det;
  5565. out[2] = -ac * det;
  5566. out[3] = aa * det;
  5567. out[4] = (ac * aty - ad * atx) * det;
  5568. out[5] = (ab * atx - aa * aty) * det;
  5569. return out;
  5570. }
  5571. };
  5572. module.exports = matrix;
  5573. /***/ }),
  5574. /* 12 */
  5575. /***/ (function(module, exports, __webpack_require__) {
  5576. var LRU = __webpack_require__(13);
  5577. var globalImageCache = new LRU(50);
  5578. var helper = {};
  5579. /**
  5580. * @param {string|HTMLImageElement|HTMLCanvasElement|Canvas} newImageOrSrc
  5581. * @return {HTMLImageElement|HTMLCanvasElement|Canvas} image
  5582. */
  5583. helper.findExistImage = function (newImageOrSrc) {
  5584. if (typeof newImageOrSrc === 'string') {
  5585. var cachedImgObj = globalImageCache.get(newImageOrSrc);
  5586. return cachedImgObj && cachedImgObj.image;
  5587. }
  5588. else {
  5589. return newImageOrSrc;
  5590. }
  5591. };
  5592. /**
  5593. * Caution: User should cache loaded images, but not just count on LRU.
  5594. * Consider if required images more than LRU size, will dead loop occur?
  5595. *
  5596. * @param {string|HTMLImageElement|HTMLCanvasElement|Canvas} newImageOrSrc
  5597. * @param {HTMLImageElement|HTMLCanvasElement|Canvas} image Existent image.
  5598. * @param {module:zrender/Element} [hostEl] For calling `dirty`.
  5599. * @param {Function} [cb] params: (image, cbPayload)
  5600. * @param {Object} [cbPayload] Payload on cb calling.
  5601. * @return {HTMLImageElement|HTMLCanvasElement|Canvas} image
  5602. */
  5603. helper.createOrUpdateImage = function (newImageOrSrc, image, hostEl, cb, cbPayload) {
  5604. if (!newImageOrSrc) {
  5605. return image;
  5606. }
  5607. else if (typeof newImageOrSrc === 'string') {
  5608. // Image should not be loaded repeatly.
  5609. if ((image && image.__zrImageSrc === newImageOrSrc) || !hostEl) {
  5610. return image;
  5611. }
  5612. // Only when there is no existent image or existent image src
  5613. // is different, this method is responsible for load.
  5614. var cachedImgObj = globalImageCache.get(newImageOrSrc);
  5615. var pendingWrap = {hostEl: hostEl, cb: cb, cbPayload: cbPayload};
  5616. if (cachedImgObj) {
  5617. image = cachedImgObj.image;
  5618. !isImageReady(image) && cachedImgObj.pending.push(pendingWrap);
  5619. }
  5620. else {
  5621. !image && (image = new Image());
  5622. image.onload = imageOnLoad;
  5623. globalImageCache.put(
  5624. newImageOrSrc,
  5625. image.__cachedImgObj = {
  5626. image: image,
  5627. pending: [pendingWrap]
  5628. }
  5629. );
  5630. image.src = image.__zrImageSrc = newImageOrSrc;
  5631. }
  5632. return image;
  5633. }
  5634. // newImageOrSrc is an HTMLImageElement or HTMLCanvasElement or Canvas
  5635. else {
  5636. return newImageOrSrc;
  5637. }
  5638. };
  5639. function imageOnLoad() {
  5640. var cachedImgObj = this.__cachedImgObj;
  5641. this.onload = this.__cachedImgObj = null;
  5642. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  5643. var pendingWrap = cachedImgObj.pending[i];
  5644. var cb = pendingWrap.cb;
  5645. cb && cb(this, pendingWrap.cbPayload);
  5646. pendingWrap.hostEl.dirty();
  5647. }
  5648. cachedImgObj.pending.length = 0;
  5649. }
  5650. var isImageReady = helper.isImageReady = function (image) {
  5651. return image && image.width && image.height;
  5652. };
  5653. module.exports = helper;
  5654. /***/ }),
  5655. /* 13 */
  5656. /***/ (function(module, exports) {
  5657. // Simple LRU cache use doubly linked list
  5658. // @module zrender/core/LRU
  5659. /**
  5660. * Simple double linked list. Compared with array, it has O(1) remove operation.
  5661. * @constructor
  5662. */
  5663. var LinkedList = function () {
  5664. /**
  5665. * @type {module:zrender/core/LRU~Entry}
  5666. */
  5667. this.head = null;
  5668. /**
  5669. * @type {module:zrender/core/LRU~Entry}
  5670. */
  5671. this.tail = null;
  5672. this._len = 0;
  5673. };
  5674. var linkedListProto = LinkedList.prototype;
  5675. /**
  5676. * Insert a new value at the tail
  5677. * @param {} val
  5678. * @return {module:zrender/core/LRU~Entry}
  5679. */
  5680. linkedListProto.insert = function (val) {
  5681. var entry = new Entry(val);
  5682. this.insertEntry(entry);
  5683. return entry;
  5684. };
  5685. /**
  5686. * Insert an entry at the tail
  5687. * @param {module:zrender/core/LRU~Entry} entry
  5688. */
  5689. linkedListProto.insertEntry = function (entry) {
  5690. if (!this.head) {
  5691. this.head = this.tail = entry;
  5692. }
  5693. else {
  5694. this.tail.next = entry;
  5695. entry.prev = this.tail;
  5696. entry.next = null;
  5697. this.tail = entry;
  5698. }
  5699. this._len++;
  5700. };
  5701. /**
  5702. * Remove entry.
  5703. * @param {module:zrender/core/LRU~Entry} entry
  5704. */
  5705. linkedListProto.remove = function (entry) {
  5706. var prev = entry.prev;
  5707. var next = entry.next;
  5708. if (prev) {
  5709. prev.next = next;
  5710. }
  5711. else {
  5712. // Is head
  5713. this.head = next;
  5714. }
  5715. if (next) {
  5716. next.prev = prev;
  5717. }
  5718. else {
  5719. // Is tail
  5720. this.tail = prev;
  5721. }
  5722. entry.next = entry.prev = null;
  5723. this._len--;
  5724. };
  5725. /**
  5726. * @return {number}
  5727. */
  5728. linkedListProto.len = function () {
  5729. return this._len;
  5730. };
  5731. /**
  5732. * Clear list
  5733. */
  5734. linkedListProto.clear = function () {
  5735. this.head = this.tail = null;
  5736. this._len = 0;
  5737. };
  5738. /**
  5739. * @constructor
  5740. * @param {} val
  5741. */
  5742. var Entry = function (val) {
  5743. /**
  5744. * @type {}
  5745. */
  5746. this.value = val;
  5747. /**
  5748. * @type {module:zrender/core/LRU~Entry}
  5749. */
  5750. this.next;
  5751. /**
  5752. * @type {module:zrender/core/LRU~Entry}
  5753. */
  5754. this.prev;
  5755. };
  5756. /**
  5757. * LRU Cache
  5758. * @constructor
  5759. * @alias module:zrender/core/LRU
  5760. */
  5761. var LRU = function (maxSize) {
  5762. this._list = new LinkedList();
  5763. this._map = {};
  5764. this._maxSize = maxSize || 10;
  5765. this._lastRemovedEntry = null;
  5766. };
  5767. var LRUProto = LRU.prototype;
  5768. /**
  5769. * @param {string} key
  5770. * @param {} value
  5771. * @return {} Removed value
  5772. */
  5773. LRUProto.put = function (key, value) {
  5774. var list = this._list;
  5775. var map = this._map;
  5776. var removed = null;
  5777. if (map[key] == null) {
  5778. var len = list.len();
  5779. // Reuse last removed entry
  5780. var entry = this._lastRemovedEntry;
  5781. if (len >= this._maxSize && len > 0) {
  5782. // Remove the least recently used
  5783. var leastUsedEntry = list.head;
  5784. list.remove(leastUsedEntry);
  5785. delete map[leastUsedEntry.key];
  5786. removed = leastUsedEntry.value;
  5787. this._lastRemovedEntry = leastUsedEntry;
  5788. }
  5789. if (entry) {
  5790. entry.value = value;
  5791. }
  5792. else {
  5793. entry = new Entry(value);
  5794. }
  5795. entry.key = key;
  5796. list.insertEntry(entry);
  5797. map[key] = entry;
  5798. }
  5799. return removed;
  5800. };
  5801. /**
  5802. * @param {string} key
  5803. * @return {}
  5804. */
  5805. LRUProto.get = function (key) {
  5806. var entry = this._map[key];
  5807. var list = this._list;
  5808. if (entry != null) {
  5809. // Put the latest used entry in the tail
  5810. if (entry !== list.tail) {
  5811. list.remove(entry);
  5812. list.insertEntry(entry);
  5813. }
  5814. return entry.value;
  5815. }
  5816. };
  5817. /**
  5818. * Clear the cache
  5819. */
  5820. LRUProto.clear = function () {
  5821. this._list.clear();
  5822. this._map = {};
  5823. };
  5824. module.exports = LRU;
  5825. /***/ }),
  5826. /* 14 */
  5827. /***/ (function(module, exports, __webpack_require__) {
  5828. /**
  5829. * @module echarts/model/Model
  5830. */
  5831. var zrUtil = __webpack_require__(4);
  5832. var clazzUtil = __webpack_require__(15);
  5833. var env = __webpack_require__(2);
  5834. /**
  5835. * @alias module:echarts/model/Model
  5836. * @constructor
  5837. * @param {Object} option
  5838. * @param {module:echarts/model/Model} [parentModel]
  5839. * @param {module:echarts/model/Global} [ecModel]
  5840. */
  5841. function Model(option, parentModel, ecModel) {
  5842. /**
  5843. * @type {module:echarts/model/Model}
  5844. * @readOnly
  5845. */
  5846. this.parentModel = parentModel;
  5847. /**
  5848. * @type {module:echarts/model/Global}
  5849. * @readOnly
  5850. */
  5851. this.ecModel = ecModel;
  5852. /**
  5853. * @type {Object}
  5854. * @protected
  5855. */
  5856. this.option = option;
  5857. // Simple optimization
  5858. // if (this.init) {
  5859. // if (arguments.length <= 4) {
  5860. // this.init(option, parentModel, ecModel, extraOpt);
  5861. // }
  5862. // else {
  5863. // this.init.apply(this, arguments);
  5864. // }
  5865. // }
  5866. }
  5867. Model.prototype = {
  5868. constructor: Model,
  5869. /**
  5870. * Model 的初始化函数
  5871. * @param {Object} option
  5872. */
  5873. init: null,
  5874. /**
  5875. * 从新的 Option merge
  5876. */
  5877. mergeOption: function (option) {
  5878. zrUtil.merge(this.option, option, true);
  5879. },
  5880. /**
  5881. * @param {string|Array.<string>} path
  5882. * @param {boolean} [ignoreParent=false]
  5883. * @return {*}
  5884. */
  5885. get: function (path, ignoreParent) {
  5886. if (path == null) {
  5887. return this.option;
  5888. }
  5889. return doGet(
  5890. this.option,
  5891. this.parsePath(path),
  5892. !ignoreParent && getParent(this, path)
  5893. );
  5894. },
  5895. /**
  5896. * @param {string} key
  5897. * @param {boolean} [ignoreParent=false]
  5898. * @return {*}
  5899. */
  5900. getShallow: function (key, ignoreParent) {
  5901. var option = this.option;
  5902. var val = option == null ? option : option[key];
  5903. var parentModel = !ignoreParent && getParent(this, key);
  5904. if (val == null && parentModel) {
  5905. val = parentModel.getShallow(key);
  5906. }
  5907. return val;
  5908. },
  5909. /**
  5910. * @param {string|Array.<string>} [path]
  5911. * @param {module:echarts/model/Model} [parentModel]
  5912. * @return {module:echarts/model/Model}
  5913. */
  5914. getModel: function (path, parentModel) {
  5915. var obj = path == null
  5916. ? this.option
  5917. : doGet(this.option, path = this.parsePath(path));
  5918. var thisParentModel;
  5919. parentModel = parentModel || (
  5920. (thisParentModel = getParent(this, path))
  5921. && thisParentModel.getModel(path)
  5922. );
  5923. return new Model(obj, parentModel, this.ecModel);
  5924. },
  5925. /**
  5926. * If model has option
  5927. */
  5928. isEmpty: function () {
  5929. return this.option == null;
  5930. },
  5931. restoreData: function () {},
  5932. // Pending
  5933. clone: function () {
  5934. var Ctor = this.constructor;
  5935. return new Ctor(zrUtil.clone(this.option));
  5936. },
  5937. setReadOnly: function (properties) {
  5938. clazzUtil.setReadOnly(this, properties);
  5939. },
  5940. // If path is null/undefined, return null/undefined.
  5941. parsePath: function(path) {
  5942. if (typeof path === 'string') {
  5943. path = path.split('.');
  5944. }
  5945. return path;
  5946. },
  5947. /**
  5948. * @param {Function} getParentMethod
  5949. * param {Array.<string>|string} path
  5950. * return {module:echarts/model/Model}
  5951. */
  5952. customizeGetParent: function (getParentMethod) {
  5953. clazzUtil.set(this, 'getParent', getParentMethod);
  5954. },
  5955. isAnimationEnabled: function () {
  5956. if (!env.node) {
  5957. if (this.option.animation != null) {
  5958. return !!this.option.animation;
  5959. }
  5960. else if (this.parentModel) {
  5961. return this.parentModel.isAnimationEnabled();
  5962. }
  5963. }
  5964. }
  5965. };
  5966. function doGet(obj, pathArr, parentModel) {
  5967. for (var i = 0; i < pathArr.length; i++) {
  5968. // Ignore empty
  5969. if (!pathArr[i]) {
  5970. continue;
  5971. }
  5972. // obj could be number/string/... (like 0)
  5973. obj = (obj && typeof obj === 'object') ? obj[pathArr[i]] : null;
  5974. if (obj == null) {
  5975. break;
  5976. }
  5977. }
  5978. if (obj == null && parentModel) {
  5979. obj = parentModel.get(pathArr);
  5980. }
  5981. return obj;
  5982. }
  5983. // `path` can be null/undefined
  5984. function getParent(model, path) {
  5985. var getParentMethod = clazzUtil.get(model, 'getParent');
  5986. return getParentMethod ? getParentMethod.call(model, path) : model.parentModel;
  5987. }
  5988. // Enable Model.extend.
  5989. clazzUtil.enableClassExtend(Model);
  5990. var mixin = zrUtil.mixin;
  5991. mixin(Model, __webpack_require__(16));
  5992. mixin(Model, __webpack_require__(18));
  5993. mixin(Model, __webpack_require__(19));
  5994. mixin(Model, __webpack_require__(71));
  5995. module.exports = Model;
  5996. /***/ }),
  5997. /* 15 */
  5998. /***/ (function(module, exports, __webpack_require__) {
  5999. var zrUtil = __webpack_require__(4);
  6000. var clazz = {};
  6001. var TYPE_DELIMITER = '.';
  6002. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  6003. var MEMBER_PRIFIX = '\0ec_\0';
  6004. /**
  6005. * Hide private class member.
  6006. * The same behavior as `host[name] = value;` (can be right-value)
  6007. * @public
  6008. */
  6009. clazz.set = function (host, name, value) {
  6010. return (host[MEMBER_PRIFIX + name] = value);
  6011. };
  6012. /**
  6013. * Hide private class member.
  6014. * The same behavior as `host[name];`
  6015. * @public
  6016. */
  6017. clazz.get = function (host, name) {
  6018. return host[MEMBER_PRIFIX + name];
  6019. };
  6020. /**
  6021. * For hidden private class member.
  6022. * The same behavior as `host.hasOwnProperty(name);`
  6023. * @public
  6024. */
  6025. clazz.hasOwn = function (host, name) {
  6026. return host.hasOwnProperty(MEMBER_PRIFIX + name);
  6027. };
  6028. /**
  6029. * Notice, parseClassType('') should returns {main: '', sub: ''}
  6030. * @public
  6031. */
  6032. var parseClassType = clazz.parseClassType = function (componentType) {
  6033. var ret = {main: '', sub: ''};
  6034. if (componentType) {
  6035. componentType = componentType.split(TYPE_DELIMITER);
  6036. ret.main = componentType[0] || '';
  6037. ret.sub = componentType[1] || '';
  6038. }
  6039. return ret;
  6040. };
  6041. /**
  6042. * @public
  6043. */
  6044. function checkClassType(componentType) {
  6045. zrUtil.assert(
  6046. /^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType),
  6047. 'componentType "' + componentType + '" illegal'
  6048. );
  6049. }
  6050. /**
  6051. * @public
  6052. */
  6053. clazz.enableClassExtend = function (RootClass, mandatoryMethods) {
  6054. RootClass.$constructor = RootClass;
  6055. RootClass.extend = function (proto) {
  6056. if (true) {
  6057. zrUtil.each(mandatoryMethods, function (method) {
  6058. if (!proto[method]) {
  6059. console.warn(
  6060. 'Method `' + method + '` should be implemented'
  6061. + (proto.type ? ' in ' + proto.type : '') + '.'
  6062. );
  6063. }
  6064. });
  6065. }
  6066. var superClass = this;
  6067. var ExtendedClass = function () {
  6068. if (!proto.$constructor) {
  6069. superClass.apply(this, arguments);
  6070. }
  6071. else {
  6072. proto.$constructor.apply(this, arguments);
  6073. }
  6074. };
  6075. zrUtil.extend(ExtendedClass.prototype, proto);
  6076. ExtendedClass.extend = this.extend;
  6077. ExtendedClass.superCall = superCall;
  6078. ExtendedClass.superApply = superApply;
  6079. zrUtil.inherits(ExtendedClass, this);
  6080. ExtendedClass.superClass = superClass;
  6081. return ExtendedClass;
  6082. };
  6083. };
  6084. // superCall should have class info, which can not be fetch from 'this'.
  6085. // Consider this case:
  6086. // class A has method f,
  6087. // class B inherits class A, overrides method f, f call superApply('f'),
  6088. // class C inherits class B, do not overrides method f,
  6089. // then when method of class C is called, dead loop occured.
  6090. function superCall(context, methodName) {
  6091. var args = zrUtil.slice(arguments, 2);
  6092. return this.superClass.prototype[methodName].apply(context, args);
  6093. }
  6094. function superApply(context, methodName, args) {
  6095. return this.superClass.prototype[methodName].apply(context, args);
  6096. }
  6097. /**
  6098. * @param {Object} entity
  6099. * @param {Object} options
  6100. * @param {boolean} [options.registerWhenExtend]
  6101. * @public
  6102. */
  6103. clazz.enableClassManagement = function (entity, options) {
  6104. options = options || {};
  6105. /**
  6106. * Component model classes
  6107. * key: componentType,
  6108. * value:
  6109. * componentClass, when componentType is 'xxx'
  6110. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  6111. * @type {Object}
  6112. */
  6113. var storage = {};
  6114. entity.registerClass = function (Clazz, componentType) {
  6115. if (componentType) {
  6116. checkClassType(componentType);
  6117. componentType = parseClassType(componentType);
  6118. if (!componentType.sub) {
  6119. if (true) {
  6120. if (storage[componentType.main]) {
  6121. console.warn(componentType.main + ' exists.');
  6122. }
  6123. }
  6124. storage[componentType.main] = Clazz;
  6125. }
  6126. else if (componentType.sub !== IS_CONTAINER) {
  6127. var container = makeContainer(componentType);
  6128. container[componentType.sub] = Clazz;
  6129. }
  6130. }
  6131. return Clazz;
  6132. };
  6133. entity.getClass = function (componentMainType, subType, throwWhenNotFound) {
  6134. var Clazz = storage[componentMainType];
  6135. if (Clazz && Clazz[IS_CONTAINER]) {
  6136. Clazz = subType ? Clazz[subType] : null;
  6137. }
  6138. if (throwWhenNotFound && !Clazz) {
  6139. throw new Error(
  6140. !subType
  6141. ? componentMainType + '.' + 'type should be specified.'
  6142. : 'Component ' + componentMainType + '.' + (subType || '') + ' not exists. Load it first.'
  6143. );
  6144. }
  6145. return Clazz;
  6146. };
  6147. entity.getClassesByMainType = function (componentType) {
  6148. componentType = parseClassType(componentType);
  6149. var result = [];
  6150. var obj = storage[componentType.main];
  6151. if (obj && obj[IS_CONTAINER]) {
  6152. zrUtil.each(obj, function (o, type) {
  6153. type !== IS_CONTAINER && result.push(o);
  6154. });
  6155. }
  6156. else {
  6157. result.push(obj);
  6158. }
  6159. return result;
  6160. };
  6161. entity.hasClass = function (componentType) {
  6162. // Just consider componentType.main.
  6163. componentType = parseClassType(componentType);
  6164. return !!storage[componentType.main];
  6165. };
  6166. /**
  6167. * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
  6168. */
  6169. entity.getAllClassMainTypes = function () {
  6170. var types = [];
  6171. zrUtil.each(storage, function (obj, type) {
  6172. types.push(type);
  6173. });
  6174. return types;
  6175. };
  6176. /**
  6177. * If a main type is container and has sub types
  6178. * @param {string} mainType
  6179. * @return {boolean}
  6180. */
  6181. entity.hasSubTypes = function (componentType) {
  6182. componentType = parseClassType(componentType);
  6183. var obj = storage[componentType.main];
  6184. return obj && obj[IS_CONTAINER];
  6185. };
  6186. entity.parseClassType = parseClassType;
  6187. function makeContainer(componentType) {
  6188. var container = storage[componentType.main];
  6189. if (!container || !container[IS_CONTAINER]) {
  6190. container = storage[componentType.main] = {};
  6191. container[IS_CONTAINER] = true;
  6192. }
  6193. return container;
  6194. }
  6195. if (options.registerWhenExtend) {
  6196. var originalExtend = entity.extend;
  6197. if (originalExtend) {
  6198. entity.extend = function (proto) {
  6199. var ExtendedClass = originalExtend.call(this, proto);
  6200. return entity.registerClass(ExtendedClass, proto.type);
  6201. };
  6202. }
  6203. }
  6204. return entity;
  6205. };
  6206. /**
  6207. * @param {string|Array.<string>} properties
  6208. */
  6209. clazz.setReadOnly = function (obj, properties) {
  6210. // FIXME It seems broken in IE8 simulation of IE11
  6211. // if (!zrUtil.isArray(properties)) {
  6212. // properties = properties != null ? [properties] : [];
  6213. // }
  6214. // zrUtil.each(properties, function (prop) {
  6215. // var value = obj[prop];
  6216. // Object.defineProperty
  6217. // && Object.defineProperty(obj, prop, {
  6218. // value: value, writable: false
  6219. // });
  6220. // zrUtil.isArray(obj[prop])
  6221. // && Object.freeze
  6222. // && Object.freeze(obj[prop]);
  6223. // });
  6224. };
  6225. module.exports = clazz;
  6226. /***/ }),
  6227. /* 16 */
  6228. /***/ (function(module, exports, __webpack_require__) {
  6229. var getLineStyle = __webpack_require__(17)(
  6230. [
  6231. ['lineWidth', 'width'],
  6232. ['stroke', 'color'],
  6233. ['opacity'],
  6234. ['shadowBlur'],
  6235. ['shadowOffsetX'],
  6236. ['shadowOffsetY'],
  6237. ['shadowColor']
  6238. ]
  6239. );
  6240. module.exports = {
  6241. getLineStyle: function (excludes) {
  6242. var style = getLineStyle.call(this, excludes);
  6243. var lineDash = this.getLineDash(style.lineWidth);
  6244. lineDash && (style.lineDash = lineDash);
  6245. return style;
  6246. },
  6247. getLineDash: function (lineWidth) {
  6248. if (lineWidth == null) {
  6249. lineWidth = 1;
  6250. }
  6251. var lineType = this.get('type');
  6252. var dotSize = Math.max(lineWidth, 2);
  6253. var dashSize = lineWidth * 4;
  6254. return (lineType === 'solid' || lineType == null) ? null
  6255. : (lineType === 'dashed' ? [dashSize, dashSize] : [dotSize, dotSize]);
  6256. }
  6257. };
  6258. /***/ }),
  6259. /* 17 */
  6260. /***/ (function(module, exports, __webpack_require__) {
  6261. // TODO Parse shadow style
  6262. // TODO Only shallow path support
  6263. var zrUtil = __webpack_require__(4);
  6264. module.exports = function (properties) {
  6265. // Normalize
  6266. for (var i = 0; i < properties.length; i++) {
  6267. if (!properties[i][1]) {
  6268. properties[i][1] = properties[i][0];
  6269. }
  6270. }
  6271. return function (excludes, includes) {
  6272. var style = {};
  6273. for (var i = 0; i < properties.length; i++) {
  6274. var propName = properties[i][1];
  6275. if ((excludes && zrUtil.indexOf(excludes, propName) >= 0)
  6276. || (includes && zrUtil.indexOf(includes, propName) < 0)
  6277. ) {
  6278. continue;
  6279. }
  6280. var val = this.getShallow(propName);
  6281. if (val != null) {
  6282. style[properties[i][0]] = val;
  6283. }
  6284. }
  6285. return style;
  6286. };
  6287. };
  6288. /***/ }),
  6289. /* 18 */
  6290. /***/ (function(module, exports, __webpack_require__) {
  6291. module.exports = {
  6292. getAreaStyle: __webpack_require__(17)(
  6293. [
  6294. ['fill', 'color'],
  6295. ['shadowBlur'],
  6296. ['shadowOffsetX'],
  6297. ['shadowOffsetY'],
  6298. ['opacity'],
  6299. ['shadowColor']
  6300. ]
  6301. )
  6302. };
  6303. /***/ }),
  6304. /* 19 */
  6305. /***/ (function(module, exports, __webpack_require__) {
  6306. var textContain = __webpack_require__(8);
  6307. var graphicUtil = __webpack_require__(20);
  6308. var PATH_COLOR = ['textStyle', 'color'];
  6309. module.exports = {
  6310. /**
  6311. * Get color property or get color from option.textStyle.color
  6312. * @param {boolean} [isEmphasis]
  6313. * @return {string}
  6314. */
  6315. getTextColor: function (isEmphasis) {
  6316. var ecModel = this.ecModel;
  6317. return this.getShallow('color')
  6318. || (
  6319. (!isEmphasis && ecModel) ? ecModel.get(PATH_COLOR) : null
  6320. );
  6321. },
  6322. /**
  6323. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  6324. * @return {string}
  6325. */
  6326. getFont: function () {
  6327. return graphicUtil.getFont({
  6328. fontStyle: this.getShallow('fontStyle'),
  6329. fontWeight: this.getShallow('fontWeight'),
  6330. fontSize: this.getShallow('fontSize'),
  6331. fontFamily: this.getShallow('fontFamily')
  6332. }, this.ecModel);
  6333. },
  6334. getTextRect: function (text) {
  6335. return textContain.getBoundingRect(
  6336. text,
  6337. this.getFont(),
  6338. this.getShallow('align'),
  6339. this.getShallow('verticalAlign') || this.getShallow('baseline'),
  6340. this.getShallow('padding'),
  6341. this.getShallow('rich'),
  6342. this.getShallow('truncateText')
  6343. );
  6344. }
  6345. };
  6346. /***/ }),
  6347. /* 20 */
  6348. /***/ (function(module, exports, __webpack_require__) {
  6349. 'use strict';
  6350. var zrUtil = __webpack_require__(4);
  6351. var pathTool = __webpack_require__(21);
  6352. var Path = __webpack_require__(22);
  6353. var colorTool = __webpack_require__(33);
  6354. var matrix = __webpack_require__(11);
  6355. var vector = __webpack_require__(10);
  6356. var Transformable = __webpack_require__(28);
  6357. var BoundingRect = __webpack_require__(9);
  6358. var round = Math.round;
  6359. var mathMax = Math.max;
  6360. var mathMin = Math.min;
  6361. var EMPTY_OBJ = {};
  6362. var graphic = {};
  6363. graphic.Group = __webpack_require__(51);
  6364. graphic.Image = __webpack_require__(52);
  6365. graphic.Text = __webpack_require__(53);
  6366. graphic.Circle = __webpack_require__(54);
  6367. graphic.Sector = __webpack_require__(55);
  6368. graphic.Ring = __webpack_require__(57);
  6369. graphic.Polygon = __webpack_require__(58);
  6370. graphic.Polyline = __webpack_require__(62);
  6371. graphic.Rect = __webpack_require__(63);
  6372. graphic.Line = __webpack_require__(64);
  6373. graphic.BezierCurve = __webpack_require__(65);
  6374. graphic.Arc = __webpack_require__(66);
  6375. graphic.CompoundPath = __webpack_require__(67);
  6376. graphic.LinearGradient = __webpack_require__(68);
  6377. graphic.RadialGradient = __webpack_require__(70);
  6378. graphic.BoundingRect = BoundingRect;
  6379. /**
  6380. * Extend shape with parameters
  6381. */
  6382. graphic.extendShape = function (opts) {
  6383. return Path.extend(opts);
  6384. };
  6385. /**
  6386. * Extend path
  6387. */
  6388. graphic.extendPath = function (pathData, opts) {
  6389. return pathTool.extendFromString(pathData, opts);
  6390. };
  6391. /**
  6392. * Create a path element from path data string
  6393. * @param {string} pathData
  6394. * @param {Object} opts
  6395. * @param {module:zrender/core/BoundingRect} rect
  6396. * @param {string} [layout=cover] 'center' or 'cover'
  6397. */
  6398. graphic.makePath = function (pathData, opts, rect, layout) {
  6399. var path = pathTool.createFromString(pathData, opts);
  6400. var boundingRect = path.getBoundingRect();
  6401. if (rect) {
  6402. var aspect = boundingRect.width / boundingRect.height;
  6403. if (layout === 'center') {
  6404. // Set rect to center, keep width / height ratio.
  6405. var width = rect.height * aspect;
  6406. var height;
  6407. if (width <= rect.width) {
  6408. height = rect.height;
  6409. }
  6410. else {
  6411. width = rect.width;
  6412. height = width / aspect;
  6413. }
  6414. var cx = rect.x + rect.width / 2;
  6415. var cy = rect.y + rect.height / 2;
  6416. rect.x = cx - width / 2;
  6417. rect.y = cy - height / 2;
  6418. rect.width = width;
  6419. rect.height = height;
  6420. }
  6421. graphic.resizePath(path, rect);
  6422. }
  6423. return path;
  6424. };
  6425. graphic.mergePath = pathTool.mergePath,
  6426. /**
  6427. * Resize a path to fit the rect
  6428. * @param {module:zrender/graphic/Path} path
  6429. * @param {Object} rect
  6430. */
  6431. graphic.resizePath = function (path, rect) {
  6432. if (!path.applyTransform) {
  6433. return;
  6434. }
  6435. var pathRect = path.getBoundingRect();
  6436. var m = pathRect.calculateTransform(rect);
  6437. path.applyTransform(m);
  6438. };
  6439. /**
  6440. * Sub pixel optimize line for canvas
  6441. *
  6442. * @param {Object} param
  6443. * @param {Object} [param.shape]
  6444. * @param {number} [param.shape.x1]
  6445. * @param {number} [param.shape.y1]
  6446. * @param {number} [param.shape.x2]
  6447. * @param {number} [param.shape.y2]
  6448. * @param {Object} [param.style]
  6449. * @param {number} [param.style.lineWidth]
  6450. * @return {Object} Modified param
  6451. */
  6452. graphic.subPixelOptimizeLine = function (param) {
  6453. var shape = param.shape;
  6454. var lineWidth = param.style.lineWidth;
  6455. if (round(shape.x1 * 2) === round(shape.x2 * 2)) {
  6456. shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true);
  6457. }
  6458. if (round(shape.y1 * 2) === round(shape.y2 * 2)) {
  6459. shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true);
  6460. }
  6461. return param;
  6462. };
  6463. /**
  6464. * Sub pixel optimize rect for canvas
  6465. *
  6466. * @param {Object} param
  6467. * @param {Object} [param.shape]
  6468. * @param {number} [param.shape.x]
  6469. * @param {number} [param.shape.y]
  6470. * @param {number} [param.shape.width]
  6471. * @param {number} [param.shape.height]
  6472. * @param {Object} [param.style]
  6473. * @param {number} [param.style.lineWidth]
  6474. * @return {Object} Modified param
  6475. */
  6476. graphic.subPixelOptimizeRect = function (param) {
  6477. var shape = param.shape;
  6478. var lineWidth = param.style.lineWidth;
  6479. var originX = shape.x;
  6480. var originY = shape.y;
  6481. var originWidth = shape.width;
  6482. var originHeight = shape.height;
  6483. shape.x = subPixelOptimize(shape.x, lineWidth, true);
  6484. shape.y = subPixelOptimize(shape.y, lineWidth, true);
  6485. shape.width = Math.max(
  6486. subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x,
  6487. originWidth === 0 ? 0 : 1
  6488. );
  6489. shape.height = Math.max(
  6490. subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y,
  6491. originHeight === 0 ? 0 : 1
  6492. );
  6493. return param;
  6494. };
  6495. /**
  6496. * Sub pixel optimize for canvas
  6497. *
  6498. * @param {number} position Coordinate, such as x, y
  6499. * @param {number} lineWidth Should be nonnegative integer.
  6500. * @param {boolean=} positiveOrNegative Default false (negative).
  6501. * @return {number} Optimized position.
  6502. */
  6503. var subPixelOptimize = graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
  6504. // Assure that (position + lineWidth / 2) is near integer edge,
  6505. // otherwise line will be fuzzy in canvas.
  6506. var doubledPosition = round(position * 2);
  6507. return (doubledPosition + round(lineWidth)) % 2 === 0
  6508. ? doubledPosition / 2
  6509. : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  6510. };
  6511. function hasFillOrStroke(fillOrStroke) {
  6512. return fillOrStroke != null && fillOrStroke != 'none';
  6513. }
  6514. function liftColor(color) {
  6515. return typeof color === 'string' ? colorTool.lift(color, -0.1) : color;
  6516. }
  6517. /**
  6518. * @private
  6519. */
  6520. function cacheElementStl(el) {
  6521. if (el.__hoverStlDirty) {
  6522. var stroke = el.style.stroke;
  6523. var fill = el.style.fill;
  6524. // Create hoverStyle on mouseover
  6525. var hoverStyle = el.__hoverStl;
  6526. hoverStyle.fill = hoverStyle.fill
  6527. || (hasFillOrStroke(fill) ? liftColor(fill) : null);
  6528. hoverStyle.stroke = hoverStyle.stroke
  6529. || (hasFillOrStroke(stroke) ? liftColor(stroke) : null);
  6530. var normalStyle = {};
  6531. for (var name in hoverStyle) {
  6532. // See comment in `doSingleEnterHover`.
  6533. if (hoverStyle[name] != null) {
  6534. normalStyle[name] = el.style[name];
  6535. }
  6536. }
  6537. el.__normalStl = normalStyle;
  6538. el.__hoverStlDirty = false;
  6539. }
  6540. }
  6541. /**
  6542. * @private
  6543. */
  6544. function doSingleEnterHover(el) {
  6545. if (el.__isHover) {
  6546. return;
  6547. }
  6548. cacheElementStl(el);
  6549. if (el.useHoverLayer) {
  6550. el.__zr && el.__zr.addHover(el, el.__hoverStl);
  6551. }
  6552. else {
  6553. var style = el.style;
  6554. var insideRollbackOpt = style.insideRollbackOpt;
  6555. // Consider case: only `position: 'top'` is set on emphasis, then text
  6556. // color should be returned to `autoColor`, rather than remain '#fff'.
  6557. // So we should rollback then apply again after style merging.
  6558. insideRollbackOpt && rollbackInsideStyle(style);
  6559. // styles can be:
  6560. // {
  6561. // label: {
  6562. // normal: {
  6563. // show: false,
  6564. // position: 'outside',
  6565. // fontSize: 18
  6566. // },
  6567. // emphasis: {
  6568. // show: true
  6569. // }
  6570. // }
  6571. // },
  6572. // where properties of `emphasis` may not appear in `normal`. We previously use
  6573. // module:echarts/util/model#defaultEmphasis to merge `normal` to `emphasis`.
  6574. // But consider rich text and setOption in merge mode, it is impossible to cover
  6575. // all properties in merge. So we use merge mode when setting style here, where
  6576. // only properties that is not `null/undefined` can be set. The disadventage:
  6577. // null/undefined can not be used to remove style any more in `emphasis`.
  6578. style.extendFrom(el.__hoverStl);
  6579. // Do not save `insideRollback`.
  6580. if (insideRollbackOpt) {
  6581. applyInsideStyle(style, style.insideOriginalTextPosition, insideRollbackOpt);
  6582. // textFill may be rollbacked to null.
  6583. if (style.textFill == null) {
  6584. style.textFill = insideRollbackOpt.autoColor;
  6585. }
  6586. }
  6587. el.dirty(false);
  6588. el.z2 += 1;
  6589. }
  6590. el.__isHover = true;
  6591. }
  6592. /**
  6593. * @inner
  6594. */
  6595. function doSingleLeaveHover(el) {
  6596. if (!el.__isHover) {
  6597. return;
  6598. }
  6599. var normalStl = el.__normalStl;
  6600. if (el.useHoverLayer) {
  6601. el.__zr && el.__zr.removeHover(el);
  6602. }
  6603. else {
  6604. // Consider null/undefined value, should use
  6605. // `setStyle` but not `extendFrom(stl, true)`.
  6606. normalStl && el.setStyle(normalStl);
  6607. el.z2 -= 1;
  6608. }
  6609. el.__isHover = false;
  6610. }
  6611. /**
  6612. * @inner
  6613. */
  6614. function doEnterHover(el) {
  6615. el.type === 'group'
  6616. ? el.traverse(function (child) {
  6617. if (child.type !== 'group') {
  6618. doSingleEnterHover(child);
  6619. }
  6620. })
  6621. : doSingleEnterHover(el);
  6622. }
  6623. function doLeaveHover(el) {
  6624. el.type === 'group'
  6625. ? el.traverse(function (child) {
  6626. if (child.type !== 'group') {
  6627. doSingleLeaveHover(child);
  6628. }
  6629. })
  6630. : doSingleLeaveHover(el);
  6631. }
  6632. /**
  6633. * @inner
  6634. */
  6635. function setElementHoverStl(el, hoverStl) {
  6636. // If element has sepcified hoverStyle, then use it instead of given hoverStyle
  6637. // Often used when item group has a label element and it's hoverStyle is different
  6638. el.__hoverStl = el.hoverStyle || hoverStl || {};
  6639. el.__hoverStlDirty = true;
  6640. if (el.__isHover) {
  6641. cacheElementStl(el);
  6642. }
  6643. }
  6644. /**
  6645. * @inner
  6646. */
  6647. function onElementMouseOver(e) {
  6648. if (this.__hoverSilentOnTouch && e.zrByTouch) {
  6649. return;
  6650. }
  6651. // Only if element is not in emphasis status
  6652. !this.__isEmphasis && doEnterHover(this);
  6653. }
  6654. /**
  6655. * @inner
  6656. */
  6657. function onElementMouseOut(e) {
  6658. if (this.__hoverSilentOnTouch && e.zrByTouch) {
  6659. return;
  6660. }
  6661. // Only if element is not in emphasis status
  6662. !this.__isEmphasis && doLeaveHover(this);
  6663. }
  6664. /**
  6665. * @inner
  6666. */
  6667. function enterEmphasis() {
  6668. this.__isEmphasis = true;
  6669. doEnterHover(this);
  6670. }
  6671. /**
  6672. * @inner
  6673. */
  6674. function leaveEmphasis() {
  6675. this.__isEmphasis = false;
  6676. doLeaveHover(this);
  6677. }
  6678. /**
  6679. * Set hover style of element.
  6680. * This method can be called repeatly without side-effects.
  6681. * @param {module:zrender/Element} el
  6682. * @param {Object} [hoverStyle]
  6683. * @param {Object} [opt]
  6684. * @param {boolean} [opt.hoverSilentOnTouch=false]
  6685. * In touch device, mouseover event will be trigger on touchstart event
  6686. * (see module:zrender/dom/HandlerProxy). By this mechanism, we can
  6687. * conviniently use hoverStyle when tap on touch screen without additional
  6688. * code for compatibility.
  6689. * But if the chart/component has select feature, which usually also use
  6690. * hoverStyle, there might be conflict between 'select-highlight' and
  6691. * 'hover-highlight' especially when roam is enabled (see geo for example).
  6692. * In this case, hoverSilentOnTouch should be used to disable hover-highlight
  6693. * on touch device.
  6694. */
  6695. graphic.setHoverStyle = function (el, hoverStyle, opt) {
  6696. el.__hoverSilentOnTouch = opt && opt.hoverSilentOnTouch;
  6697. el.type === 'group'
  6698. ? el.traverse(function (child) {
  6699. if (child.type !== 'group') {
  6700. setElementHoverStl(child, hoverStyle);
  6701. }
  6702. })
  6703. : setElementHoverStl(el, hoverStyle);
  6704. // Duplicated function will be auto-ignored, see Eventful.js.
  6705. el.on('mouseover', onElementMouseOver)
  6706. .on('mouseout', onElementMouseOut);
  6707. // Emphasis, normal can be triggered manually
  6708. el.on('emphasis', enterEmphasis)
  6709. .on('normal', leaveEmphasis);
  6710. };
  6711. /**
  6712. * @param {Object|module:zrender/graphic/Style} normalStyle
  6713. * @param {Object} emphasisStyle
  6714. * @param {module:echarts/model/Model} normalModel
  6715. * @param {module:echarts/model/Model} emphasisModel
  6716. * @param {Object} opt Check `opt` of `setTextStyleCommon` to find other props.
  6717. * @param {Object} [opt.defaultText]
  6718. * @param {module:echarts/model/Model} [opt.labelFetcher] Fetch text by
  6719. * `opt.labelFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
  6720. * @param {module:echarts/model/Model} [opt.labelDataIndex] Fetch text by
  6721. * `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
  6722. * @param {module:echarts/model/Model} [opt.labelDimIndex] Fetch text by
  6723. * `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex)`
  6724. * @param {Object} [normalSpecified]
  6725. * @param {Object} [emphasisSpecified]
  6726. */
  6727. graphic.setLabelStyle = function (
  6728. normalStyle, emphasisStyle,
  6729. normalModel, emphasisModel,
  6730. opt,
  6731. normalSpecified, emphasisSpecified
  6732. ) {
  6733. opt = opt || EMPTY_OBJ;
  6734. var labelFetcher = opt.labelFetcher;
  6735. var labelDataIndex = opt.labelDataIndex;
  6736. var labelDimIndex = opt.labelDimIndex;
  6737. // This scenario, `label.normal.show = true; label.emphasis.show = false`,
  6738. // is not supported util someone requests.
  6739. var showNormal = normalModel.getShallow('show');
  6740. var showEmphasis = emphasisModel.getShallow('show');
  6741. // Consider performance, only fetch label when necessary.
  6742. // If `normal.show` is `false` and `emphasis.show` is `true` and `emphasis.formatter` is not set,
  6743. // label should be displayed, where text is fetched by `normal.formatter` or `opt.defaultText`.
  6744. var baseText = (showNormal || showEmphasis)
  6745. ? zrUtil.retrieve2(
  6746. labelFetcher
  6747. ? labelFetcher.getFormattedLabel(labelDataIndex, 'normal', null, labelDimIndex)
  6748. : null,
  6749. opt.defaultText
  6750. )
  6751. : null;
  6752. var normalStyleText = showNormal ? baseText : null;
  6753. var emphasisStyleText = showEmphasis
  6754. ? zrUtil.retrieve2(
  6755. labelFetcher
  6756. ? labelFetcher.getFormattedLabel(labelDataIndex, 'emphasis', null, labelDimIndex)
  6757. : null,
  6758. baseText
  6759. )
  6760. : null;
  6761. // Optimize: If style.text is null, text will not be drawn.
  6762. if (normalStyleText != null || emphasisStyleText != null) {
  6763. // Always set `textStyle` even if `normalStyle.text` is null, because default
  6764. // values have to be set on `normalStyle`.
  6765. // If we set default values on `emphasisStyle`, consider case:
  6766. // Firstly, `setOption(... label: {normal: {text: null}, emphasis: {show: true}} ...);`
  6767. // Secondly, `setOption(... label: {noraml: {show: true, text: 'abc', color: 'red'} ...);`
  6768. // Then the 'red' will not work on emphasis.
  6769. setTextStyle(normalStyle, normalModel, normalSpecified, opt);
  6770. setTextStyle(emphasisStyle, emphasisModel, emphasisSpecified, opt, true);
  6771. }
  6772. normalStyle.text = normalStyleText;
  6773. emphasisStyle.text = emphasisStyleText;
  6774. };
  6775. /**
  6776. * Set basic textStyle properties.
  6777. * @param {Object|module:zrender/graphic/Style} textStyle
  6778. * @param {module:echarts/model/Model} model
  6779. * @param {Object} [specifiedTextStyle] Can be overrided by settings in model.
  6780. * @param {Object} [opt] See `opt` of `setTextStyleCommon`.
  6781. * @param {boolean} [isEmphasis]
  6782. */
  6783. var setTextStyle = graphic.setTextStyle = function (
  6784. textStyle, textStyleModel, specifiedTextStyle, opt, isEmphasis
  6785. ) {
  6786. setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis);
  6787. specifiedTextStyle && zrUtil.extend(textStyle, specifiedTextStyle);
  6788. textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
  6789. return textStyle;
  6790. };
  6791. /**
  6792. * Set text option in the style.
  6793. * @deprecated
  6794. * @param {Object} textStyle
  6795. * @param {module:echarts/model/Model} labelModel
  6796. * @param {string|boolean} defaultColor Default text color.
  6797. * If set as false, it will be processed as a emphasis style.
  6798. */
  6799. graphic.setText = function (textStyle, labelModel, defaultColor) {
  6800. var opt = {isRectText: true};
  6801. var isEmphasis;
  6802. if (defaultColor === false) {
  6803. isEmphasis = true;
  6804. }
  6805. else {
  6806. // Support setting color as 'auto' to get visual color.
  6807. opt.autoColor = defaultColor;
  6808. }
  6809. setTextStyleCommon(textStyle, labelModel, opt, isEmphasis);
  6810. textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
  6811. };
  6812. /**
  6813. * {
  6814. * disableBox: boolean, Whether diable drawing box of block (outer most).
  6815. * isRectText: boolean,
  6816. * autoColor: string, specify a color when color is 'auto',
  6817. * for textFill, textStroke, textBackgroundColor, and textBorderColor.
  6818. * If autoColor specified, it is used as default textFill.
  6819. * useInsideStyle:
  6820. * `true`: Use inside style (textFill, textStroke, textStrokeWidth)
  6821. * if `textFill` is not specified.
  6822. * `false`: Do not use inside style.
  6823. * `null/undefined`: use inside style if `isRectText` is true and
  6824. * `textFill` is not specified and textPosition contains `'inside'`.
  6825. * forceRich: boolean
  6826. * }
  6827. */
  6828. function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
  6829. // Consider there will be abnormal when merge hover style to normal style if given default value.
  6830. opt = opt || EMPTY_OBJ;
  6831. if (opt.isRectText) {
  6832. var textPosition = textStyleModel.getShallow('position')
  6833. || (isEmphasis ? null : 'inside');
  6834. // 'outside' is not a valid zr textPostion value, but used
  6835. // in bar series, and magric type should be considered.
  6836. textPosition === 'outside' && (textPosition = 'top');
  6837. textStyle.textPosition = textPosition;
  6838. textStyle.textOffset = textStyleModel.getShallow('offset');
  6839. var labelRotate = textStyleModel.getShallow('rotate');
  6840. labelRotate != null && (labelRotate *= Math.PI / 180);
  6841. textStyle.textRotation = labelRotate;
  6842. textStyle.textDistance = zrUtil.retrieve2(
  6843. textStyleModel.getShallow('distance'), isEmphasis ? null : 5
  6844. );
  6845. }
  6846. var ecModel = textStyleModel.ecModel;
  6847. var globalTextStyle = ecModel && ecModel.option.textStyle;
  6848. // Consider case:
  6849. // {
  6850. // data: [{
  6851. // value: 12,
  6852. // label: {
  6853. // normal: {
  6854. // rich: {
  6855. // // no 'a' here but using parent 'a'.
  6856. // }
  6857. // }
  6858. // }
  6859. // }],
  6860. // rich: {
  6861. // a: { ... }
  6862. // }
  6863. // }
  6864. var richItemNames = getRichItemNames(textStyleModel);
  6865. var richResult;
  6866. if (richItemNames) {
  6867. richResult = {};
  6868. for (var name in richItemNames) {
  6869. if (richItemNames.hasOwnProperty(name)) {
  6870. // Cascade is supported in rich.
  6871. var richTextStyle = textStyleModel.getModel(['rich', name]);
  6872. // In rich, never `disableBox`.
  6873. setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
  6874. }
  6875. }
  6876. }
  6877. textStyle.rich = richResult;
  6878. setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);
  6879. if (opt.forceRich && !opt.textStyle) {
  6880. opt.textStyle = {};
  6881. }
  6882. return textStyle;
  6883. }
  6884. // Consider case:
  6885. // {
  6886. // data: [{
  6887. // value: 12,
  6888. // label: {
  6889. // normal: {
  6890. // rich: {
  6891. // // no 'a' here but using parent 'a'.
  6892. // }
  6893. // }
  6894. // }
  6895. // }],
  6896. // rich: {
  6897. // a: { ... }
  6898. // }
  6899. // }
  6900. function getRichItemNames(textStyleModel) {
  6901. // Use object to remove duplicated names.
  6902. var richItemNameMap;
  6903. while (textStyleModel && textStyleModel !== textStyleModel.ecModel) {
  6904. var rich = (textStyleModel.option || EMPTY_OBJ).rich;
  6905. if (rich) {
  6906. richItemNameMap = richItemNameMap || {};
  6907. for (var name in rich) {
  6908. if (rich.hasOwnProperty(name)) {
  6909. richItemNameMap[name] = 1;
  6910. }
  6911. }
  6912. }
  6913. textStyleModel = textStyleModel.parentModel;
  6914. }
  6915. return richItemNameMap;
  6916. }
  6917. function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, isBlock) {
  6918. // In merge mode, default value should not be given.
  6919. globalTextStyle = !isEmphasis && globalTextStyle || EMPTY_OBJ;
  6920. textStyle.textFill = getAutoColor(textStyleModel.getShallow('color'), opt)
  6921. || globalTextStyle.color;
  6922. textStyle.textStroke = getAutoColor(textStyleModel.getShallow('textBorderColor'), opt)
  6923. || globalTextStyle.textBorderColor;
  6924. textStyle.textStrokeWidth = zrUtil.retrieve2(
  6925. textStyleModel.getShallow('textBorderWidth'),
  6926. globalTextStyle.textBorderWidth
  6927. );
  6928. if (!isEmphasis) {
  6929. if (isBlock) {
  6930. // Always set `insideRollback`, for clearing previous.
  6931. var originalTextPosition = textStyle.textPosition;
  6932. textStyle.insideRollback = applyInsideStyle(textStyle, originalTextPosition, opt);
  6933. // Save original textPosition, because style.textPosition will be repalced by
  6934. // real location (like [10, 30]) in zrender.
  6935. textStyle.insideOriginalTextPosition = originalTextPosition;
  6936. textStyle.insideRollbackOpt = opt;
  6937. }
  6938. // Set default finally.
  6939. if (textStyle.textFill == null) {
  6940. textStyle.textFill = opt.autoColor;
  6941. }
  6942. }
  6943. // Do not use `getFont` here, because merge should be supported, where
  6944. // part of these properties may be changed in emphasis style, and the
  6945. // others should remain their original value got from normal style.
  6946. textStyle.fontStyle = textStyleModel.getShallow('fontStyle') || globalTextStyle.fontStyle;
  6947. textStyle.fontWeight = textStyleModel.getShallow('fontWeight') || globalTextStyle.fontWeight;
  6948. textStyle.fontSize = textStyleModel.getShallow('fontSize') || globalTextStyle.fontSize;
  6949. textStyle.fontFamily = textStyleModel.getShallow('fontFamily') || globalTextStyle.fontFamily;
  6950. textStyle.textAlign = textStyleModel.getShallow('align');
  6951. textStyle.textVerticalAlign = textStyleModel.getShallow('verticalAlign')
  6952. || textStyleModel.getShallow('baseline');
  6953. textStyle.textLineHeight = textStyleModel.getShallow('lineHeight');
  6954. textStyle.textWidth = textStyleModel.getShallow('width');
  6955. textStyle.textHeight = textStyleModel.getShallow('height');
  6956. textStyle.textTag = textStyleModel.getShallow('tag');
  6957. if (!isBlock || !opt.disableBox) {
  6958. textStyle.textBackgroundColor = getAutoColor(textStyleModel.getShallow('backgroundColor'), opt);
  6959. textStyle.textPadding = textStyleModel.getShallow('padding');
  6960. textStyle.textBorderColor = getAutoColor(textStyleModel.getShallow('borderColor'), opt);
  6961. textStyle.textBorderWidth = textStyleModel.getShallow('borderWidth');
  6962. textStyle.textBorderRadius = textStyleModel.getShallow('borderRadius');
  6963. textStyle.textBoxShadowColor = textStyleModel.getShallow('shadowColor');
  6964. textStyle.textBoxShadowBlur = textStyleModel.getShallow('shadowBlur');
  6965. textStyle.textBoxShadowOffsetX = textStyleModel.getShallow('shadowOffsetX');
  6966. textStyle.textBoxShadowOffsetY = textStyleModel.getShallow('shadowOffsetY');
  6967. }
  6968. textStyle.textShadowColor = textStyleModel.getShallow('textShadowColor')
  6969. || globalTextStyle.textShadowColor;
  6970. textStyle.textShadowBlur = textStyleModel.getShallow('textShadowBlur')
  6971. || globalTextStyle.textShadowBlur;
  6972. textStyle.textShadowOffsetX = textStyleModel.getShallow('textShadowOffsetX')
  6973. || globalTextStyle.textShadowOffsetX;
  6974. textStyle.textShadowOffsetY = textStyleModel.getShallow('textShadowOffsetY')
  6975. || globalTextStyle.textShadowOffsetY;
  6976. }
  6977. function getAutoColor(color, opt) {
  6978. return color !== 'auto' ? color : (opt && opt.autoColor) ? opt.autoColor : null;
  6979. }
  6980. function applyInsideStyle(textStyle, textPosition, opt) {
  6981. var useInsideStyle = opt.useInsideStyle;
  6982. var insideRollback;
  6983. if (textStyle.textFill == null
  6984. && useInsideStyle !== false
  6985. && (useInsideStyle === true
  6986. || (opt.isRectText
  6987. && textPosition
  6988. // textPosition can be [10, 30]
  6989. && typeof textPosition === 'string'
  6990. && textPosition.indexOf('inside') >= 0
  6991. )
  6992. )
  6993. ) {
  6994. insideRollback = {
  6995. textFill: null,
  6996. textStroke: textStyle.textStroke,
  6997. textStrokeWidth: textStyle.textStrokeWidth
  6998. };
  6999. textStyle.textFill = '#fff';
  7000. // Consider text with #fff overflow its container.
  7001. if (textStyle.textStroke == null) {
  7002. textStyle.textStroke = opt.autoColor;
  7003. textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
  7004. }
  7005. }
  7006. return insideRollback;
  7007. }
  7008. function rollbackInsideStyle(style) {
  7009. var insideRollback = style.insideRollback;
  7010. if (insideRollback) {
  7011. style.textFill = insideRollback.textFill;
  7012. style.textStroke = insideRollback.textStroke;
  7013. style.textStrokeWidth = insideRollback.textStrokeWidth;
  7014. }
  7015. }
  7016. graphic.getFont = function (opt, ecModel) {
  7017. // ecModel or default text style model.
  7018. var gTextStyleModel = ecModel || ecModel.getModel('textStyle');
  7019. return [
  7020. // FIXME in node-canvas fontWeight is before fontStyle
  7021. opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
  7022. opt.fontWeight || gTextStyleModel && gTextStyleModel.getShallow('fontWeight') || '',
  7023. (opt.fontSize || gTextStyleModel && gTextStyleModel.getShallow('fontSize') || 12) + 'px',
  7024. opt.fontFamily || gTextStyleModel && gTextStyleModel.getShallow('fontFamily') || 'sans-serif'
  7025. ].join(' ');
  7026. };
  7027. function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
  7028. if (typeof dataIndex === 'function') {
  7029. cb = dataIndex;
  7030. dataIndex = null;
  7031. }
  7032. // Do not check 'animation' property directly here. Consider this case:
  7033. // animation model is an `itemModel`, whose does not have `isAnimationEnabled`
  7034. // but its parent model (`seriesModel`) does.
  7035. var animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
  7036. if (animationEnabled) {
  7037. var postfix = isUpdate ? 'Update' : '';
  7038. var duration = animatableModel.getShallow('animationDuration' + postfix);
  7039. var animationEasing = animatableModel.getShallow('animationEasing' + postfix);
  7040. var animationDelay = animatableModel.getShallow('animationDelay' + postfix);
  7041. if (typeof animationDelay === 'function') {
  7042. animationDelay = animationDelay(
  7043. dataIndex,
  7044. animatableModel.getAnimationDelayParams
  7045. ? animatableModel.getAnimationDelayParams(el, dataIndex)
  7046. : null
  7047. );
  7048. }
  7049. if (typeof duration === 'function') {
  7050. duration = duration(dataIndex);
  7051. }
  7052. duration > 0
  7053. ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb, !!cb)
  7054. : (el.stopAnimation(), el.attr(props), cb && cb());
  7055. }
  7056. else {
  7057. el.stopAnimation();
  7058. el.attr(props);
  7059. cb && cb();
  7060. }
  7061. }
  7062. /**
  7063. * Update graphic element properties with or without animation according to the configuration in series
  7064. * @param {module:zrender/Element} el
  7065. * @param {Object} props
  7066. * @param {module:echarts/model/Model} [animatableModel]
  7067. * @param {number} [dataIndex]
  7068. * @param {Function} [cb]
  7069. * @example
  7070. * graphic.updateProps(el, {
  7071. * position: [100, 100]
  7072. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  7073. * // Or
  7074. * graphic.updateProps(el, {
  7075. * position: [100, 100]
  7076. * }, seriesModel, function () { console.log('Animation done!'); });
  7077. */
  7078. graphic.updateProps = function (el, props, animatableModel, dataIndex, cb) {
  7079. animateOrSetProps(true, el, props, animatableModel, dataIndex, cb);
  7080. };
  7081. /**
  7082. * Init graphic element properties with or without animation according to the configuration in series
  7083. * @param {module:zrender/Element} el
  7084. * @param {Object} props
  7085. * @param {module:echarts/model/Model} [animatableModel]
  7086. * @param {number} [dataIndex]
  7087. * @param {Function} cb
  7088. */
  7089. graphic.initProps = function (el, props, animatableModel, dataIndex, cb) {
  7090. animateOrSetProps(false, el, props, animatableModel, dataIndex, cb);
  7091. };
  7092. /**
  7093. * Get transform matrix of target (param target),
  7094. * in coordinate of its ancestor (param ancestor)
  7095. *
  7096. * @param {module:zrender/mixin/Transformable} target
  7097. * @param {module:zrender/mixin/Transformable} [ancestor]
  7098. */
  7099. graphic.getTransform = function (target, ancestor) {
  7100. var mat = matrix.identity([]);
  7101. while (target && target !== ancestor) {
  7102. matrix.mul(mat, target.getLocalTransform(), mat);
  7103. target = target.parent;
  7104. }
  7105. return mat;
  7106. };
  7107. /**
  7108. * Apply transform to an vertex.
  7109. * @param {Array.<number>} target [x, y]
  7110. * @param {Array.<number>|TypedArray.<number>|Object} transform Can be:
  7111. * + Transform matrix: like [1, 0, 0, 1, 0, 0]
  7112. * + {position, rotation, scale}, the same as `zrender/Transformable`.
  7113. * @param {boolean=} invert Whether use invert matrix.
  7114. * @return {Array.<number>} [x, y]
  7115. */
  7116. graphic.applyTransform = function (target, transform, invert) {
  7117. if (transform && !zrUtil.isArrayLike(transform)) {
  7118. transform = Transformable.getLocalTransform(transform);
  7119. }
  7120. if (invert) {
  7121. transform = matrix.invert([], transform);
  7122. }
  7123. return vector.applyTransform([], target, transform);
  7124. };
  7125. /**
  7126. * @param {string} direction 'left' 'right' 'top' 'bottom'
  7127. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  7128. * @param {boolean=} invert Whether use invert matrix.
  7129. * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom'
  7130. */
  7131. graphic.transformDirection = function (direction, transform, invert) {
  7132. // Pick a base, ensure that transform result will not be (0, 0).
  7133. var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0)
  7134. ? 1 : Math.abs(2 * transform[4] / transform[0]);
  7135. var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0)
  7136. ? 1 : Math.abs(2 * transform[4] / transform[2]);
  7137. var vertex = [
  7138. direction === 'left' ? -hBase : direction === 'right' ? hBase : 0,
  7139. direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0
  7140. ];
  7141. vertex = graphic.applyTransform(vertex, transform, invert);
  7142. return Math.abs(vertex[0]) > Math.abs(vertex[1])
  7143. ? (vertex[0] > 0 ? 'right' : 'left')
  7144. : (vertex[1] > 0 ? 'bottom' : 'top');
  7145. };
  7146. /**
  7147. * Apply group transition animation from g1 to g2.
  7148. * If no animatableModel, no animation.
  7149. */
  7150. graphic.groupTransition = function (g1, g2, animatableModel, cb) {
  7151. if (!g1 || !g2) {
  7152. return;
  7153. }
  7154. function getElMap(g) {
  7155. var elMap = {};
  7156. g.traverse(function (el) {
  7157. if (!el.isGroup && el.anid) {
  7158. elMap[el.anid] = el;
  7159. }
  7160. });
  7161. return elMap;
  7162. }
  7163. function getAnimatableProps(el) {
  7164. var obj = {
  7165. position: vector.clone(el.position),
  7166. rotation: el.rotation
  7167. };
  7168. if (el.shape) {
  7169. obj.shape = zrUtil.extend({}, el.shape);
  7170. }
  7171. return obj;
  7172. }
  7173. var elMap1 = getElMap(g1);
  7174. g2.traverse(function (el) {
  7175. if (!el.isGroup && el.anid) {
  7176. var oldEl = elMap1[el.anid];
  7177. if (oldEl) {
  7178. var newProp = getAnimatableProps(el);
  7179. el.attr(getAnimatableProps(oldEl));
  7180. graphic.updateProps(el, newProp, animatableModel, el.dataIndex);
  7181. }
  7182. // else {
  7183. // if (el.previousProps) {
  7184. // graphic.updateProps
  7185. // }
  7186. // }
  7187. }
  7188. });
  7189. };
  7190. /**
  7191. * @param {Array.<Array.<number>>} points Like: [[23, 44], [53, 66], ...]
  7192. * @param {Object} rect {x, y, width, height}
  7193. * @return {Array.<Array.<number>>} A new clipped points.
  7194. */
  7195. graphic.clipPointsByRect = function (points, rect) {
  7196. return zrUtil.map(points, function (point) {
  7197. var x = point[0];
  7198. x = mathMax(x, rect.x);
  7199. x = mathMin(x, rect.x + rect.width);
  7200. var y = point[1];
  7201. y = mathMax(y, rect.y);
  7202. y = mathMin(y, rect.y + rect.height);
  7203. return [x, y];
  7204. });
  7205. };
  7206. /**
  7207. * @param {Object} targetRect {x, y, width, height}
  7208. * @param {Object} rect {x, y, width, height}
  7209. * @return {Object} A new clipped rect. If rect size are negative, return undefined.
  7210. */
  7211. graphic.clipRectByRect = function (targetRect, rect) {
  7212. var x = mathMax(targetRect.x, rect.x);
  7213. var x2 = mathMin(targetRect.x + targetRect.width, rect.x + rect.width);
  7214. var y = mathMax(targetRect.y, rect.y);
  7215. var y2 = mathMin(targetRect.y + targetRect.height, rect.y + rect.height);
  7216. if (x2 >= x && y2 >= y) {
  7217. return {
  7218. x: x,
  7219. y: y,
  7220. width: x2 - x,
  7221. height: y2 - y
  7222. };
  7223. }
  7224. };
  7225. /**
  7226. * @param {string} iconStr Support 'image://' or 'path://' or direct svg path.
  7227. * @param {Object} [opt] Properties of `module:zrender/Element`, except `style`.
  7228. * @param {Object} [rect] {x, y, width, height}
  7229. * @return {module:zrender/Element} Icon path or image element.
  7230. */
  7231. graphic.createIcon = function (iconStr, opt, rect) {
  7232. opt = zrUtil.extend({rectHover: true}, opt);
  7233. var style = opt.style = {strokeNoScale: true};
  7234. rect = rect || {x: -1, y: -1, width: 2, height: 2};
  7235. if (iconStr) {
  7236. return iconStr.indexOf('image://') === 0
  7237. ? (
  7238. style.image = iconStr.slice(8),
  7239. zrUtil.defaults(style, rect),
  7240. new graphic.Image(opt)
  7241. )
  7242. : (
  7243. graphic.makePath(
  7244. iconStr.replace('path://', ''),
  7245. opt,
  7246. rect,
  7247. 'center'
  7248. )
  7249. );
  7250. }
  7251. };
  7252. module.exports = graphic;
  7253. /***/ }),
  7254. /* 21 */
  7255. /***/ (function(module, exports, __webpack_require__) {
  7256. var Path = __webpack_require__(22);
  7257. var PathProxy = __webpack_require__(39);
  7258. var transformPath = __webpack_require__(50);
  7259. // command chars
  7260. var cc = [
  7261. 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',
  7262. 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'
  7263. ];
  7264. var mathSqrt = Math.sqrt;
  7265. var mathSin = Math.sin;
  7266. var mathCos = Math.cos;
  7267. var PI = Math.PI;
  7268. var vMag = function(v) {
  7269. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  7270. };
  7271. var vRatio = function(u, v) {
  7272. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  7273. };
  7274. var vAngle = function(u, v) {
  7275. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)
  7276. * Math.acos(vRatio(u, v));
  7277. };
  7278. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  7279. var psi = psiDeg * (PI / 180.0);
  7280. var xp = mathCos(psi) * (x1 - x2) / 2.0
  7281. + mathSin(psi) * (y1 - y2) / 2.0;
  7282. var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
  7283. + mathCos(psi) * (y1 - y2) / 2.0;
  7284. var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
  7285. if (lambda > 1) {
  7286. rx *= mathSqrt(lambda);
  7287. ry *= mathSqrt(lambda);
  7288. }
  7289. var f = (fa === fs ? -1 : 1)
  7290. * mathSqrt((((rx * rx) * (ry * ry))
  7291. - ((rx * rx) * (yp * yp))
  7292. - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
  7293. + (ry * ry) * (xp * xp))
  7294. ) || 0;
  7295. var cxp = f * rx * yp / ry;
  7296. var cyp = f * -ry * xp / rx;
  7297. var cx = (x1 + x2) / 2.0
  7298. + mathCos(psi) * cxp
  7299. - mathSin(psi) * cyp;
  7300. var cy = (y1 + y2) / 2.0
  7301. + mathSin(psi) * cxp
  7302. + mathCos(psi) * cyp;
  7303. var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);
  7304. var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];
  7305. var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];
  7306. var dTheta = vAngle(u, v);
  7307. if (vRatio(u, v) <= -1) {
  7308. dTheta = PI;
  7309. }
  7310. if (vRatio(u, v) >= 1) {
  7311. dTheta = 0;
  7312. }
  7313. if (fs === 0 && dTheta > 0) {
  7314. dTheta = dTheta - 2 * PI;
  7315. }
  7316. if (fs === 1 && dTheta < 0) {
  7317. dTheta = dTheta + 2 * PI;
  7318. }
  7319. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  7320. }
  7321. function createPathProxyFromString(data) {
  7322. if (!data) {
  7323. return [];
  7324. }
  7325. // command string
  7326. var cs = data.replace(/-/g, ' -')
  7327. .replace(/ /g, ' ')
  7328. .replace(/ /g, ',')
  7329. .replace(/,,/g, ',');
  7330. var n;
  7331. // create pipes so that we can split the data
  7332. for (n = 0; n < cc.length; n++) {
  7333. cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
  7334. }
  7335. // create array
  7336. var arr = cs.split('|');
  7337. // init context point
  7338. var cpx = 0;
  7339. var cpy = 0;
  7340. var path = new PathProxy();
  7341. var CMD = PathProxy.CMD;
  7342. var prevCmd;
  7343. for (n = 1; n < arr.length; n++) {
  7344. var str = arr[n];
  7345. var c = str.charAt(0);
  7346. var off = 0;
  7347. var p = str.slice(1).replace(/e,-/g, 'e-').split(',');
  7348. var cmd;
  7349. if (p.length > 0 && p[0] === '') {
  7350. p.shift();
  7351. }
  7352. for (var i = 0; i < p.length; i++) {
  7353. p[i] = parseFloat(p[i]);
  7354. }
  7355. while (off < p.length && !isNaN(p[off])) {
  7356. if (isNaN(p[0])) {
  7357. break;
  7358. }
  7359. var ctlPtx;
  7360. var ctlPty;
  7361. var rx;
  7362. var ry;
  7363. var psi;
  7364. var fa;
  7365. var fs;
  7366. var x1 = cpx;
  7367. var y1 = cpy;
  7368. // convert l, H, h, V, and v to L
  7369. switch (c) {
  7370. case 'l':
  7371. cpx += p[off++];
  7372. cpy += p[off++];
  7373. cmd = CMD.L;
  7374. path.addData(cmd, cpx, cpy);
  7375. break;
  7376. case 'L':
  7377. cpx = p[off++];
  7378. cpy = p[off++];
  7379. cmd = CMD.L;
  7380. path.addData(cmd, cpx, cpy);
  7381. break;
  7382. case 'm':
  7383. cpx += p[off++];
  7384. cpy += p[off++];
  7385. cmd = CMD.M;
  7386. path.addData(cmd, cpx, cpy);
  7387. c = 'l';
  7388. break;
  7389. case 'M':
  7390. cpx = p[off++];
  7391. cpy = p[off++];
  7392. cmd = CMD.M;
  7393. path.addData(cmd, cpx, cpy);
  7394. c = 'L';
  7395. break;
  7396. case 'h':
  7397. cpx += p[off++];
  7398. cmd = CMD.L;
  7399. path.addData(cmd, cpx, cpy);
  7400. break;
  7401. case 'H':
  7402. cpx = p[off++];
  7403. cmd = CMD.L;
  7404. path.addData(cmd, cpx, cpy);
  7405. break;
  7406. case 'v':
  7407. cpy += p[off++];
  7408. cmd = CMD.L;
  7409. path.addData(cmd, cpx, cpy);
  7410. break;
  7411. case 'V':
  7412. cpy = p[off++];
  7413. cmd = CMD.L;
  7414. path.addData(cmd, cpx, cpy);
  7415. break;
  7416. case 'C':
  7417. cmd = CMD.C;
  7418. path.addData(
  7419. cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
  7420. );
  7421. cpx = p[off - 2];
  7422. cpy = p[off - 1];
  7423. break;
  7424. case 'c':
  7425. cmd = CMD.C;
  7426. path.addData(
  7427. cmd,
  7428. p[off++] + cpx, p[off++] + cpy,
  7429. p[off++] + cpx, p[off++] + cpy,
  7430. p[off++] + cpx, p[off++] + cpy
  7431. );
  7432. cpx += p[off - 2];
  7433. cpy += p[off - 1];
  7434. break;
  7435. case 'S':
  7436. ctlPtx = cpx;
  7437. ctlPty = cpy;
  7438. var len = path.len();
  7439. var pathData = path.data;
  7440. if (prevCmd === CMD.C) {
  7441. ctlPtx += cpx - pathData[len - 4];
  7442. ctlPty += cpy - pathData[len - 3];
  7443. }
  7444. cmd = CMD.C;
  7445. x1 = p[off++];
  7446. y1 = p[off++];
  7447. cpx = p[off++];
  7448. cpy = p[off++];
  7449. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  7450. break;
  7451. case 's':
  7452. ctlPtx = cpx;
  7453. ctlPty = cpy;
  7454. var len = path.len();
  7455. var pathData = path.data;
  7456. if (prevCmd === CMD.C) {
  7457. ctlPtx += cpx - pathData[len - 4];
  7458. ctlPty += cpy - pathData[len - 3];
  7459. }
  7460. cmd = CMD.C;
  7461. x1 = cpx + p[off++];
  7462. y1 = cpy + p[off++];
  7463. cpx += p[off++];
  7464. cpy += p[off++];
  7465. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  7466. break;
  7467. case 'Q':
  7468. x1 = p[off++];
  7469. y1 = p[off++];
  7470. cpx = p[off++];
  7471. cpy = p[off++];
  7472. cmd = CMD.Q;
  7473. path.addData(cmd, x1, y1, cpx, cpy);
  7474. break;
  7475. case 'q':
  7476. x1 = p[off++] + cpx;
  7477. y1 = p[off++] + cpy;
  7478. cpx += p[off++];
  7479. cpy += p[off++];
  7480. cmd = CMD.Q;
  7481. path.addData(cmd, x1, y1, cpx, cpy);
  7482. break;
  7483. case 'T':
  7484. ctlPtx = cpx;
  7485. ctlPty = cpy;
  7486. var len = path.len();
  7487. var pathData = path.data;
  7488. if (prevCmd === CMD.Q) {
  7489. ctlPtx += cpx - pathData[len - 4];
  7490. ctlPty += cpy - pathData[len - 3];
  7491. }
  7492. cpx = p[off++];
  7493. cpy = p[off++];
  7494. cmd = CMD.Q;
  7495. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  7496. break;
  7497. case 't':
  7498. ctlPtx = cpx;
  7499. ctlPty = cpy;
  7500. var len = path.len();
  7501. var pathData = path.data;
  7502. if (prevCmd === CMD.Q) {
  7503. ctlPtx += cpx - pathData[len - 4];
  7504. ctlPty += cpy - pathData[len - 3];
  7505. }
  7506. cpx += p[off++];
  7507. cpy += p[off++];
  7508. cmd = CMD.Q;
  7509. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  7510. break;
  7511. case 'A':
  7512. rx = p[off++];
  7513. ry = p[off++];
  7514. psi = p[off++];
  7515. fa = p[off++];
  7516. fs = p[off++];
  7517. x1 = cpx, y1 = cpy;
  7518. cpx = p[off++];
  7519. cpy = p[off++];
  7520. cmd = CMD.A;
  7521. processArc(
  7522. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  7523. );
  7524. break;
  7525. case 'a':
  7526. rx = p[off++];
  7527. ry = p[off++];
  7528. psi = p[off++];
  7529. fa = p[off++];
  7530. fs = p[off++];
  7531. x1 = cpx, y1 = cpy;
  7532. cpx += p[off++];
  7533. cpy += p[off++];
  7534. cmd = CMD.A;
  7535. processArc(
  7536. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  7537. );
  7538. break;
  7539. }
  7540. }
  7541. if (c === 'z' || c === 'Z') {
  7542. cmd = CMD.Z;
  7543. path.addData(cmd);
  7544. }
  7545. prevCmd = cmd;
  7546. }
  7547. path.toStatic();
  7548. return path;
  7549. }
  7550. // TODO Optimize double memory cost problem
  7551. function createPathOptions(str, opts) {
  7552. var pathProxy = createPathProxyFromString(str);
  7553. opts = opts || {};
  7554. opts.buildPath = function (path) {
  7555. if (path.setData) {
  7556. path.setData(pathProxy.data);
  7557. // Svg and vml renderer don't have context
  7558. var ctx = path.getContext();
  7559. if (ctx) {
  7560. path.rebuildPath(ctx);
  7561. }
  7562. }
  7563. else {
  7564. var ctx = path;
  7565. pathProxy.rebuildPath(ctx);
  7566. }
  7567. };
  7568. opts.applyTransform = function (m) {
  7569. transformPath(pathProxy, m);
  7570. this.dirty(true);
  7571. };
  7572. return opts;
  7573. }
  7574. module.exports = {
  7575. /**
  7576. * Create a Path object from path string data
  7577. * http://www.w3.org/TR/SVG/paths.html#PathData
  7578. * @param {Object} opts Other options
  7579. */
  7580. createFromString: function (str, opts) {
  7581. return new Path(createPathOptions(str, opts));
  7582. },
  7583. /**
  7584. * Create a Path class from path string data
  7585. * @param {string} str
  7586. * @param {Object} opts Other options
  7587. */
  7588. extendFromString: function (str, opts) {
  7589. return Path.extend(createPathOptions(str, opts));
  7590. },
  7591. /**
  7592. * Merge multiple paths
  7593. */
  7594. // TODO Apply transform
  7595. // TODO stroke dash
  7596. // TODO Optimize double memory cost problem
  7597. mergePath: function (pathEls, opts) {
  7598. var pathList = [];
  7599. var len = pathEls.length;
  7600. for (var i = 0; i < len; i++) {
  7601. var pathEl = pathEls[i];
  7602. if (!pathEl.path) {
  7603. pathEl.createPathProxy();
  7604. }
  7605. if (pathEl.__dirtyPath) {
  7606. pathEl.buildPath(pathEl.path, pathEl.shape, true);
  7607. }
  7608. pathList.push(pathEl.path);
  7609. }
  7610. var pathBundle = new Path(opts);
  7611. // Need path proxy.
  7612. pathBundle.createPathProxy();
  7613. pathBundle.buildPath = function (path) {
  7614. path.appendPath(pathList);
  7615. // Svg and vml renderer don't have context
  7616. var ctx = path.getContext();
  7617. if (ctx) {
  7618. path.rebuildPath(ctx);
  7619. }
  7620. };
  7621. return pathBundle;
  7622. }
  7623. };
  7624. /***/ }),
  7625. /* 22 */
  7626. /***/ (function(module, exports, __webpack_require__) {
  7627. /**
  7628. * Path element
  7629. * @module zrender/graphic/Path
  7630. */
  7631. var Displayable = __webpack_require__(23);
  7632. var zrUtil = __webpack_require__(4);
  7633. var PathProxy = __webpack_require__(39);
  7634. var pathContain = __webpack_require__(42);
  7635. var Pattern = __webpack_require__(49);
  7636. var getCanvasPattern = Pattern.prototype.getCanvasPattern;
  7637. var abs = Math.abs;
  7638. var pathProxyForDraw = new PathProxy(true);
  7639. /**
  7640. * @alias module:zrender/graphic/Path
  7641. * @extends module:zrender/graphic/Displayable
  7642. * @constructor
  7643. * @param {Object} opts
  7644. */
  7645. function Path(opts) {
  7646. Displayable.call(this, opts);
  7647. /**
  7648. * @type {module:zrender/core/PathProxy}
  7649. * @readOnly
  7650. */
  7651. this.path = null;
  7652. }
  7653. Path.prototype = {
  7654. constructor: Path,
  7655. type: 'path',
  7656. __dirtyPath: true,
  7657. strokeContainThreshold: 5,
  7658. brush: function (ctx, prevEl) {
  7659. var style = this.style;
  7660. var path = this.path || pathProxyForDraw;
  7661. var hasStroke = style.hasStroke();
  7662. var hasFill = style.hasFill();
  7663. var fill = style.fill;
  7664. var stroke = style.stroke;
  7665. var hasFillGradient = hasFill && !!(fill.colorStops);
  7666. var hasStrokeGradient = hasStroke && !!(stroke.colorStops);
  7667. var hasFillPattern = hasFill && !!(fill.image);
  7668. var hasStrokePattern = hasStroke && !!(stroke.image);
  7669. style.bind(ctx, this, prevEl);
  7670. this.setTransform(ctx);
  7671. if (this.__dirty) {
  7672. var rect;
  7673. // Update gradient because bounding rect may changed
  7674. if (hasFillGradient) {
  7675. rect = rect || this.getBoundingRect();
  7676. this._fillGradient = style.getGradient(ctx, fill, rect);
  7677. }
  7678. if (hasStrokeGradient) {
  7679. rect = rect || this.getBoundingRect();
  7680. this._strokeGradient = style.getGradient(ctx, stroke, rect);
  7681. }
  7682. }
  7683. // Use the gradient or pattern
  7684. if (hasFillGradient) {
  7685. // PENDING If may have affect the state
  7686. ctx.fillStyle = this._fillGradient;
  7687. }
  7688. else if (hasFillPattern) {
  7689. ctx.fillStyle = getCanvasPattern.call(fill, ctx);
  7690. }
  7691. if (hasStrokeGradient) {
  7692. ctx.strokeStyle = this._strokeGradient;
  7693. }
  7694. else if (hasStrokePattern) {
  7695. ctx.strokeStyle = getCanvasPattern.call(stroke, ctx);
  7696. }
  7697. var lineDash = style.lineDash;
  7698. var lineDashOffset = style.lineDashOffset;
  7699. var ctxLineDash = !!ctx.setLineDash;
  7700. // Update path sx, sy
  7701. var scale = this.getGlobalScale();
  7702. path.setScale(scale[0], scale[1]);
  7703. // Proxy context
  7704. // Rebuild path in following 2 cases
  7705. // 1. Path is dirty
  7706. // 2. Path needs javascript implemented lineDash stroking.
  7707. // In this case, lineDash information will not be saved in PathProxy
  7708. if (this.__dirtyPath
  7709. || (lineDash && !ctxLineDash && hasStroke)
  7710. ) {
  7711. path.beginPath(ctx);
  7712. // Setting line dash before build path
  7713. if (lineDash && !ctxLineDash) {
  7714. path.setLineDash(lineDash);
  7715. path.setLineDashOffset(lineDashOffset);
  7716. }
  7717. this.buildPath(path, this.shape, false);
  7718. // Clear path dirty flag
  7719. if (this.path) {
  7720. this.__dirtyPath = false;
  7721. }
  7722. }
  7723. else {
  7724. // Replay path building
  7725. ctx.beginPath();
  7726. this.path.rebuildPath(ctx);
  7727. }
  7728. hasFill && path.fill(ctx);
  7729. if (lineDash && ctxLineDash) {
  7730. ctx.setLineDash(lineDash);
  7731. ctx.lineDashOffset = lineDashOffset;
  7732. }
  7733. hasStroke && path.stroke(ctx);
  7734. if (lineDash && ctxLineDash) {
  7735. // PENDING
  7736. // Remove lineDash
  7737. ctx.setLineDash([]);
  7738. }
  7739. this.restoreTransform(ctx);
  7740. // Draw rect text
  7741. if (style.text != null) {
  7742. this.drawRectText(ctx, this.getBoundingRect());
  7743. }
  7744. },
  7745. // When bundling path, some shape may decide if use moveTo to begin a new subpath or closePath
  7746. // Like in circle
  7747. buildPath: function (ctx, shapeCfg, inBundle) {},
  7748. createPathProxy: function () {
  7749. this.path = new PathProxy();
  7750. },
  7751. getBoundingRect: function () {
  7752. var rect = this._rect;
  7753. var style = this.style;
  7754. var needsUpdateRect = !rect;
  7755. if (needsUpdateRect) {
  7756. var path = this.path;
  7757. if (!path) {
  7758. // Create path on demand.
  7759. path = this.path = new PathProxy();
  7760. }
  7761. if (this.__dirtyPath) {
  7762. path.beginPath();
  7763. this.buildPath(path, this.shape, false);
  7764. }
  7765. rect = path.getBoundingRect();
  7766. }
  7767. this._rect = rect;
  7768. if (style.hasStroke()) {
  7769. // Needs update rect with stroke lineWidth when
  7770. // 1. Element changes scale or lineWidth
  7771. // 2. Shape is changed
  7772. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  7773. if (this.__dirty || needsUpdateRect) {
  7774. rectWithStroke.copy(rect);
  7775. // FIXME Must after updateTransform
  7776. var w = style.lineWidth;
  7777. // PENDING, Min line width is needed when line is horizontal or vertical
  7778. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  7779. // Only add extra hover lineWidth when there are no fill
  7780. if (!style.hasFill()) {
  7781. w = Math.max(w, this.strokeContainThreshold || 4);
  7782. }
  7783. // Consider line width
  7784. // Line scale can't be 0;
  7785. if (lineScale > 1e-10) {
  7786. rectWithStroke.width += w / lineScale;
  7787. rectWithStroke.height += w / lineScale;
  7788. rectWithStroke.x -= w / lineScale / 2;
  7789. rectWithStroke.y -= w / lineScale / 2;
  7790. }
  7791. }
  7792. // Return rect with stroke
  7793. return rectWithStroke;
  7794. }
  7795. return rect;
  7796. },
  7797. contain: function (x, y) {
  7798. var localPos = this.transformCoordToLocal(x, y);
  7799. var rect = this.getBoundingRect();
  7800. var style = this.style;
  7801. x = localPos[0];
  7802. y = localPos[1];
  7803. if (rect.contain(x, y)) {
  7804. var pathData = this.path.data;
  7805. if (style.hasStroke()) {
  7806. var lineWidth = style.lineWidth;
  7807. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  7808. // Line scale can't be 0;
  7809. if (lineScale > 1e-10) {
  7810. // Only add extra hover lineWidth when there are no fill
  7811. if (!style.hasFill()) {
  7812. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  7813. }
  7814. if (pathContain.containStroke(
  7815. pathData, lineWidth / lineScale, x, y
  7816. )) {
  7817. return true;
  7818. }
  7819. }
  7820. }
  7821. if (style.hasFill()) {
  7822. return pathContain.contain(pathData, x, y);
  7823. }
  7824. }
  7825. return false;
  7826. },
  7827. /**
  7828. * @param {boolean} dirtyPath
  7829. */
  7830. dirty: function (dirtyPath) {
  7831. if (dirtyPath == null) {
  7832. dirtyPath = true;
  7833. }
  7834. // Only mark dirty, not mark clean
  7835. if (dirtyPath) {
  7836. this.__dirtyPath = dirtyPath;
  7837. this._rect = null;
  7838. }
  7839. this.__dirty = true;
  7840. this.__zr && this.__zr.refresh();
  7841. // Used as a clipping path
  7842. if (this.__clipTarget) {
  7843. this.__clipTarget.dirty();
  7844. }
  7845. },
  7846. /**
  7847. * Alias for animate('shape')
  7848. * @param {boolean} loop
  7849. */
  7850. animateShape: function (loop) {
  7851. return this.animate('shape', loop);
  7852. },
  7853. // Overwrite attrKV
  7854. attrKV: function (key, value) {
  7855. // FIXME
  7856. if (key === 'shape') {
  7857. this.setShape(value);
  7858. this.__dirtyPath = true;
  7859. this._rect = null;
  7860. }
  7861. else {
  7862. Displayable.prototype.attrKV.call(this, key, value);
  7863. }
  7864. },
  7865. /**
  7866. * @param {Object|string} key
  7867. * @param {*} value
  7868. */
  7869. setShape: function (key, value) {
  7870. var shape = this.shape;
  7871. // Path from string may not have shape
  7872. if (shape) {
  7873. if (zrUtil.isObject(key)) {
  7874. for (var name in key) {
  7875. if (key.hasOwnProperty(name)) {
  7876. shape[name] = key[name];
  7877. }
  7878. }
  7879. }
  7880. else {
  7881. shape[key] = value;
  7882. }
  7883. this.dirty(true);
  7884. }
  7885. return this;
  7886. },
  7887. getLineScale: function () {
  7888. var m = this.transform;
  7889. // Get the line scale.
  7890. // Determinant of `m` means how much the area is enlarged by the
  7891. // transformation. So its square root can be used as a scale factor
  7892. // for width.
  7893. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10
  7894. ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1]))
  7895. : 1;
  7896. }
  7897. };
  7898. /**
  7899. * 扩展一个 Path element, 比如星形,圆等。
  7900. * Extend a path element
  7901. * @param {Object} props
  7902. * @param {string} props.type Path type
  7903. * @param {Function} props.init Initialize
  7904. * @param {Function} props.buildPath Overwrite buildPath method
  7905. * @param {Object} [props.style] Extended default style config
  7906. * @param {Object} [props.shape] Extended default shape config
  7907. */
  7908. Path.extend = function (defaults) {
  7909. var Sub = function (opts) {
  7910. Path.call(this, opts);
  7911. if (defaults.style) {
  7912. // Extend default style
  7913. this.style.extendFrom(defaults.style, false);
  7914. }
  7915. // Extend default shape
  7916. var defaultShape = defaults.shape;
  7917. if (defaultShape) {
  7918. this.shape = this.shape || {};
  7919. var thisShape = this.shape;
  7920. for (var name in defaultShape) {
  7921. if (
  7922. ! thisShape.hasOwnProperty(name)
  7923. && defaultShape.hasOwnProperty(name)
  7924. ) {
  7925. thisShape[name] = defaultShape[name];
  7926. }
  7927. }
  7928. }
  7929. defaults.init && defaults.init.call(this, opts);
  7930. };
  7931. zrUtil.inherits(Sub, Path);
  7932. // FIXME 不能 extend position, rotation 等引用对象
  7933. for (var name in defaults) {
  7934. // Extending prototype values and methods
  7935. if (name !== 'style' && name !== 'shape') {
  7936. Sub.prototype[name] = defaults[name];
  7937. }
  7938. }
  7939. return Sub;
  7940. };
  7941. zrUtil.inherits(Path, Displayable);
  7942. module.exports = Path;
  7943. /***/ }),
  7944. /* 23 */
  7945. /***/ (function(module, exports, __webpack_require__) {
  7946. /**
  7947. * 可绘制的图形基类
  7948. * Base class of all displayable graphic objects
  7949. * @module zrender/graphic/Displayable
  7950. */
  7951. var zrUtil = __webpack_require__(4);
  7952. var Style = __webpack_require__(24);
  7953. var Element = __webpack_require__(25);
  7954. var RectText = __webpack_require__(36);
  7955. // var Stateful = require('./mixin/Stateful');
  7956. /**
  7957. * @alias module:zrender/graphic/Displayable
  7958. * @extends module:zrender/Element
  7959. * @extends module:zrender/graphic/mixin/RectText
  7960. */
  7961. function Displayable(opts) {
  7962. opts = opts || {};
  7963. Element.call(this, opts);
  7964. // Extend properties
  7965. for (var name in opts) {
  7966. if (
  7967. opts.hasOwnProperty(name) &&
  7968. name !== 'style'
  7969. ) {
  7970. this[name] = opts[name];
  7971. }
  7972. }
  7973. /**
  7974. * @type {module:zrender/graphic/Style}
  7975. */
  7976. this.style = new Style(opts.style, this);
  7977. this._rect = null;
  7978. // Shapes for cascade clipping.
  7979. this.__clipPaths = [];
  7980. // FIXME Stateful must be mixined after style is setted
  7981. // Stateful.call(this, opts);
  7982. }
  7983. Displayable.prototype = {
  7984. constructor: Displayable,
  7985. type: 'displayable',
  7986. /**
  7987. * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制
  7988. * Dirty flag. From which painter will determine if this displayable object needs brush
  7989. * @name module:zrender/graphic/Displayable#__dirty
  7990. * @type {boolean}
  7991. */
  7992. __dirty: true,
  7993. /**
  7994. * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件
  7995. * If ignore drawing of the displayable object. Mouse event will still be triggered
  7996. * @name module:/zrender/graphic/Displayable#invisible
  7997. * @type {boolean}
  7998. * @default false
  7999. */
  8000. invisible: false,
  8001. /**
  8002. * @name module:/zrender/graphic/Displayable#z
  8003. * @type {number}
  8004. * @default 0
  8005. */
  8006. z: 0,
  8007. /**
  8008. * @name module:/zrender/graphic/Displayable#z
  8009. * @type {number}
  8010. * @default 0
  8011. */
  8012. z2: 0,
  8013. /**
  8014. * z层level,决定绘画在哪层canvas中
  8015. * @name module:/zrender/graphic/Displayable#zlevel
  8016. * @type {number}
  8017. * @default 0
  8018. */
  8019. zlevel: 0,
  8020. /**
  8021. * 是否可拖拽
  8022. * @name module:/zrender/graphic/Displayable#draggable
  8023. * @type {boolean}
  8024. * @default false
  8025. */
  8026. draggable: false,
  8027. /**
  8028. * 是否正在拖拽
  8029. * @name module:/zrender/graphic/Displayable#draggable
  8030. * @type {boolean}
  8031. * @default false
  8032. */
  8033. dragging: false,
  8034. /**
  8035. * 是否相应鼠标事件
  8036. * @name module:/zrender/graphic/Displayable#silent
  8037. * @type {boolean}
  8038. * @default false
  8039. */
  8040. silent: false,
  8041. /**
  8042. * If enable culling
  8043. * @type {boolean}
  8044. * @default false
  8045. */
  8046. culling: false,
  8047. /**
  8048. * Mouse cursor when hovered
  8049. * @name module:/zrender/graphic/Displayable#cursor
  8050. * @type {string}
  8051. */
  8052. cursor: 'pointer',
  8053. /**
  8054. * If hover area is bounding rect
  8055. * @name module:/zrender/graphic/Displayable#rectHover
  8056. * @type {string}
  8057. */
  8058. rectHover: false,
  8059. /**
  8060. * Render the element progressively when the value >= 0,
  8061. * usefull for large data.
  8062. * @type {number}
  8063. */
  8064. progressive: -1,
  8065. beforeBrush: function (ctx) {},
  8066. afterBrush: function (ctx) {},
  8067. /**
  8068. * 图形绘制方法
  8069. * @param {CanvasRenderingContext2D} ctx
  8070. */
  8071. // Interface
  8072. brush: function (ctx, prevEl) {},
  8073. /**
  8074. * 获取最小包围盒
  8075. * @return {module:zrender/core/BoundingRect}
  8076. */
  8077. // Interface
  8078. getBoundingRect: function () {},
  8079. /**
  8080. * 判断坐标 x, y 是否在图形上
  8081. * If displayable element contain coord x, y
  8082. * @param {number} x
  8083. * @param {number} y
  8084. * @return {boolean}
  8085. */
  8086. contain: function (x, y) {
  8087. return this.rectContain(x, y);
  8088. },
  8089. /**
  8090. * @param {Function} cb
  8091. * @param {} context
  8092. */
  8093. traverse: function (cb, context) {
  8094. cb.call(context, this);
  8095. },
  8096. /**
  8097. * 判断坐标 x, y 是否在图形的包围盒上
  8098. * If bounding rect of element contain coord x, y
  8099. * @param {number} x
  8100. * @param {number} y
  8101. * @return {boolean}
  8102. */
  8103. rectContain: function (x, y) {
  8104. var coord = this.transformCoordToLocal(x, y);
  8105. var rect = this.getBoundingRect();
  8106. return rect.contain(coord[0], coord[1]);
  8107. },
  8108. /**
  8109. * 标记图形元素为脏,并且在下一帧重绘
  8110. * Mark displayable element dirty and refresh next frame
  8111. */
  8112. dirty: function () {
  8113. this.__dirty = true;
  8114. this._rect = null;
  8115. this.__zr && this.__zr.refresh();
  8116. },
  8117. /**
  8118. * 图形是否会触发事件
  8119. * If displayable object binded any event
  8120. * @return {boolean}
  8121. */
  8122. // TODO, 通过 bind 绑定的事件
  8123. // isSilent: function () {
  8124. // return !(
  8125. // this.hoverable || this.draggable
  8126. // || this.onmousemove || this.onmouseover || this.onmouseout
  8127. // || this.onmousedown || this.onmouseup || this.onclick
  8128. // || this.ondragenter || this.ondragover || this.ondragleave
  8129. // || this.ondrop
  8130. // );
  8131. // },
  8132. /**
  8133. * Alias for animate('style')
  8134. * @param {boolean} loop
  8135. */
  8136. animateStyle: function (loop) {
  8137. return this.animate('style', loop);
  8138. },
  8139. attrKV: function (key, value) {
  8140. if (key !== 'style') {
  8141. Element.prototype.attrKV.call(this, key, value);
  8142. }
  8143. else {
  8144. this.style.set(value);
  8145. }
  8146. },
  8147. /**
  8148. * @param {Object|string} key
  8149. * @param {*} value
  8150. */
  8151. setStyle: function (key, value) {
  8152. this.style.set(key, value);
  8153. this.dirty(false);
  8154. return this;
  8155. },
  8156. /**
  8157. * Use given style object
  8158. * @param {Object} obj
  8159. */
  8160. useStyle: function (obj) {
  8161. this.style = new Style(obj, this);
  8162. this.dirty(false);
  8163. return this;
  8164. }
  8165. };
  8166. zrUtil.inherits(Displayable, Element);
  8167. zrUtil.mixin(Displayable, RectText);
  8168. // zrUtil.mixin(Displayable, Stateful);
  8169. module.exports = Displayable;
  8170. /***/ }),
  8171. /* 24 */
  8172. /***/ (function(module, exports) {
  8173. /**
  8174. * @module zrender/graphic/Style
  8175. */
  8176. var STYLE_COMMON_PROPS = [
  8177. ['shadowBlur', 0], ['shadowOffsetX', 0], ['shadowOffsetY', 0], ['shadowColor', '#000'],
  8178. ['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]
  8179. ];
  8180. // var SHADOW_PROPS = STYLE_COMMON_PROPS.slice(0, 4);
  8181. // var LINE_PROPS = STYLE_COMMON_PROPS.slice(4);
  8182. var Style = function (opts, host) {
  8183. this.extendFrom(opts, false);
  8184. this.host = host;
  8185. };
  8186. function createLinearGradient(ctx, obj, rect) {
  8187. var x = obj.x == null ? 0 : obj.x;
  8188. var x2 = obj.x2 == null ? 1 : obj.x2;
  8189. var y = obj.y == null ? 0 : obj.y;
  8190. var y2 = obj.y2 == null ? 0 : obj.y2;
  8191. if (!obj.global) {
  8192. x = x * rect.width + rect.x;
  8193. x2 = x2 * rect.width + rect.x;
  8194. y = y * rect.height + rect.y;
  8195. y2 = y2 * rect.height + rect.y;
  8196. }
  8197. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  8198. return canvasGradient;
  8199. }
  8200. function createRadialGradient(ctx, obj, rect) {
  8201. var width = rect.width;
  8202. var height = rect.height;
  8203. var min = Math.min(width, height);
  8204. var x = obj.x == null ? 0.5 : obj.x;
  8205. var y = obj.y == null ? 0.5 : obj.y;
  8206. var r = obj.r == null ? 0.5 : obj.r;
  8207. if (!obj.global) {
  8208. x = x * width + rect.x;
  8209. y = y * height + rect.y;
  8210. r = r * min;
  8211. }
  8212. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  8213. return canvasGradient;
  8214. }
  8215. Style.prototype = {
  8216. constructor: Style,
  8217. /**
  8218. * @type {module:zrender/graphic/Displayable}
  8219. */
  8220. host: null,
  8221. /**
  8222. * @type {string}
  8223. */
  8224. fill: '#000',
  8225. /**
  8226. * @type {string}
  8227. */
  8228. stroke: null,
  8229. /**
  8230. * @type {number}
  8231. */
  8232. opacity: 1,
  8233. /**
  8234. * @type {Array.<number>}
  8235. */
  8236. lineDash: null,
  8237. /**
  8238. * @type {number}
  8239. */
  8240. lineDashOffset: 0,
  8241. /**
  8242. * @type {number}
  8243. */
  8244. shadowBlur: 0,
  8245. /**
  8246. * @type {number}
  8247. */
  8248. shadowOffsetX: 0,
  8249. /**
  8250. * @type {number}
  8251. */
  8252. shadowOffsetY: 0,
  8253. /**
  8254. * @type {number}
  8255. */
  8256. lineWidth: 1,
  8257. /**
  8258. * If stroke ignore scale
  8259. * @type {Boolean}
  8260. */
  8261. strokeNoScale: false,
  8262. // Bounding rect text configuration
  8263. // Not affected by element transform
  8264. /**
  8265. * @type {string}
  8266. */
  8267. text: null,
  8268. /**
  8269. * If `fontSize` or `fontFamily` exists, `font` will be reset by
  8270. * `fontSize`, `fontStyle`, `fontWeight`, `fontFamily`.
  8271. * So do not visit it directly in upper application (like echarts),
  8272. * but use `contain/text#makeFont` instead.
  8273. * @type {string}
  8274. */
  8275. font: null,
  8276. /**
  8277. * The same as font. Use font please.
  8278. * @deprecated
  8279. * @type {string}
  8280. */
  8281. textFont: null,
  8282. /**
  8283. * It helps merging respectively, rather than parsing an entire font string.
  8284. * @type {string}
  8285. */
  8286. fontStyle: null,
  8287. /**
  8288. * It helps merging respectively, rather than parsing an entire font string.
  8289. * @type {string}
  8290. */
  8291. fontWeight: null,
  8292. /**
  8293. * It helps merging respectively, rather than parsing an entire font string.
  8294. * Should be 12 but not '12px'.
  8295. * @type {number}
  8296. */
  8297. fontSize: null,
  8298. /**
  8299. * It helps merging respectively, rather than parsing an entire font string.
  8300. * @type {string}
  8301. */
  8302. fontFamily: null,
  8303. /**
  8304. * Reserved for special functinality, like 'hr'.
  8305. * @type {string}
  8306. */
  8307. textTag: null,
  8308. /**
  8309. * @type {string}
  8310. */
  8311. textFill: '#000',
  8312. /**
  8313. * @type {string}
  8314. */
  8315. textStroke: null,
  8316. /**
  8317. * @type {number}
  8318. */
  8319. textWidth: null,
  8320. /**
  8321. * Only for textBackground.
  8322. * @type {number}
  8323. */
  8324. textHeight: null,
  8325. /**
  8326. * textStroke may be set as some color as a default
  8327. * value in upper applicaion, where the default value
  8328. * of textStrokeWidth should be 0 to make sure that
  8329. * user can choose to do not use text stroke.
  8330. * @type {number}
  8331. */
  8332. textStrokeWidth: 0,
  8333. /**
  8334. * @type {number}
  8335. */
  8336. textLineHeight: null,
  8337. /**
  8338. * 'inside', 'left', 'right', 'top', 'bottom'
  8339. * [x, y]
  8340. * Based on x, y of rect.
  8341. * @type {string|Array.<number>}
  8342. * @default 'inside'
  8343. */
  8344. textPosition: 'inside',
  8345. /**
  8346. * If not specified, use the boundingRect of a `displayable`.
  8347. * @type {Object}
  8348. */
  8349. textRect: null,
  8350. /**
  8351. * [x, y]
  8352. * @type {Array.<number>}
  8353. */
  8354. textOffset: null,
  8355. /**
  8356. * @type {string}
  8357. */
  8358. textAlign: null,
  8359. /**
  8360. * @type {string}
  8361. */
  8362. textVerticalAlign: null,
  8363. /**
  8364. * @type {number}
  8365. */
  8366. textDistance: 5,
  8367. /**
  8368. * @type {string}
  8369. */
  8370. textShadowColor: 'transparent',
  8371. /**
  8372. * @type {number}
  8373. */
  8374. textShadowBlur: 0,
  8375. /**
  8376. * @type {number}
  8377. */
  8378. textShadowOffsetX: 0,
  8379. /**
  8380. * @type {number}
  8381. */
  8382. textShadowOffsetY: 0,
  8383. /**
  8384. * @type {string}
  8385. */
  8386. textBoxShadowColor: 'transparent',
  8387. /**
  8388. * @type {number}
  8389. */
  8390. textBoxShadowBlur: 0,
  8391. /**
  8392. * @type {number}
  8393. */
  8394. textBoxShadowOffsetX: 0,
  8395. /**
  8396. * @type {number}
  8397. */
  8398. textBoxShadowOffsetY: 0,
  8399. /**
  8400. * Whether transform text.
  8401. * Only useful in Path and Image element
  8402. * @type {boolean}
  8403. */
  8404. transformText: false,
  8405. /**
  8406. * Text rotate around position of Path or Image
  8407. * Only useful in Path and Image element and transformText is false.
  8408. */
  8409. textRotation: 0,
  8410. /**
  8411. * Text origin of text rotation, like [10, 40].
  8412. * Based on x, y of rect.
  8413. * Useful in label rotation of circular symbol.
  8414. * By default, this origin is textPosition.
  8415. * Can be 'center'.
  8416. * @type {string|Array.<number>}
  8417. */
  8418. textOrigin: null,
  8419. /**
  8420. * @type {string}
  8421. */
  8422. textBackgroundColor: null,
  8423. /**
  8424. * @type {string}
  8425. */
  8426. textBorderColor: null,
  8427. /**
  8428. * @type {number}
  8429. */
  8430. textBorderWidth: 0,
  8431. /**
  8432. * @type {number}
  8433. */
  8434. textBorderRadius: 0,
  8435. /**
  8436. * Can be `2` or `[2, 4]` or `[2, 3, 4, 5]`
  8437. * @type {number|Array.<number>}
  8438. */
  8439. textPadding: null,
  8440. /**
  8441. * Text styles for rich text.
  8442. * @type {Object}
  8443. */
  8444. rich: null,
  8445. /**
  8446. * {outerWidth, outerHeight, ellipsis, placeholder}
  8447. * @type {Object}
  8448. */
  8449. truncate: null,
  8450. /**
  8451. * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  8452. * @type {string}
  8453. */
  8454. blend: null,
  8455. /**
  8456. * @param {CanvasRenderingContext2D} ctx
  8457. */
  8458. bind: function (ctx, el, prevEl) {
  8459. var style = this;
  8460. var prevStyle = prevEl && prevEl.style;
  8461. var firstDraw = !prevStyle;
  8462. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  8463. var prop = STYLE_COMMON_PROPS[i];
  8464. var styleName = prop[0];
  8465. if (firstDraw || style[styleName] !== prevStyle[styleName]) {
  8466. // FIXME Invalid property value will cause style leak from previous element.
  8467. ctx[styleName] = style[styleName] || prop[1];
  8468. }
  8469. }
  8470. if ((firstDraw || style.fill !== prevStyle.fill)) {
  8471. ctx.fillStyle = style.fill;
  8472. }
  8473. if ((firstDraw || style.stroke !== prevStyle.stroke)) {
  8474. ctx.strokeStyle = style.stroke;
  8475. }
  8476. if ((firstDraw || style.opacity !== prevStyle.opacity)) {
  8477. ctx.globalAlpha = style.opacity == null ? 1 : style.opacity;
  8478. }
  8479. if ((firstDraw || style.blend !== prevStyle.blend)) {
  8480. ctx.globalCompositeOperation = style.blend || 'source-over';
  8481. }
  8482. if (this.hasStroke()) {
  8483. var lineWidth = style.lineWidth;
  8484. ctx.lineWidth = lineWidth / (
  8485. (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1
  8486. );
  8487. }
  8488. },
  8489. hasFill: function () {
  8490. var fill = this.fill;
  8491. return fill != null && fill !== 'none';
  8492. },
  8493. hasStroke: function () {
  8494. var stroke = this.stroke;
  8495. return stroke != null && stroke !== 'none' && this.lineWidth > 0;
  8496. },
  8497. /**
  8498. * Extend from other style
  8499. * @param {zrender/graphic/Style} otherStyle
  8500. * @param {boolean} overwrite true: overwrirte any way.
  8501. * false: overwrite only when !target.hasOwnProperty
  8502. * others: overwrite when property is not null/undefined.
  8503. */
  8504. extendFrom: function (otherStyle, overwrite) {
  8505. if (otherStyle) {
  8506. for (var name in otherStyle) {
  8507. if (otherStyle.hasOwnProperty(name)
  8508. && (overwrite === true
  8509. || (
  8510. overwrite === false
  8511. ? !this.hasOwnProperty(name)
  8512. : otherStyle[name] != null
  8513. )
  8514. )
  8515. ) {
  8516. this[name] = otherStyle[name];
  8517. }
  8518. }
  8519. }
  8520. },
  8521. /**
  8522. * Batch setting style with a given object
  8523. * @param {Object|string} obj
  8524. * @param {*} [obj]
  8525. */
  8526. set: function (obj, value) {
  8527. if (typeof obj === 'string') {
  8528. this[obj] = value;
  8529. }
  8530. else {
  8531. this.extendFrom(obj, true);
  8532. }
  8533. },
  8534. /**
  8535. * Clone
  8536. * @return {zrender/graphic/Style} [description]
  8537. */
  8538. clone: function () {
  8539. var newStyle = new this.constructor();
  8540. newStyle.extendFrom(this, true);
  8541. return newStyle;
  8542. },
  8543. getGradient: function (ctx, obj, rect) {
  8544. var method = obj.type === 'radial' ? createRadialGradient : createLinearGradient;
  8545. var canvasGradient = method(ctx, obj, rect);
  8546. var colorStops = obj.colorStops;
  8547. for (var i = 0; i < colorStops.length; i++) {
  8548. canvasGradient.addColorStop(
  8549. colorStops[i].offset, colorStops[i].color
  8550. );
  8551. }
  8552. return canvasGradient;
  8553. }
  8554. };
  8555. var styleProto = Style.prototype;
  8556. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  8557. var prop = STYLE_COMMON_PROPS[i];
  8558. if (!(prop[0] in styleProto)) {
  8559. styleProto[prop[0]] = prop[1];
  8560. }
  8561. }
  8562. // Provide for others
  8563. Style.getGradient = styleProto.getGradient;
  8564. module.exports = Style;
  8565. /***/ }),
  8566. /* 25 */
  8567. /***/ (function(module, exports, __webpack_require__) {
  8568. 'use strict';
  8569. /**
  8570. * @module zrender/Element
  8571. */
  8572. var guid = __webpack_require__(26);
  8573. var Eventful = __webpack_require__(27);
  8574. var Transformable = __webpack_require__(28);
  8575. var Animatable = __webpack_require__(29);
  8576. var zrUtil = __webpack_require__(4);
  8577. /**
  8578. * @alias module:zrender/Element
  8579. * @constructor
  8580. * @extends {module:zrender/mixin/Animatable}
  8581. * @extends {module:zrender/mixin/Transformable}
  8582. * @extends {module:zrender/mixin/Eventful}
  8583. */
  8584. var Element = function (opts) {
  8585. Transformable.call(this, opts);
  8586. Eventful.call(this, opts);
  8587. Animatable.call(this, opts);
  8588. /**
  8589. * 画布元素ID
  8590. * @type {string}
  8591. */
  8592. this.id = opts.id || guid();
  8593. };
  8594. Element.prototype = {
  8595. /**
  8596. * 元素类型
  8597. * Element type
  8598. * @type {string}
  8599. */
  8600. type: 'element',
  8601. /**
  8602. * 元素名字
  8603. * Element name
  8604. * @type {string}
  8605. */
  8606. name: '',
  8607. /**
  8608. * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值
  8609. * ZRender instance will be assigned when element is associated with zrender
  8610. * @name module:/zrender/Element#__zr
  8611. * @type {module:zrender/ZRender}
  8612. */
  8613. __zr: null,
  8614. /**
  8615. * 图形是否忽略,为true时忽略图形的绘制以及事件触发
  8616. * If ignore drawing and events of the element object
  8617. * @name module:/zrender/Element#ignore
  8618. * @type {boolean}
  8619. * @default false
  8620. */
  8621. ignore: false,
  8622. /**
  8623. * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪
  8624. * 该路径会继承被裁减对象的变换
  8625. * @type {module:zrender/graphic/Path}
  8626. * @see http://www.w3.org/TR/2dcontext/#clipping-region
  8627. * @readOnly
  8628. */
  8629. clipPath: null,
  8630. /**
  8631. * Drift element
  8632. * @param {number} dx dx on the global space
  8633. * @param {number} dy dy on the global space
  8634. */
  8635. drift: function (dx, dy) {
  8636. switch (this.draggable) {
  8637. case 'horizontal':
  8638. dy = 0;
  8639. break;
  8640. case 'vertical':
  8641. dx = 0;
  8642. break;
  8643. }
  8644. var m = this.transform;
  8645. if (!m) {
  8646. m = this.transform = [1, 0, 0, 1, 0, 0];
  8647. }
  8648. m[4] += dx;
  8649. m[5] += dy;
  8650. this.decomposeTransform();
  8651. this.dirty(false);
  8652. },
  8653. /**
  8654. * Hook before update
  8655. */
  8656. beforeUpdate: function () {},
  8657. /**
  8658. * Hook after update
  8659. */
  8660. afterUpdate: function () {},
  8661. /**
  8662. * Update each frame
  8663. */
  8664. update: function () {
  8665. this.updateTransform();
  8666. },
  8667. /**
  8668. * @param {Function} cb
  8669. * @param {} context
  8670. */
  8671. traverse: function (cb, context) {},
  8672. /**
  8673. * @protected
  8674. */
  8675. attrKV: function (key, value) {
  8676. if (key === 'position' || key === 'scale' || key === 'origin') {
  8677. // Copy the array
  8678. if (value) {
  8679. var target = this[key];
  8680. if (!target) {
  8681. target = this[key] = [];
  8682. }
  8683. target[0] = value[0];
  8684. target[1] = value[1];
  8685. }
  8686. }
  8687. else {
  8688. this[key] = value;
  8689. }
  8690. },
  8691. /**
  8692. * Hide the element
  8693. */
  8694. hide: function () {
  8695. this.ignore = true;
  8696. this.__zr && this.__zr.refresh();
  8697. },
  8698. /**
  8699. * Show the element
  8700. */
  8701. show: function () {
  8702. this.ignore = false;
  8703. this.__zr && this.__zr.refresh();
  8704. },
  8705. /**
  8706. * @param {string|Object} key
  8707. * @param {*} value
  8708. */
  8709. attr: function (key, value) {
  8710. if (typeof key === 'string') {
  8711. this.attrKV(key, value);
  8712. }
  8713. else if (zrUtil.isObject(key)) {
  8714. for (var name in key) {
  8715. if (key.hasOwnProperty(name)) {
  8716. this.attrKV(name, key[name]);
  8717. }
  8718. }
  8719. }
  8720. this.dirty(false);
  8721. return this;
  8722. },
  8723. /**
  8724. * @param {module:zrender/graphic/Path} clipPath
  8725. */
  8726. setClipPath: function (clipPath) {
  8727. var zr = this.__zr;
  8728. if (zr) {
  8729. clipPath.addSelfToZr(zr);
  8730. }
  8731. // Remove previous clip path
  8732. if (this.clipPath && this.clipPath !== clipPath) {
  8733. this.removeClipPath();
  8734. }
  8735. this.clipPath = clipPath;
  8736. clipPath.__zr = zr;
  8737. clipPath.__clipTarget = this;
  8738. this.dirty(false);
  8739. },
  8740. /**
  8741. */
  8742. removeClipPath: function () {
  8743. var clipPath = this.clipPath;
  8744. if (clipPath) {
  8745. if (clipPath.__zr) {
  8746. clipPath.removeSelfFromZr(clipPath.__zr);
  8747. }
  8748. clipPath.__zr = null;
  8749. clipPath.__clipTarget = null;
  8750. this.clipPath = null;
  8751. this.dirty(false);
  8752. }
  8753. },
  8754. /**
  8755. * Add self from zrender instance.
  8756. * Not recursively because it will be invoked when element added to storage.
  8757. * @param {module:zrender/ZRender} zr
  8758. */
  8759. addSelfToZr: function (zr) {
  8760. this.__zr = zr;
  8761. // 添加动画
  8762. var animators = this.animators;
  8763. if (animators) {
  8764. for (var i = 0; i < animators.length; i++) {
  8765. zr.animation.addAnimator(animators[i]);
  8766. }
  8767. }
  8768. if (this.clipPath) {
  8769. this.clipPath.addSelfToZr(zr);
  8770. }
  8771. },
  8772. /**
  8773. * Remove self from zrender instance.
  8774. * Not recursively because it will be invoked when element added to storage.
  8775. * @param {module:zrender/ZRender} zr
  8776. */
  8777. removeSelfFromZr: function (zr) {
  8778. this.__zr = null;
  8779. // 移除动画
  8780. var animators = this.animators;
  8781. if (animators) {
  8782. for (var i = 0; i < animators.length; i++) {
  8783. zr.animation.removeAnimator(animators[i]);
  8784. }
  8785. }
  8786. if (this.clipPath) {
  8787. this.clipPath.removeSelfFromZr(zr);
  8788. }
  8789. }
  8790. };
  8791. zrUtil.mixin(Element, Animatable);
  8792. zrUtil.mixin(Element, Transformable);
  8793. zrUtil.mixin(Element, Eventful);
  8794. module.exports = Element;
  8795. /***/ }),
  8796. /* 26 */
  8797. /***/ (function(module, exports) {
  8798. /**
  8799. * zrender: 生成唯一id
  8800. *
  8801. * @author errorrik (errorrik@gmail.com)
  8802. */
  8803. var idStart = 0x0907;
  8804. module.exports = function () {
  8805. return idStart++;
  8806. };
  8807. /***/ }),
  8808. /* 27 */
  8809. /***/ (function(module, exports) {
  8810. /**
  8811. * 事件扩展
  8812. * @module zrender/mixin/Eventful
  8813. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  8814. * pissang (https://www.github.com/pissang)
  8815. */
  8816. var arrySlice = Array.prototype.slice;
  8817. /**
  8818. * 事件分发器
  8819. * @alias module:zrender/mixin/Eventful
  8820. * @constructor
  8821. */
  8822. var Eventful = function () {
  8823. this._$handlers = {};
  8824. };
  8825. Eventful.prototype = {
  8826. constructor: Eventful,
  8827. /**
  8828. * 单次触发绑定,trigger后销毁
  8829. *
  8830. * @param {string} event 事件名
  8831. * @param {Function} handler 响应函数
  8832. * @param {Object} context
  8833. */
  8834. one: function (event, handler, context) {
  8835. var _h = this._$handlers;
  8836. if (!handler || !event) {
  8837. return this;
  8838. }
  8839. if (!_h[event]) {
  8840. _h[event] = [];
  8841. }
  8842. for (var i = 0; i < _h[event].length; i++) {
  8843. if (_h[event][i].h === handler) {
  8844. return this;
  8845. }
  8846. }
  8847. _h[event].push({
  8848. h: handler,
  8849. one: true,
  8850. ctx: context || this
  8851. });
  8852. return this;
  8853. },
  8854. /**
  8855. * 绑定事件
  8856. * @param {string} event 事件名
  8857. * @param {Function} handler 事件处理函数
  8858. * @param {Object} [context]
  8859. */
  8860. on: function (event, handler, context) {
  8861. var _h = this._$handlers;
  8862. if (!handler || !event) {
  8863. return this;
  8864. }
  8865. if (!_h[event]) {
  8866. _h[event] = [];
  8867. }
  8868. for (var i = 0; i < _h[event].length; i++) {
  8869. if (_h[event][i].h === handler) {
  8870. return this;
  8871. }
  8872. }
  8873. _h[event].push({
  8874. h: handler,
  8875. one: false,
  8876. ctx: context || this
  8877. });
  8878. return this;
  8879. },
  8880. /**
  8881. * 是否绑定了事件
  8882. * @param {string} event
  8883. * @return {boolean}
  8884. */
  8885. isSilent: function (event) {
  8886. var _h = this._$handlers;
  8887. return _h[event] && _h[event].length;
  8888. },
  8889. /**
  8890. * 解绑事件
  8891. * @param {string} event 事件名
  8892. * @param {Function} [handler] 事件处理函数
  8893. */
  8894. off: function (event, handler) {
  8895. var _h = this._$handlers;
  8896. if (!event) {
  8897. this._$handlers = {};
  8898. return this;
  8899. }
  8900. if (handler) {
  8901. if (_h[event]) {
  8902. var newList = [];
  8903. for (var i = 0, l = _h[event].length; i < l; i++) {
  8904. if (_h[event][i]['h'] != handler) {
  8905. newList.push(_h[event][i]);
  8906. }
  8907. }
  8908. _h[event] = newList;
  8909. }
  8910. if (_h[event] && _h[event].length === 0) {
  8911. delete _h[event];
  8912. }
  8913. }
  8914. else {
  8915. delete _h[event];
  8916. }
  8917. return this;
  8918. },
  8919. /**
  8920. * 事件分发
  8921. *
  8922. * @param {string} type 事件类型
  8923. */
  8924. trigger: function (type) {
  8925. if (this._$handlers[type]) {
  8926. var args = arguments;
  8927. var argLen = args.length;
  8928. if (argLen > 3) {
  8929. args = arrySlice.call(args, 1);
  8930. }
  8931. var _h = this._$handlers[type];
  8932. var len = _h.length;
  8933. for (var i = 0; i < len;) {
  8934. // Optimize advise from backbone
  8935. switch (argLen) {
  8936. case 1:
  8937. _h[i]['h'].call(_h[i]['ctx']);
  8938. break;
  8939. case 2:
  8940. _h[i]['h'].call(_h[i]['ctx'], args[1]);
  8941. break;
  8942. case 3:
  8943. _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]);
  8944. break;
  8945. default:
  8946. // have more than 2 given arguments
  8947. _h[i]['h'].apply(_h[i]['ctx'], args);
  8948. break;
  8949. }
  8950. if (_h[i]['one']) {
  8951. _h.splice(i, 1);
  8952. len--;
  8953. }
  8954. else {
  8955. i++;
  8956. }
  8957. }
  8958. }
  8959. return this;
  8960. },
  8961. /**
  8962. * 带有context的事件分发, 最后一个参数是事件回调的context
  8963. * @param {string} type 事件类型
  8964. */
  8965. triggerWithContext: function (type) {
  8966. if (this._$handlers[type]) {
  8967. var args = arguments;
  8968. var argLen = args.length;
  8969. if (argLen > 4) {
  8970. args = arrySlice.call(args, 1, args.length - 1);
  8971. }
  8972. var ctx = args[args.length - 1];
  8973. var _h = this._$handlers[type];
  8974. var len = _h.length;
  8975. for (var i = 0; i < len;) {
  8976. // Optimize advise from backbone
  8977. switch (argLen) {
  8978. case 1:
  8979. _h[i]['h'].call(ctx);
  8980. break;
  8981. case 2:
  8982. _h[i]['h'].call(ctx, args[1]);
  8983. break;
  8984. case 3:
  8985. _h[i]['h'].call(ctx, args[1], args[2]);
  8986. break;
  8987. default:
  8988. // have more than 2 given arguments
  8989. _h[i]['h'].apply(ctx, args);
  8990. break;
  8991. }
  8992. if (_h[i]['one']) {
  8993. _h.splice(i, 1);
  8994. len--;
  8995. }
  8996. else {
  8997. i++;
  8998. }
  8999. }
  9000. }
  9001. return this;
  9002. }
  9003. };
  9004. // 对象可以通过 onxxxx 绑定事件
  9005. /**
  9006. * @event module:zrender/mixin/Eventful#onclick
  9007. * @type {Function}
  9008. * @default null
  9009. */
  9010. /**
  9011. * @event module:zrender/mixin/Eventful#onmouseover
  9012. * @type {Function}
  9013. * @default null
  9014. */
  9015. /**
  9016. * @event module:zrender/mixin/Eventful#onmouseout
  9017. * @type {Function}
  9018. * @default null
  9019. */
  9020. /**
  9021. * @event module:zrender/mixin/Eventful#onmousemove
  9022. * @type {Function}
  9023. * @default null
  9024. */
  9025. /**
  9026. * @event module:zrender/mixin/Eventful#onmousewheel
  9027. * @type {Function}
  9028. * @default null
  9029. */
  9030. /**
  9031. * @event module:zrender/mixin/Eventful#onmousedown
  9032. * @type {Function}
  9033. * @default null
  9034. */
  9035. /**
  9036. * @event module:zrender/mixin/Eventful#onmouseup
  9037. * @type {Function}
  9038. * @default null
  9039. */
  9040. /**
  9041. * @event module:zrender/mixin/Eventful#ondrag
  9042. * @type {Function}
  9043. * @default null
  9044. */
  9045. /**
  9046. * @event module:zrender/mixin/Eventful#ondragstart
  9047. * @type {Function}
  9048. * @default null
  9049. */
  9050. /**
  9051. * @event module:zrender/mixin/Eventful#ondragend
  9052. * @type {Function}
  9053. * @default null
  9054. */
  9055. /**
  9056. * @event module:zrender/mixin/Eventful#ondragenter
  9057. * @type {Function}
  9058. * @default null
  9059. */
  9060. /**
  9061. * @event module:zrender/mixin/Eventful#ondragleave
  9062. * @type {Function}
  9063. * @default null
  9064. */
  9065. /**
  9066. * @event module:zrender/mixin/Eventful#ondragover
  9067. * @type {Function}
  9068. * @default null
  9069. */
  9070. /**
  9071. * @event module:zrender/mixin/Eventful#ondrop
  9072. * @type {Function}
  9073. * @default null
  9074. */
  9075. module.exports = Eventful;
  9076. /***/ }),
  9077. /* 28 */
  9078. /***/ (function(module, exports, __webpack_require__) {
  9079. 'use strict';
  9080. /**
  9081. * 提供变换扩展
  9082. * @module zrender/mixin/Transformable
  9083. * @author pissang (https://www.github.com/pissang)
  9084. */
  9085. var matrix = __webpack_require__(11);
  9086. var vector = __webpack_require__(10);
  9087. var mIdentity = matrix.identity;
  9088. var EPSILON = 5e-5;
  9089. function isNotAroundZero(val) {
  9090. return val > EPSILON || val < -EPSILON;
  9091. }
  9092. /**
  9093. * @alias module:zrender/mixin/Transformable
  9094. * @constructor
  9095. */
  9096. var Transformable = function (opts) {
  9097. opts = opts || {};
  9098. // If there are no given position, rotation, scale
  9099. if (!opts.position) {
  9100. /**
  9101. * 平移
  9102. * @type {Array.<number>}
  9103. * @default [0, 0]
  9104. */
  9105. this.position = [0, 0];
  9106. }
  9107. if (opts.rotation == null) {
  9108. /**
  9109. * 旋转
  9110. * @type {Array.<number>}
  9111. * @default 0
  9112. */
  9113. this.rotation = 0;
  9114. }
  9115. if (!opts.scale) {
  9116. /**
  9117. * 缩放
  9118. * @type {Array.<number>}
  9119. * @default [1, 1]
  9120. */
  9121. this.scale = [1, 1];
  9122. }
  9123. /**
  9124. * 旋转和缩放的原点
  9125. * @type {Array.<number>}
  9126. * @default null
  9127. */
  9128. this.origin = this.origin || null;
  9129. };
  9130. var transformableProto = Transformable.prototype;
  9131. transformableProto.transform = null;
  9132. /**
  9133. * 判断是否需要有坐标变换
  9134. * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
  9135. */
  9136. transformableProto.needLocalTransform = function () {
  9137. return isNotAroundZero(this.rotation)
  9138. || isNotAroundZero(this.position[0])
  9139. || isNotAroundZero(this.position[1])
  9140. || isNotAroundZero(this.scale[0] - 1)
  9141. || isNotAroundZero(this.scale[1] - 1);
  9142. };
  9143. transformableProto.updateTransform = function () {
  9144. var parent = this.parent;
  9145. var parentHasTransform = parent && parent.transform;
  9146. var needLocalTransform = this.needLocalTransform();
  9147. var m = this.transform;
  9148. if (!(needLocalTransform || parentHasTransform)) {
  9149. m && mIdentity(m);
  9150. return;
  9151. }
  9152. m = m || matrix.create();
  9153. if (needLocalTransform) {
  9154. this.getLocalTransform(m);
  9155. }
  9156. else {
  9157. mIdentity(m);
  9158. }
  9159. // 应用父节点变换
  9160. if (parentHasTransform) {
  9161. if (needLocalTransform) {
  9162. matrix.mul(m, parent.transform, m);
  9163. }
  9164. else {
  9165. matrix.copy(m, parent.transform);
  9166. }
  9167. }
  9168. // 保存这个变换矩阵
  9169. this.transform = m;
  9170. this.invTransform = this.invTransform || matrix.create();
  9171. matrix.invert(this.invTransform, m);
  9172. };
  9173. transformableProto.getLocalTransform = function (m) {
  9174. return Transformable.getLocalTransform(this, m);
  9175. };
  9176. /**
  9177. * 将自己的transform应用到context上
  9178. * @param {CanvasRenderingContext2D} ctx
  9179. */
  9180. transformableProto.setTransform = function (ctx) {
  9181. var m = this.transform;
  9182. var dpr = ctx.dpr || 1;
  9183. if (m) {
  9184. ctx.setTransform(dpr * m[0], dpr * m[1], dpr * m[2], dpr * m[3], dpr * m[4], dpr * m[5]);
  9185. }
  9186. else {
  9187. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  9188. }
  9189. };
  9190. transformableProto.restoreTransform = function (ctx) {
  9191. var dpr = ctx.dpr || 1;
  9192. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  9193. };
  9194. var tmpTransform = [];
  9195. /**
  9196. * 分解`transform`矩阵到`position`, `rotation`, `scale`
  9197. */
  9198. transformableProto.decomposeTransform = function () {
  9199. if (!this.transform) {
  9200. return;
  9201. }
  9202. var parent = this.parent;
  9203. var m = this.transform;
  9204. if (parent && parent.transform) {
  9205. // Get local transform and decompose them to position, scale, rotation
  9206. matrix.mul(tmpTransform, parent.invTransform, m);
  9207. m = tmpTransform;
  9208. }
  9209. var sx = m[0] * m[0] + m[1] * m[1];
  9210. var sy = m[2] * m[2] + m[3] * m[3];
  9211. var position = this.position;
  9212. var scale = this.scale;
  9213. if (isNotAroundZero(sx - 1)) {
  9214. sx = Math.sqrt(sx);
  9215. }
  9216. if (isNotAroundZero(sy - 1)) {
  9217. sy = Math.sqrt(sy);
  9218. }
  9219. if (m[0] < 0) {
  9220. sx = -sx;
  9221. }
  9222. if (m[3] < 0) {
  9223. sy = -sy;
  9224. }
  9225. position[0] = m[4];
  9226. position[1] = m[5];
  9227. scale[0] = sx;
  9228. scale[1] = sy;
  9229. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  9230. };
  9231. /**
  9232. * Get global scale
  9233. * @return {Array.<number>}
  9234. */
  9235. transformableProto.getGlobalScale = function () {
  9236. var m = this.transform;
  9237. if (!m) {
  9238. return [1, 1];
  9239. }
  9240. var sx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  9241. var sy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  9242. if (m[0] < 0) {
  9243. sx = -sx;
  9244. }
  9245. if (m[3] < 0) {
  9246. sy = -sy;
  9247. }
  9248. return [sx, sy];
  9249. };
  9250. /**
  9251. * 变换坐标位置到 shape 的局部坐标空间
  9252. * @method
  9253. * @param {number} x
  9254. * @param {number} y
  9255. * @return {Array.<number>}
  9256. */
  9257. transformableProto.transformCoordToLocal = function (x, y) {
  9258. var v2 = [x, y];
  9259. var invTransform = this.invTransform;
  9260. if (invTransform) {
  9261. vector.applyTransform(v2, v2, invTransform);
  9262. }
  9263. return v2;
  9264. };
  9265. /**
  9266. * 变换局部坐标位置到全局坐标空间
  9267. * @method
  9268. * @param {number} x
  9269. * @param {number} y
  9270. * @return {Array.<number>}
  9271. */
  9272. transformableProto.transformCoordToGlobal = function (x, y) {
  9273. var v2 = [x, y];
  9274. var transform = this.transform;
  9275. if (transform) {
  9276. vector.applyTransform(v2, v2, transform);
  9277. }
  9278. return v2;
  9279. };
  9280. /**
  9281. * @static
  9282. * @param {Object} target
  9283. * @param {Array.<number>} target.origin
  9284. * @param {number} target.rotation
  9285. * @param {Array.<number>} target.position
  9286. * @param {Array.<number>} [m]
  9287. */
  9288. Transformable.getLocalTransform = function (target, m) {
  9289. m = m || [];
  9290. mIdentity(m);
  9291. var origin = target.origin;
  9292. var scale = target.scale || [1, 1];
  9293. var rotation = target.rotation || 0;
  9294. var position = target.position || [0, 0];
  9295. if (origin) {
  9296. // Translate to origin
  9297. m[4] -= origin[0];
  9298. m[5] -= origin[1];
  9299. }
  9300. matrix.scale(m, m, scale);
  9301. if (rotation) {
  9302. matrix.rotate(m, m, rotation);
  9303. }
  9304. if (origin) {
  9305. // Translate back from origin
  9306. m[4] += origin[0];
  9307. m[5] += origin[1];
  9308. }
  9309. m[4] += position[0];
  9310. m[5] += position[1];
  9311. return m;
  9312. };
  9313. module.exports = Transformable;
  9314. /***/ }),
  9315. /* 29 */
  9316. /***/ (function(module, exports, __webpack_require__) {
  9317. 'use strict';
  9318. /**
  9319. * @module zrender/mixin/Animatable
  9320. */
  9321. var Animator = __webpack_require__(30);
  9322. var util = __webpack_require__(4);
  9323. var isString = util.isString;
  9324. var isFunction = util.isFunction;
  9325. var isObject = util.isObject;
  9326. var log = __webpack_require__(34);
  9327. /**
  9328. * @alias modue:zrender/mixin/Animatable
  9329. * @constructor
  9330. */
  9331. var Animatable = function () {
  9332. /**
  9333. * @type {Array.<module:zrender/animation/Animator>}
  9334. * @readOnly
  9335. */
  9336. this.animators = [];
  9337. };
  9338. Animatable.prototype = {
  9339. constructor: Animatable,
  9340. /**
  9341. * 动画
  9342. *
  9343. * @param {string} path The path to fetch value from object, like 'a.b.c'.
  9344. * @param {boolean} [loop] Whether to loop animation.
  9345. * @return {module:zrender/animation/Animator}
  9346. * @example:
  9347. * el.animate('style', false)
  9348. * .when(1000, {x: 10} )
  9349. * .done(function(){ // Animation done })
  9350. * .start()
  9351. */
  9352. animate: function (path, loop) {
  9353. var target;
  9354. var animatingShape = false;
  9355. var el = this;
  9356. var zr = this.__zr;
  9357. if (path) {
  9358. var pathSplitted = path.split('.');
  9359. var prop = el;
  9360. // If animating shape
  9361. animatingShape = pathSplitted[0] === 'shape';
  9362. for (var i = 0, l = pathSplitted.length; i < l; i++) {
  9363. if (!prop) {
  9364. continue;
  9365. }
  9366. prop = prop[pathSplitted[i]];
  9367. }
  9368. if (prop) {
  9369. target = prop;
  9370. }
  9371. }
  9372. else {
  9373. target = el;
  9374. }
  9375. if (!target) {
  9376. log(
  9377. 'Property "'
  9378. + path
  9379. + '" is not existed in element '
  9380. + el.id
  9381. );
  9382. return;
  9383. }
  9384. var animators = el.animators;
  9385. var animator = new Animator(target, loop);
  9386. animator.during(function (target) {
  9387. el.dirty(animatingShape);
  9388. })
  9389. .done(function () {
  9390. // FIXME Animator will not be removed if use `Animator#stop` to stop animation
  9391. animators.splice(util.indexOf(animators, animator), 1);
  9392. });
  9393. animators.push(animator);
  9394. // If animate after added to the zrender
  9395. if (zr) {
  9396. zr.animation.addAnimator(animator);
  9397. }
  9398. return animator;
  9399. },
  9400. /**
  9401. * 停止动画
  9402. * @param {boolean} forwardToLast If move to last frame before stop
  9403. */
  9404. stopAnimation: function (forwardToLast) {
  9405. var animators = this.animators;
  9406. var len = animators.length;
  9407. for (var i = 0; i < len; i++) {
  9408. animators[i].stop(forwardToLast);
  9409. }
  9410. animators.length = 0;
  9411. return this;
  9412. },
  9413. /**
  9414. * Caution: this method will stop previous animation.
  9415. * So do not use this method to one element twice before
  9416. * animation starts, unless you know what you are doing.
  9417. * @param {Object} target
  9418. * @param {number} [time=500] Time in ms
  9419. * @param {string} [easing='linear']
  9420. * @param {number} [delay=0]
  9421. * @param {Function} [callback]
  9422. * @param {Function} [forceAnimate] Prevent stop animation and callback
  9423. * immediently when target values are the same as current values.
  9424. *
  9425. * @example
  9426. * // Animate position
  9427. * el.animateTo({
  9428. * position: [10, 10]
  9429. * }, function () { // done })
  9430. *
  9431. * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing
  9432. * el.animateTo({
  9433. * shape: {
  9434. * width: 500
  9435. * },
  9436. * style: {
  9437. * fill: 'red'
  9438. * }
  9439. * position: [10, 10]
  9440. * }, 100, 100, 'cubicOut', function () { // done })
  9441. */
  9442. // TODO Return animation key
  9443. animateTo: function (target, time, delay, easing, callback, forceAnimate) {
  9444. // animateTo(target, time, easing, callback);
  9445. if (isString(delay)) {
  9446. callback = easing;
  9447. easing = delay;
  9448. delay = 0;
  9449. }
  9450. // animateTo(target, time, delay, callback);
  9451. else if (isFunction(easing)) {
  9452. callback = easing;
  9453. easing = 'linear';
  9454. delay = 0;
  9455. }
  9456. // animateTo(target, time, callback);
  9457. else if (isFunction(delay)) {
  9458. callback = delay;
  9459. delay = 0;
  9460. }
  9461. // animateTo(target, callback)
  9462. else if (isFunction(time)) {
  9463. callback = time;
  9464. time = 500;
  9465. }
  9466. // animateTo(target)
  9467. else if (!time) {
  9468. time = 500;
  9469. }
  9470. // Stop all previous animations
  9471. this.stopAnimation();
  9472. this._animateToShallow('', this, target, time, delay, easing, callback);
  9473. // Animators may be removed immediately after start
  9474. // if there is nothing to animate
  9475. var animators = this.animators.slice();
  9476. var count = animators.length;
  9477. function done() {
  9478. count--;
  9479. if (!count) {
  9480. callback && callback();
  9481. }
  9482. }
  9483. // No animators. This should be checked before animators[i].start(),
  9484. // because 'done' may be executed immediately if no need to animate.
  9485. if (!count) {
  9486. callback && callback();
  9487. }
  9488. // Start after all animators created
  9489. // Incase any animator is done immediately when all animation properties are not changed
  9490. for (var i = 0; i < animators.length; i++) {
  9491. animators[i]
  9492. .done(done)
  9493. .start(easing, forceAnimate);
  9494. }
  9495. },
  9496. /**
  9497. * @private
  9498. * @param {string} path=''
  9499. * @param {Object} source=this
  9500. * @param {Object} target
  9501. * @param {number} [time=500]
  9502. * @param {number} [delay=0]
  9503. *
  9504. * @example
  9505. * // Animate position
  9506. * el._animateToShallow({
  9507. * position: [10, 10]
  9508. * })
  9509. *
  9510. * // Animate shape, style and position in 100ms, delayed 100ms
  9511. * el._animateToShallow({
  9512. * shape: {
  9513. * width: 500
  9514. * },
  9515. * style: {
  9516. * fill: 'red'
  9517. * }
  9518. * position: [10, 10]
  9519. * }, 100, 100)
  9520. */
  9521. _animateToShallow: function (path, source, target, time, delay) {
  9522. var objShallow = {};
  9523. var propertyCount = 0;
  9524. for (var name in target) {
  9525. if (!target.hasOwnProperty(name)) {
  9526. continue;
  9527. }
  9528. if (source[name] != null) {
  9529. if (isObject(target[name]) && !util.isArrayLike(target[name])) {
  9530. this._animateToShallow(
  9531. path ? path + '.' + name : name,
  9532. source[name],
  9533. target[name],
  9534. time,
  9535. delay
  9536. );
  9537. }
  9538. else {
  9539. objShallow[name] = target[name];
  9540. propertyCount++;
  9541. }
  9542. }
  9543. else if (target[name] != null) {
  9544. // Attr directly if not has property
  9545. // FIXME, if some property not needed for element ?
  9546. if (!path) {
  9547. this.attr(name, target[name]);
  9548. }
  9549. else { // Shape or style
  9550. var props = {};
  9551. props[path] = {};
  9552. props[path][name] = target[name];
  9553. this.attr(props);
  9554. }
  9555. }
  9556. }
  9557. if (propertyCount > 0) {
  9558. this.animate(path, false)
  9559. .when(time == null ? 500 : time, objShallow)
  9560. .delay(delay || 0);
  9561. }
  9562. return this;
  9563. }
  9564. };
  9565. module.exports = Animatable;
  9566. /***/ }),
  9567. /* 30 */
  9568. /***/ (function(module, exports, __webpack_require__) {
  9569. /**
  9570. * @module echarts/animation/Animator
  9571. */
  9572. var Clip = __webpack_require__(31);
  9573. var color = __webpack_require__(33);
  9574. var util = __webpack_require__(4);
  9575. var isArrayLike = util.isArrayLike;
  9576. var arraySlice = Array.prototype.slice;
  9577. function defaultGetter(target, key) {
  9578. return target[key];
  9579. }
  9580. function defaultSetter(target, key, value) {
  9581. target[key] = value;
  9582. }
  9583. /**
  9584. * @param {number} p0
  9585. * @param {number} p1
  9586. * @param {number} percent
  9587. * @return {number}
  9588. */
  9589. function interpolateNumber(p0, p1, percent) {
  9590. return (p1 - p0) * percent + p0;
  9591. }
  9592. /**
  9593. * @param {string} p0
  9594. * @param {string} p1
  9595. * @param {number} percent
  9596. * @return {string}
  9597. */
  9598. function interpolateString(p0, p1, percent) {
  9599. return percent > 0.5 ? p1 : p0;
  9600. }
  9601. /**
  9602. * @param {Array} p0
  9603. * @param {Array} p1
  9604. * @param {number} percent
  9605. * @param {Array} out
  9606. * @param {number} arrDim
  9607. */
  9608. function interpolateArray(p0, p1, percent, out, arrDim) {
  9609. var len = p0.length;
  9610. if (arrDim == 1) {
  9611. for (var i = 0; i < len; i++) {
  9612. out[i] = interpolateNumber(p0[i], p1[i], percent);
  9613. }
  9614. }
  9615. else {
  9616. var len2 = len && p0[0].length;
  9617. for (var i = 0; i < len; i++) {
  9618. for (var j = 0; j < len2; j++) {
  9619. out[i][j] = interpolateNumber(
  9620. p0[i][j], p1[i][j], percent
  9621. );
  9622. }
  9623. }
  9624. }
  9625. }
  9626. // arr0 is source array, arr1 is target array.
  9627. // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
  9628. function fillArr(arr0, arr1, arrDim) {
  9629. var arr0Len = arr0.length;
  9630. var arr1Len = arr1.length;
  9631. if (arr0Len !== arr1Len) {
  9632. // FIXME Not work for TypedArray
  9633. var isPreviousLarger = arr0Len > arr1Len;
  9634. if (isPreviousLarger) {
  9635. // Cut the previous
  9636. arr0.length = arr1Len;
  9637. }
  9638. else {
  9639. // Fill the previous
  9640. for (var i = arr0Len; i < arr1Len; i++) {
  9641. arr0.push(
  9642. arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i])
  9643. );
  9644. }
  9645. }
  9646. }
  9647. // Handling NaN value
  9648. var len2 = arr0[0] && arr0[0].length;
  9649. for (var i = 0; i < arr0.length; i++) {
  9650. if (arrDim === 1) {
  9651. if (isNaN(arr0[i])) {
  9652. arr0[i] = arr1[i];
  9653. }
  9654. }
  9655. else {
  9656. for (var j = 0; j < len2; j++) {
  9657. if (isNaN(arr0[i][j])) {
  9658. arr0[i][j] = arr1[i][j];
  9659. }
  9660. }
  9661. }
  9662. }
  9663. }
  9664. /**
  9665. * @param {Array} arr0
  9666. * @param {Array} arr1
  9667. * @param {number} arrDim
  9668. * @return {boolean}
  9669. */
  9670. function isArraySame(arr0, arr1, arrDim) {
  9671. if (arr0 === arr1) {
  9672. return true;
  9673. }
  9674. var len = arr0.length;
  9675. if (len !== arr1.length) {
  9676. return false;
  9677. }
  9678. if (arrDim === 1) {
  9679. for (var i = 0; i < len; i++) {
  9680. if (arr0[i] !== arr1[i]) {
  9681. return false;
  9682. }
  9683. }
  9684. }
  9685. else {
  9686. var len2 = arr0[0].length;
  9687. for (var i = 0; i < len; i++) {
  9688. for (var j = 0; j < len2; j++) {
  9689. if (arr0[i][j] !== arr1[i][j]) {
  9690. return false;
  9691. }
  9692. }
  9693. }
  9694. }
  9695. return true;
  9696. }
  9697. /**
  9698. * Catmull Rom interpolate array
  9699. * @param {Array} p0
  9700. * @param {Array} p1
  9701. * @param {Array} p2
  9702. * @param {Array} p3
  9703. * @param {number} t
  9704. * @param {number} t2
  9705. * @param {number} t3
  9706. * @param {Array} out
  9707. * @param {number} arrDim
  9708. */
  9709. function catmullRomInterpolateArray(
  9710. p0, p1, p2, p3, t, t2, t3, out, arrDim
  9711. ) {
  9712. var len = p0.length;
  9713. if (arrDim == 1) {
  9714. for (var i = 0; i < len; i++) {
  9715. out[i] = catmullRomInterpolate(
  9716. p0[i], p1[i], p2[i], p3[i], t, t2, t3
  9717. );
  9718. }
  9719. }
  9720. else {
  9721. var len2 = p0[0].length;
  9722. for (var i = 0; i < len; i++) {
  9723. for (var j = 0; j < len2; j++) {
  9724. out[i][j] = catmullRomInterpolate(
  9725. p0[i][j], p1[i][j], p2[i][j], p3[i][j],
  9726. t, t2, t3
  9727. );
  9728. }
  9729. }
  9730. }
  9731. }
  9732. /**
  9733. * Catmull Rom interpolate number
  9734. * @param {number} p0
  9735. * @param {number} p1
  9736. * @param {number} p2
  9737. * @param {number} p3
  9738. * @param {number} t
  9739. * @param {number} t2
  9740. * @param {number} t3
  9741. * @return {number}
  9742. */
  9743. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  9744. var v0 = (p2 - p0) * 0.5;
  9745. var v1 = (p3 - p1) * 0.5;
  9746. return (2 * (p1 - p2) + v0 + v1) * t3
  9747. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  9748. + v0 * t + p1;
  9749. }
  9750. function cloneValue(value) {
  9751. if (isArrayLike(value)) {
  9752. var len = value.length;
  9753. if (isArrayLike(value[0])) {
  9754. var ret = [];
  9755. for (var i = 0; i < len; i++) {
  9756. ret.push(arraySlice.call(value[i]));
  9757. }
  9758. return ret;
  9759. }
  9760. return arraySlice.call(value);
  9761. }
  9762. return value;
  9763. }
  9764. function rgba2String(rgba) {
  9765. rgba[0] = Math.floor(rgba[0]);
  9766. rgba[1] = Math.floor(rgba[1]);
  9767. rgba[2] = Math.floor(rgba[2]);
  9768. return 'rgba(' + rgba.join(',') + ')';
  9769. }
  9770. function getArrayDim(keyframes) {
  9771. var lastValue = keyframes[keyframes.length - 1].value;
  9772. return isArrayLike(lastValue && lastValue[0]) ? 2 : 1;
  9773. }
  9774. function createTrackClip(animator, easing, oneTrackDone, keyframes, propName, forceAnimate) {
  9775. var getter = animator._getter;
  9776. var setter = animator._setter;
  9777. var useSpline = easing === 'spline';
  9778. var trackLen = keyframes.length;
  9779. if (!trackLen) {
  9780. return;
  9781. }
  9782. // Guess data type
  9783. var firstVal = keyframes[0].value;
  9784. var isValueArray = isArrayLike(firstVal);
  9785. var isValueColor = false;
  9786. var isValueString = false;
  9787. // For vertices morphing
  9788. var arrDim = isValueArray ? getArrayDim(keyframes) : 0;
  9789. var trackMaxTime;
  9790. // Sort keyframe as ascending
  9791. keyframes.sort(function(a, b) {
  9792. return a.time - b.time;
  9793. });
  9794. trackMaxTime = keyframes[trackLen - 1].time;
  9795. // Percents of each keyframe
  9796. var kfPercents = [];
  9797. // Value of each keyframe
  9798. var kfValues = [];
  9799. var prevValue = keyframes[0].value;
  9800. var isAllValueEqual = true;
  9801. for (var i = 0; i < trackLen; i++) {
  9802. kfPercents.push(keyframes[i].time / trackMaxTime);
  9803. // Assume value is a color when it is a string
  9804. var value = keyframes[i].value;
  9805. // Check if value is equal, deep check if value is array
  9806. if (!((isValueArray && isArraySame(value, prevValue, arrDim))
  9807. || (!isValueArray && value === prevValue))) {
  9808. isAllValueEqual = false;
  9809. }
  9810. prevValue = value;
  9811. // Try converting a string to a color array
  9812. if (typeof value == 'string') {
  9813. var colorArray = color.parse(value);
  9814. if (colorArray) {
  9815. value = colorArray;
  9816. isValueColor = true;
  9817. }
  9818. else {
  9819. isValueString = true;
  9820. }
  9821. }
  9822. kfValues.push(value);
  9823. }
  9824. if (!forceAnimate && isAllValueEqual) {
  9825. return;
  9826. }
  9827. var lastValue = kfValues[trackLen - 1];
  9828. // Polyfill array and NaN value
  9829. for (var i = 0; i < trackLen - 1; i++) {
  9830. if (isValueArray) {
  9831. fillArr(kfValues[i], lastValue, arrDim);
  9832. }
  9833. else {
  9834. if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
  9835. kfValues[i] = lastValue;
  9836. }
  9837. }
  9838. }
  9839. isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim);
  9840. // Cache the key of last frame to speed up when
  9841. // animation playback is sequency
  9842. var lastFrame = 0;
  9843. var lastFramePercent = 0;
  9844. var start;
  9845. var w;
  9846. var p0;
  9847. var p1;
  9848. var p2;
  9849. var p3;
  9850. if (isValueColor) {
  9851. var rgba = [0, 0, 0, 0];
  9852. }
  9853. var onframe = function (target, percent) {
  9854. // Find the range keyframes
  9855. // kf1-----kf2---------current--------kf3
  9856. // find kf2 and kf3 and do interpolation
  9857. var frame;
  9858. // In the easing function like elasticOut, percent may less than 0
  9859. if (percent < 0) {
  9860. frame = 0;
  9861. }
  9862. else if (percent < lastFramePercent) {
  9863. // Start from next key
  9864. // PENDING start from lastFrame ?
  9865. start = Math.min(lastFrame + 1, trackLen - 1);
  9866. for (frame = start; frame >= 0; frame--) {
  9867. if (kfPercents[frame] <= percent) {
  9868. break;
  9869. }
  9870. }
  9871. // PENDING really need to do this ?
  9872. frame = Math.min(frame, trackLen - 2);
  9873. }
  9874. else {
  9875. for (frame = lastFrame; frame < trackLen; frame++) {
  9876. if (kfPercents[frame] > percent) {
  9877. break;
  9878. }
  9879. }
  9880. frame = Math.min(frame - 1, trackLen - 2);
  9881. }
  9882. lastFrame = frame;
  9883. lastFramePercent = percent;
  9884. var range = (kfPercents[frame + 1] - kfPercents[frame]);
  9885. if (range === 0) {
  9886. return;
  9887. }
  9888. else {
  9889. w = (percent - kfPercents[frame]) / range;
  9890. }
  9891. if (useSpline) {
  9892. p1 = kfValues[frame];
  9893. p0 = kfValues[frame === 0 ? frame : frame - 1];
  9894. p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
  9895. p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
  9896. if (isValueArray) {
  9897. catmullRomInterpolateArray(
  9898. p0, p1, p2, p3, w, w * w, w * w * w,
  9899. getter(target, propName),
  9900. arrDim
  9901. );
  9902. }
  9903. else {
  9904. var value;
  9905. if (isValueColor) {
  9906. value = catmullRomInterpolateArray(
  9907. p0, p1, p2, p3, w, w * w, w * w * w,
  9908. rgba, 1
  9909. );
  9910. value = rgba2String(rgba);
  9911. }
  9912. else if (isValueString) {
  9913. // String is step(0.5)
  9914. return interpolateString(p1, p2, w);
  9915. }
  9916. else {
  9917. value = catmullRomInterpolate(
  9918. p0, p1, p2, p3, w, w * w, w * w * w
  9919. );
  9920. }
  9921. setter(
  9922. target,
  9923. propName,
  9924. value
  9925. );
  9926. }
  9927. }
  9928. else {
  9929. if (isValueArray) {
  9930. interpolateArray(
  9931. kfValues[frame], kfValues[frame + 1], w,
  9932. getter(target, propName),
  9933. arrDim
  9934. );
  9935. }
  9936. else {
  9937. var value;
  9938. if (isValueColor) {
  9939. interpolateArray(
  9940. kfValues[frame], kfValues[frame + 1], w,
  9941. rgba, 1
  9942. );
  9943. value = rgba2String(rgba);
  9944. }
  9945. else if (isValueString) {
  9946. // String is step(0.5)
  9947. return interpolateString(kfValues[frame], kfValues[frame + 1], w);
  9948. }
  9949. else {
  9950. value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
  9951. }
  9952. setter(
  9953. target,
  9954. propName,
  9955. value
  9956. );
  9957. }
  9958. }
  9959. };
  9960. var clip = new Clip({
  9961. target: animator._target,
  9962. life: trackMaxTime,
  9963. loop: animator._loop,
  9964. delay: animator._delay,
  9965. onframe: onframe,
  9966. ondestroy: oneTrackDone
  9967. });
  9968. if (easing && easing !== 'spline') {
  9969. clip.easing = easing;
  9970. }
  9971. return clip;
  9972. }
  9973. /**
  9974. * @alias module:zrender/animation/Animator
  9975. * @constructor
  9976. * @param {Object} target
  9977. * @param {boolean} loop
  9978. * @param {Function} getter
  9979. * @param {Function} setter
  9980. */
  9981. var Animator = function(target, loop, getter, setter) {
  9982. this._tracks = {};
  9983. this._target = target;
  9984. this._loop = loop || false;
  9985. this._getter = getter || defaultGetter;
  9986. this._setter = setter || defaultSetter;
  9987. this._clipCount = 0;
  9988. this._delay = 0;
  9989. this._doneList = [];
  9990. this._onframeList = [];
  9991. this._clipList = [];
  9992. };
  9993. Animator.prototype = {
  9994. /**
  9995. * 设置动画关键帧
  9996. * @param {number} time 关键帧时间,单位是ms
  9997. * @param {Object} props 关键帧的属性值,key-value表示
  9998. * @return {module:zrender/animation/Animator}
  9999. */
  10000. when: function(time /* ms */, props) {
  10001. var tracks = this._tracks;
  10002. for (var propName in props) {
  10003. if (!props.hasOwnProperty(propName)) {
  10004. continue;
  10005. }
  10006. if (!tracks[propName]) {
  10007. tracks[propName] = [];
  10008. // Invalid value
  10009. var value = this._getter(this._target, propName);
  10010. if (value == null) {
  10011. // zrLog('Invalid property ' + propName);
  10012. continue;
  10013. }
  10014. // If time is 0
  10015. // Then props is given initialize value
  10016. // Else
  10017. // Initialize value from current prop value
  10018. if (time !== 0) {
  10019. tracks[propName].push({
  10020. time: 0,
  10021. value: cloneValue(value)
  10022. });
  10023. }
  10024. }
  10025. tracks[propName].push({
  10026. time: time,
  10027. value: props[propName]
  10028. });
  10029. }
  10030. return this;
  10031. },
  10032. /**
  10033. * 添加动画每一帧的回调函数
  10034. * @param {Function} callback
  10035. * @return {module:zrender/animation/Animator}
  10036. */
  10037. during: function (callback) {
  10038. this._onframeList.push(callback);
  10039. return this;
  10040. },
  10041. pause: function () {
  10042. for (var i = 0; i < this._clipList.length; i++) {
  10043. this._clipList[i].pause();
  10044. }
  10045. this._paused = true;
  10046. },
  10047. resume: function () {
  10048. for (var i = 0; i < this._clipList.length; i++) {
  10049. this._clipList[i].resume();
  10050. }
  10051. this._paused = false;
  10052. },
  10053. isPaused: function () {
  10054. return !!this._paused;
  10055. },
  10056. _doneCallback: function () {
  10057. // Clear all tracks
  10058. this._tracks = {};
  10059. // Clear all clips
  10060. this._clipList.length = 0;
  10061. var doneList = this._doneList;
  10062. var len = doneList.length;
  10063. for (var i = 0; i < len; i++) {
  10064. doneList[i].call(this);
  10065. }
  10066. },
  10067. /**
  10068. * 开始执行动画
  10069. * @param {string|Function} [easing]
  10070. * 动画缓动函数,详见{@link module:zrender/animation/easing}
  10071. * @param {boolean} forceAnimate
  10072. * @return {module:zrender/animation/Animator}
  10073. */
  10074. start: function (easing, forceAnimate) {
  10075. var self = this;
  10076. var clipCount = 0;
  10077. var oneTrackDone = function() {
  10078. clipCount--;
  10079. if (!clipCount) {
  10080. self._doneCallback();
  10081. }
  10082. };
  10083. var lastClip;
  10084. for (var propName in this._tracks) {
  10085. if (!this._tracks.hasOwnProperty(propName)) {
  10086. continue;
  10087. }
  10088. var clip = createTrackClip(
  10089. this, easing, oneTrackDone,
  10090. this._tracks[propName], propName, forceAnimate
  10091. );
  10092. if (clip) {
  10093. this._clipList.push(clip);
  10094. clipCount++;
  10095. // If start after added to animation
  10096. if (this.animation) {
  10097. this.animation.addClip(clip);
  10098. }
  10099. lastClip = clip;
  10100. }
  10101. }
  10102. // Add during callback on the last clip
  10103. if (lastClip) {
  10104. var oldOnFrame = lastClip.onframe;
  10105. lastClip.onframe = function (target, percent) {
  10106. oldOnFrame(target, percent);
  10107. for (var i = 0; i < self._onframeList.length; i++) {
  10108. self._onframeList[i](target, percent);
  10109. }
  10110. };
  10111. }
  10112. // This optimization will help the case that in the upper application
  10113. // the view may be refreshed frequently, where animation will be
  10114. // called repeatly but nothing changed.
  10115. if (!clipCount) {
  10116. this._doneCallback();
  10117. }
  10118. return this;
  10119. },
  10120. /**
  10121. * 停止动画
  10122. * @param {boolean} forwardToLast If move to last frame before stop
  10123. */
  10124. stop: function (forwardToLast) {
  10125. var clipList = this._clipList;
  10126. var animation = this.animation;
  10127. for (var i = 0; i < clipList.length; i++) {
  10128. var clip = clipList[i];
  10129. if (forwardToLast) {
  10130. // Move to last frame before stop
  10131. clip.onframe(this._target, 1);
  10132. }
  10133. animation && animation.removeClip(clip);
  10134. }
  10135. clipList.length = 0;
  10136. },
  10137. /**
  10138. * 设置动画延迟开始的时间
  10139. * @param {number} time 单位ms
  10140. * @return {module:zrender/animation/Animator}
  10141. */
  10142. delay: function (time) {
  10143. this._delay = time;
  10144. return this;
  10145. },
  10146. /**
  10147. * 添加动画结束的回调
  10148. * @param {Function} cb
  10149. * @return {module:zrender/animation/Animator}
  10150. */
  10151. done: function(cb) {
  10152. if (cb) {
  10153. this._doneList.push(cb);
  10154. }
  10155. return this;
  10156. },
  10157. /**
  10158. * @return {Array.<module:zrender/animation/Clip>}
  10159. */
  10160. getClips: function () {
  10161. return this._clipList;
  10162. }
  10163. };
  10164. module.exports = Animator;
  10165. /***/ }),
  10166. /* 31 */
  10167. /***/ (function(module, exports, __webpack_require__) {
  10168. /**
  10169. * 动画主控制器
  10170. * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件
  10171. * @config life(1000) 动画时长
  10172. * @config delay(0) 动画延迟时间
  10173. * @config loop(true)
  10174. * @config gap(0) 循环的间隔时间
  10175. * @config onframe
  10176. * @config easing(optional)
  10177. * @config ondestroy(optional)
  10178. * @config onrestart(optional)
  10179. *
  10180. * TODO pause
  10181. */
  10182. var easingFuncs = __webpack_require__(32);
  10183. function Clip(options) {
  10184. this._target = options.target;
  10185. // 生命周期
  10186. this._life = options.life || 1000;
  10187. // 延时
  10188. this._delay = options.delay || 0;
  10189. // 开始时间
  10190. // this._startTime = new Date().getTime() + this._delay;// 单位毫秒
  10191. this._initialized = false;
  10192. // 是否循环
  10193. this.loop = options.loop == null ? false : options.loop;
  10194. this.gap = options.gap || 0;
  10195. this.easing = options.easing || 'Linear';
  10196. this.onframe = options.onframe;
  10197. this.ondestroy = options.ondestroy;
  10198. this.onrestart = options.onrestart;
  10199. this._pausedTime = 0;
  10200. this._paused = false;
  10201. }
  10202. Clip.prototype = {
  10203. constructor: Clip,
  10204. step: function (globalTime, deltaTime) {
  10205. // Set startTime on first step, or _startTime may has milleseconds different between clips
  10206. // PENDING
  10207. if (!this._initialized) {
  10208. this._startTime = globalTime + this._delay;
  10209. this._initialized = true;
  10210. }
  10211. if (this._paused) {
  10212. this._pausedTime += deltaTime;
  10213. return;
  10214. }
  10215. var percent = (globalTime - this._startTime - this._pausedTime) / this._life;
  10216. // 还没开始
  10217. if (percent < 0) {
  10218. return;
  10219. }
  10220. percent = Math.min(percent, 1);
  10221. var easing = this.easing;
  10222. var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing;
  10223. var schedule = typeof easingFunc === 'function'
  10224. ? easingFunc(percent)
  10225. : percent;
  10226. this.fire('frame', schedule);
  10227. // 结束
  10228. if (percent == 1) {
  10229. if (this.loop) {
  10230. this.restart (globalTime);
  10231. // 重新开始周期
  10232. // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件
  10233. return 'restart';
  10234. }
  10235. // 动画完成将这个控制器标识为待删除
  10236. // 在Animation.update中进行批量删除
  10237. this._needsRemove = true;
  10238. return 'destroy';
  10239. }
  10240. return null;
  10241. },
  10242. restart: function (globalTime) {
  10243. var remainder = (globalTime - this._startTime - this._pausedTime) % this._life;
  10244. this._startTime = globalTime - remainder + this.gap;
  10245. this._pausedTime = 0;
  10246. this._needsRemove = false;
  10247. },
  10248. fire: function (eventType, arg) {
  10249. eventType = 'on' + eventType;
  10250. if (this[eventType]) {
  10251. this[eventType](this._target, arg);
  10252. }
  10253. },
  10254. pause: function () {
  10255. this._paused = true;
  10256. },
  10257. resume: function () {
  10258. this._paused = false;
  10259. }
  10260. };
  10261. module.exports = Clip;
  10262. /***/ }),
  10263. /* 32 */
  10264. /***/ (function(module, exports) {
  10265. /**
  10266. * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js
  10267. * @see http://sole.github.io/tween.js/examples/03_graphs.html
  10268. * @exports zrender/animation/easing
  10269. */
  10270. var easing = {
  10271. /**
  10272. * @param {number} k
  10273. * @return {number}
  10274. */
  10275. linear: function (k) {
  10276. return k;
  10277. },
  10278. /**
  10279. * @param {number} k
  10280. * @return {number}
  10281. */
  10282. quadraticIn: function (k) {
  10283. return k * k;
  10284. },
  10285. /**
  10286. * @param {number} k
  10287. * @return {number}
  10288. */
  10289. quadraticOut: function (k) {
  10290. return k * (2 - k);
  10291. },
  10292. /**
  10293. * @param {number} k
  10294. * @return {number}
  10295. */
  10296. quadraticInOut: function (k) {
  10297. if ((k *= 2) < 1) {
  10298. return 0.5 * k * k;
  10299. }
  10300. return -0.5 * (--k * (k - 2) - 1);
  10301. },
  10302. // 三次方的缓动(t^3)
  10303. /**
  10304. * @param {number} k
  10305. * @return {number}
  10306. */
  10307. cubicIn: function (k) {
  10308. return k * k * k;
  10309. },
  10310. /**
  10311. * @param {number} k
  10312. * @return {number}
  10313. */
  10314. cubicOut: function (k) {
  10315. return --k * k * k + 1;
  10316. },
  10317. /**
  10318. * @param {number} k
  10319. * @return {number}
  10320. */
  10321. cubicInOut: function (k) {
  10322. if ((k *= 2) < 1) {
  10323. return 0.5 * k * k * k;
  10324. }
  10325. return 0.5 * ((k -= 2) * k * k + 2);
  10326. },
  10327. // 四次方的缓动(t^4)
  10328. /**
  10329. * @param {number} k
  10330. * @return {number}
  10331. */
  10332. quarticIn: function (k) {
  10333. return k * k * k * k;
  10334. },
  10335. /**
  10336. * @param {number} k
  10337. * @return {number}
  10338. */
  10339. quarticOut: function (k) {
  10340. return 1 - (--k * k * k * k);
  10341. },
  10342. /**
  10343. * @param {number} k
  10344. * @return {number}
  10345. */
  10346. quarticInOut: function (k) {
  10347. if ((k *= 2) < 1) {
  10348. return 0.5 * k * k * k * k;
  10349. }
  10350. return -0.5 * ((k -= 2) * k * k * k - 2);
  10351. },
  10352. // 五次方的缓动(t^5)
  10353. /**
  10354. * @param {number} k
  10355. * @return {number}
  10356. */
  10357. quinticIn: function (k) {
  10358. return k * k * k * k * k;
  10359. },
  10360. /**
  10361. * @param {number} k
  10362. * @return {number}
  10363. */
  10364. quinticOut: function (k) {
  10365. return --k * k * k * k * k + 1;
  10366. },
  10367. /**
  10368. * @param {number} k
  10369. * @return {number}
  10370. */
  10371. quinticInOut: function (k) {
  10372. if ((k *= 2) < 1) {
  10373. return 0.5 * k * k * k * k * k;
  10374. }
  10375. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  10376. },
  10377. // 正弦曲线的缓动(sin(t))
  10378. /**
  10379. * @param {number} k
  10380. * @return {number}
  10381. */
  10382. sinusoidalIn: function (k) {
  10383. return 1 - Math.cos(k * Math.PI / 2);
  10384. },
  10385. /**
  10386. * @param {number} k
  10387. * @return {number}
  10388. */
  10389. sinusoidalOut: function (k) {
  10390. return Math.sin(k * Math.PI / 2);
  10391. },
  10392. /**
  10393. * @param {number} k
  10394. * @return {number}
  10395. */
  10396. sinusoidalInOut: function (k) {
  10397. return 0.5 * (1 - Math.cos(Math.PI * k));
  10398. },
  10399. // 指数曲线的缓动(2^t)
  10400. /**
  10401. * @param {number} k
  10402. * @return {number}
  10403. */
  10404. exponentialIn: function (k) {
  10405. return k === 0 ? 0 : Math.pow(1024, k - 1);
  10406. },
  10407. /**
  10408. * @param {number} k
  10409. * @return {number}
  10410. */
  10411. exponentialOut: function (k) {
  10412. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  10413. },
  10414. /**
  10415. * @param {number} k
  10416. * @return {number}
  10417. */
  10418. exponentialInOut: function (k) {
  10419. if (k === 0) {
  10420. return 0;
  10421. }
  10422. if (k === 1) {
  10423. return 1;
  10424. }
  10425. if ((k *= 2) < 1) {
  10426. return 0.5 * Math.pow(1024, k - 1);
  10427. }
  10428. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  10429. },
  10430. // 圆形曲线的缓动(sqrt(1-t^2))
  10431. /**
  10432. * @param {number} k
  10433. * @return {number}
  10434. */
  10435. circularIn: function (k) {
  10436. return 1 - Math.sqrt(1 - k * k);
  10437. },
  10438. /**
  10439. * @param {number} k
  10440. * @return {number}
  10441. */
  10442. circularOut: function (k) {
  10443. return Math.sqrt(1 - (--k * k));
  10444. },
  10445. /**
  10446. * @param {number} k
  10447. * @return {number}
  10448. */
  10449. circularInOut: function (k) {
  10450. if ((k *= 2) < 1) {
  10451. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  10452. }
  10453. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  10454. },
  10455. // 创建类似于弹簧在停止前来回振荡的动画
  10456. /**
  10457. * @param {number} k
  10458. * @return {number}
  10459. */
  10460. elasticIn: function (k) {
  10461. var s;
  10462. var a = 0.1;
  10463. var p = 0.4;
  10464. if (k === 0) {
  10465. return 0;
  10466. }
  10467. if (k === 1) {
  10468. return 1;
  10469. }
  10470. if (!a || a < 1) {
  10471. a = 1; s = p / 4;
  10472. }
  10473. else {
  10474. s = p * Math.asin(1 / a) / (2 * Math.PI);
  10475. }
  10476. return -(a * Math.pow(2, 10 * (k -= 1)) *
  10477. Math.sin((k - s) * (2 * Math.PI) / p));
  10478. },
  10479. /**
  10480. * @param {number} k
  10481. * @return {number}
  10482. */
  10483. elasticOut: function (k) {
  10484. var s;
  10485. var a = 0.1;
  10486. var p = 0.4;
  10487. if (k === 0) {
  10488. return 0;
  10489. }
  10490. if (k === 1) {
  10491. return 1;
  10492. }
  10493. if (!a || a < 1) {
  10494. a = 1; s = p / 4;
  10495. }
  10496. else {
  10497. s = p * Math.asin(1 / a) / (2 * Math.PI);
  10498. }
  10499. return (a * Math.pow(2, -10 * k) *
  10500. Math.sin((k - s) * (2 * Math.PI) / p) + 1);
  10501. },
  10502. /**
  10503. * @param {number} k
  10504. * @return {number}
  10505. */
  10506. elasticInOut: function (k) {
  10507. var s;
  10508. var a = 0.1;
  10509. var p = 0.4;
  10510. if (k === 0) {
  10511. return 0;
  10512. }
  10513. if (k === 1) {
  10514. return 1;
  10515. }
  10516. if (!a || a < 1) {
  10517. a = 1; s = p / 4;
  10518. }
  10519. else {
  10520. s = p * Math.asin(1 / a) / (2 * Math.PI);
  10521. }
  10522. if ((k *= 2) < 1) {
  10523. return -0.5 * (a * Math.pow(2, 10 * (k -= 1))
  10524. * Math.sin((k - s) * (2 * Math.PI) / p));
  10525. }
  10526. return a * Math.pow(2, -10 * (k -= 1))
  10527. * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  10528. },
  10529. // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动
  10530. /**
  10531. * @param {number} k
  10532. * @return {number}
  10533. */
  10534. backIn: function (k) {
  10535. var s = 1.70158;
  10536. return k * k * ((s + 1) * k - s);
  10537. },
  10538. /**
  10539. * @param {number} k
  10540. * @return {number}
  10541. */
  10542. backOut: function (k) {
  10543. var s = 1.70158;
  10544. return --k * k * ((s + 1) * k + s) + 1;
  10545. },
  10546. /**
  10547. * @param {number} k
  10548. * @return {number}
  10549. */
  10550. backInOut: function (k) {
  10551. var s = 1.70158 * 1.525;
  10552. if ((k *= 2) < 1) {
  10553. return 0.5 * (k * k * ((s + 1) * k - s));
  10554. }
  10555. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  10556. },
  10557. // 创建弹跳效果
  10558. /**
  10559. * @param {number} k
  10560. * @return {number}
  10561. */
  10562. bounceIn: function (k) {
  10563. return 1 - easing.bounceOut(1 - k);
  10564. },
  10565. /**
  10566. * @param {number} k
  10567. * @return {number}
  10568. */
  10569. bounceOut: function (k) {
  10570. if (k < (1 / 2.75)) {
  10571. return 7.5625 * k * k;
  10572. }
  10573. else if (k < (2 / 2.75)) {
  10574. return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
  10575. }
  10576. else if (k < (2.5 / 2.75)) {
  10577. return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
  10578. }
  10579. else {
  10580. return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
  10581. }
  10582. },
  10583. /**
  10584. * @param {number} k
  10585. * @return {number}
  10586. */
  10587. bounceInOut: function (k) {
  10588. if (k < 0.5) {
  10589. return easing.bounceIn(k * 2) * 0.5;
  10590. }
  10591. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  10592. }
  10593. };
  10594. module.exports = easing;
  10595. /***/ }),
  10596. /* 33 */
  10597. /***/ (function(module, exports, __webpack_require__) {
  10598. /**
  10599. * @module zrender/tool/color
  10600. */
  10601. var LRU = __webpack_require__(13);
  10602. var kCSSColorTable = {
  10603. 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1],
  10604. 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1],
  10605. 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1],
  10606. 'beige': [245,245,220,1], 'bisque': [255,228,196,1],
  10607. 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1],
  10608. 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1],
  10609. 'brown': [165,42,42,1], 'burlywood': [222,184,135,1],
  10610. 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1],
  10611. 'chocolate': [210,105,30,1], 'coral': [255,127,80,1],
  10612. 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1],
  10613. 'crimson': [220,20,60,1], 'cyan': [0,255,255,1],
  10614. 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1],
  10615. 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1],
  10616. 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1],
  10617. 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1],
  10618. 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1],
  10619. 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1],
  10620. 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1],
  10621. 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1],
  10622. 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1],
  10623. 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1],
  10624. 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1],
  10625. 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1],
  10626. 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1],
  10627. 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1],
  10628. 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1],
  10629. 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1],
  10630. 'gray': [128,128,128,1], 'green': [0,128,0,1],
  10631. 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1],
  10632. 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1],
  10633. 'indianred': [205,92,92,1], 'indigo': [75,0,130,1],
  10634. 'ivory': [255,255,240,1], 'khaki': [240,230,140,1],
  10635. 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1],
  10636. 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1],
  10637. 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1],
  10638. 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1],
  10639. 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1],
  10640. 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1],
  10641. 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1],
  10642. 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1],
  10643. 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1],
  10644. 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1],
  10645. 'limegreen': [50,205,50,1], 'linen': [250,240,230,1],
  10646. 'magenta': [255,0,255,1], 'maroon': [128,0,0,1],
  10647. 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1],
  10648. 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1],
  10649. 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1],
  10650. 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1],
  10651. 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1],
  10652. 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1],
  10653. 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1],
  10654. 'navy': [0,0,128,1], 'oldlace': [253,245,230,1],
  10655. 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1],
  10656. 'orange': [255,165,0,1], 'orangered': [255,69,0,1],
  10657. 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1],
  10658. 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1],
  10659. 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1],
  10660. 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1],
  10661. 'pink': [255,192,203,1], 'plum': [221,160,221,1],
  10662. 'powderblue': [176,224,230,1], 'purple': [128,0,128,1],
  10663. 'red': [255,0,0,1], 'rosybrown': [188,143,143,1],
  10664. 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1],
  10665. 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1],
  10666. 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1],
  10667. 'sienna': [160,82,45,1], 'silver': [192,192,192,1],
  10668. 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1],
  10669. 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1],
  10670. 'snow': [255,250,250,1], 'springgreen': [0,255,127,1],
  10671. 'steelblue': [70,130,180,1], 'tan': [210,180,140,1],
  10672. 'teal': [0,128,128,1], 'thistle': [216,191,216,1],
  10673. 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1],
  10674. 'violet': [238,130,238,1], 'wheat': [245,222,179,1],
  10675. 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1],
  10676. 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1]
  10677. };
  10678. function clampCssByte(i) { // Clamp to integer 0 .. 255.
  10679. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  10680. return i < 0 ? 0 : i > 255 ? 255 : i;
  10681. }
  10682. function clampCssAngle(i) { // Clamp to integer 0 .. 360.
  10683. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  10684. return i < 0 ? 0 : i > 360 ? 360 : i;
  10685. }
  10686. function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0.
  10687. return f < 0 ? 0 : f > 1 ? 1 : f;
  10688. }
  10689. function parseCssInt(str) { // int or percentage.
  10690. if (str.length && str.charAt(str.length - 1) === '%') {
  10691. return clampCssByte(parseFloat(str) / 100 * 255);
  10692. }
  10693. return clampCssByte(parseInt(str, 10));
  10694. }
  10695. function parseCssFloat(str) { // float or percentage.
  10696. if (str.length && str.charAt(str.length - 1) === '%') {
  10697. return clampCssFloat(parseFloat(str) / 100);
  10698. }
  10699. return clampCssFloat(parseFloat(str));
  10700. }
  10701. function cssHueToRgb(m1, m2, h) {
  10702. if (h < 0) {
  10703. h += 1;
  10704. }
  10705. else if (h > 1) {
  10706. h -= 1;
  10707. }
  10708. if (h * 6 < 1) {
  10709. return m1 + (m2 - m1) * h * 6;
  10710. }
  10711. if (h * 2 < 1) {
  10712. return m2;
  10713. }
  10714. if (h * 3 < 2) {
  10715. return m1 + (m2 - m1) * (2/3 - h) * 6;
  10716. }
  10717. return m1;
  10718. }
  10719. function lerpNumber(a, b, p) {
  10720. return a + (b - a) * p;
  10721. }
  10722. function setRgba(out, r, g, b, a) {
  10723. out[0] = r; out[1] = g; out[2] = b; out[3] = a;
  10724. return out;
  10725. }
  10726. function copyRgba(out, a) {
  10727. out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3];
  10728. return out;
  10729. }
  10730. var colorCache = new LRU(20);
  10731. var lastRemovedArr = null;
  10732. function putToCache(colorStr, rgbaArr) {
  10733. // Reuse removed array
  10734. if (lastRemovedArr) {
  10735. copyRgba(lastRemovedArr, rgbaArr);
  10736. }
  10737. lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || (rgbaArr.slice()));
  10738. }
  10739. /**
  10740. * @param {string} colorStr
  10741. * @param {Array.<number>} out
  10742. * @return {Array.<number>}
  10743. * @memberOf module:zrender/util/color
  10744. */
  10745. function parse(colorStr, rgbaArr) {
  10746. if (!colorStr) {
  10747. return;
  10748. }
  10749. rgbaArr = rgbaArr || [];
  10750. var cached = colorCache.get(colorStr);
  10751. if (cached) {
  10752. return copyRgba(rgbaArr, cached);
  10753. }
  10754. // colorStr may be not string
  10755. colorStr = colorStr + '';
  10756. // Remove all whitespace, not compliant, but should just be more accepting.
  10757. var str = colorStr.replace(/ /g, '').toLowerCase();
  10758. // Color keywords (and transparent) lookup.
  10759. if (str in kCSSColorTable) {
  10760. copyRgba(rgbaArr, kCSSColorTable[str]);
  10761. putToCache(colorStr, rgbaArr);
  10762. return rgbaArr;
  10763. }
  10764. // #abc and #abc123 syntax.
  10765. if (str.charAt(0) === '#') {
  10766. if (str.length === 4) {
  10767. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  10768. if (!(iv >= 0 && iv <= 0xfff)) {
  10769. setRgba(rgbaArr, 0, 0, 0, 1);
  10770. return; // Covers NaN.
  10771. }
  10772. setRgba(rgbaArr,
  10773. ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
  10774. (iv & 0xf0) | ((iv & 0xf0) >> 4),
  10775. (iv & 0xf) | ((iv & 0xf) << 4),
  10776. 1
  10777. );
  10778. putToCache(colorStr, rgbaArr);
  10779. return rgbaArr;
  10780. }
  10781. else if (str.length === 7) {
  10782. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  10783. if (!(iv >= 0 && iv <= 0xffffff)) {
  10784. setRgba(rgbaArr, 0, 0, 0, 1);
  10785. return; // Covers NaN.
  10786. }
  10787. setRgba(rgbaArr,
  10788. (iv & 0xff0000) >> 16,
  10789. (iv & 0xff00) >> 8,
  10790. iv & 0xff,
  10791. 1
  10792. );
  10793. putToCache(colorStr, rgbaArr);
  10794. return rgbaArr;
  10795. }
  10796. return;
  10797. }
  10798. var op = str.indexOf('('), ep = str.indexOf(')');
  10799. if (op !== -1 && ep + 1 === str.length) {
  10800. var fname = str.substr(0, op);
  10801. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  10802. var alpha = 1; // To allow case fallthrough.
  10803. switch (fname) {
  10804. case 'rgba':
  10805. if (params.length !== 4) {
  10806. setRgba(rgbaArr, 0, 0, 0, 1);
  10807. return;
  10808. }
  10809. alpha = parseCssFloat(params.pop()); // jshint ignore:line
  10810. // Fall through.
  10811. case 'rgb':
  10812. if (params.length !== 3) {
  10813. setRgba(rgbaArr, 0, 0, 0, 1);
  10814. return;
  10815. }
  10816. setRgba(rgbaArr,
  10817. parseCssInt(params[0]),
  10818. parseCssInt(params[1]),
  10819. parseCssInt(params[2]),
  10820. alpha
  10821. );
  10822. putToCache(colorStr, rgbaArr);
  10823. return rgbaArr;
  10824. case 'hsla':
  10825. if (params.length !== 4) {
  10826. setRgba(rgbaArr, 0, 0, 0, 1);
  10827. return;
  10828. }
  10829. params[3] = parseCssFloat(params[3]);
  10830. hsla2rgba(params, rgbaArr);
  10831. putToCache(colorStr, rgbaArr);
  10832. return rgbaArr;
  10833. case 'hsl':
  10834. if (params.length !== 3) {
  10835. setRgba(rgbaArr, 0, 0, 0, 1);
  10836. return;
  10837. }
  10838. hsla2rgba(params, rgbaArr);
  10839. putToCache(colorStr, rgbaArr);
  10840. return rgbaArr;
  10841. default:
  10842. return;
  10843. }
  10844. }
  10845. setRgba(rgbaArr, 0, 0, 0, 1);
  10846. return;
  10847. }
  10848. /**
  10849. * @param {Array.<number>} hsla
  10850. * @param {Array.<number>} rgba
  10851. * @return {Array.<number>} rgba
  10852. */
  10853. function hsla2rgba(hsla, rgba) {
  10854. var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1
  10855. // NOTE(deanm): According to the CSS spec s/l should only be
  10856. // percentages, but we don't bother and let float or percentage.
  10857. var s = parseCssFloat(hsla[1]);
  10858. var l = parseCssFloat(hsla[2]);
  10859. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  10860. var m1 = l * 2 - m2;
  10861. rgba = rgba || [];
  10862. setRgba(rgba,
  10863. clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
  10864. clampCssByte(cssHueToRgb(m1, m2, h) * 255),
  10865. clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255),
  10866. 1
  10867. );
  10868. if (hsla.length === 4) {
  10869. rgba[3] = hsla[3];
  10870. }
  10871. return rgba;
  10872. }
  10873. /**
  10874. * @param {Array.<number>} rgba
  10875. * @return {Array.<number>} hsla
  10876. */
  10877. function rgba2hsla(rgba) {
  10878. if (!rgba) {
  10879. return;
  10880. }
  10881. // RGB from 0 to 255
  10882. var R = rgba[0] / 255;
  10883. var G = rgba[1] / 255;
  10884. var B = rgba[2] / 255;
  10885. var vMin = Math.min(R, G, B); // Min. value of RGB
  10886. var vMax = Math.max(R, G, B); // Max. value of RGB
  10887. var delta = vMax - vMin; // Delta RGB value
  10888. var L = (vMax + vMin) / 2;
  10889. var H;
  10890. var S;
  10891. // HSL results from 0 to 1
  10892. if (delta === 0) {
  10893. H = 0;
  10894. S = 0;
  10895. }
  10896. else {
  10897. if (L < 0.5) {
  10898. S = delta / (vMax + vMin);
  10899. }
  10900. else {
  10901. S = delta / (2 - vMax - vMin);
  10902. }
  10903. var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
  10904. var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
  10905. var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
  10906. if (R === vMax) {
  10907. H = deltaB - deltaG;
  10908. }
  10909. else if (G === vMax) {
  10910. H = (1 / 3) + deltaR - deltaB;
  10911. }
  10912. else if (B === vMax) {
  10913. H = (2 / 3) + deltaG - deltaR;
  10914. }
  10915. if (H < 0) {
  10916. H += 1;
  10917. }
  10918. if (H > 1) {
  10919. H -= 1;
  10920. }
  10921. }
  10922. var hsla = [H * 360, S, L];
  10923. if (rgba[3] != null) {
  10924. hsla.push(rgba[3]);
  10925. }
  10926. return hsla;
  10927. }
  10928. /**
  10929. * @param {string} color
  10930. * @param {number} level
  10931. * @return {string}
  10932. * @memberOf module:zrender/util/color
  10933. */
  10934. function lift(color, level) {
  10935. var colorArr = parse(color);
  10936. if (colorArr) {
  10937. for (var i = 0; i < 3; i++) {
  10938. if (level < 0) {
  10939. colorArr[i] = colorArr[i] * (1 - level) | 0;
  10940. }
  10941. else {
  10942. colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
  10943. }
  10944. }
  10945. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  10946. }
  10947. }
  10948. /**
  10949. * @param {string} color
  10950. * @return {string}
  10951. * @memberOf module:zrender/util/color
  10952. */
  10953. function toHex(color, level) {
  10954. var colorArr = parse(color);
  10955. if (colorArr) {
  10956. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
  10957. }
  10958. }
  10959. /**
  10960. * Map value to color. Faster than lerp methods because color is represented by rgba array.
  10961. * @param {number} normalizedValue A float between 0 and 1.
  10962. * @param {Array.<Array.<number>>} colors List of rgba color array
  10963. * @param {Array.<number>} [out] Mapped gba color array
  10964. * @return {Array.<number>} will be null/undefined if input illegal.
  10965. */
  10966. function fastLerp(normalizedValue, colors, out) {
  10967. if (!(colors && colors.length)
  10968. || !(normalizedValue >= 0 && normalizedValue <= 1)
  10969. ) {
  10970. return;
  10971. }
  10972. out = out || [];
  10973. var value = normalizedValue * (colors.length - 1);
  10974. var leftIndex = Math.floor(value);
  10975. var rightIndex = Math.ceil(value);
  10976. var leftColor = colors[leftIndex];
  10977. var rightColor = colors[rightIndex];
  10978. var dv = value - leftIndex;
  10979. out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv));
  10980. out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv));
  10981. out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv));
  10982. out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv));
  10983. return out;
  10984. }
  10985. /**
  10986. * @param {number} normalizedValue A float between 0 and 1.
  10987. * @param {Array.<string>} colors Color list.
  10988. * @param {boolean=} fullOutput Default false.
  10989. * @return {(string|Object)} Result color. If fullOutput,
  10990. * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
  10991. * @memberOf module:zrender/util/color
  10992. */
  10993. function lerp(normalizedValue, colors, fullOutput) {
  10994. if (!(colors && colors.length)
  10995. || !(normalizedValue >= 0 && normalizedValue <= 1)
  10996. ) {
  10997. return;
  10998. }
  10999. var value = normalizedValue * (colors.length - 1);
  11000. var leftIndex = Math.floor(value);
  11001. var rightIndex = Math.ceil(value);
  11002. var leftColor = parse(colors[leftIndex]);
  11003. var rightColor = parse(colors[rightIndex]);
  11004. var dv = value - leftIndex;
  11005. var color = stringify(
  11006. [
  11007. clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)),
  11008. clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)),
  11009. clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)),
  11010. clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))
  11011. ],
  11012. 'rgba'
  11013. );
  11014. return fullOutput
  11015. ? {
  11016. color: color,
  11017. leftIndex: leftIndex,
  11018. rightIndex: rightIndex,
  11019. value: value
  11020. }
  11021. : color;
  11022. }
  11023. /**
  11024. * @param {string} color
  11025. * @param {number=} h 0 ~ 360, ignore when null.
  11026. * @param {number=} s 0 ~ 1, ignore when null.
  11027. * @param {number=} l 0 ~ 1, ignore when null.
  11028. * @return {string} Color string in rgba format.
  11029. * @memberOf module:zrender/util/color
  11030. */
  11031. function modifyHSL(color, h, s, l) {
  11032. color = parse(color);
  11033. if (color) {
  11034. color = rgba2hsla(color);
  11035. h != null && (color[0] = clampCssAngle(h));
  11036. s != null && (color[1] = parseCssFloat(s));
  11037. l != null && (color[2] = parseCssFloat(l));
  11038. return stringify(hsla2rgba(color), 'rgba');
  11039. }
  11040. }
  11041. /**
  11042. * @param {string} color
  11043. * @param {number=} alpha 0 ~ 1
  11044. * @return {string} Color string in rgba format.
  11045. * @memberOf module:zrender/util/color
  11046. */
  11047. function modifyAlpha(color, alpha) {
  11048. color = parse(color);
  11049. if (color && alpha != null) {
  11050. color[3] = clampCssFloat(alpha);
  11051. return stringify(color, 'rgba');
  11052. }
  11053. }
  11054. /**
  11055. * @param {Array.<number>} arrColor like [12,33,44,0.4]
  11056. * @param {string} type 'rgba', 'hsva', ...
  11057. * @return {string} Result color. (If input illegal, return undefined).
  11058. */
  11059. function stringify(arrColor, type) {
  11060. if (!arrColor || !arrColor.length) {
  11061. return;
  11062. }
  11063. var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
  11064. if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
  11065. colorStr += ',' + arrColor[3];
  11066. }
  11067. return type + '(' + colorStr + ')';
  11068. }
  11069. module.exports = {
  11070. parse: parse,
  11071. lift: lift,
  11072. toHex: toHex,
  11073. fastLerp: fastLerp,
  11074. fastMapToColor: fastLerp, // Deprecated
  11075. lerp: lerp,
  11076. mapToColor: lerp, // Deprecated
  11077. modifyHSL: modifyHSL,
  11078. modifyAlpha: modifyAlpha,
  11079. stringify: stringify
  11080. };
  11081. /***/ }),
  11082. /* 34 */
  11083. /***/ (function(module, exports, __webpack_require__) {
  11084. var config = __webpack_require__(35);
  11085. /**
  11086. * @exports zrender/tool/log
  11087. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  11088. */
  11089. module.exports = function() {
  11090. if (config.debugMode === 0) {
  11091. return;
  11092. }
  11093. else if (config.debugMode == 1) {
  11094. for (var k in arguments) {
  11095. throw new Error(arguments[k]);
  11096. }
  11097. }
  11098. else if (config.debugMode > 1) {
  11099. for (var k in arguments) {
  11100. console.log(arguments[k]);
  11101. }
  11102. }
  11103. };
  11104. /* for debug
  11105. return function(mes) {
  11106. document.getElementById('wrong-message').innerHTML =
  11107. mes + ' ' + (new Date() - 0)
  11108. + '<br/>'
  11109. + document.getElementById('wrong-message').innerHTML;
  11110. };
  11111. */
  11112. /***/ }),
  11113. /* 35 */
  11114. /***/ (function(module, exports) {
  11115. var dpr = 1;
  11116. // If in browser environment
  11117. if (typeof window !== 'undefined') {
  11118. dpr = Math.max(window.devicePixelRatio || 1, 1);
  11119. }
  11120. /**
  11121. * config默认配置项
  11122. * @exports zrender/config
  11123. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  11124. */
  11125. var config = {
  11126. /**
  11127. * debug日志选项:catchBrushException为true下有效
  11128. * 0 : 不生成debug数据,发布用
  11129. * 1 : 异常抛出,调试用
  11130. * 2 : 控制台输出,调试用
  11131. */
  11132. debugMode: 0,
  11133. // retina 屏幕优化
  11134. devicePixelRatio: dpr
  11135. };
  11136. module.exports = config;
  11137. /***/ }),
  11138. /* 36 */
  11139. /***/ (function(module, exports, __webpack_require__) {
  11140. /**
  11141. * Mixin for drawing text in a element bounding rect
  11142. * @module zrender/mixin/RectText
  11143. */
  11144. var textHelper = __webpack_require__(37);
  11145. var BoundingRect = __webpack_require__(9);
  11146. var tmpRect = new BoundingRect();
  11147. var RectText = function () {};
  11148. RectText.prototype = {
  11149. constructor: RectText,
  11150. /**
  11151. * Draw text in a rect with specified position.
  11152. * @param {CanvasRenderingContext2D} ctx
  11153. * @param {Object} rect Displayable rect
  11154. */
  11155. drawRectText: function (ctx, rect) {
  11156. var style = this.style;
  11157. rect = style.textRect || rect;
  11158. // Optimize, avoid normalize every time.
  11159. this.__dirty && textHelper.normalizeTextStyle(style, true);
  11160. var text = style.text;
  11161. // Convert to string
  11162. text != null && (text += '');
  11163. if (!textHelper.needDrawText(text, style)) {
  11164. return;
  11165. }
  11166. // FIXME
  11167. ctx.save();
  11168. // Transform rect to view space
  11169. var transform = this.transform;
  11170. if (!style.transformText) {
  11171. if (transform) {
  11172. tmpRect.copy(rect);
  11173. tmpRect.applyTransform(transform);
  11174. rect = tmpRect;
  11175. }
  11176. }
  11177. else {
  11178. this.setTransform(ctx);
  11179. }
  11180. // transformText and textRotation can not be used at the same time.
  11181. textHelper.renderText(this, ctx, text, style, rect);
  11182. ctx.restore();
  11183. }
  11184. };
  11185. module.exports = RectText;
  11186. /***/ }),
  11187. /* 37 */
  11188. /***/ (function(module, exports, __webpack_require__) {
  11189. var textContain = __webpack_require__(8);
  11190. var util = __webpack_require__(4);
  11191. var roundRectHelper = __webpack_require__(38);
  11192. var imageHelper = __webpack_require__(12);
  11193. var retrieve3 = util.retrieve3;
  11194. var retrieve2 = util.retrieve2;
  11195. // TODO: Have not support 'start', 'end' yet.
  11196. var VALID_TEXT_ALIGN = {left: 1, right: 1, center: 1};
  11197. var VALID_TEXT_VERTICAL_ALIGN = {top: 1, bottom: 1, middle: 1};
  11198. var helper = {};
  11199. /**
  11200. * @param {module:zrender/graphic/Style} style
  11201. * @return {module:zrender/graphic/Style} The input style.
  11202. */
  11203. helper.normalizeTextStyle = function (style) {
  11204. normalizeStyle(style);
  11205. util.each(style.rich, normalizeStyle);
  11206. return style;
  11207. };
  11208. function normalizeStyle(style) {
  11209. if (style) {
  11210. style.font = textContain.makeFont(style);
  11211. var textAlign = style.textAlign;
  11212. textAlign === 'middle' && (textAlign = 'center');
  11213. style.textAlign = (
  11214. textAlign == null || VALID_TEXT_ALIGN[textAlign]
  11215. ) ? textAlign : 'left';
  11216. // Compatible with textBaseline.
  11217. var textVerticalAlign = style.textVerticalAlign || style.textBaseline;
  11218. textVerticalAlign === 'center' && (textVerticalAlign = 'middle');
  11219. style.textVerticalAlign = (
  11220. textVerticalAlign == null || VALID_TEXT_VERTICAL_ALIGN[textVerticalAlign]
  11221. ) ? textVerticalAlign : 'top';
  11222. var textPadding = style.textPadding;
  11223. if (textPadding) {
  11224. style.textPadding = util.normalizeCssArray(style.textPadding);
  11225. }
  11226. }
  11227. }
  11228. /**
  11229. * @param {CanvasRenderingContext2D} ctx
  11230. * @param {string} text
  11231. * @param {module:zrender/graphic/Style} style
  11232. * @param {Object|boolean} [rect] {x, y, width, height}
  11233. * If set false, rect text is not used.
  11234. */
  11235. helper.renderText = function (hostEl, ctx, text, style, rect) {
  11236. style.rich
  11237. ? renderRichText(hostEl, ctx, text, style, rect)
  11238. : renderPlainText(hostEl, ctx, text, style, rect);
  11239. };
  11240. function renderPlainText(hostEl, ctx, text, style, rect) {
  11241. var font = setCtx(ctx, 'font', style.font || textContain.DEFAULT_FONT);
  11242. var textPadding = style.textPadding;
  11243. var contentBlock = hostEl.__textCotentBlock;
  11244. if (!contentBlock || hostEl.__dirty) {
  11245. contentBlock = hostEl.__textCotentBlock = textContain.parsePlainText(
  11246. text, font, textPadding, style.truncate
  11247. );
  11248. }
  11249. var outerHeight = contentBlock.outerHeight;
  11250. var textLines = contentBlock.lines;
  11251. var lineHeight = contentBlock.lineHeight;
  11252. var boxPos = getBoxPosition(outerHeight, style, rect);
  11253. var baseX = boxPos.baseX;
  11254. var baseY = boxPos.baseY;
  11255. var textAlign = boxPos.textAlign;
  11256. var textVerticalAlign = boxPos.textVerticalAlign;
  11257. // Origin of textRotation should be the base point of text drawing.
  11258. applyTextRotation(ctx, style, rect, baseX, baseY);
  11259. var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
  11260. var textX = baseX;
  11261. var textY = boxY;
  11262. var needDrawBg = needDrawBackground(style);
  11263. if (needDrawBg || textPadding) {
  11264. // Consider performance, do not call getTextWidth util necessary.
  11265. var textWidth = textContain.getWidth(text, font);
  11266. var outerWidth = textWidth;
  11267. textPadding && (outerWidth += textPadding[1] + textPadding[3]);
  11268. var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
  11269. needDrawBg && drawBackground(hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight);
  11270. if (textPadding) {
  11271. textX = getTextXForPadding(baseX, textAlign, textPadding);
  11272. textY += textPadding[0];
  11273. }
  11274. }
  11275. setCtx(ctx, 'textAlign', textAlign || 'left');
  11276. // Force baseline to be "middle". Otherwise, if using "top", the
  11277. // text will offset downward a little bit in font "Microsoft YaHei".
  11278. setCtx(ctx, 'textBaseline', 'middle');
  11279. // Always set shadowBlur and shadowOffset to avoid leak from displayable.
  11280. setCtx(ctx, 'shadowBlur', style.textShadowBlur || 0);
  11281. setCtx(ctx, 'shadowColor', style.textShadowColor || 'transparent');
  11282. setCtx(ctx, 'shadowOffsetX', style.textShadowOffsetX || 0);
  11283. setCtx(ctx, 'shadowOffsetY', style.textShadowOffsetY || 0);
  11284. // `textBaseline` is set as 'middle'.
  11285. textY += lineHeight / 2;
  11286. var textStrokeWidth = style.textStrokeWidth;
  11287. var textStroke = getStroke(style.textStroke, textStrokeWidth);
  11288. var textFill = getFill(style.textFill);
  11289. if (textStroke) {
  11290. setCtx(ctx, 'lineWidth', textStrokeWidth);
  11291. setCtx(ctx, 'strokeStyle', textStroke);
  11292. }
  11293. if (textFill) {
  11294. setCtx(ctx, 'fillStyle', textFill);
  11295. }
  11296. for (var i = 0; i < textLines.length; i++) {
  11297. // Fill after stroke so the outline will not cover the main part.
  11298. textStroke && ctx.strokeText(textLines[i], textX, textY);
  11299. textFill && ctx.fillText(textLines[i], textX, textY);
  11300. textY += lineHeight;
  11301. }
  11302. }
  11303. function renderRichText(hostEl, ctx, text, style, rect) {
  11304. var contentBlock = hostEl.__textCotentBlock;
  11305. if (!contentBlock || hostEl.__dirty) {
  11306. contentBlock = hostEl.__textCotentBlock = textContain.parseRichText(text, style);
  11307. }
  11308. drawRichText(hostEl, ctx, contentBlock, style, rect);
  11309. }
  11310. function drawRichText(hostEl, ctx, contentBlock, style, rect) {
  11311. var contentWidth = contentBlock.width;
  11312. var outerWidth = contentBlock.outerWidth;
  11313. var outerHeight = contentBlock.outerHeight;
  11314. var textPadding = style.textPadding;
  11315. var boxPos = getBoxPosition(outerHeight, style, rect);
  11316. var baseX = boxPos.baseX;
  11317. var baseY = boxPos.baseY;
  11318. var textAlign = boxPos.textAlign;
  11319. var textVerticalAlign = boxPos.textVerticalAlign;
  11320. // Origin of textRotation should be the base point of text drawing.
  11321. applyTextRotation(ctx, style, rect, baseX, baseY);
  11322. var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
  11323. var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
  11324. var xLeft = boxX;
  11325. var lineTop = boxY;
  11326. if (textPadding) {
  11327. xLeft += textPadding[3];
  11328. lineTop += textPadding[0];
  11329. }
  11330. var xRight = xLeft + contentWidth;
  11331. needDrawBackground(style) && drawBackground(
  11332. hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight
  11333. );
  11334. for (var i = 0; i < contentBlock.lines.length; i++) {
  11335. var line = contentBlock.lines[i];
  11336. var tokens = line.tokens;
  11337. var tokenCount = tokens.length;
  11338. var lineHeight = line.lineHeight;
  11339. var usedWidth = line.width;
  11340. var leftIndex = 0;
  11341. var lineXLeft = xLeft;
  11342. var lineXRight = xRight;
  11343. var rightIndex = tokenCount - 1;
  11344. var token;
  11345. while (
  11346. leftIndex < tokenCount
  11347. && (token = tokens[leftIndex], !token.textAlign || token.textAlign === 'left')
  11348. ) {
  11349. placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft, 'left');
  11350. usedWidth -= token.width;
  11351. lineXLeft += token.width;
  11352. leftIndex++;
  11353. }
  11354. while (
  11355. rightIndex >= 0
  11356. && (token = tokens[rightIndex], token.textAlign === 'right')
  11357. ) {
  11358. placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXRight, 'right');
  11359. usedWidth -= token.width;
  11360. lineXRight -= token.width;
  11361. rightIndex--;
  11362. }
  11363. // The other tokens are placed as textAlign 'center' if there is enough space.
  11364. lineXLeft += (contentWidth - (lineXLeft - xLeft) - (xRight - lineXRight) - usedWidth) / 2;
  11365. while (leftIndex <= rightIndex) {
  11366. token = tokens[leftIndex];
  11367. // Consider width specified by user, use 'center' rather than 'left'.
  11368. placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft + token.width / 2, 'center');
  11369. lineXLeft += token.width;
  11370. leftIndex++;
  11371. }
  11372. lineTop += lineHeight;
  11373. }
  11374. }
  11375. function applyTextRotation(ctx, style, rect, x, y) {
  11376. // textRotation only apply in RectText.
  11377. if (rect && style.textRotation) {
  11378. var origin = style.textOrigin;
  11379. if (origin === 'center') {
  11380. x = rect.width / 2 + rect.x;
  11381. y = rect.height / 2 + rect.y;
  11382. }
  11383. else if (origin) {
  11384. x = origin[0] + rect.x;
  11385. y = origin[1] + rect.y;
  11386. }
  11387. ctx.translate(x, y);
  11388. // Positive: anticlockwise
  11389. ctx.rotate(-style.textRotation);
  11390. ctx.translate(-x, -y);
  11391. }
  11392. }
  11393. function placeToken(hostEl, ctx, token, style, lineHeight, lineTop, x, textAlign) {
  11394. var tokenStyle = style.rich[token.styleName] || {};
  11395. // 'ctx.textBaseline' is always set as 'middle', for sake of
  11396. // the bias of "Microsoft YaHei".
  11397. var textVerticalAlign = token.textVerticalAlign;
  11398. var y = lineTop + lineHeight / 2;
  11399. if (textVerticalAlign === 'top') {
  11400. y = lineTop + token.height / 2;
  11401. }
  11402. else if (textVerticalAlign === 'bottom') {
  11403. y = lineTop + lineHeight - token.height / 2;
  11404. }
  11405. !token.isLineHolder && needDrawBackground(tokenStyle) && drawBackground(
  11406. hostEl,
  11407. ctx,
  11408. tokenStyle,
  11409. textAlign === 'right'
  11410. ? x - token.width
  11411. : textAlign === 'center'
  11412. ? x - token.width / 2
  11413. : x,
  11414. y - token.height / 2,
  11415. token.width,
  11416. token.height
  11417. );
  11418. var textPadding = token.textPadding;
  11419. if (textPadding) {
  11420. x = getTextXForPadding(x, textAlign, textPadding);
  11421. y -= token.height / 2 - textPadding[2] - token.textHeight / 2;
  11422. }
  11423. setCtx(ctx, 'shadowBlur', retrieve3(tokenStyle.textShadowBlur, style.textShadowBlur, 0));
  11424. setCtx(ctx, 'shadowColor', tokenStyle.textShadowColor || style.textShadowColor || 'transparent');
  11425. setCtx(ctx, 'shadowOffsetX', retrieve3(tokenStyle.textShadowOffsetX, style.textShadowOffsetX, 0));
  11426. setCtx(ctx, 'shadowOffsetY', retrieve3(tokenStyle.textShadowOffsetY, style.textShadowOffsetY, 0));
  11427. setCtx(ctx, 'textAlign', textAlign);
  11428. // Force baseline to be "middle". Otherwise, if using "top", the
  11429. // text will offset downward a little bit in font "Microsoft YaHei".
  11430. setCtx(ctx, 'textBaseline', 'middle');
  11431. setCtx(ctx, 'font', token.font || textContain.DEFAULT_FONT);
  11432. var textStroke = getStroke(tokenStyle.textStroke || style.textStroke, textStrokeWidth);
  11433. var textFill = getFill(tokenStyle.textFill || style.textFill);
  11434. var textStrokeWidth = retrieve2(tokenStyle.textStrokeWidth, style.textStrokeWidth);
  11435. // Fill after stroke so the outline will not cover the main part.
  11436. if (textStroke) {
  11437. setCtx(ctx, 'lineWidth', textStrokeWidth);
  11438. setCtx(ctx, 'strokeStyle', textStroke);
  11439. ctx.strokeText(token.text, x, y);
  11440. }
  11441. if (textFill) {
  11442. setCtx(ctx, 'fillStyle', textFill);
  11443. ctx.fillText(token.text, x, y);
  11444. }
  11445. }
  11446. function needDrawBackground(style) {
  11447. return style.textBackgroundColor
  11448. || (style.textBorderWidth && style.textBorderColor);
  11449. }
  11450. // style: {textBackgroundColor, textBorderWidth, textBorderColor, textBorderRadius}
  11451. // shape: {x, y, width, height}
  11452. function drawBackground(hostEl, ctx, style, x, y, width, height) {
  11453. var textBackgroundColor = style.textBackgroundColor;
  11454. var textBorderWidth = style.textBorderWidth;
  11455. var textBorderColor = style.textBorderColor;
  11456. var isPlainBg = util.isString(textBackgroundColor);
  11457. setCtx(ctx, 'shadowBlur', style.textBoxShadowBlur || 0);
  11458. setCtx(ctx, 'shadowColor', style.textBoxShadowColor || 'transparent');
  11459. setCtx(ctx, 'shadowOffsetX', style.textBoxShadowOffsetX || 0);
  11460. setCtx(ctx, 'shadowOffsetY', style.textBoxShadowOffsetY || 0);
  11461. if (isPlainBg || (textBorderWidth && textBorderColor)) {
  11462. ctx.beginPath();
  11463. var textBorderRadius = style.textBorderRadius;
  11464. if (!textBorderRadius) {
  11465. ctx.rect(x, y, width, height);
  11466. }
  11467. else {
  11468. roundRectHelper.buildPath(ctx, {
  11469. x: x, y: y, width: width, height: height, r: textBorderRadius
  11470. });
  11471. }
  11472. ctx.closePath();
  11473. }
  11474. if (isPlainBg) {
  11475. setCtx(ctx, 'fillStyle', textBackgroundColor);
  11476. ctx.fill();
  11477. }
  11478. else if (util.isObject(textBackgroundColor)) {
  11479. var image = textBackgroundColor.image;
  11480. image = imageHelper.createOrUpdateImage(
  11481. image, null, hostEl, onBgImageLoaded, textBackgroundColor
  11482. );
  11483. if (image && imageHelper.isImageReady(image)) {
  11484. ctx.drawImage(image, x, y, width, height);
  11485. }
  11486. }
  11487. if (textBorderWidth && textBorderColor) {
  11488. setCtx(ctx, 'lineWidth', textBorderWidth);
  11489. setCtx(ctx, 'strokeStyle', textBorderColor);
  11490. ctx.stroke();
  11491. }
  11492. }
  11493. function onBgImageLoaded(image, textBackgroundColor) {
  11494. // Replace image, so that `contain/text.js#parseRichText`
  11495. // will get correct result in next tick.
  11496. textBackgroundColor.image = image;
  11497. }
  11498. function getBoxPosition(blockHeiht, style, rect) {
  11499. var baseX = style.x || 0;
  11500. var baseY = style.y || 0;
  11501. var textAlign = style.textAlign;
  11502. var textVerticalAlign = style.textVerticalAlign;
  11503. // Text position represented by coord
  11504. if (rect) {
  11505. var textPosition = style.textPosition;
  11506. if (textPosition instanceof Array) {
  11507. // Percent
  11508. baseX = rect.x + parsePercent(textPosition[0], rect.width);
  11509. baseY = rect.y + parsePercent(textPosition[1], rect.height);
  11510. }
  11511. else {
  11512. var res = textContain.adjustTextPositionOnRect(
  11513. textPosition, rect, style.textDistance
  11514. );
  11515. baseX = res.x;
  11516. baseY = res.y;
  11517. // Default align and baseline when has textPosition
  11518. textAlign = textAlign || res.textAlign;
  11519. textVerticalAlign = textVerticalAlign || res.textVerticalAlign;
  11520. }
  11521. // textOffset is only support in RectText, otherwise
  11522. // we have to adjust boundingRect for textOffset.
  11523. var textOffset = style.textOffset;
  11524. if (textOffset) {
  11525. baseX += textOffset[0];
  11526. baseY += textOffset[1];
  11527. }
  11528. }
  11529. return {
  11530. baseX: baseX,
  11531. baseY: baseY,
  11532. textAlign: textAlign,
  11533. textVerticalAlign: textVerticalAlign
  11534. };
  11535. }
  11536. function setCtx(ctx, prop, value) {
  11537. // FIXME ??? performance try
  11538. // if (ctx.__currentValues[prop] !== value) {
  11539. // ctx[prop] = ctx.__currentValues[prop] = value;
  11540. ctx[prop] = value;
  11541. // }
  11542. return ctx[prop];
  11543. }
  11544. /**
  11545. * @param {string} [stroke] If specified, do not check style.textStroke.
  11546. * @param {string} [lineWidth] If specified, do not check style.textStroke.
  11547. * @param {number} style
  11548. */
  11549. var getStroke = helper.getStroke = function (stroke, lineWidth) {
  11550. return (stroke == null || lineWidth <= 0 || stroke === 'transparent' || stroke === 'none')
  11551. ? null
  11552. // TODO pattern and gradient?
  11553. : (stroke.image || stroke.colorStops)
  11554. ? '#000'
  11555. : stroke;
  11556. };
  11557. var getFill = helper.getFill = function (fill) {
  11558. return (fill == null || fill === 'none')
  11559. ? null
  11560. // TODO pattern and gradient?
  11561. : (fill.image || fill.colorStops)
  11562. ? '#000'
  11563. : fill;
  11564. };
  11565. function parsePercent(value, maxValue) {
  11566. if (typeof value === 'string') {
  11567. if (value.lastIndexOf('%') >= 0) {
  11568. return parseFloat(value) / 100 * maxValue;
  11569. }
  11570. return parseFloat(value);
  11571. }
  11572. return value;
  11573. }
  11574. function getTextXForPadding(x, textAlign, textPadding) {
  11575. return textAlign === 'right'
  11576. ? (x - textPadding[1])
  11577. : textAlign === 'center'
  11578. ? (x + textPadding[3] / 2 - textPadding[1] / 2)
  11579. : (x + textPadding[3]);
  11580. }
  11581. /**
  11582. * @param {string} text
  11583. * @param {module:zrender/Style} style
  11584. * @return {boolean}
  11585. */
  11586. helper.needDrawText = function (text, style) {
  11587. return text != null
  11588. && (text
  11589. || style.textBackgroundColor
  11590. || (style.textBorderWidth && style.textBorderColor)
  11591. || style.textPadding
  11592. );
  11593. };
  11594. module.exports = helper;
  11595. /***/ }),
  11596. /* 38 */
  11597. /***/ (function(module, exports) {
  11598. module.exports = {
  11599. buildPath: function (ctx, shape) {
  11600. var x = shape.x;
  11601. var y = shape.y;
  11602. var width = shape.width;
  11603. var height = shape.height;
  11604. var r = shape.r;
  11605. var r1;
  11606. var r2;
  11607. var r3;
  11608. var r4;
  11609. // Convert width and height to positive for better borderRadius
  11610. if (width < 0) {
  11611. x = x + width;
  11612. width = -width;
  11613. }
  11614. if (height < 0) {
  11615. y = y + height;
  11616. height = -height;
  11617. }
  11618. if (typeof r === 'number') {
  11619. r1 = r2 = r3 = r4 = r;
  11620. }
  11621. else if (r instanceof Array) {
  11622. if (r.length === 1) {
  11623. r1 = r2 = r3 = r4 = r[0];
  11624. }
  11625. else if (r.length === 2) {
  11626. r1 = r3 = r[0];
  11627. r2 = r4 = r[1];
  11628. }
  11629. else if (r.length === 3) {
  11630. r1 = r[0];
  11631. r2 = r4 = r[1];
  11632. r3 = r[2];
  11633. }
  11634. else {
  11635. r1 = r[0];
  11636. r2 = r[1];
  11637. r3 = r[2];
  11638. r4 = r[3];
  11639. }
  11640. }
  11641. else {
  11642. r1 = r2 = r3 = r4 = 0;
  11643. }
  11644. var total;
  11645. if (r1 + r2 > width) {
  11646. total = r1 + r2;
  11647. r1 *= width / total;
  11648. r2 *= width / total;
  11649. }
  11650. if (r3 + r4 > width) {
  11651. total = r3 + r4;
  11652. r3 *= width / total;
  11653. r4 *= width / total;
  11654. }
  11655. if (r2 + r3 > height) {
  11656. total = r2 + r3;
  11657. r2 *= height / total;
  11658. r3 *= height / total;
  11659. }
  11660. if (r1 + r4 > height) {
  11661. total = r1 + r4;
  11662. r1 *= height / total;
  11663. r4 *= height / total;
  11664. }
  11665. ctx.moveTo(x + r1, y);
  11666. ctx.lineTo(x + width - r2, y);
  11667. r2 !== 0 && ctx.quadraticCurveTo(
  11668. x + width, y, x + width, y + r2
  11669. );
  11670. ctx.lineTo(x + width, y + height - r3);
  11671. r3 !== 0 && ctx.quadraticCurveTo(
  11672. x + width, y + height, x + width - r3, y + height
  11673. );
  11674. ctx.lineTo(x + r4, y + height);
  11675. r4 !== 0 && ctx.quadraticCurveTo(
  11676. x, y + height, x, y + height - r4
  11677. );
  11678. ctx.lineTo(x, y + r1);
  11679. r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
  11680. }
  11681. };
  11682. /***/ }),
  11683. /* 39 */
  11684. /***/ (function(module, exports, __webpack_require__) {
  11685. 'use strict';
  11686. /**
  11687. * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中
  11688. * 可以用于 isInsidePath 判断以及获取boundingRect
  11689. *
  11690. * @module zrender/core/PathProxy
  11691. * @author Yi Shen (http://www.github.com/pissang)
  11692. */
  11693. // TODO getTotalLength, getPointAtLength
  11694. var curve = __webpack_require__(40);
  11695. var vec2 = __webpack_require__(10);
  11696. var bbox = __webpack_require__(41);
  11697. var BoundingRect = __webpack_require__(9);
  11698. var dpr = __webpack_require__(35).devicePixelRatio;
  11699. var CMD = {
  11700. M: 1,
  11701. L: 2,
  11702. C: 3,
  11703. Q: 4,
  11704. A: 5,
  11705. Z: 6,
  11706. // Rect
  11707. R: 7
  11708. };
  11709. // var CMD_MEM_SIZE = {
  11710. // M: 3,
  11711. // L: 3,
  11712. // C: 7,
  11713. // Q: 5,
  11714. // A: 9,
  11715. // R: 5,
  11716. // Z: 1
  11717. // };
  11718. var min = [];
  11719. var max = [];
  11720. var min2 = [];
  11721. var max2 = [];
  11722. var mathMin = Math.min;
  11723. var mathMax = Math.max;
  11724. var mathCos = Math.cos;
  11725. var mathSin = Math.sin;
  11726. var mathSqrt = Math.sqrt;
  11727. var mathAbs = Math.abs;
  11728. var hasTypedArray = typeof Float32Array != 'undefined';
  11729. /**
  11730. * @alias module:zrender/core/PathProxy
  11731. * @constructor
  11732. */
  11733. var PathProxy = function (notSaveData) {
  11734. this._saveData = !(notSaveData || false);
  11735. if (this._saveData) {
  11736. /**
  11737. * Path data. Stored as flat array
  11738. * @type {Array.<Object>}
  11739. */
  11740. this.data = [];
  11741. }
  11742. this._ctx = null;
  11743. };
  11744. /**
  11745. * 快速计算Path包围盒(并不是最小包围盒)
  11746. * @return {Object}
  11747. */
  11748. PathProxy.prototype = {
  11749. constructor: PathProxy,
  11750. _xi: 0,
  11751. _yi: 0,
  11752. _x0: 0,
  11753. _y0: 0,
  11754. // Unit x, Unit y. Provide for avoiding drawing that too short line segment
  11755. _ux: 0,
  11756. _uy: 0,
  11757. _len: 0,
  11758. _lineDash: null,
  11759. _dashOffset: 0,
  11760. _dashIdx: 0,
  11761. _dashSum: 0,
  11762. /**
  11763. * @readOnly
  11764. */
  11765. setScale: function (sx, sy) {
  11766. this._ux = mathAbs(1 / dpr / sx) || 0;
  11767. this._uy = mathAbs(1 / dpr / sy) || 0;
  11768. },
  11769. getContext: function () {
  11770. return this._ctx;
  11771. },
  11772. /**
  11773. * @param {CanvasRenderingContext2D} ctx
  11774. * @return {module:zrender/core/PathProxy}
  11775. */
  11776. beginPath: function (ctx) {
  11777. this._ctx = ctx;
  11778. ctx && ctx.beginPath();
  11779. ctx && (this.dpr = ctx.dpr);
  11780. // Reset
  11781. if (this._saveData) {
  11782. this._len = 0;
  11783. }
  11784. if (this._lineDash) {
  11785. this._lineDash = null;
  11786. this._dashOffset = 0;
  11787. }
  11788. return this;
  11789. },
  11790. /**
  11791. * @param {number} x
  11792. * @param {number} y
  11793. * @return {module:zrender/core/PathProxy}
  11794. */
  11795. moveTo: function (x, y) {
  11796. this.addData(CMD.M, x, y);
  11797. this._ctx && this._ctx.moveTo(x, y);
  11798. // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用
  11799. // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。
  11800. // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要
  11801. // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持
  11802. this._x0 = x;
  11803. this._y0 = y;
  11804. this._xi = x;
  11805. this._yi = y;
  11806. return this;
  11807. },
  11808. /**
  11809. * @param {number} x
  11810. * @param {number} y
  11811. * @return {module:zrender/core/PathProxy}
  11812. */
  11813. lineTo: function (x, y) {
  11814. var exceedUnit = mathAbs(x - this._xi) > this._ux
  11815. || mathAbs(y - this._yi) > this._uy
  11816. // Force draw the first segment
  11817. || this._len < 5;
  11818. this.addData(CMD.L, x, y);
  11819. if (this._ctx && exceedUnit) {
  11820. this._needsDash() ? this._dashedLineTo(x, y)
  11821. : this._ctx.lineTo(x, y);
  11822. }
  11823. if (exceedUnit) {
  11824. this._xi = x;
  11825. this._yi = y;
  11826. }
  11827. return this;
  11828. },
  11829. /**
  11830. * @param {number} x1
  11831. * @param {number} y1
  11832. * @param {number} x2
  11833. * @param {number} y2
  11834. * @param {number} x3
  11835. * @param {number} y3
  11836. * @return {module:zrender/core/PathProxy}
  11837. */
  11838. bezierCurveTo: function (x1, y1, x2, y2, x3, y3) {
  11839. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  11840. if (this._ctx) {
  11841. this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3)
  11842. : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  11843. }
  11844. this._xi = x3;
  11845. this._yi = y3;
  11846. return this;
  11847. },
  11848. /**
  11849. * @param {number} x1
  11850. * @param {number} y1
  11851. * @param {number} x2
  11852. * @param {number} y2
  11853. * @return {module:zrender/core/PathProxy}
  11854. */
  11855. quadraticCurveTo: function (x1, y1, x2, y2) {
  11856. this.addData(CMD.Q, x1, y1, x2, y2);
  11857. if (this._ctx) {
  11858. this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2)
  11859. : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  11860. }
  11861. this._xi = x2;
  11862. this._yi = y2;
  11863. return this;
  11864. },
  11865. /**
  11866. * @param {number} cx
  11867. * @param {number} cy
  11868. * @param {number} r
  11869. * @param {number} startAngle
  11870. * @param {number} endAngle
  11871. * @param {boolean} anticlockwise
  11872. * @return {module:zrender/core/PathProxy}
  11873. */
  11874. arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  11875. this.addData(
  11876. CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1
  11877. );
  11878. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  11879. this._xi = mathCos(endAngle) * r + cx;
  11880. this._yi = mathSin(endAngle) * r + cx;
  11881. return this;
  11882. },
  11883. // TODO
  11884. arcTo: function (x1, y1, x2, y2, radius) {
  11885. if (this._ctx) {
  11886. this._ctx.arcTo(x1, y1, x2, y2, radius);
  11887. }
  11888. return this;
  11889. },
  11890. // TODO
  11891. rect: function (x, y, w, h) {
  11892. this._ctx && this._ctx.rect(x, y, w, h);
  11893. this.addData(CMD.R, x, y, w, h);
  11894. return this;
  11895. },
  11896. /**
  11897. * @return {module:zrender/core/PathProxy}
  11898. */
  11899. closePath: function () {
  11900. this.addData(CMD.Z);
  11901. var ctx = this._ctx;
  11902. var x0 = this._x0;
  11903. var y0 = this._y0;
  11904. if (ctx) {
  11905. this._needsDash() && this._dashedLineTo(x0, y0);
  11906. ctx.closePath();
  11907. }
  11908. this._xi = x0;
  11909. this._yi = y0;
  11910. return this;
  11911. },
  11912. /**
  11913. * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。
  11914. * stroke 同样
  11915. * @param {CanvasRenderingContext2D} ctx
  11916. * @return {module:zrender/core/PathProxy}
  11917. */
  11918. fill: function (ctx) {
  11919. ctx && ctx.fill();
  11920. this.toStatic();
  11921. },
  11922. /**
  11923. * @param {CanvasRenderingContext2D} ctx
  11924. * @return {module:zrender/core/PathProxy}
  11925. */
  11926. stroke: function (ctx) {
  11927. ctx && ctx.stroke();
  11928. this.toStatic();
  11929. },
  11930. /**
  11931. * 必须在其它绘制命令前调用
  11932. * Must be invoked before all other path drawing methods
  11933. * @return {module:zrender/core/PathProxy}
  11934. */
  11935. setLineDash: function (lineDash) {
  11936. if (lineDash instanceof Array) {
  11937. this._lineDash = lineDash;
  11938. this._dashIdx = 0;
  11939. var lineDashSum = 0;
  11940. for (var i = 0; i < lineDash.length; i++) {
  11941. lineDashSum += lineDash[i];
  11942. }
  11943. this._dashSum = lineDashSum;
  11944. }
  11945. return this;
  11946. },
  11947. /**
  11948. * 必须在其它绘制命令前调用
  11949. * Must be invoked before all other path drawing methods
  11950. * @return {module:zrender/core/PathProxy}
  11951. */
  11952. setLineDashOffset: function (offset) {
  11953. this._dashOffset = offset;
  11954. return this;
  11955. },
  11956. /**
  11957. *
  11958. * @return {boolean}
  11959. */
  11960. len: function () {
  11961. return this._len;
  11962. },
  11963. /**
  11964. * 直接设置 Path 数据
  11965. */
  11966. setData: function (data) {
  11967. var len = data.length;
  11968. if (! (this.data && this.data.length == len) && hasTypedArray) {
  11969. this.data = new Float32Array(len);
  11970. }
  11971. for (var i = 0; i < len; i++) {
  11972. this.data[i] = data[i];
  11973. }
  11974. this._len = len;
  11975. },
  11976. /**
  11977. * 添加子路径
  11978. * @param {module:zrender/core/PathProxy|Array.<module:zrender/core/PathProxy>} path
  11979. */
  11980. appendPath: function (path) {
  11981. if (!(path instanceof Array)) {
  11982. path = [path];
  11983. }
  11984. var len = path.length;
  11985. var appendSize = 0;
  11986. var offset = this._len;
  11987. for (var i = 0; i < len; i++) {
  11988. appendSize += path[i].len();
  11989. }
  11990. if (hasTypedArray && (this.data instanceof Float32Array)) {
  11991. this.data = new Float32Array(offset + appendSize);
  11992. }
  11993. for (var i = 0; i < len; i++) {
  11994. var appendPathData = path[i].data;
  11995. for (var k = 0; k < appendPathData.length; k++) {
  11996. this.data[offset++] = appendPathData[k];
  11997. }
  11998. }
  11999. this._len = offset;
  12000. },
  12001. /**
  12002. * 填充 Path 数据。
  12003. * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。
  12004. */
  12005. addData: function (cmd) {
  12006. if (!this._saveData) {
  12007. return;
  12008. }
  12009. var data = this.data;
  12010. if (this._len + arguments.length > data.length) {
  12011. // 因为之前的数组已经转换成静态的 Float32Array
  12012. // 所以不够用时需要扩展一个新的动态数组
  12013. this._expandData();
  12014. data = this.data;
  12015. }
  12016. for (var i = 0; i < arguments.length; i++) {
  12017. data[this._len++] = arguments[i];
  12018. }
  12019. this._prevCmd = cmd;
  12020. },
  12021. _expandData: function () {
  12022. // Only if data is Float32Array
  12023. if (!(this.data instanceof Array)) {
  12024. var newData = [];
  12025. for (var i = 0; i < this._len; i++) {
  12026. newData[i] = this.data[i];
  12027. }
  12028. this.data = newData;
  12029. }
  12030. },
  12031. /**
  12032. * If needs js implemented dashed line
  12033. * @return {boolean}
  12034. * @private
  12035. */
  12036. _needsDash: function () {
  12037. return this._lineDash;
  12038. },
  12039. _dashedLineTo: function (x1, y1) {
  12040. var dashSum = this._dashSum;
  12041. var offset = this._dashOffset;
  12042. var lineDash = this._lineDash;
  12043. var ctx = this._ctx;
  12044. var x0 = this._xi;
  12045. var y0 = this._yi;
  12046. var dx = x1 - x0;
  12047. var dy = y1 - y0;
  12048. var dist = mathSqrt(dx * dx + dy * dy);
  12049. var x = x0;
  12050. var y = y0;
  12051. var dash;
  12052. var nDash = lineDash.length;
  12053. var idx;
  12054. dx /= dist;
  12055. dy /= dist;
  12056. if (offset < 0) {
  12057. // Convert to positive offset
  12058. offset = dashSum + offset;
  12059. }
  12060. offset %= dashSum;
  12061. x -= offset * dx;
  12062. y -= offset * dy;
  12063. while ((dx > 0 && x <= x1) || (dx < 0 && x >= x1)
  12064. || (dx == 0 && ((dy > 0 && y <= y1) || (dy < 0 && y >= y1)))) {
  12065. idx = this._dashIdx;
  12066. dash = lineDash[idx];
  12067. x += dx * dash;
  12068. y += dy * dash;
  12069. this._dashIdx = (idx + 1) % nDash;
  12070. // Skip positive offset
  12071. if ((dx > 0 && x < x0) || (dx < 0 && x > x0) || (dy > 0 && y < y0) || (dy < 0 && y > y0)) {
  12072. continue;
  12073. }
  12074. ctx[idx % 2 ? 'moveTo' : 'lineTo'](
  12075. dx >= 0 ? mathMin(x, x1) : mathMax(x, x1),
  12076. dy >= 0 ? mathMin(y, y1) : mathMax(y, y1)
  12077. );
  12078. }
  12079. // Offset for next lineTo
  12080. dx = x - x1;
  12081. dy = y - y1;
  12082. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  12083. },
  12084. // Not accurate dashed line to
  12085. _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) {
  12086. var dashSum = this._dashSum;
  12087. var offset = this._dashOffset;
  12088. var lineDash = this._lineDash;
  12089. var ctx = this._ctx;
  12090. var x0 = this._xi;
  12091. var y0 = this._yi;
  12092. var t;
  12093. var dx;
  12094. var dy;
  12095. var cubicAt = curve.cubicAt;
  12096. var bezierLen = 0;
  12097. var idx = this._dashIdx;
  12098. var nDash = lineDash.length;
  12099. var x;
  12100. var y;
  12101. var tmpLen = 0;
  12102. if (offset < 0) {
  12103. // Convert to positive offset
  12104. offset = dashSum + offset;
  12105. }
  12106. offset %= dashSum;
  12107. // Bezier approx length
  12108. for (t = 0; t < 1; t += 0.1) {
  12109. dx = cubicAt(x0, x1, x2, x3, t + 0.1)
  12110. - cubicAt(x0, x1, x2, x3, t);
  12111. dy = cubicAt(y0, y1, y2, y3, t + 0.1)
  12112. - cubicAt(y0, y1, y2, y3, t);
  12113. bezierLen += mathSqrt(dx * dx + dy * dy);
  12114. }
  12115. // Find idx after add offset
  12116. for (; idx < nDash; idx++) {
  12117. tmpLen += lineDash[idx];
  12118. if (tmpLen > offset) {
  12119. break;
  12120. }
  12121. }
  12122. t = (tmpLen - offset) / bezierLen;
  12123. while (t <= 1) {
  12124. x = cubicAt(x0, x1, x2, x3, t);
  12125. y = cubicAt(y0, y1, y2, y3, t);
  12126. // Use line to approximate dashed bezier
  12127. // Bad result if dash is long
  12128. idx % 2 ? ctx.moveTo(x, y)
  12129. : ctx.lineTo(x, y);
  12130. t += lineDash[idx] / bezierLen;
  12131. idx = (idx + 1) % nDash;
  12132. }
  12133. // Finish the last segment and calculate the new offset
  12134. (idx % 2 !== 0) && ctx.lineTo(x3, y3);
  12135. dx = x3 - x;
  12136. dy = y3 - y;
  12137. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  12138. },
  12139. _dashedQuadraticTo: function (x1, y1, x2, y2) {
  12140. // Convert quadratic to cubic using degree elevation
  12141. var x3 = x2;
  12142. var y3 = y2;
  12143. x2 = (x2 + 2 * x1) / 3;
  12144. y2 = (y2 + 2 * y1) / 3;
  12145. x1 = (this._xi + 2 * x1) / 3;
  12146. y1 = (this._yi + 2 * y1) / 3;
  12147. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  12148. },
  12149. /**
  12150. * 转成静态的 Float32Array 减少堆内存占用
  12151. * Convert dynamic array to static Float32Array
  12152. */
  12153. toStatic: function () {
  12154. var data = this.data;
  12155. if (data instanceof Array) {
  12156. data.length = this._len;
  12157. if (hasTypedArray) {
  12158. this.data = new Float32Array(data);
  12159. }
  12160. }
  12161. },
  12162. /**
  12163. * @return {module:zrender/core/BoundingRect}
  12164. */
  12165. getBoundingRect: function () {
  12166. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  12167. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  12168. var data = this.data;
  12169. var xi = 0;
  12170. var yi = 0;
  12171. var x0 = 0;
  12172. var y0 = 0;
  12173. for (var i = 0; i < data.length;) {
  12174. var cmd = data[i++];
  12175. if (i == 1) {
  12176. // 如果第一个命令是 L, C, Q
  12177. // 则 previous point 同绘制命令的第一个 point
  12178. //
  12179. // 第一个命令为 Arc 的情况下会在后面特殊处理
  12180. xi = data[i];
  12181. yi = data[i + 1];
  12182. x0 = xi;
  12183. y0 = yi;
  12184. }
  12185. switch (cmd) {
  12186. case CMD.M:
  12187. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  12188. // 在 closePath 的时候使用
  12189. x0 = data[i++];
  12190. y0 = data[i++];
  12191. xi = x0;
  12192. yi = y0;
  12193. min2[0] = x0;
  12194. min2[1] = y0;
  12195. max2[0] = x0;
  12196. max2[1] = y0;
  12197. break;
  12198. case CMD.L:
  12199. bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  12200. xi = data[i++];
  12201. yi = data[i++];
  12202. break;
  12203. case CMD.C:
  12204. bbox.fromCubic(
  12205. xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  12206. min2, max2
  12207. );
  12208. xi = data[i++];
  12209. yi = data[i++];
  12210. break;
  12211. case CMD.Q:
  12212. bbox.fromQuadratic(
  12213. xi, yi, data[i++], data[i++], data[i], data[i + 1],
  12214. min2, max2
  12215. );
  12216. xi = data[i++];
  12217. yi = data[i++];
  12218. break;
  12219. case CMD.A:
  12220. // TODO Arc 判断的开销比较大
  12221. var cx = data[i++];
  12222. var cy = data[i++];
  12223. var rx = data[i++];
  12224. var ry = data[i++];
  12225. var startAngle = data[i++];
  12226. var endAngle = data[i++] + startAngle;
  12227. // TODO Arc 旋转
  12228. var psi = data[i++];
  12229. var anticlockwise = 1 - data[i++];
  12230. if (i == 1) {
  12231. // 直接使用 arc 命令
  12232. // 第一个命令起点还未定义
  12233. x0 = mathCos(startAngle) * rx + cx;
  12234. y0 = mathSin(startAngle) * ry + cy;
  12235. }
  12236. bbox.fromArc(
  12237. cx, cy, rx, ry, startAngle, endAngle,
  12238. anticlockwise, min2, max2
  12239. );
  12240. xi = mathCos(endAngle) * rx + cx;
  12241. yi = mathSin(endAngle) * ry + cy;
  12242. break;
  12243. case CMD.R:
  12244. x0 = xi = data[i++];
  12245. y0 = yi = data[i++];
  12246. var width = data[i++];
  12247. var height = data[i++];
  12248. // Use fromLine
  12249. bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  12250. break;
  12251. case CMD.Z:
  12252. xi = x0;
  12253. yi = y0;
  12254. break;
  12255. }
  12256. // Union
  12257. vec2.min(min, min, min2);
  12258. vec2.max(max, max, max2);
  12259. }
  12260. // No data
  12261. if (i === 0) {
  12262. min[0] = min[1] = max[0] = max[1] = 0;
  12263. }
  12264. return new BoundingRect(
  12265. min[0], min[1], max[0] - min[0], max[1] - min[1]
  12266. );
  12267. },
  12268. /**
  12269. * Rebuild path from current data
  12270. * Rebuild path will not consider javascript implemented line dash.
  12271. * @param {CanvasRenderingContext2D} ctx
  12272. */
  12273. rebuildPath: function (ctx) {
  12274. var d = this.data;
  12275. var x0, y0;
  12276. var xi, yi;
  12277. var x, y;
  12278. var ux = this._ux;
  12279. var uy = this._uy;
  12280. var len = this._len;
  12281. for (var i = 0; i < len;) {
  12282. var cmd = d[i++];
  12283. if (i == 1) {
  12284. // 如果第一个命令是 L, C, Q
  12285. // 则 previous point 同绘制命令的第一个 point
  12286. //
  12287. // 第一个命令为 Arc 的情况下会在后面特殊处理
  12288. xi = d[i];
  12289. yi = d[i + 1];
  12290. x0 = xi;
  12291. y0 = yi;
  12292. }
  12293. switch (cmd) {
  12294. case CMD.M:
  12295. x0 = xi = d[i++];
  12296. y0 = yi = d[i++];
  12297. ctx.moveTo(xi, yi);
  12298. break;
  12299. case CMD.L:
  12300. x = d[i++];
  12301. y = d[i++];
  12302. // Not draw too small seg between
  12303. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
  12304. ctx.lineTo(x, y);
  12305. xi = x;
  12306. yi = y;
  12307. }
  12308. break;
  12309. case CMD.C:
  12310. ctx.bezierCurveTo(
  12311. d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]
  12312. );
  12313. xi = d[i - 2];
  12314. yi = d[i - 1];
  12315. break;
  12316. case CMD.Q:
  12317. ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
  12318. xi = d[i - 2];
  12319. yi = d[i - 1];
  12320. break;
  12321. case CMD.A:
  12322. var cx = d[i++];
  12323. var cy = d[i++];
  12324. var rx = d[i++];
  12325. var ry = d[i++];
  12326. var theta = d[i++];
  12327. var dTheta = d[i++];
  12328. var psi = d[i++];
  12329. var fs = d[i++];
  12330. var r = (rx > ry) ? rx : ry;
  12331. var scaleX = (rx > ry) ? 1 : rx / ry;
  12332. var scaleY = (rx > ry) ? ry / rx : 1;
  12333. var isEllipse = Math.abs(rx - ry) > 1e-3;
  12334. var endAngle = theta + dTheta;
  12335. if (isEllipse) {
  12336. ctx.translate(cx, cy);
  12337. ctx.rotate(psi);
  12338. ctx.scale(scaleX, scaleY);
  12339. ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
  12340. ctx.scale(1 / scaleX, 1 / scaleY);
  12341. ctx.rotate(-psi);
  12342. ctx.translate(-cx, -cy);
  12343. }
  12344. else {
  12345. ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
  12346. }
  12347. if (i == 1) {
  12348. // 直接使用 arc 命令
  12349. // 第一个命令起点还未定义
  12350. x0 = mathCos(theta) * rx + cx;
  12351. y0 = mathSin(theta) * ry + cy;
  12352. }
  12353. xi = mathCos(endAngle) * rx + cx;
  12354. yi = mathSin(endAngle) * ry + cy;
  12355. break;
  12356. case CMD.R:
  12357. x0 = xi = d[i];
  12358. y0 = yi = d[i + 1];
  12359. ctx.rect(d[i++], d[i++], d[i++], d[i++]);
  12360. break;
  12361. case CMD.Z:
  12362. ctx.closePath();
  12363. xi = x0;
  12364. yi = y0;
  12365. }
  12366. }
  12367. }
  12368. };
  12369. PathProxy.CMD = CMD;
  12370. module.exports = PathProxy;
  12371. /***/ }),
  12372. /* 40 */
  12373. /***/ (function(module, exports, __webpack_require__) {
  12374. 'use strict';
  12375. /**
  12376. * 曲线辅助模块
  12377. * @module zrender/core/curve
  12378. * @author pissang(https://www.github.com/pissang)
  12379. */
  12380. var vec2 = __webpack_require__(10);
  12381. var v2Create = vec2.create;
  12382. var v2DistSquare = vec2.distSquare;
  12383. var mathPow = Math.pow;
  12384. var mathSqrt = Math.sqrt;
  12385. var EPSILON = 1e-8;
  12386. var EPSILON_NUMERIC = 1e-4;
  12387. var THREE_SQRT = mathSqrt(3);
  12388. var ONE_THIRD = 1 / 3;
  12389. // 临时变量
  12390. var _v0 = v2Create();
  12391. var _v1 = v2Create();
  12392. var _v2 = v2Create();
  12393. // var _v3 = vec2.create();
  12394. function isAroundZero(val) {
  12395. return val > -EPSILON && val < EPSILON;
  12396. }
  12397. function isNotAroundZero(val) {
  12398. return val > EPSILON || val < -EPSILON;
  12399. }
  12400. /**
  12401. * 计算三次贝塞尔值
  12402. * @memberOf module:zrender/core/curve
  12403. * @param {number} p0
  12404. * @param {number} p1
  12405. * @param {number} p2
  12406. * @param {number} p3
  12407. * @param {number} t
  12408. * @return {number}
  12409. */
  12410. function cubicAt(p0, p1, p2, p3, t) {
  12411. var onet = 1 - t;
  12412. return onet * onet * (onet * p0 + 3 * t * p1)
  12413. + t * t * (t * p3 + 3 * onet * p2);
  12414. }
  12415. /**
  12416. * 计算三次贝塞尔导数值
  12417. * @memberOf module:zrender/core/curve
  12418. * @param {number} p0
  12419. * @param {number} p1
  12420. * @param {number} p2
  12421. * @param {number} p3
  12422. * @param {number} t
  12423. * @return {number}
  12424. */
  12425. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  12426. var onet = 1 - t;
  12427. return 3 * (
  12428. ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet
  12429. + (p3 - p2) * t * t
  12430. );
  12431. }
  12432. /**
  12433. * 计算三次贝塞尔方程根,使用盛金公式
  12434. * @memberOf module:zrender/core/curve
  12435. * @param {number} p0
  12436. * @param {number} p1
  12437. * @param {number} p2
  12438. * @param {number} p3
  12439. * @param {number} val
  12440. * @param {Array.<number>} roots
  12441. * @return {number} 有效根数目
  12442. */
  12443. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  12444. // Evaluate roots of cubic functions
  12445. var a = p3 + 3 * (p1 - p2) - p0;
  12446. var b = 3 * (p2 - p1 * 2 + p0);
  12447. var c = 3 * (p1 - p0);
  12448. var d = p0 - val;
  12449. var A = b * b - 3 * a * c;
  12450. var B = b * c - 9 * a * d;
  12451. var C = c * c - 3 * b * d;
  12452. var n = 0;
  12453. if (isAroundZero(A) && isAroundZero(B)) {
  12454. if (isAroundZero(b)) {
  12455. roots[0] = 0;
  12456. }
  12457. else {
  12458. var t1 = -c / b; //t1, t2, t3, b is not zero
  12459. if (t1 >= 0 && t1 <= 1) {
  12460. roots[n++] = t1;
  12461. }
  12462. }
  12463. }
  12464. else {
  12465. var disc = B * B - 4 * A * C;
  12466. if (isAroundZero(disc)) {
  12467. var K = B / A;
  12468. var t1 = -b / a + K; // t1, a is not zero
  12469. var t2 = -K / 2; // t2, t3
  12470. if (t1 >= 0 && t1 <= 1) {
  12471. roots[n++] = t1;
  12472. }
  12473. if (t2 >= 0 && t2 <= 1) {
  12474. roots[n++] = t2;
  12475. }
  12476. }
  12477. else if (disc > 0) {
  12478. var discSqrt = mathSqrt(disc);
  12479. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  12480. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  12481. if (Y1 < 0) {
  12482. Y1 = -mathPow(-Y1, ONE_THIRD);
  12483. }
  12484. else {
  12485. Y1 = mathPow(Y1, ONE_THIRD);
  12486. }
  12487. if (Y2 < 0) {
  12488. Y2 = -mathPow(-Y2, ONE_THIRD);
  12489. }
  12490. else {
  12491. Y2 = mathPow(Y2, ONE_THIRD);
  12492. }
  12493. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  12494. if (t1 >= 0 && t1 <= 1) {
  12495. roots[n++] = t1;
  12496. }
  12497. }
  12498. else {
  12499. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A));
  12500. var theta = Math.acos(T) / 3;
  12501. var ASqrt = mathSqrt(A);
  12502. var tmp = Math.cos(theta);
  12503. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  12504. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  12505. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  12506. if (t1 >= 0 && t1 <= 1) {
  12507. roots[n++] = t1;
  12508. }
  12509. if (t2 >= 0 && t2 <= 1) {
  12510. roots[n++] = t2;
  12511. }
  12512. if (t3 >= 0 && t3 <= 1) {
  12513. roots[n++] = t3;
  12514. }
  12515. }
  12516. }
  12517. return n;
  12518. }
  12519. /**
  12520. * 计算三次贝塞尔方程极限值的位置
  12521. * @memberOf module:zrender/core/curve
  12522. * @param {number} p0
  12523. * @param {number} p1
  12524. * @param {number} p2
  12525. * @param {number} p3
  12526. * @param {Array.<number>} extrema
  12527. * @return {number} 有效数目
  12528. */
  12529. function cubicExtrema(p0, p1, p2, p3, extrema) {
  12530. var b = 6 * p2 - 12 * p1 + 6 * p0;
  12531. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  12532. var c = 3 * p1 - 3 * p0;
  12533. var n = 0;
  12534. if (isAroundZero(a)) {
  12535. if (isNotAroundZero(b)) {
  12536. var t1 = -c / b;
  12537. if (t1 >= 0 && t1 <=1) {
  12538. extrema[n++] = t1;
  12539. }
  12540. }
  12541. }
  12542. else {
  12543. var disc = b * b - 4 * a * c;
  12544. if (isAroundZero(disc)) {
  12545. extrema[0] = -b / (2 * a);
  12546. }
  12547. else if (disc > 0) {
  12548. var discSqrt = mathSqrt(disc);
  12549. var t1 = (-b + discSqrt) / (2 * a);
  12550. var t2 = (-b - discSqrt) / (2 * a);
  12551. if (t1 >= 0 && t1 <= 1) {
  12552. extrema[n++] = t1;
  12553. }
  12554. if (t2 >= 0 && t2 <= 1) {
  12555. extrema[n++] = t2;
  12556. }
  12557. }
  12558. }
  12559. return n;
  12560. }
  12561. /**
  12562. * 细分三次贝塞尔曲线
  12563. * @memberOf module:zrender/core/curve
  12564. * @param {number} p0
  12565. * @param {number} p1
  12566. * @param {number} p2
  12567. * @param {number} p3
  12568. * @param {number} t
  12569. * @param {Array.<number>} out
  12570. */
  12571. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  12572. var p01 = (p1 - p0) * t + p0;
  12573. var p12 = (p2 - p1) * t + p1;
  12574. var p23 = (p3 - p2) * t + p2;
  12575. var p012 = (p12 - p01) * t + p01;
  12576. var p123 = (p23 - p12) * t + p12;
  12577. var p0123 = (p123 - p012) * t + p012;
  12578. // Seg0
  12579. out[0] = p0;
  12580. out[1] = p01;
  12581. out[2] = p012;
  12582. out[3] = p0123;
  12583. // Seg1
  12584. out[4] = p0123;
  12585. out[5] = p123;
  12586. out[6] = p23;
  12587. out[7] = p3;
  12588. }
  12589. /**
  12590. * 投射点到三次贝塞尔曲线上,返回投射距离。
  12591. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  12592. * @param {number} x0
  12593. * @param {number} y0
  12594. * @param {number} x1
  12595. * @param {number} y1
  12596. * @param {number} x2
  12597. * @param {number} y2
  12598. * @param {number} x3
  12599. * @param {number} y3
  12600. * @param {number} x
  12601. * @param {number} y
  12602. * @param {Array.<number>} [out] 投射点
  12603. * @return {number}
  12604. */
  12605. function cubicProjectPoint(
  12606. x0, y0, x1, y1, x2, y2, x3, y3,
  12607. x, y, out
  12608. ) {
  12609. // http://pomax.github.io/bezierinfo/#projections
  12610. var t;
  12611. var interval = 0.005;
  12612. var d = Infinity;
  12613. var prev;
  12614. var next;
  12615. var d1;
  12616. var d2;
  12617. _v0[0] = x;
  12618. _v0[1] = y;
  12619. // 先粗略估计一下可能的最小距离的 t 值
  12620. // PENDING
  12621. for (var _t = 0; _t < 1; _t += 0.05) {
  12622. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  12623. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  12624. d1 = v2DistSquare(_v0, _v1);
  12625. if (d1 < d) {
  12626. t = _t;
  12627. d = d1;
  12628. }
  12629. }
  12630. d = Infinity;
  12631. // At most 32 iteration
  12632. for (var i = 0; i < 32; i++) {
  12633. if (interval < EPSILON_NUMERIC) {
  12634. break;
  12635. }
  12636. prev = t - interval;
  12637. next = t + interval;
  12638. // t - interval
  12639. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  12640. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  12641. d1 = v2DistSquare(_v1, _v0);
  12642. if (prev >= 0 && d1 < d) {
  12643. t = prev;
  12644. d = d1;
  12645. }
  12646. else {
  12647. // t + interval
  12648. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  12649. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  12650. d2 = v2DistSquare(_v2, _v0);
  12651. if (next <= 1 && d2 < d) {
  12652. t = next;
  12653. d = d2;
  12654. }
  12655. else {
  12656. interval *= 0.5;
  12657. }
  12658. }
  12659. }
  12660. // t
  12661. if (out) {
  12662. out[0] = cubicAt(x0, x1, x2, x3, t);
  12663. out[1] = cubicAt(y0, y1, y2, y3, t);
  12664. }
  12665. // console.log(interval, i);
  12666. return mathSqrt(d);
  12667. }
  12668. /**
  12669. * 计算二次方贝塞尔值
  12670. * @param {number} p0
  12671. * @param {number} p1
  12672. * @param {number} p2
  12673. * @param {number} t
  12674. * @return {number}
  12675. */
  12676. function quadraticAt(p0, p1, p2, t) {
  12677. var onet = 1 - t;
  12678. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  12679. }
  12680. /**
  12681. * 计算二次方贝塞尔导数值
  12682. * @param {number} p0
  12683. * @param {number} p1
  12684. * @param {number} p2
  12685. * @param {number} t
  12686. * @return {number}
  12687. */
  12688. function quadraticDerivativeAt(p0, p1, p2, t) {
  12689. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  12690. }
  12691. /**
  12692. * 计算二次方贝塞尔方程根
  12693. * @param {number} p0
  12694. * @param {number} p1
  12695. * @param {number} p2
  12696. * @param {number} t
  12697. * @param {Array.<number>} roots
  12698. * @return {number} 有效根数目
  12699. */
  12700. function quadraticRootAt(p0, p1, p2, val, roots) {
  12701. var a = p0 - 2 * p1 + p2;
  12702. var b = 2 * (p1 - p0);
  12703. var c = p0 - val;
  12704. var n = 0;
  12705. if (isAroundZero(a)) {
  12706. if (isNotAroundZero(b)) {
  12707. var t1 = -c / b;
  12708. if (t1 >= 0 && t1 <= 1) {
  12709. roots[n++] = t1;
  12710. }
  12711. }
  12712. }
  12713. else {
  12714. var disc = b * b - 4 * a * c;
  12715. if (isAroundZero(disc)) {
  12716. var t1 = -b / (2 * a);
  12717. if (t1 >= 0 && t1 <= 1) {
  12718. roots[n++] = t1;
  12719. }
  12720. }
  12721. else if (disc > 0) {
  12722. var discSqrt = mathSqrt(disc);
  12723. var t1 = (-b + discSqrt) / (2 * a);
  12724. var t2 = (-b - discSqrt) / (2 * a);
  12725. if (t1 >= 0 && t1 <= 1) {
  12726. roots[n++] = t1;
  12727. }
  12728. if (t2 >= 0 && t2 <= 1) {
  12729. roots[n++] = t2;
  12730. }
  12731. }
  12732. }
  12733. return n;
  12734. }
  12735. /**
  12736. * 计算二次贝塞尔方程极限值
  12737. * @memberOf module:zrender/core/curve
  12738. * @param {number} p0
  12739. * @param {number} p1
  12740. * @param {number} p2
  12741. * @return {number}
  12742. */
  12743. function quadraticExtremum(p0, p1, p2) {
  12744. var divider = p0 + p2 - 2 * p1;
  12745. if (divider === 0) {
  12746. // p1 is center of p0 and p2
  12747. return 0.5;
  12748. }
  12749. else {
  12750. return (p0 - p1) / divider;
  12751. }
  12752. }
  12753. /**
  12754. * 细分二次贝塞尔曲线
  12755. * @memberOf module:zrender/core/curve
  12756. * @param {number} p0
  12757. * @param {number} p1
  12758. * @param {number} p2
  12759. * @param {number} t
  12760. * @param {Array.<number>} out
  12761. */
  12762. function quadraticSubdivide(p0, p1, p2, t, out) {
  12763. var p01 = (p1 - p0) * t + p0;
  12764. var p12 = (p2 - p1) * t + p1;
  12765. var p012 = (p12 - p01) * t + p01;
  12766. // Seg0
  12767. out[0] = p0;
  12768. out[1] = p01;
  12769. out[2] = p012;
  12770. // Seg1
  12771. out[3] = p012;
  12772. out[4] = p12;
  12773. out[5] = p2;
  12774. }
  12775. /**
  12776. * 投射点到二次贝塞尔曲线上,返回投射距离。
  12777. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  12778. * @param {number} x0
  12779. * @param {number} y0
  12780. * @param {number} x1
  12781. * @param {number} y1
  12782. * @param {number} x2
  12783. * @param {number} y2
  12784. * @param {number} x
  12785. * @param {number} y
  12786. * @param {Array.<number>} out 投射点
  12787. * @return {number}
  12788. */
  12789. function quadraticProjectPoint(
  12790. x0, y0, x1, y1, x2, y2,
  12791. x, y, out
  12792. ) {
  12793. // http://pomax.github.io/bezierinfo/#projections
  12794. var t;
  12795. var interval = 0.005;
  12796. var d = Infinity;
  12797. _v0[0] = x;
  12798. _v0[1] = y;
  12799. // 先粗略估计一下可能的最小距离的 t 值
  12800. // PENDING
  12801. for (var _t = 0; _t < 1; _t += 0.05) {
  12802. _v1[0] = quadraticAt(x0, x1, x2, _t);
  12803. _v1[1] = quadraticAt(y0, y1, y2, _t);
  12804. var d1 = v2DistSquare(_v0, _v1);
  12805. if (d1 < d) {
  12806. t = _t;
  12807. d = d1;
  12808. }
  12809. }
  12810. d = Infinity;
  12811. // At most 32 iteration
  12812. for (var i = 0; i < 32; i++) {
  12813. if (interval < EPSILON_NUMERIC) {
  12814. break;
  12815. }
  12816. var prev = t - interval;
  12817. var next = t + interval;
  12818. // t - interval
  12819. _v1[0] = quadraticAt(x0, x1, x2, prev);
  12820. _v1[1] = quadraticAt(y0, y1, y2, prev);
  12821. var d1 = v2DistSquare(_v1, _v0);
  12822. if (prev >= 0 && d1 < d) {
  12823. t = prev;
  12824. d = d1;
  12825. }
  12826. else {
  12827. // t + interval
  12828. _v2[0] = quadraticAt(x0, x1, x2, next);
  12829. _v2[1] = quadraticAt(y0, y1, y2, next);
  12830. var d2 = v2DistSquare(_v2, _v0);
  12831. if (next <= 1 && d2 < d) {
  12832. t = next;
  12833. d = d2;
  12834. }
  12835. else {
  12836. interval *= 0.5;
  12837. }
  12838. }
  12839. }
  12840. // t
  12841. if (out) {
  12842. out[0] = quadraticAt(x0, x1, x2, t);
  12843. out[1] = quadraticAt(y0, y1, y2, t);
  12844. }
  12845. // console.log(interval, i);
  12846. return mathSqrt(d);
  12847. }
  12848. module.exports = {
  12849. cubicAt: cubicAt,
  12850. cubicDerivativeAt: cubicDerivativeAt,
  12851. cubicRootAt: cubicRootAt,
  12852. cubicExtrema: cubicExtrema,
  12853. cubicSubdivide: cubicSubdivide,
  12854. cubicProjectPoint: cubicProjectPoint,
  12855. quadraticAt: quadraticAt,
  12856. quadraticDerivativeAt: quadraticDerivativeAt,
  12857. quadraticRootAt: quadraticRootAt,
  12858. quadraticExtremum: quadraticExtremum,
  12859. quadraticSubdivide: quadraticSubdivide,
  12860. quadraticProjectPoint: quadraticProjectPoint
  12861. };
  12862. /***/ }),
  12863. /* 41 */
  12864. /***/ (function(module, exports, __webpack_require__) {
  12865. /**
  12866. * @author Yi Shen(https://github.com/pissang)
  12867. */
  12868. var vec2 = __webpack_require__(10);
  12869. var curve = __webpack_require__(40);
  12870. var bbox = {};
  12871. var mathMin = Math.min;
  12872. var mathMax = Math.max;
  12873. var mathSin = Math.sin;
  12874. var mathCos = Math.cos;
  12875. var start = vec2.create();
  12876. var end = vec2.create();
  12877. var extremity = vec2.create();
  12878. var PI2 = Math.PI * 2;
  12879. /**
  12880. * 从顶点数组中计算出最小包围盒,写入`min`和`max`中
  12881. * @module zrender/core/bbox
  12882. * @param {Array<Object>} points 顶点数组
  12883. * @param {number} min
  12884. * @param {number} max
  12885. */
  12886. bbox.fromPoints = function(points, min, max) {
  12887. if (points.length === 0) {
  12888. return;
  12889. }
  12890. var p = points[0];
  12891. var left = p[0];
  12892. var right = p[0];
  12893. var top = p[1];
  12894. var bottom = p[1];
  12895. var i;
  12896. for (i = 1; i < points.length; i++) {
  12897. p = points[i];
  12898. left = mathMin(left, p[0]);
  12899. right = mathMax(right, p[0]);
  12900. top = mathMin(top, p[1]);
  12901. bottom = mathMax(bottom, p[1]);
  12902. }
  12903. min[0] = left;
  12904. min[1] = top;
  12905. max[0] = right;
  12906. max[1] = bottom;
  12907. };
  12908. /**
  12909. * @memberOf module:zrender/core/bbox
  12910. * @param {number} x0
  12911. * @param {number} y0
  12912. * @param {number} x1
  12913. * @param {number} y1
  12914. * @param {Array.<number>} min
  12915. * @param {Array.<number>} max
  12916. */
  12917. bbox.fromLine = function (x0, y0, x1, y1, min, max) {
  12918. min[0] = mathMin(x0, x1);
  12919. min[1] = mathMin(y0, y1);
  12920. max[0] = mathMax(x0, x1);
  12921. max[1] = mathMax(y0, y1);
  12922. };
  12923. var xDim = [];
  12924. var yDim = [];
  12925. /**
  12926. * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中
  12927. * @memberOf module:zrender/core/bbox
  12928. * @param {number} x0
  12929. * @param {number} y0
  12930. * @param {number} x1
  12931. * @param {number} y1
  12932. * @param {number} x2
  12933. * @param {number} y2
  12934. * @param {number} x3
  12935. * @param {number} y3
  12936. * @param {Array.<number>} min
  12937. * @param {Array.<number>} max
  12938. */
  12939. bbox.fromCubic = function(
  12940. x0, y0, x1, y1, x2, y2, x3, y3, min, max
  12941. ) {
  12942. var cubicExtrema = curve.cubicExtrema;
  12943. var cubicAt = curve.cubicAt;
  12944. var i;
  12945. var n = cubicExtrema(x0, x1, x2, x3, xDim);
  12946. min[0] = Infinity;
  12947. min[1] = Infinity;
  12948. max[0] = -Infinity;
  12949. max[1] = -Infinity;
  12950. for (i = 0; i < n; i++) {
  12951. var x = cubicAt(x0, x1, x2, x3, xDim[i]);
  12952. min[0] = mathMin(x, min[0]);
  12953. max[0] = mathMax(x, max[0]);
  12954. }
  12955. n = cubicExtrema(y0, y1, y2, y3, yDim);
  12956. for (i = 0; i < n; i++) {
  12957. var y = cubicAt(y0, y1, y2, y3, yDim[i]);
  12958. min[1] = mathMin(y, min[1]);
  12959. max[1] = mathMax(y, max[1]);
  12960. }
  12961. min[0] = mathMin(x0, min[0]);
  12962. max[0] = mathMax(x0, max[0]);
  12963. min[0] = mathMin(x3, min[0]);
  12964. max[0] = mathMax(x3, max[0]);
  12965. min[1] = mathMin(y0, min[1]);
  12966. max[1] = mathMax(y0, max[1]);
  12967. min[1] = mathMin(y3, min[1]);
  12968. max[1] = mathMax(y3, max[1]);
  12969. };
  12970. /**
  12971. * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中
  12972. * @memberOf module:zrender/core/bbox
  12973. * @param {number} x0
  12974. * @param {number} y0
  12975. * @param {number} x1
  12976. * @param {number} y1
  12977. * @param {number} x2
  12978. * @param {number} y2
  12979. * @param {Array.<number>} min
  12980. * @param {Array.<number>} max
  12981. */
  12982. bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) {
  12983. var quadraticExtremum = curve.quadraticExtremum;
  12984. var quadraticAt = curve.quadraticAt;
  12985. // Find extremities, where derivative in x dim or y dim is zero
  12986. var tx =
  12987. mathMax(
  12988. mathMin(quadraticExtremum(x0, x1, x2), 1), 0
  12989. );
  12990. var ty =
  12991. mathMax(
  12992. mathMin(quadraticExtremum(y0, y1, y2), 1), 0
  12993. );
  12994. var x = quadraticAt(x0, x1, x2, tx);
  12995. var y = quadraticAt(y0, y1, y2, ty);
  12996. min[0] = mathMin(x0, x2, x);
  12997. min[1] = mathMin(y0, y2, y);
  12998. max[0] = mathMax(x0, x2, x);
  12999. max[1] = mathMax(y0, y2, y);
  13000. };
  13001. /**
  13002. * 从圆弧中计算出最小包围盒,写入`min`和`max`中
  13003. * @method
  13004. * @memberOf module:zrender/core/bbox
  13005. * @param {number} x
  13006. * @param {number} y
  13007. * @param {number} rx
  13008. * @param {number} ry
  13009. * @param {number} startAngle
  13010. * @param {number} endAngle
  13011. * @param {number} anticlockwise
  13012. * @param {Array.<number>} min
  13013. * @param {Array.<number>} max
  13014. */
  13015. bbox.fromArc = function (
  13016. x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max
  13017. ) {
  13018. var vec2Min = vec2.min;
  13019. var vec2Max = vec2.max;
  13020. var diff = Math.abs(startAngle - endAngle);
  13021. if (diff % PI2 < 1e-4 && diff > 1e-4) {
  13022. // Is a circle
  13023. min[0] = x - rx;
  13024. min[1] = y - ry;
  13025. max[0] = x + rx;
  13026. max[1] = y + ry;
  13027. return;
  13028. }
  13029. start[0] = mathCos(startAngle) * rx + x;
  13030. start[1] = mathSin(startAngle) * ry + y;
  13031. end[0] = mathCos(endAngle) * rx + x;
  13032. end[1] = mathSin(endAngle) * ry + y;
  13033. vec2Min(min, start, end);
  13034. vec2Max(max, start, end);
  13035. // Thresh to [0, Math.PI * 2]
  13036. startAngle = startAngle % (PI2);
  13037. if (startAngle < 0) {
  13038. startAngle = startAngle + PI2;
  13039. }
  13040. endAngle = endAngle % (PI2);
  13041. if (endAngle < 0) {
  13042. endAngle = endAngle + PI2;
  13043. }
  13044. if (startAngle > endAngle && !anticlockwise) {
  13045. endAngle += PI2;
  13046. }
  13047. else if (startAngle < endAngle && anticlockwise) {
  13048. startAngle += PI2;
  13049. }
  13050. if (anticlockwise) {
  13051. var tmp = endAngle;
  13052. endAngle = startAngle;
  13053. startAngle = tmp;
  13054. }
  13055. // var number = 0;
  13056. // var step = (anticlockwise ? -Math.PI : Math.PI) / 2;
  13057. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  13058. if (angle > startAngle) {
  13059. extremity[0] = mathCos(angle) * rx + x;
  13060. extremity[1] = mathSin(angle) * ry + y;
  13061. vec2Min(min, extremity, min);
  13062. vec2Max(max, extremity, max);
  13063. }
  13064. }
  13065. };
  13066. module.exports = bbox;
  13067. /***/ }),
  13068. /* 42 */
  13069. /***/ (function(module, exports, __webpack_require__) {
  13070. 'use strict';
  13071. var CMD = __webpack_require__(39).CMD;
  13072. var line = __webpack_require__(43);
  13073. var cubic = __webpack_require__(44);
  13074. var quadratic = __webpack_require__(45);
  13075. var arc = __webpack_require__(46);
  13076. var normalizeRadian = __webpack_require__(47).normalizeRadian;
  13077. var curve = __webpack_require__(40);
  13078. var windingLine = __webpack_require__(48);
  13079. var containStroke = line.containStroke;
  13080. var PI2 = Math.PI * 2;
  13081. var EPSILON = 1e-4;
  13082. function isAroundEqual(a, b) {
  13083. return Math.abs(a - b) < EPSILON;
  13084. }
  13085. // 临时数组
  13086. var roots = [-1, -1, -1];
  13087. var extrema = [-1, -1];
  13088. function swapExtrema() {
  13089. var tmp = extrema[0];
  13090. extrema[0] = extrema[1];
  13091. extrema[1] = tmp;
  13092. }
  13093. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  13094. // Quick reject
  13095. if (
  13096. (y > y0 && y > y1 && y > y2 && y > y3)
  13097. || (y < y0 && y < y1 && y < y2 && y < y3)
  13098. ) {
  13099. return 0;
  13100. }
  13101. var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
  13102. if (nRoots === 0) {
  13103. return 0;
  13104. }
  13105. else {
  13106. var w = 0;
  13107. var nExtrema = -1;
  13108. var y0_, y1_;
  13109. for (var i = 0; i < nRoots; i++) {
  13110. var t = roots[i];
  13111. // Avoid winding error when intersection point is the connect point of two line of polygon
  13112. var unit = (t === 0 || t === 1) ? 0.5 : 1;
  13113. var x_ = curve.cubicAt(x0, x1, x2, x3, t);
  13114. if (x_ < x) { // Quick reject
  13115. continue;
  13116. }
  13117. if (nExtrema < 0) {
  13118. nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
  13119. if (extrema[1] < extrema[0] && nExtrema > 1) {
  13120. swapExtrema();
  13121. }
  13122. y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
  13123. if (nExtrema > 1) {
  13124. y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
  13125. }
  13126. }
  13127. if (nExtrema == 2) {
  13128. // 分成三段单调函数
  13129. if (t < extrema[0]) {
  13130. w += y0_ < y0 ? unit : -unit;
  13131. }
  13132. else if (t < extrema[1]) {
  13133. w += y1_ < y0_ ? unit : -unit;
  13134. }
  13135. else {
  13136. w += y3 < y1_ ? unit : -unit;
  13137. }
  13138. }
  13139. else {
  13140. // 分成两段单调函数
  13141. if (t < extrema[0]) {
  13142. w += y0_ < y0 ? unit : -unit;
  13143. }
  13144. else {
  13145. w += y3 < y0_ ? unit : -unit;
  13146. }
  13147. }
  13148. }
  13149. return w;
  13150. }
  13151. }
  13152. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  13153. // Quick reject
  13154. if (
  13155. (y > y0 && y > y1 && y > y2)
  13156. || (y < y0 && y < y1 && y < y2)
  13157. ) {
  13158. return 0;
  13159. }
  13160. var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
  13161. if (nRoots === 0) {
  13162. return 0;
  13163. }
  13164. else {
  13165. var t = curve.quadraticExtremum(y0, y1, y2);
  13166. if (t >= 0 && t <= 1) {
  13167. var w = 0;
  13168. var y_ = curve.quadraticAt(y0, y1, y2, t);
  13169. for (var i = 0; i < nRoots; i++) {
  13170. // Remove one endpoint.
  13171. var unit = (roots[i] === 0 || roots[i] === 1) ? 0.5 : 1;
  13172. var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
  13173. if (x_ < x) { // Quick reject
  13174. continue;
  13175. }
  13176. if (roots[i] < t) {
  13177. w += y_ < y0 ? unit : -unit;
  13178. }
  13179. else {
  13180. w += y2 < y_ ? unit : -unit;
  13181. }
  13182. }
  13183. return w;
  13184. }
  13185. else {
  13186. // Remove one endpoint.
  13187. var unit = (roots[0] === 0 || roots[0] === 1) ? 0.5 : 1;
  13188. var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
  13189. if (x_ < x) { // Quick reject
  13190. return 0;
  13191. }
  13192. return y2 < y0 ? unit : -unit;
  13193. }
  13194. }
  13195. }
  13196. // TODO
  13197. // Arc 旋转
  13198. function windingArc(
  13199. cx, cy, r, startAngle, endAngle, anticlockwise, x, y
  13200. ) {
  13201. y -= cy;
  13202. if (y > r || y < -r) {
  13203. return 0;
  13204. }
  13205. var tmp = Math.sqrt(r * r - y * y);
  13206. roots[0] = -tmp;
  13207. roots[1] = tmp;
  13208. var diff = Math.abs(startAngle - endAngle);
  13209. if (diff < 1e-4) {
  13210. return 0;
  13211. }
  13212. if (diff % PI2 < 1e-4) {
  13213. // Is a circle
  13214. startAngle = 0;
  13215. endAngle = PI2;
  13216. var dir = anticlockwise ? 1 : -1;
  13217. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  13218. return dir;
  13219. } else {
  13220. return 0;
  13221. }
  13222. }
  13223. if (anticlockwise) {
  13224. var tmp = startAngle;
  13225. startAngle = normalizeRadian(endAngle);
  13226. endAngle = normalizeRadian(tmp);
  13227. }
  13228. else {
  13229. startAngle = normalizeRadian(startAngle);
  13230. endAngle = normalizeRadian(endAngle);
  13231. }
  13232. if (startAngle > endAngle) {
  13233. endAngle += PI2;
  13234. }
  13235. var w = 0;
  13236. for (var i = 0; i < 2; i++) {
  13237. var x_ = roots[i];
  13238. if (x_ + cx > x) {
  13239. var angle = Math.atan2(y, x_);
  13240. var dir = anticlockwise ? 1 : -1;
  13241. if (angle < 0) {
  13242. angle = PI2 + angle;
  13243. }
  13244. if (
  13245. (angle >= startAngle && angle <= endAngle)
  13246. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle)
  13247. ) {
  13248. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  13249. dir = -dir;
  13250. }
  13251. w += dir;
  13252. }
  13253. }
  13254. }
  13255. return w;
  13256. }
  13257. function containPath(data, lineWidth, isStroke, x, y) {
  13258. var w = 0;
  13259. var xi = 0;
  13260. var yi = 0;
  13261. var x0 = 0;
  13262. var y0 = 0;
  13263. for (var i = 0; i < data.length;) {
  13264. var cmd = data[i++];
  13265. // Begin a new subpath
  13266. if (cmd === CMD.M && i > 1) {
  13267. // Close previous subpath
  13268. if (!isStroke) {
  13269. w += windingLine(xi, yi, x0, y0, x, y);
  13270. }
  13271. // 如果被任何一个 subpath 包含
  13272. // if (w !== 0) {
  13273. // return true;
  13274. // }
  13275. }
  13276. if (i == 1) {
  13277. // 如果第一个命令是 L, C, Q
  13278. // 则 previous point 同绘制命令的第一个 point
  13279. //
  13280. // 第一个命令为 Arc 的情况下会在后面特殊处理
  13281. xi = data[i];
  13282. yi = data[i + 1];
  13283. x0 = xi;
  13284. y0 = yi;
  13285. }
  13286. switch (cmd) {
  13287. case CMD.M:
  13288. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  13289. // 在 closePath 的时候使用
  13290. x0 = data[i++];
  13291. y0 = data[i++];
  13292. xi = x0;
  13293. yi = y0;
  13294. break;
  13295. case CMD.L:
  13296. if (isStroke) {
  13297. if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  13298. return true;
  13299. }
  13300. }
  13301. else {
  13302. // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN
  13303. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  13304. }
  13305. xi = data[i++];
  13306. yi = data[i++];
  13307. break;
  13308. case CMD.C:
  13309. if (isStroke) {
  13310. if (cubic.containStroke(xi, yi,
  13311. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  13312. lineWidth, x, y
  13313. )) {
  13314. return true;
  13315. }
  13316. }
  13317. else {
  13318. w += windingCubic(
  13319. xi, yi,
  13320. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  13321. x, y
  13322. ) || 0;
  13323. }
  13324. xi = data[i++];
  13325. yi = data[i++];
  13326. break;
  13327. case CMD.Q:
  13328. if (isStroke) {
  13329. if (quadratic.containStroke(xi, yi,
  13330. data[i++], data[i++], data[i], data[i + 1],
  13331. lineWidth, x, y
  13332. )) {
  13333. return true;
  13334. }
  13335. }
  13336. else {
  13337. w += windingQuadratic(
  13338. xi, yi,
  13339. data[i++], data[i++], data[i], data[i + 1],
  13340. x, y
  13341. ) || 0;
  13342. }
  13343. xi = data[i++];
  13344. yi = data[i++];
  13345. break;
  13346. case CMD.A:
  13347. // TODO Arc 判断的开销比较大
  13348. var cx = data[i++];
  13349. var cy = data[i++];
  13350. var rx = data[i++];
  13351. var ry = data[i++];
  13352. var theta = data[i++];
  13353. var dTheta = data[i++];
  13354. // TODO Arc 旋转
  13355. var psi = data[i++];
  13356. var anticlockwise = 1 - data[i++];
  13357. var x1 = Math.cos(theta) * rx + cx;
  13358. var y1 = Math.sin(theta) * ry + cy;
  13359. // 不是直接使用 arc 命令
  13360. if (i > 1) {
  13361. w += windingLine(xi, yi, x1, y1, x, y);
  13362. }
  13363. else {
  13364. // 第一个命令起点还未定义
  13365. x0 = x1;
  13366. y0 = y1;
  13367. }
  13368. // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  13369. var _x = (x - cx) * ry / rx + cx;
  13370. if (isStroke) {
  13371. if (arc.containStroke(
  13372. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  13373. lineWidth, _x, y
  13374. )) {
  13375. return true;
  13376. }
  13377. }
  13378. else {
  13379. w += windingArc(
  13380. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  13381. _x, y
  13382. );
  13383. }
  13384. xi = Math.cos(theta + dTheta) * rx + cx;
  13385. yi = Math.sin(theta + dTheta) * ry + cy;
  13386. break;
  13387. case CMD.R:
  13388. x0 = xi = data[i++];
  13389. y0 = yi = data[i++];
  13390. var width = data[i++];
  13391. var height = data[i++];
  13392. var x1 = x0 + width;
  13393. var y1 = y0 + height;
  13394. if (isStroke) {
  13395. if (containStroke(x0, y0, x1, y0, lineWidth, x, y)
  13396. || containStroke(x1, y0, x1, y1, lineWidth, x, y)
  13397. || containStroke(x1, y1, x0, y1, lineWidth, x, y)
  13398. || containStroke(x0, y1, x0, y0, lineWidth, x, y)
  13399. ) {
  13400. return true;
  13401. }
  13402. }
  13403. else {
  13404. // FIXME Clockwise ?
  13405. w += windingLine(x1, y0, x1, y1, x, y);
  13406. w += windingLine(x0, y1, x0, y0, x, y);
  13407. }
  13408. break;
  13409. case CMD.Z:
  13410. if (isStroke) {
  13411. if (containStroke(
  13412. xi, yi, x0, y0, lineWidth, x, y
  13413. )) {
  13414. return true;
  13415. }
  13416. }
  13417. else {
  13418. // Close a subpath
  13419. w += windingLine(xi, yi, x0, y0, x, y);
  13420. // 如果被任何一个 subpath 包含
  13421. // FIXME subpaths may overlap
  13422. // if (w !== 0) {
  13423. // return true;
  13424. // }
  13425. }
  13426. xi = x0;
  13427. yi = y0;
  13428. break;
  13429. }
  13430. }
  13431. if (!isStroke && !isAroundEqual(yi, y0)) {
  13432. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  13433. }
  13434. return w !== 0;
  13435. }
  13436. module.exports = {
  13437. contain: function (pathData, x, y) {
  13438. return containPath(pathData, 0, false, x, y);
  13439. },
  13440. containStroke: function (pathData, lineWidth, x, y) {
  13441. return containPath(pathData, lineWidth, true, x, y);
  13442. }
  13443. };
  13444. /***/ }),
  13445. /* 43 */
  13446. /***/ (function(module, exports) {
  13447. module.exports = {
  13448. /**
  13449. * 线段包含判断
  13450. * @param {number} x0
  13451. * @param {number} y0
  13452. * @param {number} x1
  13453. * @param {number} y1
  13454. * @param {number} lineWidth
  13455. * @param {number} x
  13456. * @param {number} y
  13457. * @return {boolean}
  13458. */
  13459. containStroke: function (x0, y0, x1, y1, lineWidth, x, y) {
  13460. if (lineWidth === 0) {
  13461. return false;
  13462. }
  13463. var _l = lineWidth;
  13464. var _a = 0;
  13465. var _b = x0;
  13466. // Quick reject
  13467. if (
  13468. (y > y0 + _l && y > y1 + _l)
  13469. || (y < y0 - _l && y < y1 - _l)
  13470. || (x > x0 + _l && x > x1 + _l)
  13471. || (x < x0 - _l && x < x1 - _l)
  13472. ) {
  13473. return false;
  13474. }
  13475. if (x0 !== x1) {
  13476. _a = (y0 - y1) / (x0 - x1);
  13477. _b = (x0 * y1 - x1 * y0) / (x0 - x1) ;
  13478. }
  13479. else {
  13480. return Math.abs(x - x0) <= _l / 2;
  13481. }
  13482. var tmp = _a * x - y + _b;
  13483. var _s = tmp * tmp / (_a * _a + 1);
  13484. return _s <= _l / 2 * _l / 2;
  13485. }
  13486. };
  13487. /***/ }),
  13488. /* 44 */
  13489. /***/ (function(module, exports, __webpack_require__) {
  13490. var curve = __webpack_require__(40);
  13491. module.exports = {
  13492. /**
  13493. * 三次贝塞尔曲线描边包含判断
  13494. * @param {number} x0
  13495. * @param {number} y0
  13496. * @param {number} x1
  13497. * @param {number} y1
  13498. * @param {number} x2
  13499. * @param {number} y2
  13500. * @param {number} x3
  13501. * @param {number} y3
  13502. * @param {number} lineWidth
  13503. * @param {number} x
  13504. * @param {number} y
  13505. * @return {boolean}
  13506. */
  13507. containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  13508. if (lineWidth === 0) {
  13509. return false;
  13510. }
  13511. var _l = lineWidth;
  13512. // Quick reject
  13513. if (
  13514. (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
  13515. || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
  13516. || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
  13517. || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
  13518. ) {
  13519. return false;
  13520. }
  13521. var d = curve.cubicProjectPoint(
  13522. x0, y0, x1, y1, x2, y2, x3, y3,
  13523. x, y, null
  13524. );
  13525. return d <= _l / 2;
  13526. }
  13527. };
  13528. /***/ }),
  13529. /* 45 */
  13530. /***/ (function(module, exports, __webpack_require__) {
  13531. var curve = __webpack_require__(40);
  13532. module.exports = {
  13533. /**
  13534. * 二次贝塞尔曲线描边包含判断
  13535. * @param {number} x0
  13536. * @param {number} y0
  13537. * @param {number} x1
  13538. * @param {number} y1
  13539. * @param {number} x2
  13540. * @param {number} y2
  13541. * @param {number} lineWidth
  13542. * @param {number} x
  13543. * @param {number} y
  13544. * @return {boolean}
  13545. */
  13546. containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  13547. if (lineWidth === 0) {
  13548. return false;
  13549. }
  13550. var _l = lineWidth;
  13551. // Quick reject
  13552. if (
  13553. (y > y0 + _l && y > y1 + _l && y > y2 + _l)
  13554. || (y < y0 - _l && y < y1 - _l && y < y2 - _l)
  13555. || (x > x0 + _l && x > x1 + _l && x > x2 + _l)
  13556. || (x < x0 - _l && x < x1 - _l && x < x2 - _l)
  13557. ) {
  13558. return false;
  13559. }
  13560. var d = curve.quadraticProjectPoint(
  13561. x0, y0, x1, y1, x2, y2,
  13562. x, y, null
  13563. );
  13564. return d <= _l / 2;
  13565. }
  13566. };
  13567. /***/ }),
  13568. /* 46 */
  13569. /***/ (function(module, exports, __webpack_require__) {
  13570. var normalizeRadian = __webpack_require__(47).normalizeRadian;
  13571. var PI2 = Math.PI * 2;
  13572. module.exports = {
  13573. /**
  13574. * 圆弧描边包含判断
  13575. * @param {number} cx
  13576. * @param {number} cy
  13577. * @param {number} r
  13578. * @param {number} startAngle
  13579. * @param {number} endAngle
  13580. * @param {boolean} anticlockwise
  13581. * @param {number} lineWidth
  13582. * @param {number} x
  13583. * @param {number} y
  13584. * @return {Boolean}
  13585. */
  13586. containStroke: function (
  13587. cx, cy, r, startAngle, endAngle, anticlockwise,
  13588. lineWidth, x, y
  13589. ) {
  13590. if (lineWidth === 0) {
  13591. return false;
  13592. }
  13593. var _l = lineWidth;
  13594. x -= cx;
  13595. y -= cy;
  13596. var d = Math.sqrt(x * x + y * y);
  13597. if ((d - _l > r) || (d + _l < r)) {
  13598. return false;
  13599. }
  13600. if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
  13601. // Is a circle
  13602. return true;
  13603. }
  13604. if (anticlockwise) {
  13605. var tmp = startAngle;
  13606. startAngle = normalizeRadian(endAngle);
  13607. endAngle = normalizeRadian(tmp);
  13608. } else {
  13609. startAngle = normalizeRadian(startAngle);
  13610. endAngle = normalizeRadian(endAngle);
  13611. }
  13612. if (startAngle > endAngle) {
  13613. endAngle += PI2;
  13614. }
  13615. var angle = Math.atan2(y, x);
  13616. if (angle < 0) {
  13617. angle += PI2;
  13618. }
  13619. return (angle >= startAngle && angle <= endAngle)
  13620. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle);
  13621. }
  13622. };
  13623. /***/ }),
  13624. /* 47 */
  13625. /***/ (function(module, exports) {
  13626. var PI2 = Math.PI * 2;
  13627. module.exports = {
  13628. normalizeRadian: function(angle) {
  13629. angle %= PI2;
  13630. if (angle < 0) {
  13631. angle += PI2;
  13632. }
  13633. return angle;
  13634. }
  13635. };
  13636. /***/ }),
  13637. /* 48 */
  13638. /***/ (function(module, exports) {
  13639. module.exports = function windingLine(x0, y0, x1, y1, x, y) {
  13640. if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
  13641. return 0;
  13642. }
  13643. // Ignore horizontal line
  13644. if (y1 === y0) {
  13645. return 0;
  13646. }
  13647. var dir = y1 < y0 ? 1 : -1;
  13648. var t = (y - y0) / (y1 - y0);
  13649. // Avoid winding error when intersection point is the connect point of two line of polygon
  13650. if (t === 1 || t === 0) {
  13651. dir = y1 < y0 ? 0.5 : -0.5;
  13652. }
  13653. var x_ = t * (x1 - x0) + x0;
  13654. return x_ > x ? dir : 0;
  13655. };
  13656. /***/ }),
  13657. /* 49 */
  13658. /***/ (function(module, exports) {
  13659. var Pattern = function (image, repeat) {
  13660. // Should do nothing more in this constructor. Because gradient can be
  13661. // declard by `color: {image: ...}`, where this constructor will not be called.
  13662. this.image = image;
  13663. this.repeat = repeat;
  13664. // Can be cloned
  13665. this.type = 'pattern';
  13666. };
  13667. Pattern.prototype.getCanvasPattern = function (ctx) {
  13668. return ctx.createPattern(this.image, this.repeat || 'repeat');
  13669. };
  13670. module.exports = Pattern;
  13671. /***/ }),
  13672. /* 50 */
  13673. /***/ (function(module, exports, __webpack_require__) {
  13674. var CMD = __webpack_require__(39).CMD;
  13675. var vec2 = __webpack_require__(10);
  13676. var v2ApplyTransform = vec2.applyTransform;
  13677. var points = [[], [], []];
  13678. var mathSqrt = Math.sqrt;
  13679. var mathAtan2 = Math.atan2;
  13680. function transformPath(path, m) {
  13681. var data = path.data;
  13682. var cmd;
  13683. var nPoint;
  13684. var i;
  13685. var j;
  13686. var k;
  13687. var p;
  13688. var M = CMD.M;
  13689. var C = CMD.C;
  13690. var L = CMD.L;
  13691. var R = CMD.R;
  13692. var A = CMD.A;
  13693. var Q = CMD.Q;
  13694. for (i = 0, j = 0; i < data.length;) {
  13695. cmd = data[i++];
  13696. j = i;
  13697. nPoint = 0;
  13698. switch (cmd) {
  13699. case M:
  13700. nPoint = 1;
  13701. break;
  13702. case L:
  13703. nPoint = 1;
  13704. break;
  13705. case C:
  13706. nPoint = 3;
  13707. break;
  13708. case Q:
  13709. nPoint = 2;
  13710. break;
  13711. case A:
  13712. var x = m[4];
  13713. var y = m[5];
  13714. var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
  13715. var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
  13716. var angle = mathAtan2(-m[1] / sy, m[0] / sx);
  13717. // cx
  13718. data[i] *= sx;
  13719. data[i++] += x;
  13720. // cy
  13721. data[i] *= sy;
  13722. data[i++] += y;
  13723. // Scale rx and ry
  13724. // FIXME Assume psi is 0 here
  13725. data[i++] *= sx;
  13726. data[i++] *= sy;
  13727. // Start angle
  13728. data[i++] += angle;
  13729. // end angle
  13730. data[i++] += angle;
  13731. // FIXME psi
  13732. i += 2;
  13733. j = i;
  13734. break;
  13735. case R:
  13736. // x0, y0
  13737. p[0] = data[i++];
  13738. p[1] = data[i++];
  13739. v2ApplyTransform(p, p, m);
  13740. data[j++] = p[0];
  13741. data[j++] = p[1];
  13742. // x1, y1
  13743. p[0] += data[i++];
  13744. p[1] += data[i++];
  13745. v2ApplyTransform(p, p, m);
  13746. data[j++] = p[0];
  13747. data[j++] = p[1];
  13748. }
  13749. for (k = 0; k < nPoint; k++) {
  13750. var p = points[k];
  13751. p[0] = data[i++];
  13752. p[1] = data[i++];
  13753. v2ApplyTransform(p, p, m);
  13754. // Write back
  13755. data[j++] = p[0];
  13756. data[j++] = p[1];
  13757. }
  13758. }
  13759. }
  13760. module.exports = transformPath;
  13761. /***/ }),
  13762. /* 51 */
  13763. /***/ (function(module, exports, __webpack_require__) {
  13764. /**
  13765. * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
  13766. * @module zrender/graphic/Group
  13767. * @example
  13768. * var Group = require('zrender/lib/container/Group');
  13769. * var Circle = require('zrender/lib/graphic/shape/Circle');
  13770. * var g = new Group();
  13771. * g.position[0] = 100;
  13772. * g.position[1] = 100;
  13773. * g.add(new Circle({
  13774. * style: {
  13775. * x: 100,
  13776. * y: 100,
  13777. * r: 20,
  13778. * }
  13779. * }));
  13780. * zr.add(g);
  13781. */
  13782. var zrUtil = __webpack_require__(4);
  13783. var Element = __webpack_require__(25);
  13784. var BoundingRect = __webpack_require__(9);
  13785. /**
  13786. * @alias module:zrender/graphic/Group
  13787. * @constructor
  13788. * @extends module:zrender/mixin/Transformable
  13789. * @extends module:zrender/mixin/Eventful
  13790. */
  13791. var Group = function (opts) {
  13792. opts = opts || {};
  13793. Element.call(this, opts);
  13794. for (var key in opts) {
  13795. if (opts.hasOwnProperty(key)) {
  13796. this[key] = opts[key];
  13797. }
  13798. }
  13799. this._children = [];
  13800. this.__storage = null;
  13801. this.__dirty = true;
  13802. };
  13803. Group.prototype = {
  13804. constructor: Group,
  13805. isGroup: true,
  13806. /**
  13807. * @type {string}
  13808. */
  13809. type: 'group',
  13810. /**
  13811. * 所有子孙元素是否响应鼠标事件
  13812. * @name module:/zrender/container/Group#silent
  13813. * @type {boolean}
  13814. * @default false
  13815. */
  13816. silent: false,
  13817. /**
  13818. * @return {Array.<module:zrender/Element>}
  13819. */
  13820. children: function () {
  13821. return this._children.slice();
  13822. },
  13823. /**
  13824. * 获取指定 index 的儿子节点
  13825. * @param {number} idx
  13826. * @return {module:zrender/Element}
  13827. */
  13828. childAt: function (idx) {
  13829. return this._children[idx];
  13830. },
  13831. /**
  13832. * 获取指定名字的儿子节点
  13833. * @param {string} name
  13834. * @return {module:zrender/Element}
  13835. */
  13836. childOfName: function (name) {
  13837. var children = this._children;
  13838. for (var i = 0; i < children.length; i++) {
  13839. if (children[i].name === name) {
  13840. return children[i];
  13841. }
  13842. }
  13843. },
  13844. /**
  13845. * @return {number}
  13846. */
  13847. childCount: function () {
  13848. return this._children.length;
  13849. },
  13850. /**
  13851. * 添加子节点到最后
  13852. * @param {module:zrender/Element} child
  13853. */
  13854. add: function (child) {
  13855. if (child && child !== this && child.parent !== this) {
  13856. this._children.push(child);
  13857. this._doAdd(child);
  13858. }
  13859. return this;
  13860. },
  13861. /**
  13862. * 添加子节点在 nextSibling 之前
  13863. * @param {module:zrender/Element} child
  13864. * @param {module:zrender/Element} nextSibling
  13865. */
  13866. addBefore: function (child, nextSibling) {
  13867. if (child && child !== this && child.parent !== this
  13868. && nextSibling && nextSibling.parent === this) {
  13869. var children = this._children;
  13870. var idx = children.indexOf(nextSibling);
  13871. if (idx >= 0) {
  13872. children.splice(idx, 0, child);
  13873. this._doAdd(child);
  13874. }
  13875. }
  13876. return this;
  13877. },
  13878. _doAdd: function (child) {
  13879. if (child.parent) {
  13880. child.parent.remove(child);
  13881. }
  13882. child.parent = this;
  13883. var storage = this.__storage;
  13884. var zr = this.__zr;
  13885. if (storage && storage !== child.__storage) {
  13886. storage.addToStorage(child);
  13887. if (child instanceof Group) {
  13888. child.addChildrenToStorage(storage);
  13889. }
  13890. }
  13891. zr && zr.refresh();
  13892. },
  13893. /**
  13894. * 移除子节点
  13895. * @param {module:zrender/Element} child
  13896. */
  13897. remove: function (child) {
  13898. var zr = this.__zr;
  13899. var storage = this.__storage;
  13900. var children = this._children;
  13901. var idx = zrUtil.indexOf(children, child);
  13902. if (idx < 0) {
  13903. return this;
  13904. }
  13905. children.splice(idx, 1);
  13906. child.parent = null;
  13907. if (storage) {
  13908. storage.delFromStorage(child);
  13909. if (child instanceof Group) {
  13910. child.delChildrenFromStorage(storage);
  13911. }
  13912. }
  13913. zr && zr.refresh();
  13914. return this;
  13915. },
  13916. /**
  13917. * 移除所有子节点
  13918. */
  13919. removeAll: function () {
  13920. var children = this._children;
  13921. var storage = this.__storage;
  13922. var child;
  13923. var i;
  13924. for (i = 0; i < children.length; i++) {
  13925. child = children[i];
  13926. if (storage) {
  13927. storage.delFromStorage(child);
  13928. if (child instanceof Group) {
  13929. child.delChildrenFromStorage(storage);
  13930. }
  13931. }
  13932. child.parent = null;
  13933. }
  13934. children.length = 0;
  13935. return this;
  13936. },
  13937. /**
  13938. * 遍历所有子节点
  13939. * @param {Function} cb
  13940. * @param {} context
  13941. */
  13942. eachChild: function (cb, context) {
  13943. var children = this._children;
  13944. for (var i = 0; i < children.length; i++) {
  13945. var child = children[i];
  13946. cb.call(context, child, i);
  13947. }
  13948. return this;
  13949. },
  13950. /**
  13951. * 深度优先遍历所有子孙节点
  13952. * @param {Function} cb
  13953. * @param {} context
  13954. */
  13955. traverse: function (cb, context) {
  13956. for (var i = 0; i < this._children.length; i++) {
  13957. var child = this._children[i];
  13958. cb.call(context, child);
  13959. if (child.type === 'group') {
  13960. child.traverse(cb, context);
  13961. }
  13962. }
  13963. return this;
  13964. },
  13965. addChildrenToStorage: function (storage) {
  13966. for (var i = 0; i < this._children.length; i++) {
  13967. var child = this._children[i];
  13968. storage.addToStorage(child);
  13969. if (child instanceof Group) {
  13970. child.addChildrenToStorage(storage);
  13971. }
  13972. }
  13973. },
  13974. delChildrenFromStorage: function (storage) {
  13975. for (var i = 0; i < this._children.length; i++) {
  13976. var child = this._children[i];
  13977. storage.delFromStorage(child);
  13978. if (child instanceof Group) {
  13979. child.delChildrenFromStorage(storage);
  13980. }
  13981. }
  13982. },
  13983. dirty: function () {
  13984. this.__dirty = true;
  13985. this.__zr && this.__zr.refresh();
  13986. return this;
  13987. },
  13988. /**
  13989. * @return {module:zrender/core/BoundingRect}
  13990. */
  13991. getBoundingRect: function (includeChildren) {
  13992. // TODO Caching
  13993. var rect = null;
  13994. var tmpRect = new BoundingRect(0, 0, 0, 0);
  13995. var children = includeChildren || this._children;
  13996. var tmpMat = [];
  13997. for (var i = 0; i < children.length; i++) {
  13998. var child = children[i];
  13999. if (child.ignore || child.invisible) {
  14000. continue;
  14001. }
  14002. var childRect = child.getBoundingRect();
  14003. var transform = child.getLocalTransform(tmpMat);
  14004. // TODO
  14005. // The boundingRect cacluated by transforming original
  14006. // rect may be bigger than the actual bundingRect when rotation
  14007. // is used. (Consider a circle rotated aginst its center, where
  14008. // the actual boundingRect should be the same as that not be
  14009. // rotated.) But we can not find better approach to calculate
  14010. // actual boundingRect yet, considering performance.
  14011. if (transform) {
  14012. tmpRect.copy(childRect);
  14013. tmpRect.applyTransform(transform);
  14014. rect = rect || tmpRect.clone();
  14015. rect.union(tmpRect);
  14016. }
  14017. else {
  14018. rect = rect || childRect.clone();
  14019. rect.union(childRect);
  14020. }
  14021. }
  14022. return rect || tmpRect;
  14023. }
  14024. };
  14025. zrUtil.inherits(Group, Element);
  14026. module.exports = Group;
  14027. /***/ }),
  14028. /* 52 */
  14029. /***/ (function(module, exports, __webpack_require__) {
  14030. /**
  14031. * Image element
  14032. * @module zrender/graphic/Image
  14033. */
  14034. var Displayable = __webpack_require__(23);
  14035. var BoundingRect = __webpack_require__(9);
  14036. var zrUtil = __webpack_require__(4);
  14037. var imageHelper = __webpack_require__(12);
  14038. /**
  14039. * @alias zrender/graphic/Image
  14040. * @extends module:zrender/graphic/Displayable
  14041. * @constructor
  14042. * @param {Object} opts
  14043. */
  14044. function ZImage(opts) {
  14045. Displayable.call(this, opts);
  14046. }
  14047. ZImage.prototype = {
  14048. constructor: ZImage,
  14049. type: 'image',
  14050. brush: function (ctx, prevEl) {
  14051. var style = this.style;
  14052. var src = style.image;
  14053. // Must bind each time
  14054. style.bind(ctx, this, prevEl);
  14055. var image = this._image = imageHelper.createOrUpdateImage(src, this._image, this);
  14056. if (!image || !imageHelper.isImageReady(image)) {
  14057. return;
  14058. }
  14059. // 图片已经加载完成
  14060. // if (image.nodeName.toUpperCase() == 'IMG') {
  14061. // if (!image.complete) {
  14062. // return;
  14063. // }
  14064. // }
  14065. // Else is canvas
  14066. var x = style.x || 0;
  14067. var y = style.y || 0;
  14068. var width = style.width;
  14069. var height = style.height;
  14070. var aspect = image.width / image.height;
  14071. if (width == null && height != null) {
  14072. // Keep image/height ratio
  14073. width = height * aspect;
  14074. }
  14075. else if (height == null && width != null) {
  14076. height = width / aspect;
  14077. }
  14078. else if (width == null && height == null) {
  14079. width = image.width;
  14080. height = image.height;
  14081. }
  14082. // 设置transform
  14083. this.setTransform(ctx);
  14084. if (style.sWidth && style.sHeight) {
  14085. var sx = style.sx || 0;
  14086. var sy = style.sy || 0;
  14087. ctx.drawImage(
  14088. image,
  14089. sx, sy, style.sWidth, style.sHeight,
  14090. x, y, width, height
  14091. );
  14092. }
  14093. else if (style.sx && style.sy) {
  14094. var sx = style.sx;
  14095. var sy = style.sy;
  14096. var sWidth = width - sx;
  14097. var sHeight = height - sy;
  14098. ctx.drawImage(
  14099. image,
  14100. sx, sy, sWidth, sHeight,
  14101. x, y, width, height
  14102. );
  14103. }
  14104. else {
  14105. ctx.drawImage(image, x, y, width, height);
  14106. }
  14107. this.restoreTransform(ctx);
  14108. // Draw rect text
  14109. if (style.text != null) {
  14110. this.drawRectText(ctx, this.getBoundingRect());
  14111. }
  14112. },
  14113. getBoundingRect: function () {
  14114. var style = this.style;
  14115. if (! this._rect) {
  14116. this._rect = new BoundingRect(
  14117. style.x || 0, style.y || 0, style.width || 0, style.height || 0
  14118. );
  14119. }
  14120. return this._rect;
  14121. }
  14122. };
  14123. zrUtil.inherits(ZImage, Displayable);
  14124. module.exports = ZImage;
  14125. /***/ }),
  14126. /* 53 */
  14127. /***/ (function(module, exports, __webpack_require__) {
  14128. /**
  14129. * Text element
  14130. * @module zrender/graphic/Text
  14131. *
  14132. * TODO Wrapping
  14133. *
  14134. * Text not support gradient
  14135. */
  14136. var Displayable = __webpack_require__(23);
  14137. var zrUtil = __webpack_require__(4);
  14138. var textContain = __webpack_require__(8);
  14139. var textHelper = __webpack_require__(37);
  14140. /**
  14141. * @alias zrender/graphic/Text
  14142. * @extends module:zrender/graphic/Displayable
  14143. * @constructor
  14144. * @param {Object} opts
  14145. */
  14146. var Text = function (opts) {
  14147. Displayable.call(this, opts);
  14148. };
  14149. Text.prototype = {
  14150. constructor: Text,
  14151. type: 'text',
  14152. brush: function (ctx, prevEl) {
  14153. var style = this.style;
  14154. // Optimize, avoid normalize every time.
  14155. this.__dirty && textHelper.normalizeTextStyle(style, true);
  14156. // Use props with prefix 'text'.
  14157. style.fill = style.stroke = style.shadowBlur = style.shadowColor =
  14158. style.shadowOffsetX = style.shadowOffsetY = null;
  14159. var text = style.text;
  14160. // Convert to string
  14161. text != null && (text += '');
  14162. // Always bind style
  14163. style.bind(ctx, this, prevEl);
  14164. if (!textHelper.needDrawText(text, style)) {
  14165. return;
  14166. }
  14167. this.setTransform(ctx);
  14168. textHelper.renderText(this, ctx, text, style);
  14169. this.restoreTransform(ctx);
  14170. },
  14171. getBoundingRect: function () {
  14172. var style = this.style;
  14173. // Optimize, avoid normalize every time.
  14174. this.__dirty && textHelper.normalizeTextStyle(style, true);
  14175. if (!this._rect) {
  14176. var text = style.text;
  14177. text != null ? (text += '') : (text = '');
  14178. var rect = textContain.getBoundingRect(
  14179. style.text + '',
  14180. style.font,
  14181. style.textAlign,
  14182. style.textVerticalAlign,
  14183. style.textPadding,
  14184. style.rich
  14185. );
  14186. rect.x += style.x || 0;
  14187. rect.y += style.y || 0;
  14188. if (textHelper.getStroke(style.textStroke, style.textStrokeWidth)) {
  14189. var w = style.textStrokeWidth;
  14190. rect.x -= w / 2;
  14191. rect.y -= w / 2;
  14192. rect.width += w;
  14193. rect.height += w;
  14194. }
  14195. this._rect = rect;
  14196. }
  14197. return this._rect;
  14198. }
  14199. };
  14200. zrUtil.inherits(Text, Displayable);
  14201. module.exports = Text;
  14202. /***/ }),
  14203. /* 54 */
  14204. /***/ (function(module, exports, __webpack_require__) {
  14205. 'use strict';
  14206. /**
  14207. * 圆形
  14208. * @module zrender/shape/Circle
  14209. */
  14210. module.exports = __webpack_require__(22).extend({
  14211. type: 'circle',
  14212. shape: {
  14213. cx: 0,
  14214. cy: 0,
  14215. r: 0
  14216. },
  14217. buildPath : function (ctx, shape, inBundle) {
  14218. // Better stroking in ShapeBundle
  14219. // Always do it may have performence issue ( fill may be 2x more cost)
  14220. if (inBundle) {
  14221. ctx.moveTo(shape.cx + shape.r, shape.cy);
  14222. }
  14223. // else {
  14224. // if (ctx.allocate && !ctx.data.length) {
  14225. // ctx.allocate(ctx.CMD_MEM_SIZE.A);
  14226. // }
  14227. // }
  14228. // Better stroking in ShapeBundle
  14229. // ctx.moveTo(shape.cx + shape.r, shape.cy);
  14230. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true);
  14231. }
  14232. });
  14233. /***/ }),
  14234. /* 55 */
  14235. /***/ (function(module, exports, __webpack_require__) {
  14236. /**
  14237. * 扇形
  14238. * @module zrender/graphic/shape/Sector
  14239. */
  14240. var Path = __webpack_require__(22);
  14241. var fixClipWithShadow = __webpack_require__(56);
  14242. module.exports = Path.extend({
  14243. type: 'sector',
  14244. shape: {
  14245. cx: 0,
  14246. cy: 0,
  14247. r0: 0,
  14248. r: 0,
  14249. startAngle: 0,
  14250. endAngle: Math.PI * 2,
  14251. clockwise: true
  14252. },
  14253. brush: fixClipWithShadow(Path.prototype.brush),
  14254. buildPath: function (ctx, shape) {
  14255. var x = shape.cx;
  14256. var y = shape.cy;
  14257. var r0 = Math.max(shape.r0 || 0, 0);
  14258. var r = Math.max(shape.r, 0);
  14259. var startAngle = shape.startAngle;
  14260. var endAngle = shape.endAngle;
  14261. var clockwise = shape.clockwise;
  14262. var unitX = Math.cos(startAngle);
  14263. var unitY = Math.sin(startAngle);
  14264. ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  14265. ctx.lineTo(unitX * r + x, unitY * r + y);
  14266. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  14267. ctx.lineTo(
  14268. Math.cos(endAngle) * r0 + x,
  14269. Math.sin(endAngle) * r0 + y
  14270. );
  14271. if (r0 !== 0) {
  14272. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  14273. }
  14274. ctx.closePath();
  14275. }
  14276. });
  14277. /***/ }),
  14278. /* 56 */
  14279. /***/ (function(module, exports, __webpack_require__) {
  14280. var env = __webpack_require__(2);
  14281. // Fix weird bug in some version of IE11 (like 11.0.9600.178**),
  14282. // where exception "unexpected call to method or property access"
  14283. // might be thrown when calling ctx.fill or ctx.stroke after a path
  14284. // whose area size is zero is drawn and ctx.clip() is called and
  14285. // shadowBlur is set. See #4572, #3112, #5777.
  14286. // (e.g.,
  14287. // ctx.moveTo(10, 10);
  14288. // ctx.lineTo(20, 10);
  14289. // ctx.closePath();
  14290. // ctx.clip();
  14291. // ctx.shadowBlur = 10;
  14292. // ...
  14293. // ctx.fill();
  14294. // )
  14295. var shadowTemp = [
  14296. ['shadowBlur', 0],
  14297. ['shadowColor', '#000'],
  14298. ['shadowOffsetX', 0],
  14299. ['shadowOffsetY', 0]
  14300. ];
  14301. module.exports = function (orignalBrush) {
  14302. // version string can be: '11.0'
  14303. return (env.browser.ie && env.browser.version >= 11)
  14304. ? function () {
  14305. var clipPaths = this.__clipPaths;
  14306. var style = this.style;
  14307. var modified;
  14308. if (clipPaths) {
  14309. for (var i = 0; i < clipPaths.length; i++) {
  14310. var clipPath = clipPaths[i];
  14311. var shape = clipPath && clipPath.shape;
  14312. var type = clipPath && clipPath.type;
  14313. if (shape && (
  14314. (type === 'sector' && shape.startAngle === shape.endAngle)
  14315. || (type === 'rect' && (!shape.width || !shape.height))
  14316. )) {
  14317. for (var j = 0; j < shadowTemp.length; j++) {
  14318. // It is save to put shadowTemp static, because shadowTemp
  14319. // will be all modified each item brush called.
  14320. shadowTemp[j][2] = style[shadowTemp[j][0]];
  14321. style[shadowTemp[j][0]] = shadowTemp[j][1];
  14322. }
  14323. modified = true;
  14324. break;
  14325. }
  14326. }
  14327. }
  14328. orignalBrush.apply(this, arguments);
  14329. if (modified) {
  14330. for (var j = 0; j < shadowTemp.length; j++) {
  14331. style[shadowTemp[j][0]] = shadowTemp[j][2];
  14332. }
  14333. }
  14334. }
  14335. : orignalBrush;
  14336. };
  14337. /***/ }),
  14338. /* 57 */
  14339. /***/ (function(module, exports, __webpack_require__) {
  14340. /**
  14341. * 圆环
  14342. * @module zrender/graphic/shape/Ring
  14343. */
  14344. module.exports = __webpack_require__(22).extend({
  14345. type: 'ring',
  14346. shape: {
  14347. cx: 0,
  14348. cy: 0,
  14349. r: 0,
  14350. r0: 0
  14351. },
  14352. buildPath: function (ctx, shape) {
  14353. var x = shape.cx;
  14354. var y = shape.cy;
  14355. var PI2 = Math.PI * 2;
  14356. ctx.moveTo(x + shape.r, y);
  14357. ctx.arc(x, y, shape.r, 0, PI2, false);
  14358. ctx.moveTo(x + shape.r0, y);
  14359. ctx.arc(x, y, shape.r0, 0, PI2, true);
  14360. }
  14361. });
  14362. /***/ }),
  14363. /* 58 */
  14364. /***/ (function(module, exports, __webpack_require__) {
  14365. /**
  14366. * 多边形
  14367. * @module zrender/shape/Polygon
  14368. */
  14369. var polyHelper = __webpack_require__(59);
  14370. module.exports = __webpack_require__(22).extend({
  14371. type: 'polygon',
  14372. shape: {
  14373. points: null,
  14374. smooth: false,
  14375. smoothConstraint: null
  14376. },
  14377. buildPath: function (ctx, shape) {
  14378. polyHelper.buildPath(ctx, shape, true);
  14379. }
  14380. });
  14381. /***/ }),
  14382. /* 59 */
  14383. /***/ (function(module, exports, __webpack_require__) {
  14384. var smoothSpline = __webpack_require__(60);
  14385. var smoothBezier = __webpack_require__(61);
  14386. module.exports = {
  14387. buildPath: function (ctx, shape, closePath) {
  14388. var points = shape.points;
  14389. var smooth = shape.smooth;
  14390. if (points && points.length >= 2) {
  14391. if (smooth && smooth !== 'spline') {
  14392. var controlPoints = smoothBezier(
  14393. points, smooth, closePath, shape.smoothConstraint
  14394. );
  14395. ctx.moveTo(points[0][0], points[0][1]);
  14396. var len = points.length;
  14397. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  14398. var cp1 = controlPoints[i * 2];
  14399. var cp2 = controlPoints[i * 2 + 1];
  14400. var p = points[(i + 1) % len];
  14401. ctx.bezierCurveTo(
  14402. cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]
  14403. );
  14404. }
  14405. }
  14406. else {
  14407. if (smooth === 'spline') {
  14408. points = smoothSpline(points, closePath);
  14409. }
  14410. ctx.moveTo(points[0][0], points[0][1]);
  14411. for (var i = 1, l = points.length; i < l; i++) {
  14412. ctx.lineTo(points[i][0], points[i][1]);
  14413. }
  14414. }
  14415. closePath && ctx.closePath();
  14416. }
  14417. }
  14418. };
  14419. /***/ }),
  14420. /* 60 */
  14421. /***/ (function(module, exports, __webpack_require__) {
  14422. /**
  14423. * Catmull-Rom spline 插值折线
  14424. * @module zrender/shape/util/smoothSpline
  14425. * @author pissang (https://www.github.com/pissang)
  14426. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14427. * errorrik (errorrik@gmail.com)
  14428. */
  14429. var vec2 = __webpack_require__(10);
  14430. /**
  14431. * @inner
  14432. */
  14433. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  14434. var v0 = (p2 - p0) * 0.5;
  14435. var v1 = (p3 - p1) * 0.5;
  14436. return (2 * (p1 - p2) + v0 + v1) * t3
  14437. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  14438. + v0 * t + p1;
  14439. }
  14440. /**
  14441. * @alias module:zrender/shape/util/smoothSpline
  14442. * @param {Array} points 线段顶点数组
  14443. * @param {boolean} isLoop
  14444. * @return {Array}
  14445. */
  14446. module.exports = function (points, isLoop) {
  14447. var len = points.length;
  14448. var ret = [];
  14449. var distance = 0;
  14450. for (var i = 1; i < len; i++) {
  14451. distance += vec2.distance(points[i - 1], points[i]);
  14452. }
  14453. var segs = distance / 2;
  14454. segs = segs < len ? len : segs;
  14455. for (var i = 0; i < segs; i++) {
  14456. var pos = i / (segs - 1) * (isLoop ? len : len - 1);
  14457. var idx = Math.floor(pos);
  14458. var w = pos - idx;
  14459. var p0;
  14460. var p1 = points[idx % len];
  14461. var p2;
  14462. var p3;
  14463. if (!isLoop) {
  14464. p0 = points[idx === 0 ? idx : idx - 1];
  14465. p2 = points[idx > len - 2 ? len - 1 : idx + 1];
  14466. p3 = points[idx > len - 3 ? len - 1 : idx + 2];
  14467. }
  14468. else {
  14469. p0 = points[(idx - 1 + len) % len];
  14470. p2 = points[(idx + 1) % len];
  14471. p3 = points[(idx + 2) % len];
  14472. }
  14473. var w2 = w * w;
  14474. var w3 = w * w2;
  14475. ret.push([
  14476. interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
  14477. interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
  14478. ]);
  14479. }
  14480. return ret;
  14481. };
  14482. /***/ }),
  14483. /* 61 */
  14484. /***/ (function(module, exports, __webpack_require__) {
  14485. /**
  14486. * 贝塞尔平滑曲线
  14487. * @module zrender/shape/util/smoothBezier
  14488. * @author pissang (https://www.github.com/pissang)
  14489. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14490. * errorrik (errorrik@gmail.com)
  14491. */
  14492. var vec2 = __webpack_require__(10);
  14493. var v2Min = vec2.min;
  14494. var v2Max = vec2.max;
  14495. var v2Scale = vec2.scale;
  14496. var v2Distance = vec2.distance;
  14497. var v2Add = vec2.add;
  14498. /**
  14499. * 贝塞尔平滑曲线
  14500. * @alias module:zrender/shape/util/smoothBezier
  14501. * @param {Array} points 线段顶点数组
  14502. * @param {number} smooth 平滑等级, 0-1
  14503. * @param {boolean} isLoop
  14504. * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内
  14505. * 比如 [[0, 0], [100, 100]], 这个包围盒会与
  14506. * 整个折线的包围盒做一个并集用来约束控制点。
  14507. * @param {Array} 计算出来的控制点数组
  14508. */
  14509. module.exports = function (points, smooth, isLoop, constraint) {
  14510. var cps = [];
  14511. var v = [];
  14512. var v1 = [];
  14513. var v2 = [];
  14514. var prevPoint;
  14515. var nextPoint;
  14516. var min, max;
  14517. if (constraint) {
  14518. min = [Infinity, Infinity];
  14519. max = [-Infinity, -Infinity];
  14520. for (var i = 0, len = points.length; i < len; i++) {
  14521. v2Min(min, min, points[i]);
  14522. v2Max(max, max, points[i]);
  14523. }
  14524. // 与指定的包围盒做并集
  14525. v2Min(min, min, constraint[0]);
  14526. v2Max(max, max, constraint[1]);
  14527. }
  14528. for (var i = 0, len = points.length; i < len; i++) {
  14529. var point = points[i];
  14530. if (isLoop) {
  14531. prevPoint = points[i ? i - 1 : len - 1];
  14532. nextPoint = points[(i + 1) % len];
  14533. }
  14534. else {
  14535. if (i === 0 || i === len - 1) {
  14536. cps.push(vec2.clone(points[i]));
  14537. continue;
  14538. }
  14539. else {
  14540. prevPoint = points[i - 1];
  14541. nextPoint = points[i + 1];
  14542. }
  14543. }
  14544. vec2.sub(v, nextPoint, prevPoint);
  14545. // use degree to scale the handle length
  14546. v2Scale(v, v, smooth);
  14547. var d0 = v2Distance(point, prevPoint);
  14548. var d1 = v2Distance(point, nextPoint);
  14549. var sum = d0 + d1;
  14550. if (sum !== 0) {
  14551. d0 /= sum;
  14552. d1 /= sum;
  14553. }
  14554. v2Scale(v1, v, -d0);
  14555. v2Scale(v2, v, d1);
  14556. var cp0 = v2Add([], point, v1);
  14557. var cp1 = v2Add([], point, v2);
  14558. if (constraint) {
  14559. v2Max(cp0, cp0, min);
  14560. v2Min(cp0, cp0, max);
  14561. v2Max(cp1, cp1, min);
  14562. v2Min(cp1, cp1, max);
  14563. }
  14564. cps.push(cp0);
  14565. cps.push(cp1);
  14566. }
  14567. if (isLoop) {
  14568. cps.push(cps.shift());
  14569. }
  14570. return cps;
  14571. };
  14572. /***/ }),
  14573. /* 62 */
  14574. /***/ (function(module, exports, __webpack_require__) {
  14575. /**
  14576. * @module zrender/graphic/shape/Polyline
  14577. */
  14578. var polyHelper = __webpack_require__(59);
  14579. module.exports = __webpack_require__(22).extend({
  14580. type: 'polyline',
  14581. shape: {
  14582. points: null,
  14583. smooth: false,
  14584. smoothConstraint: null
  14585. },
  14586. style: {
  14587. stroke: '#000',
  14588. fill: null
  14589. },
  14590. buildPath: function (ctx, shape) {
  14591. polyHelper.buildPath(ctx, shape, false);
  14592. }
  14593. });
  14594. /***/ }),
  14595. /* 63 */
  14596. /***/ (function(module, exports, __webpack_require__) {
  14597. /**
  14598. * 矩形
  14599. * @module zrender/graphic/shape/Rect
  14600. */
  14601. var roundRectHelper = __webpack_require__(38);
  14602. module.exports = __webpack_require__(22).extend({
  14603. type: 'rect',
  14604. shape: {
  14605. // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
  14606. // r缩写为1 相当于 [1, 1, 1, 1]
  14607. // r缩写为[1] 相当于 [1, 1, 1, 1]
  14608. // r缩写为[1, 2] 相当于 [1, 2, 1, 2]
  14609. // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2]
  14610. r: 0,
  14611. x: 0,
  14612. y: 0,
  14613. width: 0,
  14614. height: 0
  14615. },
  14616. buildPath: function (ctx, shape) {
  14617. var x = shape.x;
  14618. var y = shape.y;
  14619. var width = shape.width;
  14620. var height = shape.height;
  14621. if (!shape.r) {
  14622. ctx.rect(x, y, width, height);
  14623. }
  14624. else {
  14625. roundRectHelper.buildPath(ctx, shape);
  14626. }
  14627. ctx.closePath();
  14628. return;
  14629. }
  14630. });
  14631. /***/ }),
  14632. /* 64 */
  14633. /***/ (function(module, exports, __webpack_require__) {
  14634. /**
  14635. * 直线
  14636. * @module zrender/graphic/shape/Line
  14637. */
  14638. module.exports = __webpack_require__(22).extend({
  14639. type: 'line',
  14640. shape: {
  14641. // Start point
  14642. x1: 0,
  14643. y1: 0,
  14644. // End point
  14645. x2: 0,
  14646. y2: 0,
  14647. percent: 1
  14648. },
  14649. style: {
  14650. stroke: '#000',
  14651. fill: null
  14652. },
  14653. buildPath: function (ctx, shape) {
  14654. var x1 = shape.x1;
  14655. var y1 = shape.y1;
  14656. var x2 = shape.x2;
  14657. var y2 = shape.y2;
  14658. var percent = shape.percent;
  14659. if (percent === 0) {
  14660. return;
  14661. }
  14662. ctx.moveTo(x1, y1);
  14663. if (percent < 1) {
  14664. x2 = x1 * (1 - percent) + x2 * percent;
  14665. y2 = y1 * (1 - percent) + y2 * percent;
  14666. }
  14667. ctx.lineTo(x2, y2);
  14668. },
  14669. /**
  14670. * Get point at percent
  14671. * @param {number} percent
  14672. * @return {Array.<number>}
  14673. */
  14674. pointAt: function (p) {
  14675. var shape = this.shape;
  14676. return [
  14677. shape.x1 * (1 - p) + shape.x2 * p,
  14678. shape.y1 * (1 - p) + shape.y2 * p
  14679. ];
  14680. }
  14681. });
  14682. /***/ }),
  14683. /* 65 */
  14684. /***/ (function(module, exports, __webpack_require__) {
  14685. 'use strict';
  14686. /**
  14687. * 贝塞尔曲线
  14688. * @module zrender/shape/BezierCurve
  14689. */
  14690. var curveTool = __webpack_require__(40);
  14691. var vec2 = __webpack_require__(10);
  14692. var quadraticSubdivide = curveTool.quadraticSubdivide;
  14693. var cubicSubdivide = curveTool.cubicSubdivide;
  14694. var quadraticAt = curveTool.quadraticAt;
  14695. var cubicAt = curveTool.cubicAt;
  14696. var quadraticDerivativeAt = curveTool.quadraticDerivativeAt;
  14697. var cubicDerivativeAt = curveTool.cubicDerivativeAt;
  14698. var out = [];
  14699. function someVectorAt(shape, t, isTangent) {
  14700. var cpx2 = shape.cpx2;
  14701. var cpy2 = shape.cpy2;
  14702. if (cpx2 === null || cpy2 === null) {
  14703. return [
  14704. (isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t),
  14705. (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)
  14706. ];
  14707. }
  14708. else {
  14709. return [
  14710. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t),
  14711. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)
  14712. ];
  14713. }
  14714. }
  14715. module.exports = __webpack_require__(22).extend({
  14716. type: 'bezier-curve',
  14717. shape: {
  14718. x1: 0,
  14719. y1: 0,
  14720. x2: 0,
  14721. y2: 0,
  14722. cpx1: 0,
  14723. cpy1: 0,
  14724. // cpx2: 0,
  14725. // cpy2: 0
  14726. // Curve show percent, for animating
  14727. percent: 1
  14728. },
  14729. style: {
  14730. stroke: '#000',
  14731. fill: null
  14732. },
  14733. buildPath: function (ctx, shape) {
  14734. var x1 = shape.x1;
  14735. var y1 = shape.y1;
  14736. var x2 = shape.x2;
  14737. var y2 = shape.y2;
  14738. var cpx1 = shape.cpx1;
  14739. var cpy1 = shape.cpy1;
  14740. var cpx2 = shape.cpx2;
  14741. var cpy2 = shape.cpy2;
  14742. var percent = shape.percent;
  14743. if (percent === 0) {
  14744. return;
  14745. }
  14746. ctx.moveTo(x1, y1);
  14747. if (cpx2 == null || cpy2 == null) {
  14748. if (percent < 1) {
  14749. quadraticSubdivide(
  14750. x1, cpx1, x2, percent, out
  14751. );
  14752. cpx1 = out[1];
  14753. x2 = out[2];
  14754. quadraticSubdivide(
  14755. y1, cpy1, y2, percent, out
  14756. );
  14757. cpy1 = out[1];
  14758. y2 = out[2];
  14759. }
  14760. ctx.quadraticCurveTo(
  14761. cpx1, cpy1,
  14762. x2, y2
  14763. );
  14764. }
  14765. else {
  14766. if (percent < 1) {
  14767. cubicSubdivide(
  14768. x1, cpx1, cpx2, x2, percent, out
  14769. );
  14770. cpx1 = out[1];
  14771. cpx2 = out[2];
  14772. x2 = out[3];
  14773. cubicSubdivide(
  14774. y1, cpy1, cpy2, y2, percent, out
  14775. );
  14776. cpy1 = out[1];
  14777. cpy2 = out[2];
  14778. y2 = out[3];
  14779. }
  14780. ctx.bezierCurveTo(
  14781. cpx1, cpy1,
  14782. cpx2, cpy2,
  14783. x2, y2
  14784. );
  14785. }
  14786. },
  14787. /**
  14788. * Get point at percent
  14789. * @param {number} t
  14790. * @return {Array.<number>}
  14791. */
  14792. pointAt: function (t) {
  14793. return someVectorAt(this.shape, t, false);
  14794. },
  14795. /**
  14796. * Get tangent at percent
  14797. * @param {number} t
  14798. * @return {Array.<number>}
  14799. */
  14800. tangentAt: function (t) {
  14801. var p = someVectorAt(this.shape, t, true);
  14802. return vec2.normalize(p, p);
  14803. }
  14804. });
  14805. /***/ }),
  14806. /* 66 */
  14807. /***/ (function(module, exports, __webpack_require__) {
  14808. /**
  14809. * 圆弧
  14810. * @module zrender/graphic/shape/Arc
  14811. */
  14812. module.exports = __webpack_require__(22).extend({
  14813. type: 'arc',
  14814. shape: {
  14815. cx: 0,
  14816. cy: 0,
  14817. r: 0,
  14818. startAngle: 0,
  14819. endAngle: Math.PI * 2,
  14820. clockwise: true
  14821. },
  14822. style: {
  14823. stroke: '#000',
  14824. fill: null
  14825. },
  14826. buildPath: function (ctx, shape) {
  14827. var x = shape.cx;
  14828. var y = shape.cy;
  14829. var r = Math.max(shape.r, 0);
  14830. var startAngle = shape.startAngle;
  14831. var endAngle = shape.endAngle;
  14832. var clockwise = shape.clockwise;
  14833. var unitX = Math.cos(startAngle);
  14834. var unitY = Math.sin(startAngle);
  14835. ctx.moveTo(unitX * r + x, unitY * r + y);
  14836. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  14837. }
  14838. });
  14839. /***/ }),
  14840. /* 67 */
  14841. /***/ (function(module, exports, __webpack_require__) {
  14842. // CompoundPath to improve performance
  14843. var Path = __webpack_require__(22);
  14844. module.exports = Path.extend({
  14845. type: 'compound',
  14846. shape: {
  14847. paths: null
  14848. },
  14849. _updatePathDirty: function () {
  14850. var dirtyPath = this.__dirtyPath;
  14851. var paths = this.shape.paths;
  14852. for (var i = 0; i < paths.length; i++) {
  14853. // Mark as dirty if any subpath is dirty
  14854. dirtyPath = dirtyPath || paths[i].__dirtyPath;
  14855. }
  14856. this.__dirtyPath = dirtyPath;
  14857. this.__dirty = this.__dirty || dirtyPath;
  14858. },
  14859. beforeBrush: function () {
  14860. this._updatePathDirty();
  14861. var paths = this.shape.paths || [];
  14862. var scale = this.getGlobalScale();
  14863. // Update path scale
  14864. for (var i = 0; i < paths.length; i++) {
  14865. if (!paths[i].path) {
  14866. paths[i].createPathProxy();
  14867. }
  14868. paths[i].path.setScale(scale[0], scale[1]);
  14869. }
  14870. },
  14871. buildPath: function (ctx, shape) {
  14872. var paths = shape.paths || [];
  14873. for (var i = 0; i < paths.length; i++) {
  14874. paths[i].buildPath(ctx, paths[i].shape, true);
  14875. }
  14876. },
  14877. afterBrush: function () {
  14878. var paths = this.shape.paths;
  14879. for (var i = 0; i < paths.length; i++) {
  14880. paths[i].__dirtyPath = false;
  14881. }
  14882. },
  14883. getBoundingRect: function () {
  14884. this._updatePathDirty();
  14885. return Path.prototype.getBoundingRect.call(this);
  14886. }
  14887. });
  14888. /***/ }),
  14889. /* 68 */
  14890. /***/ (function(module, exports, __webpack_require__) {
  14891. 'use strict';
  14892. var zrUtil = __webpack_require__(4);
  14893. var Gradient = __webpack_require__(69);
  14894. /**
  14895. * x, y, x2, y2 are all percent from 0 to 1
  14896. * @param {number} [x=0]
  14897. * @param {number} [y=0]
  14898. * @param {number} [x2=1]
  14899. * @param {number} [y2=0]
  14900. * @param {Array.<Object>} colorStops
  14901. * @param {boolean} [globalCoord=false]
  14902. */
  14903. var LinearGradient = function (x, y, x2, y2, colorStops, globalCoord) {
  14904. // Should do nothing more in this constructor. Because gradient can be
  14905. // declard by `color: {type: 'linear', colorStops: ...}`, where
  14906. // this constructor will not be called.
  14907. this.x = x == null ? 0 : x;
  14908. this.y = y == null ? 0 : y;
  14909. this.x2 = x2 == null ? 1 : x2;
  14910. this.y2 = y2 == null ? 0 : y2;
  14911. // Can be cloned
  14912. this.type = 'linear';
  14913. // If use global coord
  14914. this.global = globalCoord || false;
  14915. Gradient.call(this, colorStops);
  14916. };
  14917. LinearGradient.prototype = {
  14918. constructor: LinearGradient
  14919. };
  14920. zrUtil.inherits(LinearGradient, Gradient);
  14921. module.exports = LinearGradient;
  14922. /***/ }),
  14923. /* 69 */
  14924. /***/ (function(module, exports) {
  14925. /**
  14926. * @param {Array.<Object>} colorStops
  14927. */
  14928. var Gradient = function (colorStops) {
  14929. this.colorStops = colorStops || [];
  14930. };
  14931. Gradient.prototype = {
  14932. constructor: Gradient,
  14933. addColorStop: function (offset, color) {
  14934. this.colorStops.push({
  14935. offset: offset,
  14936. color: color
  14937. });
  14938. }
  14939. };
  14940. module.exports = Gradient;
  14941. /***/ }),
  14942. /* 70 */
  14943. /***/ (function(module, exports, __webpack_require__) {
  14944. 'use strict';
  14945. var zrUtil = __webpack_require__(4);
  14946. var Gradient = __webpack_require__(69);
  14947. /**
  14948. * x, y, r are all percent from 0 to 1
  14949. * @param {number} [x=0.5]
  14950. * @param {number} [y=0.5]
  14951. * @param {number} [r=0.5]
  14952. * @param {Array.<Object>} [colorStops]
  14953. * @param {boolean} [globalCoord=false]
  14954. */
  14955. var RadialGradient = function (x, y, r, colorStops, globalCoord) {
  14956. // Should do nothing more in this constructor. Because gradient can be
  14957. // declard by `color: {type: 'radial', colorStops: ...}`, where
  14958. // this constructor will not be called.
  14959. this.x = x == null ? 0.5 : x;
  14960. this.y = y == null ? 0.5 : y;
  14961. this.r = r == null ? 0.5 : r;
  14962. // Can be cloned
  14963. this.type = 'radial';
  14964. // If use global coord
  14965. this.global = globalCoord || false;
  14966. Gradient.call(this, colorStops);
  14967. };
  14968. RadialGradient.prototype = {
  14969. constructor: RadialGradient
  14970. };
  14971. zrUtil.inherits(RadialGradient, Gradient);
  14972. module.exports = RadialGradient;
  14973. /***/ }),
  14974. /* 71 */
  14975. /***/ (function(module, exports, __webpack_require__) {
  14976. var getItemStyle = __webpack_require__(17)(
  14977. [
  14978. ['fill', 'color'],
  14979. ['stroke', 'borderColor'],
  14980. ['lineWidth', 'borderWidth'],
  14981. ['opacity'],
  14982. ['shadowBlur'],
  14983. ['shadowOffsetX'],
  14984. ['shadowOffsetY'],
  14985. ['shadowColor'],
  14986. ['textPosition'],
  14987. ['textAlign']
  14988. ]
  14989. );
  14990. module.exports = {
  14991. getItemStyle: function (excludes, includes) {
  14992. var style = getItemStyle.call(this, excludes, includes);
  14993. var lineDash = this.getBorderLineDash();
  14994. lineDash && (style.lineDash = lineDash);
  14995. return style;
  14996. },
  14997. getBorderLineDash: function () {
  14998. var lineType = this.get('borderType');
  14999. return (lineType === 'solid' || lineType == null) ? null
  15000. : (lineType === 'dashed' ? [5, 5] : [1, 1]);
  15001. }
  15002. };
  15003. /***/ }),
  15004. /* 72 */
  15005. /***/ (function(module, exports, __webpack_require__) {
  15006. /**
  15007. * Component model
  15008. *
  15009. * @module echarts/model/Component
  15010. */
  15011. var Model = __webpack_require__(14);
  15012. var zrUtil = __webpack_require__(4);
  15013. var arrayPush = Array.prototype.push;
  15014. var componentUtil = __webpack_require__(73);
  15015. var clazzUtil = __webpack_require__(15);
  15016. var layout = __webpack_require__(74);
  15017. /**
  15018. * @alias module:echarts/model/Component
  15019. * @constructor
  15020. * @param {Object} option
  15021. * @param {module:echarts/model/Model} parentModel
  15022. * @param {module:echarts/model/Model} ecModel
  15023. */
  15024. var ComponentModel = Model.extend({
  15025. type: 'component',
  15026. /**
  15027. * @readOnly
  15028. * @type {string}
  15029. */
  15030. id: '',
  15031. /**
  15032. * @readOnly
  15033. */
  15034. name: '',
  15035. /**
  15036. * @readOnly
  15037. * @type {string}
  15038. */
  15039. mainType: '',
  15040. /**
  15041. * @readOnly
  15042. * @type {string}
  15043. */
  15044. subType: '',
  15045. /**
  15046. * @readOnly
  15047. * @type {number}
  15048. */
  15049. componentIndex: 0,
  15050. /**
  15051. * @type {Object}
  15052. * @protected
  15053. */
  15054. defaultOption: null,
  15055. /**
  15056. * @type {module:echarts/model/Global}
  15057. * @readOnly
  15058. */
  15059. ecModel: null,
  15060. /**
  15061. * key: componentType
  15062. * value: Component model list, can not be null.
  15063. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  15064. * @readOnly
  15065. */
  15066. dependentModels: [],
  15067. /**
  15068. * @type {string}
  15069. * @readOnly
  15070. */
  15071. uid: null,
  15072. /**
  15073. * Support merge layout params.
  15074. * Only support 'box' now (left/right/top/bottom/width/height).
  15075. * @type {string|Object} Object can be {ignoreSize: true}
  15076. * @readOnly
  15077. */
  15078. layoutMode: null,
  15079. $constructor: function (option, parentModel, ecModel, extraOpt) {
  15080. Model.call(this, option, parentModel, ecModel, extraOpt);
  15081. this.uid = componentUtil.getUID('componentModel');
  15082. },
  15083. init: function (option, parentModel, ecModel, extraOpt) {
  15084. this.mergeDefaultAndTheme(option, ecModel);
  15085. },
  15086. mergeDefaultAndTheme: function (option, ecModel) {
  15087. var layoutMode = this.layoutMode;
  15088. var inputPositionParams = layoutMode
  15089. ? layout.getLayoutParams(option) : {};
  15090. var themeModel = ecModel.getTheme();
  15091. zrUtil.merge(option, themeModel.get(this.mainType));
  15092. zrUtil.merge(option, this.getDefaultOption());
  15093. if (layoutMode) {
  15094. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  15095. }
  15096. },
  15097. mergeOption: function (option, extraOpt) {
  15098. zrUtil.merge(this.option, option, true);
  15099. var layoutMode = this.layoutMode;
  15100. if (layoutMode) {
  15101. layout.mergeLayoutParam(this.option, option, layoutMode);
  15102. }
  15103. },
  15104. // Hooker after init or mergeOption
  15105. optionUpdated: function (newCptOption, isInit) {},
  15106. getDefaultOption: function () {
  15107. if (!clazzUtil.hasOwn(this, '__defaultOption')) {
  15108. var optList = [];
  15109. var Class = this.constructor;
  15110. while (Class) {
  15111. var opt = Class.prototype.defaultOption;
  15112. opt && optList.push(opt);
  15113. Class = Class.superClass;
  15114. }
  15115. var defaultOption = {};
  15116. for (var i = optList.length - 1; i >= 0; i--) {
  15117. defaultOption = zrUtil.merge(defaultOption, optList[i], true);
  15118. }
  15119. clazzUtil.set(this, '__defaultOption', defaultOption);
  15120. }
  15121. return clazzUtil.get(this, '__defaultOption');
  15122. },
  15123. getReferringComponents: function (mainType) {
  15124. return this.ecModel.queryComponents({
  15125. mainType: mainType,
  15126. index: this.get(mainType + 'Index', true),
  15127. id: this.get(mainType + 'Id', true)
  15128. });
  15129. }
  15130. });
  15131. // Reset ComponentModel.extend, add preConstruct.
  15132. // clazzUtil.enableClassExtend(
  15133. // ComponentModel,
  15134. // function (option, parentModel, ecModel, extraOpt) {
  15135. // // Set dependentModels, componentIndex, name, id, mainType, subType.
  15136. // zrUtil.extend(this, extraOpt);
  15137. // this.uid = componentUtil.getUID('componentModel');
  15138. // // this.setReadOnly([
  15139. // // 'type', 'id', 'uid', 'name', 'mainType', 'subType',
  15140. // // 'dependentModels', 'componentIndex'
  15141. // // ]);
  15142. // }
  15143. // );
  15144. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  15145. clazzUtil.enableClassManagement(
  15146. ComponentModel, {registerWhenExtend: true}
  15147. );
  15148. componentUtil.enableSubTypeDefaulter(ComponentModel);
  15149. // Add capability of ComponentModel.topologicalTravel.
  15150. componentUtil.enableTopologicalTravel(ComponentModel, getDependencies);
  15151. function getDependencies(componentType) {
  15152. var deps = [];
  15153. zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) {
  15154. arrayPush.apply(deps, Clazz.prototype.dependencies || []);
  15155. });
  15156. // Ensure main type
  15157. return zrUtil.map(deps, function (type) {
  15158. return clazzUtil.parseClassType(type).main;
  15159. });
  15160. }
  15161. zrUtil.mixin(ComponentModel, __webpack_require__(75));
  15162. module.exports = ComponentModel;
  15163. /***/ }),
  15164. /* 73 */
  15165. /***/ (function(module, exports, __webpack_require__) {
  15166. var zrUtil = __webpack_require__(4);
  15167. var clazz = __webpack_require__(15);
  15168. var parseClassType = clazz.parseClassType;
  15169. var base = 0;
  15170. var componentUtil = {};
  15171. var DELIMITER = '_';
  15172. /**
  15173. * @public
  15174. * @param {string} type
  15175. * @return {string}
  15176. */
  15177. componentUtil.getUID = function (type) {
  15178. // Considering the case of crossing js context,
  15179. // use Math.random to make id as unique as possible.
  15180. return [(type || ''), base++, Math.random()].join(DELIMITER);
  15181. };
  15182. /**
  15183. * @inner
  15184. */
  15185. componentUtil.enableSubTypeDefaulter = function (entity) {
  15186. var subTypeDefaulters = {};
  15187. entity.registerSubTypeDefaulter = function (componentType, defaulter) {
  15188. componentType = parseClassType(componentType);
  15189. subTypeDefaulters[componentType.main] = defaulter;
  15190. };
  15191. entity.determineSubType = function (componentType, option) {
  15192. var type = option.type;
  15193. if (!type) {
  15194. var componentTypeMain = parseClassType(componentType).main;
  15195. if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) {
  15196. type = subTypeDefaulters[componentTypeMain](option);
  15197. }
  15198. }
  15199. return type;
  15200. };
  15201. return entity;
  15202. };
  15203. /**
  15204. * Topological travel on Activity Network (Activity On Vertices).
  15205. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  15206. *
  15207. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  15208. *
  15209. * If there is circle dependencey, Error will be thrown.
  15210. *
  15211. */
  15212. componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) {
  15213. /**
  15214. * @public
  15215. * @param {Array.<string>} targetNameList Target Component type list.
  15216. * Can be ['aa', 'bb', 'aa.xx']
  15217. * @param {Array.<string>} fullNameList By which we can build dependency graph.
  15218. * @param {Function} callback Params: componentType, dependencies.
  15219. * @param {Object} context Scope of callback.
  15220. */
  15221. entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) {
  15222. if (!targetNameList.length) {
  15223. return;
  15224. }
  15225. var result = makeDepndencyGraph(fullNameList);
  15226. var graph = result.graph;
  15227. var stack = result.noEntryList;
  15228. var targetNameSet = {};
  15229. zrUtil.each(targetNameList, function (name) {
  15230. targetNameSet[name] = true;
  15231. });
  15232. while (stack.length) {
  15233. var currComponentType = stack.pop();
  15234. var currVertex = graph[currComponentType];
  15235. var isInTargetNameSet = !!targetNameSet[currComponentType];
  15236. if (isInTargetNameSet) {
  15237. callback.call(context, currComponentType, currVertex.originalDeps.slice());
  15238. delete targetNameSet[currComponentType];
  15239. }
  15240. zrUtil.each(
  15241. currVertex.successor,
  15242. isInTargetNameSet ? removeEdgeAndAdd : removeEdge
  15243. );
  15244. }
  15245. zrUtil.each(targetNameSet, function () {
  15246. throw new Error('Circle dependency may exists');
  15247. });
  15248. function removeEdge(succComponentType) {
  15249. graph[succComponentType].entryCount--;
  15250. if (graph[succComponentType].entryCount === 0) {
  15251. stack.push(succComponentType);
  15252. }
  15253. }
  15254. // Consider this case: legend depends on series, and we call
  15255. // chart.setOption({series: [...]}), where only series is in option.
  15256. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  15257. // not be called, but only sereis.mergeOption is called. Thus legend
  15258. // have no chance to update its local record about series (like which
  15259. // name of series is available in legend).
  15260. function removeEdgeAndAdd(succComponentType) {
  15261. targetNameSet[succComponentType] = true;
  15262. removeEdge(succComponentType);
  15263. }
  15264. };
  15265. /**
  15266. * DepndencyGraph: {Object}
  15267. * key: conponentType,
  15268. * value: {
  15269. * successor: [conponentTypes...],
  15270. * originalDeps: [conponentTypes...],
  15271. * entryCount: {number}
  15272. * }
  15273. */
  15274. function makeDepndencyGraph(fullNameList) {
  15275. var graph = {};
  15276. var noEntryList = [];
  15277. zrUtil.each(fullNameList, function (name) {
  15278. var thisItem = createDependencyGraphItem(graph, name);
  15279. var originalDeps = thisItem.originalDeps = dependencyGetter(name);
  15280. var availableDeps = getAvailableDependencies(originalDeps, fullNameList);
  15281. thisItem.entryCount = availableDeps.length;
  15282. if (thisItem.entryCount === 0) {
  15283. noEntryList.push(name);
  15284. }
  15285. zrUtil.each(availableDeps, function (dependentName) {
  15286. if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) {
  15287. thisItem.predecessor.push(dependentName);
  15288. }
  15289. var thatItem = createDependencyGraphItem(graph, dependentName);
  15290. if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) {
  15291. thatItem.successor.push(name);
  15292. }
  15293. });
  15294. });
  15295. return {graph: graph, noEntryList: noEntryList};
  15296. }
  15297. function createDependencyGraphItem(graph, name) {
  15298. if (!graph[name]) {
  15299. graph[name] = {predecessor: [], successor: []};
  15300. }
  15301. return graph[name];
  15302. }
  15303. function getAvailableDependencies(originalDeps, fullNameList) {
  15304. var availableDeps = [];
  15305. zrUtil.each(originalDeps, function (dep) {
  15306. zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep);
  15307. });
  15308. return availableDeps;
  15309. }
  15310. };
  15311. module.exports = componentUtil;
  15312. /***/ }),
  15313. /* 74 */
  15314. /***/ (function(module, exports, __webpack_require__) {
  15315. 'use strict';
  15316. // Layout helpers for each component positioning
  15317. var zrUtil = __webpack_require__(4);
  15318. var BoundingRect = __webpack_require__(9);
  15319. var numberUtil = __webpack_require__(7);
  15320. var formatUtil = __webpack_require__(6);
  15321. var parsePercent = numberUtil.parsePercent;
  15322. var each = zrUtil.each;
  15323. var layout = {};
  15324. /**
  15325. * @public
  15326. */
  15327. var LOCATION_PARAMS = layout.LOCATION_PARAMS = [
  15328. 'left', 'right', 'top', 'bottom', 'width', 'height'
  15329. ];
  15330. /**
  15331. * @public
  15332. */
  15333. var HV_NAMES = layout.HV_NAMES = [
  15334. ['width', 'left', 'right'],
  15335. ['height', 'top', 'bottom']
  15336. ];
  15337. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  15338. var x = 0;
  15339. var y = 0;
  15340. if (maxWidth == null) {
  15341. maxWidth = Infinity;
  15342. }
  15343. if (maxHeight == null) {
  15344. maxHeight = Infinity;
  15345. }
  15346. var currentLineMaxSize = 0;
  15347. group.eachChild(function (child, idx) {
  15348. var position = child.position;
  15349. var rect = child.getBoundingRect();
  15350. var nextChild = group.childAt(idx + 1);
  15351. var nextChildRect = nextChild && nextChild.getBoundingRect();
  15352. var nextX;
  15353. var nextY;
  15354. if (orient === 'horizontal') {
  15355. var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
  15356. nextX = x + moveX;
  15357. // Wrap when width exceeds maxWidth or meet a `newline` group
  15358. // FIXME compare before adding gap?
  15359. if (nextX > maxWidth || child.newline) {
  15360. x = 0;
  15361. nextX = moveX;
  15362. y += currentLineMaxSize + gap;
  15363. currentLineMaxSize = rect.height;
  15364. }
  15365. else {
  15366. // FIXME: consider rect.y is not `0`?
  15367. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
  15368. }
  15369. }
  15370. else {
  15371. var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
  15372. nextY = y + moveY;
  15373. // Wrap when width exceeds maxHeight or meet a `newline` group
  15374. if (nextY > maxHeight || child.newline) {
  15375. x += currentLineMaxSize + gap;
  15376. y = 0;
  15377. nextY = moveY;
  15378. currentLineMaxSize = rect.width;
  15379. }
  15380. else {
  15381. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
  15382. }
  15383. }
  15384. if (child.newline) {
  15385. return;
  15386. }
  15387. position[0] = x;
  15388. position[1] = y;
  15389. orient === 'horizontal'
  15390. ? (x = nextX + gap)
  15391. : (y = nextY + gap);
  15392. });
  15393. }
  15394. /**
  15395. * VBox or HBox layouting
  15396. * @param {string} orient
  15397. * @param {module:zrender/container/Group} group
  15398. * @param {number} gap
  15399. * @param {number} [width=Infinity]
  15400. * @param {number} [height=Infinity]
  15401. */
  15402. layout.box = boxLayout;
  15403. /**
  15404. * VBox layouting
  15405. * @param {module:zrender/container/Group} group
  15406. * @param {number} gap
  15407. * @param {number} [width=Infinity]
  15408. * @param {number} [height=Infinity]
  15409. */
  15410. layout.vbox = zrUtil.curry(boxLayout, 'vertical');
  15411. /**
  15412. * HBox layouting
  15413. * @param {module:zrender/container/Group} group
  15414. * @param {number} gap
  15415. * @param {number} [width=Infinity]
  15416. * @param {number} [height=Infinity]
  15417. */
  15418. layout.hbox = zrUtil.curry(boxLayout, 'horizontal');
  15419. /**
  15420. * If x or x2 is not specified or 'center' 'left' 'right',
  15421. * the width would be as long as possible.
  15422. * If y or y2 is not specified or 'middle' 'top' 'bottom',
  15423. * the height would be as long as possible.
  15424. *
  15425. * @param {Object} positionInfo
  15426. * @param {number|string} [positionInfo.x]
  15427. * @param {number|string} [positionInfo.y]
  15428. * @param {number|string} [positionInfo.x2]
  15429. * @param {number|string} [positionInfo.y2]
  15430. * @param {Object} containerRect {width, height}
  15431. * @param {string|number} margin
  15432. * @return {Object} {width, height}
  15433. */
  15434. layout.getAvailableSize = function (positionInfo, containerRect, margin) {
  15435. var containerWidth = containerRect.width;
  15436. var containerHeight = containerRect.height;
  15437. var x = parsePercent(positionInfo.x, containerWidth);
  15438. var y = parsePercent(positionInfo.y, containerHeight);
  15439. var x2 = parsePercent(positionInfo.x2, containerWidth);
  15440. var y2 = parsePercent(positionInfo.y2, containerHeight);
  15441. (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0);
  15442. (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth);
  15443. (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0);
  15444. (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight);
  15445. margin = formatUtil.normalizeCssArray(margin || 0);
  15446. return {
  15447. width: Math.max(x2 - x - margin[1] - margin[3], 0),
  15448. height: Math.max(y2 - y - margin[0] - margin[2], 0)
  15449. };
  15450. };
  15451. /**
  15452. * Parse position info.
  15453. *
  15454. * @param {Object} positionInfo
  15455. * @param {number|string} [positionInfo.left]
  15456. * @param {number|string} [positionInfo.top]
  15457. * @param {number|string} [positionInfo.right]
  15458. * @param {number|string} [positionInfo.bottom]
  15459. * @param {number|string} [positionInfo.width]
  15460. * @param {number|string} [positionInfo.height]
  15461. * @param {number|string} [positionInfo.aspect] Aspect is width / height
  15462. * @param {Object} containerRect
  15463. * @param {string|number} [margin]
  15464. *
  15465. * @return {module:zrender/core/BoundingRect}
  15466. */
  15467. layout.getLayoutRect = function (
  15468. positionInfo, containerRect, margin
  15469. ) {
  15470. margin = formatUtil.normalizeCssArray(margin || 0);
  15471. var containerWidth = containerRect.width;
  15472. var containerHeight = containerRect.height;
  15473. var left = parsePercent(positionInfo.left, containerWidth);
  15474. var top = parsePercent(positionInfo.top, containerHeight);
  15475. var right = parsePercent(positionInfo.right, containerWidth);
  15476. var bottom = parsePercent(positionInfo.bottom, containerHeight);
  15477. var width = parsePercent(positionInfo.width, containerWidth);
  15478. var height = parsePercent(positionInfo.height, containerHeight);
  15479. var verticalMargin = margin[2] + margin[0];
  15480. var horizontalMargin = margin[1] + margin[3];
  15481. var aspect = positionInfo.aspect;
  15482. // If width is not specified, calculate width from left and right
  15483. if (isNaN(width)) {
  15484. width = containerWidth - right - horizontalMargin - left;
  15485. }
  15486. if (isNaN(height)) {
  15487. height = containerHeight - bottom - verticalMargin - top;
  15488. }
  15489. if (aspect != null) {
  15490. // If width and height are not given
  15491. // 1. Graph should not exceeds the container
  15492. // 2. Aspect must be keeped
  15493. // 3. Graph should take the space as more as possible
  15494. // FIXME
  15495. // Margin is not considered, because there is no case that both
  15496. // using margin and aspect so far.
  15497. if (isNaN(width) && isNaN(height)) {
  15498. if (aspect > containerWidth / containerHeight) {
  15499. width = containerWidth * 0.8;
  15500. }
  15501. else {
  15502. height = containerHeight * 0.8;
  15503. }
  15504. }
  15505. // Calculate width or height with given aspect
  15506. if (isNaN(width)) {
  15507. width = aspect * height;
  15508. }
  15509. if (isNaN(height)) {
  15510. height = width / aspect;
  15511. }
  15512. }
  15513. // If left is not specified, calculate left from right and width
  15514. if (isNaN(left)) {
  15515. left = containerWidth - right - width - horizontalMargin;
  15516. }
  15517. if (isNaN(top)) {
  15518. top = containerHeight - bottom - height - verticalMargin;
  15519. }
  15520. // Align left and top
  15521. switch (positionInfo.left || positionInfo.right) {
  15522. case 'center':
  15523. left = containerWidth / 2 - width / 2 - margin[3];
  15524. break;
  15525. case 'right':
  15526. left = containerWidth - width - horizontalMargin;
  15527. break;
  15528. }
  15529. switch (positionInfo.top || positionInfo.bottom) {
  15530. case 'middle':
  15531. case 'center':
  15532. top = containerHeight / 2 - height / 2 - margin[0];
  15533. break;
  15534. case 'bottom':
  15535. top = containerHeight - height - verticalMargin;
  15536. break;
  15537. }
  15538. // If something is wrong and left, top, width, height are calculated as NaN
  15539. left = left || 0;
  15540. top = top || 0;
  15541. if (isNaN(width)) {
  15542. // Width may be NaN if only one value is given except width
  15543. width = containerWidth - horizontalMargin - left - (right || 0);
  15544. }
  15545. if (isNaN(height)) {
  15546. // Height may be NaN if only one value is given except height
  15547. height = containerHeight - verticalMargin - top - (bottom || 0);
  15548. }
  15549. var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
  15550. rect.margin = margin;
  15551. return rect;
  15552. };
  15553. /**
  15554. * Position a zr element in viewport
  15555. * Group position is specified by either
  15556. * {left, top}, {right, bottom}
  15557. * If all properties exists, right and bottom will be igonred.
  15558. *
  15559. * Logic:
  15560. * 1. Scale (against origin point in parent coord)
  15561. * 2. Rotate (against origin point in parent coord)
  15562. * 3. Traslate (with el.position by this method)
  15563. * So this method only fixes the last step 'Traslate', which does not affect
  15564. * scaling and rotating.
  15565. *
  15566. * If be called repeatly with the same input el, the same result will be gotten.
  15567. *
  15568. * @param {module:zrender/Element} el Should have `getBoundingRect` method.
  15569. * @param {Object} positionInfo
  15570. * @param {number|string} [positionInfo.left]
  15571. * @param {number|string} [positionInfo.top]
  15572. * @param {number|string} [positionInfo.right]
  15573. * @param {number|string} [positionInfo.bottom]
  15574. * @param {number|string} [positionInfo.width] Only for opt.boundingModel: 'raw'
  15575. * @param {number|string} [positionInfo.height] Only for opt.boundingModel: 'raw'
  15576. * @param {Object} containerRect
  15577. * @param {string|number} margin
  15578. * @param {Object} [opt]
  15579. * @param {Array.<number>} [opt.hv=[1,1]] Only horizontal or only vertical.
  15580. * @param {Array.<number>} [opt.boundingMode='all']
  15581. * Specify how to calculate boundingRect when locating.
  15582. * 'all': Position the boundingRect that is transformed and uioned
  15583. * both itself and its descendants.
  15584. * This mode simplies confine the elements in the bounding
  15585. * of their container (e.g., using 'right: 0').
  15586. * 'raw': Position the boundingRect that is not transformed and only itself.
  15587. * This mode is useful when you want a element can overflow its
  15588. * container. (Consider a rotated circle needs to be located in a corner.)
  15589. * In this mode positionInfo.width/height can only be number.
  15590. */
  15591. layout.positionElement = function (el, positionInfo, containerRect, margin, opt) {
  15592. var h = !opt || !opt.hv || opt.hv[0];
  15593. var v = !opt || !opt.hv || opt.hv[1];
  15594. var boundingMode = opt && opt.boundingMode || 'all';
  15595. if (!h && !v) {
  15596. return;
  15597. }
  15598. var rect;
  15599. if (boundingMode === 'raw') {
  15600. rect = el.type === 'group'
  15601. ? new BoundingRect(0, 0, +positionInfo.width || 0, +positionInfo.height || 0)
  15602. : el.getBoundingRect();
  15603. }
  15604. else {
  15605. rect = el.getBoundingRect();
  15606. if (el.needLocalTransform()) {
  15607. var transform = el.getLocalTransform();
  15608. // Notice: raw rect may be inner object of el,
  15609. // which should not be modified.
  15610. rect = rect.clone();
  15611. rect.applyTransform(transform);
  15612. }
  15613. }
  15614. // The real width and height can not be specified but calculated by the given el.
  15615. positionInfo = layout.getLayoutRect(
  15616. zrUtil.defaults(
  15617. {width: rect.width, height: rect.height},
  15618. positionInfo
  15619. ),
  15620. containerRect,
  15621. margin
  15622. );
  15623. // Because 'tranlate' is the last step in transform
  15624. // (see zrender/core/Transformable#getLocalTransfrom),
  15625. // we can just only modify el.position to get final result.
  15626. var elPos = el.position;
  15627. var dx = h ? positionInfo.x - rect.x : 0;
  15628. var dy = v ? positionInfo.y - rect.y : 0;
  15629. el.attr('position', boundingMode === 'raw' ? [dx, dy] : [elPos[0] + dx, elPos[1] + dy]);
  15630. };
  15631. /**
  15632. * @param {Object} option Contains some of the properties in HV_NAMES.
  15633. * @param {number} hvIdx 0: horizontal; 1: vertical.
  15634. */
  15635. layout.sizeCalculable = function (option, hvIdx) {
  15636. return option[HV_NAMES[hvIdx][0]] != null
  15637. || (option[HV_NAMES[hvIdx][1]] != null && option[HV_NAMES[hvIdx][2]] != null);
  15638. };
  15639. /**
  15640. * Consider Case:
  15641. * When defulat option has {left: 0, width: 100}, and we set {right: 0}
  15642. * through setOption or media query, using normal zrUtil.merge will cause
  15643. * {right: 0} does not take effect.
  15644. *
  15645. * @example
  15646. * ComponentModel.extend({
  15647. * init: function () {
  15648. * ...
  15649. * var inputPositionParams = layout.getLayoutParams(option);
  15650. * this.mergeOption(inputPositionParams);
  15651. * },
  15652. * mergeOption: function (newOption) {
  15653. * newOption && zrUtil.merge(thisOption, newOption, true);
  15654. * layout.mergeLayoutParam(thisOption, newOption);
  15655. * }
  15656. * });
  15657. *
  15658. * @param {Object} targetOption
  15659. * @param {Object} newOption
  15660. * @param {Object|string} [opt]
  15661. * @param {boolean|Array.<boolean>} [opt.ignoreSize=false] Used for the components
  15662. * that width (or height) should not be calculated by left and right (or top and bottom).
  15663. */
  15664. layout.mergeLayoutParam = function (targetOption, newOption, opt) {
  15665. !zrUtil.isObject(opt) && (opt = {});
  15666. var ignoreSize = opt.ignoreSize;
  15667. !zrUtil.isArray(ignoreSize) && (ignoreSize = [ignoreSize, ignoreSize]);
  15668. var hResult = merge(HV_NAMES[0], 0);
  15669. var vResult = merge(HV_NAMES[1], 1);
  15670. copy(HV_NAMES[0], targetOption, hResult);
  15671. copy(HV_NAMES[1], targetOption, vResult);
  15672. function merge(names, hvIdx) {
  15673. var newParams = {};
  15674. var newValueCount = 0;
  15675. var merged = {};
  15676. var mergedValueCount = 0;
  15677. var enoughParamNumber = 2;
  15678. each(names, function (name) {
  15679. merged[name] = targetOption[name];
  15680. });
  15681. each(names, function (name) {
  15682. // Consider case: newOption.width is null, which is
  15683. // set by user for removing width setting.
  15684. hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
  15685. hasValue(newParams, name) && newValueCount++;
  15686. hasValue(merged, name) && mergedValueCount++;
  15687. });
  15688. if (ignoreSize[hvIdx]) {
  15689. // Only one of left/right is premitted to exist.
  15690. if (hasValue(newOption, names[1])) {
  15691. merged[names[2]] = null;
  15692. }
  15693. else if (hasValue(newOption, names[2])) {
  15694. merged[names[1]] = null;
  15695. }
  15696. return merged;
  15697. }
  15698. // Case: newOption: {width: ..., right: ...},
  15699. // or targetOption: {right: ...} and newOption: {width: ...},
  15700. // There is no conflict when merged only has params count
  15701. // little than enoughParamNumber.
  15702. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  15703. return merged;
  15704. }
  15705. // Case: newOption: {width: ..., right: ...},
  15706. // Than we can make sure user only want those two, and ignore
  15707. // all origin params in targetOption.
  15708. else if (newValueCount >= enoughParamNumber) {
  15709. return newParams;
  15710. }
  15711. else {
  15712. // Chose another param from targetOption by priority.
  15713. for (var i = 0; i < names.length; i++) {
  15714. var name = names[i];
  15715. if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
  15716. newParams[name] = targetOption[name];
  15717. break;
  15718. }
  15719. }
  15720. return newParams;
  15721. }
  15722. }
  15723. function hasProp(obj, name) {
  15724. return obj.hasOwnProperty(name);
  15725. }
  15726. function hasValue(obj, name) {
  15727. return obj[name] != null && obj[name] !== 'auto';
  15728. }
  15729. function copy(names, target, source) {
  15730. each(names, function (name) {
  15731. target[name] = source[name];
  15732. });
  15733. }
  15734. };
  15735. /**
  15736. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  15737. * @param {Object} source
  15738. * @return {Object} Result contains those props.
  15739. */
  15740. layout.getLayoutParams = function (source) {
  15741. return layout.copyLayoutParams({}, source);
  15742. };
  15743. /**
  15744. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  15745. * @param {Object} source
  15746. * @return {Object} Result contains those props.
  15747. */
  15748. layout.copyLayoutParams = function (target, source) {
  15749. source && target && each(LOCATION_PARAMS, function (name) {
  15750. source.hasOwnProperty(name) && (target[name] = source[name]);
  15751. });
  15752. return target;
  15753. };
  15754. module.exports = layout;
  15755. /***/ }),
  15756. /* 75 */
  15757. /***/ (function(module, exports) {
  15758. module.exports = {
  15759. getBoxLayoutParams: function () {
  15760. return {
  15761. left: this.get('left'),
  15762. top: this.get('top'),
  15763. right: this.get('right'),
  15764. bottom: this.get('bottom'),
  15765. width: this.get('width'),
  15766. height: this.get('height')
  15767. };
  15768. }
  15769. };
  15770. /***/ }),
  15771. /* 76 */
  15772. /***/ (function(module, exports) {
  15773. var platform = '';
  15774. // Navigator not exists in node
  15775. if (typeof navigator !== 'undefined') {
  15776. platform = navigator.platform || '';
  15777. }
  15778. module.exports = {
  15779. // 全图默认背景
  15780. // backgroundColor: 'rgba(0,0,0,0)',
  15781. // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization
  15782. // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'],
  15783. // 浅色
  15784. // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
  15785. // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'],
  15786. // 深色
  15787. color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
  15788. // 默认需要 Grid 配置项
  15789. // grid: {},
  15790. // 主题,主题
  15791. textStyle: {
  15792. // color: '#000',
  15793. // decoration: 'none',
  15794. // PENDING
  15795. fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
  15796. // fontFamily: 'Arial, Verdana, sans-serif',
  15797. fontSize: 12,
  15798. fontStyle: 'normal',
  15799. fontWeight: 'normal'
  15800. },
  15801. // http://blogs.adobe.com/webplatform/2014/02/24/using-blend-modes-in-html-canvas/
  15802. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  15803. // Default is source-over
  15804. blendMode: null,
  15805. animation: 'auto',
  15806. animationDuration: 1000,
  15807. animationDurationUpdate: 300,
  15808. animationEasing: 'exponentialOut',
  15809. animationEasingUpdate: 'cubicOut',
  15810. animationThreshold: 2000,
  15811. // Configuration for progressive/incremental rendering
  15812. progressiveThreshold: 3000,
  15813. progressive: 400,
  15814. // Threshold of if use single hover layer to optimize.
  15815. // It is recommended that `hoverLayerThreshold` is equivalent to or less than
  15816. // `progressiveThreshold`, otherwise hover will cause restart of progressive,
  15817. // which is unexpected.
  15818. // see example <echarts/test/heatmap-large.html>.
  15819. hoverLayerThreshold: 3000,
  15820. // See: module:echarts/scale/Time
  15821. useUTC: false
  15822. };
  15823. /***/ }),
  15824. /* 77 */
  15825. /***/ (function(module, exports, __webpack_require__) {
  15826. var classUtil = __webpack_require__(15);
  15827. var set = classUtil.set;
  15828. var get = classUtil.get;
  15829. module.exports = {
  15830. clearColorPalette: function () {
  15831. set(this, 'colorIdx', 0);
  15832. set(this, 'colorNameMap', {});
  15833. },
  15834. getColorFromPalette: function (name, scope) {
  15835. scope = scope || this;
  15836. var colorIdx = get(scope, 'colorIdx') || 0;
  15837. var colorNameMap = get(scope, 'colorNameMap') || set(scope, 'colorNameMap', {});
  15838. // Use `hasOwnProperty` to avoid conflict with Object.prototype.
  15839. if (colorNameMap.hasOwnProperty(name)) {
  15840. return colorNameMap[name];
  15841. }
  15842. var colorPalette = this.get('color', true) || [];
  15843. if (!colorPalette.length) {
  15844. return;
  15845. }
  15846. var color = colorPalette[colorIdx];
  15847. if (name) {
  15848. colorNameMap[name] = color;
  15849. }
  15850. set(scope, 'colorIdx', (colorIdx + 1) % colorPalette.length);
  15851. return color;
  15852. }
  15853. };
  15854. /***/ }),
  15855. /* 78 */
  15856. /***/ (function(module, exports, __webpack_require__) {
  15857. 'use strict';
  15858. var zrUtil = __webpack_require__(4);
  15859. var echartsAPIList = [
  15860. 'getDom', 'getZr', 'getWidth', 'getHeight', 'getDevicePixelRatio', 'dispatchAction', 'isDisposed',
  15861. 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption',
  15862. 'getViewOfComponentModel', 'getViewOfSeriesModel'
  15863. ];
  15864. // And `getCoordinateSystems` and `getComponentByElement` will be injected in echarts.js
  15865. function ExtensionAPI(chartInstance) {
  15866. zrUtil.each(echartsAPIList, function (name) {
  15867. this[name] = zrUtil.bind(chartInstance[name], chartInstance);
  15868. }, this);
  15869. }
  15870. module.exports = ExtensionAPI;
  15871. /***/ }),
  15872. /* 79 */
  15873. /***/ (function(module, exports, __webpack_require__) {
  15874. 'use strict';
  15875. var zrUtil = __webpack_require__(4);
  15876. var coordinateSystemCreators = {};
  15877. function CoordinateSystemManager() {
  15878. this._coordinateSystems = [];
  15879. }
  15880. CoordinateSystemManager.prototype = {
  15881. constructor: CoordinateSystemManager,
  15882. create: function (ecModel, api) {
  15883. var coordinateSystems = [];
  15884. zrUtil.each(coordinateSystemCreators, function (creater, type) {
  15885. var list = creater.create(ecModel, api);
  15886. coordinateSystems = coordinateSystems.concat(list || []);
  15887. });
  15888. this._coordinateSystems = coordinateSystems;
  15889. },
  15890. update: function (ecModel, api) {
  15891. zrUtil.each(this._coordinateSystems, function (coordSys) {
  15892. // FIXME MUST have
  15893. coordSys.update && coordSys.update(ecModel, api);
  15894. });
  15895. },
  15896. getCoordinateSystems: function () {
  15897. return this._coordinateSystems.slice();
  15898. }
  15899. };
  15900. CoordinateSystemManager.register = function (type, coordinateSystemCreator) {
  15901. coordinateSystemCreators[type] = coordinateSystemCreator;
  15902. };
  15903. CoordinateSystemManager.get = function (type) {
  15904. return coordinateSystemCreators[type];
  15905. };
  15906. module.exports = CoordinateSystemManager;
  15907. /***/ }),
  15908. /* 80 */
  15909. /***/ (function(module, exports, __webpack_require__) {
  15910. /**
  15911. * ECharts option manager
  15912. *
  15913. * @module {echarts/model/OptionManager}
  15914. */
  15915. var zrUtil = __webpack_require__(4);
  15916. var modelUtil = __webpack_require__(5);
  15917. var ComponentModel = __webpack_require__(72);
  15918. var each = zrUtil.each;
  15919. var clone = zrUtil.clone;
  15920. var map = zrUtil.map;
  15921. var merge = zrUtil.merge;
  15922. var QUERY_REG = /^(min|max)?(.+)$/;
  15923. /**
  15924. * TERM EXPLANATIONS:
  15925. *
  15926. * [option]:
  15927. *
  15928. * An object that contains definitions of components. For example:
  15929. * var option = {
  15930. * title: {...},
  15931. * legend: {...},
  15932. * visualMap: {...},
  15933. * series: [
  15934. * {data: [...]},
  15935. * {data: [...]},
  15936. * ...
  15937. * ]
  15938. * };
  15939. *
  15940. * [rawOption]:
  15941. *
  15942. * An object input to echarts.setOption. 'rawOption' may be an
  15943. * 'option', or may be an object contains multi-options. For example:
  15944. * var option = {
  15945. * baseOption: {
  15946. * title: {...},
  15947. * legend: {...},
  15948. * series: [
  15949. * {data: [...]},
  15950. * {data: [...]},
  15951. * ...
  15952. * ]
  15953. * },
  15954. * timeline: {...},
  15955. * options: [
  15956. * {title: {...}, series: {data: [...]}},
  15957. * {title: {...}, series: {data: [...]}},
  15958. * ...
  15959. * ],
  15960. * media: [
  15961. * {
  15962. * query: {maxWidth: 320},
  15963. * option: {series: {x: 20}, visualMap: {show: false}}
  15964. * },
  15965. * {
  15966. * query: {minWidth: 320, maxWidth: 720},
  15967. * option: {series: {x: 500}, visualMap: {show: true}}
  15968. * },
  15969. * {
  15970. * option: {series: {x: 1200}, visualMap: {show: true}}
  15971. * }
  15972. * ]
  15973. * };
  15974. *
  15975. * @alias module:echarts/model/OptionManager
  15976. * @param {module:echarts/ExtensionAPI} api
  15977. */
  15978. function OptionManager(api) {
  15979. /**
  15980. * @private
  15981. * @type {module:echarts/ExtensionAPI}
  15982. */
  15983. this._api = api;
  15984. /**
  15985. * @private
  15986. * @type {Array.<number>}
  15987. */
  15988. this._timelineOptions = [];
  15989. /**
  15990. * @private
  15991. * @type {Array.<Object>}
  15992. */
  15993. this._mediaList = [];
  15994. /**
  15995. * @private
  15996. * @type {Object}
  15997. */
  15998. this._mediaDefault;
  15999. /**
  16000. * -1, means default.
  16001. * empty means no media.
  16002. * @private
  16003. * @type {Array.<number>}
  16004. */
  16005. this._currentMediaIndices = [];
  16006. /**
  16007. * @private
  16008. * @type {Object}
  16009. */
  16010. this._optionBackup;
  16011. /**
  16012. * @private
  16013. * @type {Object}
  16014. */
  16015. this._newBaseOption;
  16016. }
  16017. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  16018. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  16019. // rawOption cloned and backuped when timeline changed, which does no
  16020. // good to performance. What's more, that both timeline and setOption
  16021. // method supply 'notMerge' brings complex and some problems.
  16022. // Consider this case:
  16023. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  16024. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  16025. OptionManager.prototype = {
  16026. constructor: OptionManager,
  16027. /**
  16028. * @public
  16029. * @param {Object} rawOption Raw option.
  16030. * @param {module:echarts/model/Global} ecModel
  16031. * @param {Array.<Function>} optionPreprocessorFuncs
  16032. * @return {Object} Init option
  16033. */
  16034. setOption: function (rawOption, optionPreprocessorFuncs) {
  16035. rawOption = clone(rawOption, true);
  16036. // FIXME
  16037. // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。
  16038. var oldOptionBackup = this._optionBackup;
  16039. var newParsedOption = parseRawOption.call(
  16040. this, rawOption, optionPreprocessorFuncs, !oldOptionBackup
  16041. );
  16042. this._newBaseOption = newParsedOption.baseOption;
  16043. // For setOption at second time (using merge mode);
  16044. if (oldOptionBackup) {
  16045. // Only baseOption can be merged.
  16046. mergeOption(oldOptionBackup.baseOption, newParsedOption.baseOption);
  16047. // For simplicity, timeline options and media options do not support merge,
  16048. // that is, if you `setOption` twice and both has timeline options, the latter
  16049. // timeline opitons will not be merged to the formers, but just substitude them.
  16050. if (newParsedOption.timelineOptions.length) {
  16051. oldOptionBackup.timelineOptions = newParsedOption.timelineOptions;
  16052. }
  16053. if (newParsedOption.mediaList.length) {
  16054. oldOptionBackup.mediaList = newParsedOption.mediaList;
  16055. }
  16056. if (newParsedOption.mediaDefault) {
  16057. oldOptionBackup.mediaDefault = newParsedOption.mediaDefault;
  16058. }
  16059. }
  16060. else {
  16061. this._optionBackup = newParsedOption;
  16062. }
  16063. },
  16064. /**
  16065. * @param {boolean} isRecreate
  16066. * @return {Object}
  16067. */
  16068. mountOption: function (isRecreate) {
  16069. var optionBackup = this._optionBackup;
  16070. // TODO
  16071. // 如果没有reset功能则不clone。
  16072. this._timelineOptions = map(optionBackup.timelineOptions, clone);
  16073. this._mediaList = map(optionBackup.mediaList, clone);
  16074. this._mediaDefault = clone(optionBackup.mediaDefault);
  16075. this._currentMediaIndices = [];
  16076. return clone(isRecreate
  16077. // this._optionBackup.baseOption, which is created at the first `setOption`
  16078. // called, and is merged into every new option by inner method `mergeOption`
  16079. // each time `setOption` called, can be only used in `isRecreate`, because
  16080. // its reliability is under suspicion. In other cases option merge is
  16081. // performed by `model.mergeOption`.
  16082. ? optionBackup.baseOption : this._newBaseOption
  16083. );
  16084. },
  16085. /**
  16086. * @param {module:echarts/model/Global} ecModel
  16087. * @return {Object}
  16088. */
  16089. getTimelineOption: function (ecModel) {
  16090. var option;
  16091. var timelineOptions = this._timelineOptions;
  16092. if (timelineOptions.length) {
  16093. // getTimelineOption can only be called after ecModel inited,
  16094. // so we can get currentIndex from timelineModel.
  16095. var timelineModel = ecModel.getComponent('timeline');
  16096. if (timelineModel) {
  16097. option = clone(
  16098. timelineOptions[timelineModel.getCurrentIndex()],
  16099. true
  16100. );
  16101. }
  16102. }
  16103. return option;
  16104. },
  16105. /**
  16106. * @param {module:echarts/model/Global} ecModel
  16107. * @return {Array.<Object>}
  16108. */
  16109. getMediaOption: function (ecModel) {
  16110. var ecWidth = this._api.getWidth();
  16111. var ecHeight = this._api.getHeight();
  16112. var mediaList = this._mediaList;
  16113. var mediaDefault = this._mediaDefault;
  16114. var indices = [];
  16115. var result = [];
  16116. // No media defined.
  16117. if (!mediaList.length && !mediaDefault) {
  16118. return result;
  16119. }
  16120. // Multi media may be applied, the latter defined media has higher priority.
  16121. for (var i = 0, len = mediaList.length; i < len; i++) {
  16122. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  16123. indices.push(i);
  16124. }
  16125. }
  16126. // FIXME
  16127. // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。
  16128. if (!indices.length && mediaDefault) {
  16129. indices = [-1];
  16130. }
  16131. if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) {
  16132. result = map(indices, function (index) {
  16133. return clone(
  16134. index === -1 ? mediaDefault.option : mediaList[index].option
  16135. );
  16136. });
  16137. }
  16138. // Otherwise return nothing.
  16139. this._currentMediaIndices = indices;
  16140. return result;
  16141. }
  16142. };
  16143. function parseRawOption(rawOption, optionPreprocessorFuncs, isNew) {
  16144. var timelineOptions = [];
  16145. var mediaList = [];
  16146. var mediaDefault;
  16147. var baseOption;
  16148. // Compatible with ec2.
  16149. var timelineOpt = rawOption.timeline;
  16150. if (rawOption.baseOption) {
  16151. baseOption = rawOption.baseOption;
  16152. }
  16153. // For timeline
  16154. if (timelineOpt || rawOption.options) {
  16155. baseOption = baseOption || {};
  16156. timelineOptions = (rawOption.options || []).slice();
  16157. }
  16158. // For media query
  16159. if (rawOption.media) {
  16160. baseOption = baseOption || {};
  16161. var media = rawOption.media;
  16162. each(media, function (singleMedia) {
  16163. if (singleMedia && singleMedia.option) {
  16164. if (singleMedia.query) {
  16165. mediaList.push(singleMedia);
  16166. }
  16167. else if (!mediaDefault) {
  16168. // Use the first media default.
  16169. mediaDefault = singleMedia;
  16170. }
  16171. }
  16172. });
  16173. }
  16174. // For normal option
  16175. if (!baseOption) {
  16176. baseOption = rawOption;
  16177. }
  16178. // Set timelineOpt to baseOption in ec3,
  16179. // which is convenient for merge option.
  16180. if (!baseOption.timeline) {
  16181. baseOption.timeline = timelineOpt;
  16182. }
  16183. // Preprocess.
  16184. each([baseOption].concat(timelineOptions)
  16185. .concat(zrUtil.map(mediaList, function (media) {
  16186. return media.option;
  16187. })),
  16188. function (option) {
  16189. each(optionPreprocessorFuncs, function (preProcess) {
  16190. preProcess(option, isNew);
  16191. });
  16192. }
  16193. );
  16194. return {
  16195. baseOption: baseOption,
  16196. timelineOptions: timelineOptions,
  16197. mediaDefault: mediaDefault,
  16198. mediaList: mediaList
  16199. };
  16200. }
  16201. /**
  16202. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  16203. * Support: width, height, aspectRatio
  16204. * Can use max or min as prefix.
  16205. */
  16206. function applyMediaQuery(query, ecWidth, ecHeight) {
  16207. var realMap = {
  16208. width: ecWidth,
  16209. height: ecHeight,
  16210. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  16211. };
  16212. var applicatable = true;
  16213. zrUtil.each(query, function (value, attr) {
  16214. var matched = attr.match(QUERY_REG);
  16215. if (!matched || !matched[1] || !matched[2]) {
  16216. return;
  16217. }
  16218. var operator = matched[1];
  16219. var realAttr = matched[2].toLowerCase();
  16220. if (!compare(realMap[realAttr], value, operator)) {
  16221. applicatable = false;
  16222. }
  16223. });
  16224. return applicatable;
  16225. }
  16226. function compare(real, expect, operator) {
  16227. if (operator === 'min') {
  16228. return real >= expect;
  16229. }
  16230. else if (operator === 'max') {
  16231. return real <= expect;
  16232. }
  16233. else { // Equals
  16234. return real === expect;
  16235. }
  16236. }
  16237. function indicesEquals(indices1, indices2) {
  16238. // indices is always order by asc and has only finite number.
  16239. return indices1.join(',') === indices2.join(',');
  16240. }
  16241. /**
  16242. * Consider case:
  16243. * `chart.setOption(opt1);`
  16244. * Then user do some interaction like dataZoom, dataView changing.
  16245. * `chart.setOption(opt2);`
  16246. * Then user press 'reset button' in toolbox.
  16247. *
  16248. * After doing that all of the interaction effects should be reset, the
  16249. * chart should be the same as the result of invoke
  16250. * `chart.setOption(opt1); chart.setOption(opt2);`.
  16251. *
  16252. * Although it is not able ensure that
  16253. * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to
  16254. * `chart.setOption(merge(opt1, opt2));` exactly,
  16255. * this might be the only simple way to implement that feature.
  16256. *
  16257. * MEMO: We've considered some other approaches:
  16258. * 1. Each model handle its self restoration but not uniform treatment.
  16259. * (Too complex in logic and error-prone)
  16260. * 2. Use a shadow ecModel. (Performace expensive)
  16261. */
  16262. function mergeOption(oldOption, newOption) {
  16263. newOption = newOption || {};
  16264. each(newOption, function (newCptOpt, mainType) {
  16265. if (newCptOpt == null) {
  16266. return;
  16267. }
  16268. var oldCptOpt = oldOption[mainType];
  16269. if (!ComponentModel.hasClass(mainType)) {
  16270. oldOption[mainType] = merge(oldCptOpt, newCptOpt, true);
  16271. }
  16272. else {
  16273. newCptOpt = modelUtil.normalizeToArray(newCptOpt);
  16274. oldCptOpt = modelUtil.normalizeToArray(oldCptOpt);
  16275. var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt);
  16276. oldOption[mainType] = map(mapResult, function (item) {
  16277. return (item.option && item.exist)
  16278. ? merge(item.exist, item.option, true)
  16279. : (item.exist || item.option);
  16280. });
  16281. }
  16282. });
  16283. }
  16284. module.exports = OptionManager;
  16285. /***/ }),
  16286. /* 81 */
  16287. /***/ (function(module, exports, __webpack_require__) {
  16288. // Compatitable with 2.0
  16289. var zrUtil = __webpack_require__(4);
  16290. var compatStyle = __webpack_require__(82);
  16291. function get(opt, path) {
  16292. path = path.split(',');
  16293. var obj = opt;
  16294. for (var i = 0; i < path.length; i++) {
  16295. obj = obj && obj[path[i]];
  16296. if (obj == null) {
  16297. break;
  16298. }
  16299. }
  16300. return obj;
  16301. }
  16302. function set(opt, path, val, overwrite) {
  16303. path = path.split(',');
  16304. var obj = opt;
  16305. var key;
  16306. for (var i = 0; i < path.length - 1; i++) {
  16307. key = path[i];
  16308. if (obj[key] == null) {
  16309. obj[key] = {};
  16310. }
  16311. obj = obj[key];
  16312. }
  16313. if (overwrite || obj[path[i]] == null) {
  16314. obj[path[i]] = val;
  16315. }
  16316. }
  16317. function compatLayoutProperties(option) {
  16318. each(LAYOUT_PROPERTIES, function (prop) {
  16319. if (prop[0] in option && !(prop[1] in option)) {
  16320. option[prop[1]] = option[prop[0]];
  16321. }
  16322. });
  16323. }
  16324. var LAYOUT_PROPERTIES = [
  16325. ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom']
  16326. ];
  16327. var COMPATITABLE_COMPONENTS = [
  16328. 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline'
  16329. ];
  16330. var COMPATITABLE_SERIES = [
  16331. 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter',
  16332. 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel',
  16333. 'pie', 'radar', 'sankey', 'scatter', 'treemap'
  16334. ];
  16335. var each = zrUtil.each;
  16336. module.exports = function (option, isTheme) {
  16337. compatStyle(option, isTheme);
  16338. var series = option.series;
  16339. each(zrUtil.isArray(series) ? series : [series], function (seriesOpt) {
  16340. if (!zrUtil.isObject(seriesOpt)) {
  16341. return;
  16342. }
  16343. var seriesType = seriesOpt.type;
  16344. if (seriesType === 'pie' || seriesType === 'gauge') {
  16345. if (seriesOpt.clockWise != null) {
  16346. seriesOpt.clockwise = seriesOpt.clockWise;
  16347. }
  16348. }
  16349. if (seriesType === 'gauge') {
  16350. var pointerColor = get(seriesOpt, 'pointer.color');
  16351. pointerColor != null
  16352. && set(seriesOpt, 'itemStyle.normal.color', pointerColor);
  16353. }
  16354. for (var i = 0; i < COMPATITABLE_SERIES.length; i++) {
  16355. if (COMPATITABLE_SERIES[i] === seriesOpt.type) {
  16356. compatLayoutProperties(seriesOpt);
  16357. break;
  16358. }
  16359. }
  16360. });
  16361. // dataRange has changed to visualMap
  16362. if (option.dataRange) {
  16363. option.visualMap = option.dataRange;
  16364. }
  16365. each(COMPATITABLE_COMPONENTS, function (componentName) {
  16366. var options = option[componentName];
  16367. if (options) {
  16368. if (!zrUtil.isArray(options)) {
  16369. options = [options];
  16370. }
  16371. each(options, function (option) {
  16372. compatLayoutProperties(option);
  16373. });
  16374. }
  16375. });
  16376. };
  16377. /***/ }),
  16378. /* 82 */
  16379. /***/ (function(module, exports, __webpack_require__) {
  16380. var zrUtil = __webpack_require__(4);
  16381. var modelUtil = __webpack_require__(5);
  16382. var each = zrUtil.each;
  16383. var isObject = zrUtil.isObject;
  16384. var POSSIBLE_STYLES = [
  16385. 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
  16386. 'chordStyle', 'label', 'labelLine'
  16387. ];
  16388. function compatItemStyle(opt) {
  16389. var itemStyleOpt = opt && opt.itemStyle;
  16390. if (!itemStyleOpt) {
  16391. return;
  16392. }
  16393. for (var i = 0, len = POSSIBLE_STYLES.length; i < len; i++) {
  16394. var styleName = POSSIBLE_STYLES[i];
  16395. var normalItemStyleOpt = itemStyleOpt.normal;
  16396. var emphasisItemStyleOpt = itemStyleOpt.emphasis;
  16397. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  16398. opt[styleName] = opt[styleName] || {};
  16399. if (!opt[styleName].normal) {
  16400. opt[styleName].normal = normalItemStyleOpt[styleName];
  16401. }
  16402. else {
  16403. zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
  16404. }
  16405. normalItemStyleOpt[styleName] = null;
  16406. }
  16407. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  16408. opt[styleName] = opt[styleName] || {};
  16409. if (!opt[styleName].emphasis) {
  16410. opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
  16411. }
  16412. else {
  16413. zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
  16414. }
  16415. emphasisItemStyleOpt[styleName] = null;
  16416. }
  16417. }
  16418. }
  16419. function compatTextStyle(opt, propName) {
  16420. var labelOptSingle = isObject(opt) && opt[propName];
  16421. var textStyle = isObject(labelOptSingle) && labelOptSingle.textStyle;
  16422. if (textStyle) {
  16423. for (var i = 0, len = modelUtil.TEXT_STYLE_OPTIONS.length; i < len; i++) {
  16424. var propName = modelUtil.TEXT_STYLE_OPTIONS[i];
  16425. if (textStyle.hasOwnProperty(propName)) {
  16426. labelOptSingle[propName] = textStyle[propName];
  16427. }
  16428. }
  16429. }
  16430. }
  16431. function compatLabelTextStyle(labelOpt) {
  16432. if (isObject(labelOpt)) {
  16433. compatTextStyle(labelOpt, 'normal');
  16434. compatTextStyle(labelOpt, 'emphasis');
  16435. }
  16436. }
  16437. function processSeries(seriesOpt) {
  16438. if (!isObject(seriesOpt)) {
  16439. return;
  16440. }
  16441. compatItemStyle(seriesOpt);
  16442. compatLabelTextStyle(seriesOpt.label);
  16443. // treemap
  16444. compatLabelTextStyle(seriesOpt.upperLabel);
  16445. // graph
  16446. compatLabelTextStyle(seriesOpt.edgeLabel);
  16447. var markPoint = seriesOpt.markPoint;
  16448. compatItemStyle(markPoint);
  16449. compatLabelTextStyle(markPoint && markPoint.label);
  16450. var markLine = seriesOpt.markLine;
  16451. compatItemStyle(seriesOpt.markLine);
  16452. compatLabelTextStyle(markLine && markLine.label);
  16453. var markArea = seriesOpt.markArea;
  16454. compatLabelTextStyle(markArea && markArea.label);
  16455. // For gauge
  16456. compatTextStyle(seriesOpt, 'axisLabel');
  16457. compatTextStyle(seriesOpt, 'title');
  16458. compatTextStyle(seriesOpt, 'detail');
  16459. var data = seriesOpt.data;
  16460. if (data) {
  16461. for (var i = 0; i < data.length; i++) {
  16462. compatItemStyle(data[i]);
  16463. compatLabelTextStyle(data[i] && data[i].label);
  16464. }
  16465. }
  16466. // mark point data
  16467. var markPoint = seriesOpt.markPoint;
  16468. if (markPoint && markPoint.data) {
  16469. var mpData = markPoint.data;
  16470. for (var i = 0; i < mpData.length; i++) {
  16471. compatItemStyle(mpData[i]);
  16472. compatLabelTextStyle(mpData[i] && mpData[i].label);
  16473. }
  16474. }
  16475. // mark line data
  16476. var markLine = seriesOpt.markLine;
  16477. if (markLine && markLine.data) {
  16478. var mlData = markLine.data;
  16479. for (var i = 0; i < mlData.length; i++) {
  16480. if (zrUtil.isArray(mlData[i])) {
  16481. compatItemStyle(mlData[i][0]);
  16482. compatLabelTextStyle(mlData[i][0] && mlData[i][0].label);
  16483. compatItemStyle(mlData[i][1]);
  16484. compatLabelTextStyle(mlData[i][1] && mlData[i][1].label);
  16485. }
  16486. else {
  16487. compatItemStyle(mlData[i]);
  16488. compatLabelTextStyle(mlData[i] && mlData[i].label);
  16489. }
  16490. }
  16491. }
  16492. }
  16493. function toArr(o) {
  16494. return zrUtil.isArray(o) ? o : o ? [o] : [];
  16495. }
  16496. function toObj(o) {
  16497. return (zrUtil.isArray(o) ? o[0] : o) || {};
  16498. }
  16499. module.exports = function (option, isTheme) {
  16500. each(toArr(option.series), function (seriesOpt) {
  16501. isObject(seriesOpt) && processSeries(seriesOpt);
  16502. });
  16503. var axes = ['xAxis', 'yAxis', 'radiusAxis', 'angleAxis', 'singleAxis', 'parallelAxis', 'radar'];
  16504. isTheme && axes.push('valueAxis', 'categoryAxis', 'logAxis', 'timeAxis');
  16505. each(
  16506. axes,
  16507. function (axisName) {
  16508. each(toArr(option[axisName]), function (axisOpt) {
  16509. if (axisOpt) {
  16510. compatTextStyle(axisOpt, 'axisLabel');
  16511. compatTextStyle(axisOpt.axisPointer, 'label');
  16512. }
  16513. });
  16514. }
  16515. );
  16516. each(toArr(option.parallel), function (parallelOpt) {
  16517. var parallelAxisDefault = parallelOpt && parallelOpt.parallelAxisDefault;
  16518. compatTextStyle(parallelAxisDefault, 'axisLabel');
  16519. compatTextStyle(parallelAxisDefault && parallelAxisDefault.axisPointer, 'label');
  16520. });
  16521. each(toArr(option.calendar), function (calendarOpt) {
  16522. compatTextStyle(calendarOpt, 'dayLabel');
  16523. compatTextStyle(calendarOpt, 'monthLabel');
  16524. compatTextStyle(calendarOpt, 'yearLabel');
  16525. });
  16526. // radar.name.textStyle
  16527. each(toArr(option.radar), function (radarOpt) {
  16528. compatTextStyle(radarOpt, 'name');
  16529. });
  16530. each(toArr(option.geo), function (geoOpt) {
  16531. if (isObject(geoOpt)) {
  16532. compatLabelTextStyle(geoOpt.label);
  16533. each(toArr(geoOpt.regions), function (regionObj) {
  16534. compatLabelTextStyle(regionObj.label);
  16535. });
  16536. }
  16537. });
  16538. compatLabelTextStyle(toObj(option.timeline).label);
  16539. compatTextStyle(toObj(option.axisPointer), 'label');
  16540. compatTextStyle(toObj(option.tooltip).axisPointer, 'label');
  16541. };
  16542. /***/ }),
  16543. /* 83 */
  16544. /***/ (function(module, exports, __webpack_require__) {
  16545. 'use strict';
  16546. var zrUtil = __webpack_require__(4);
  16547. var formatUtil = __webpack_require__(6);
  16548. var classUtil = __webpack_require__(15);
  16549. var modelUtil = __webpack_require__(5);
  16550. var ComponentModel = __webpack_require__(72);
  16551. var colorPaletteMixin = __webpack_require__(77);
  16552. var env = __webpack_require__(2);
  16553. var layout = __webpack_require__(74);
  16554. var set = classUtil.set;
  16555. var get = classUtil.get;
  16556. var encodeHTML = formatUtil.encodeHTML;
  16557. var addCommas = formatUtil.addCommas;
  16558. var SeriesModel = ComponentModel.extend({
  16559. type: 'series.__base__',
  16560. /**
  16561. * @readOnly
  16562. */
  16563. seriesIndex: 0,
  16564. // coodinateSystem will be injected in the echarts/CoordinateSystem
  16565. coordinateSystem: null,
  16566. /**
  16567. * @type {Object}
  16568. * @protected
  16569. */
  16570. defaultOption: null,
  16571. /**
  16572. * Data provided for legend
  16573. * @type {Function}
  16574. */
  16575. // PENDING
  16576. legendDataProvider: null,
  16577. /**
  16578. * Access path of color for visual
  16579. */
  16580. visualColorAccessPath: 'itemStyle.normal.color',
  16581. /**
  16582. * Support merge layout params.
  16583. * Only support 'box' now (left/right/top/bottom/width/height).
  16584. * @type {string|Object} Object can be {ignoreSize: true}
  16585. * @readOnly
  16586. */
  16587. layoutMode: null,
  16588. init: function (option, parentModel, ecModel, extraOpt) {
  16589. /**
  16590. * @type {number}
  16591. * @readOnly
  16592. */
  16593. this.seriesIndex = this.componentIndex;
  16594. this.mergeDefaultAndTheme(option, ecModel);
  16595. var data = this.getInitialData(option, ecModel);
  16596. if (true) {
  16597. zrUtil.assert(data, 'getInitialData returned invalid data.');
  16598. }
  16599. /**
  16600. * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph}
  16601. * @private
  16602. */
  16603. set(this, 'dataBeforeProcessed', data);
  16604. // If we reverse the order (make data firstly, and then make
  16605. // dataBeforeProcessed by cloneShallow), cloneShallow will
  16606. // cause data.graph.data !== data when using
  16607. // module:echarts/data/Graph or module:echarts/data/Tree.
  16608. // See module:echarts/data/helper/linkList
  16609. this.restoreData();
  16610. },
  16611. /**
  16612. * Util for merge default and theme to option
  16613. * @param {Object} option
  16614. * @param {module:echarts/model/Global} ecModel
  16615. */
  16616. mergeDefaultAndTheme: function (option, ecModel) {
  16617. var layoutMode = this.layoutMode;
  16618. var inputPositionParams = layoutMode
  16619. ? layout.getLayoutParams(option) : {};
  16620. // Backward compat: using subType on theme.
  16621. // But if name duplicate between series subType
  16622. // (for example: parallel) add component mainType,
  16623. // add suffix 'Series'.
  16624. var themeSubType = this.subType;
  16625. if (ComponentModel.hasClass(themeSubType)) {
  16626. themeSubType += 'Series';
  16627. }
  16628. zrUtil.merge(
  16629. option,
  16630. ecModel.getTheme().get(this.subType)
  16631. );
  16632. zrUtil.merge(option, this.getDefaultOption());
  16633. // Default label emphasis `show`
  16634. modelUtil.defaultEmphasis(option.label, ['show']);
  16635. this.fillDataTextStyle(option.data);
  16636. if (layoutMode) {
  16637. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  16638. }
  16639. },
  16640. mergeOption: function (newSeriesOption, ecModel) {
  16641. newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true);
  16642. this.fillDataTextStyle(newSeriesOption.data);
  16643. var layoutMode = this.layoutMode;
  16644. if (layoutMode) {
  16645. layout.mergeLayoutParam(this.option, newSeriesOption, layoutMode);
  16646. }
  16647. var data = this.getInitialData(newSeriesOption, ecModel);
  16648. // TODO Merge data?
  16649. if (data) {
  16650. set(this, 'data', data);
  16651. set(this, 'dataBeforeProcessed', data.cloneShallow());
  16652. }
  16653. },
  16654. fillDataTextStyle: function (data) {
  16655. // Default data label emphasis `show`
  16656. // FIXME Tree structure data ?
  16657. // FIXME Performance ?
  16658. if (data) {
  16659. var props = ['show'];
  16660. for (var i = 0; i < data.length; i++) {
  16661. if (data[i] && data[i].label) {
  16662. modelUtil.defaultEmphasis(data[i].label, props);
  16663. }
  16664. }
  16665. }
  16666. },
  16667. /**
  16668. * Init a data structure from data related option in series
  16669. * Must be overwritten
  16670. */
  16671. getInitialData: function () {},
  16672. /**
  16673. * @param {string} [dataType]
  16674. * @return {module:echarts/data/List}
  16675. */
  16676. getData: function (dataType) {
  16677. var data = get(this, 'data');
  16678. return dataType == null ? data : data.getLinkedData(dataType);
  16679. },
  16680. /**
  16681. * @param {module:echarts/data/List} data
  16682. */
  16683. setData: function (data) {
  16684. set(this, 'data', data);
  16685. },
  16686. /**
  16687. * Get data before processed
  16688. * @return {module:echarts/data/List}
  16689. */
  16690. getRawData: function () {
  16691. return get(this, 'dataBeforeProcessed');
  16692. },
  16693. /**
  16694. * Coord dimension to data dimension.
  16695. *
  16696. * By default the result is the same as dimensions of series data.
  16697. * But in some series data dimensions are different from coord dimensions (i.e.
  16698. * candlestick and boxplot). Override this method to handle those cases.
  16699. *
  16700. * Coord dimension to data dimension can be one-to-many
  16701. *
  16702. * @param {string} coordDim
  16703. * @return {Array.<string>} dimensions on the axis.
  16704. */
  16705. coordDimToDataDim: function (coordDim) {
  16706. return modelUtil.coordDimToDataDim(this.getData(), coordDim);
  16707. },
  16708. /**
  16709. * Convert data dimension to coord dimension.
  16710. *
  16711. * @param {string|number} dataDim
  16712. * @return {string}
  16713. */
  16714. dataDimToCoordDim: function (dataDim) {
  16715. return modelUtil.dataDimToCoordDim(this.getData(), dataDim);
  16716. },
  16717. /**
  16718. * Get base axis if has coordinate system and has axis.
  16719. * By default use coordSys.getBaseAxis();
  16720. * Can be overrided for some chart.
  16721. * @return {type} description
  16722. */
  16723. getBaseAxis: function () {
  16724. var coordSys = this.coordinateSystem;
  16725. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
  16726. },
  16727. // FIXME
  16728. /**
  16729. * Default tooltip formatter
  16730. *
  16731. * @param {number} dataIndex
  16732. * @param {boolean} [multipleSeries=false]
  16733. * @param {number} [dataType]
  16734. */
  16735. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  16736. function formatArrayValue(value) {
  16737. var vertially = zrUtil.reduce(value, function (vertially, val, idx) {
  16738. var dimItem = data.getDimensionInfo(idx);
  16739. return vertially |= dimItem && dimItem.tooltip !== false && dimItem.tooltipName != null;
  16740. }, 0);
  16741. var result = [];
  16742. var tooltipDims = modelUtil.otherDimToDataDim(data, 'tooltip');
  16743. tooltipDims.length
  16744. ? zrUtil.each(tooltipDims, function (dimIdx) {
  16745. setEachItem(data.get(dimIdx, dataIndex), dimIdx);
  16746. })
  16747. // By default, all dims is used on tooltip.
  16748. : zrUtil.each(value, setEachItem);
  16749. function setEachItem(val, dimIdx) {
  16750. var dimInfo = data.getDimensionInfo(dimIdx);
  16751. // If `dimInfo.tooltip` is not set, show tooltip.
  16752. if (!dimInfo || dimInfo.otherDims.tooltip === false) {
  16753. return;
  16754. }
  16755. var dimType = dimInfo.type;
  16756. var valStr = (vertially ? '- ' + (dimInfo.tooltipName || dimInfo.name) + ': ' : '')
  16757. + (dimType === 'ordinal'
  16758. ? val + ''
  16759. : dimType === 'time'
  16760. ? (multipleSeries ? '' : formatUtil.formatTime('yyyy/MM/dd hh:mm:ss', val))
  16761. : addCommas(val)
  16762. );
  16763. valStr && result.push(encodeHTML(valStr));
  16764. }
  16765. return (vertially ? '<br/>' : '') + result.join(vertially ? '<br/>' : ', ');
  16766. }
  16767. var data = get(this, 'data');
  16768. var value = this.getRawValue(dataIndex);
  16769. var formattedValue = zrUtil.isArray(value)
  16770. ? formatArrayValue(value) : encodeHTML(addCommas(value));
  16771. var name = data.getName(dataIndex);
  16772. var color = data.getItemVisual(dataIndex, 'color');
  16773. if (zrUtil.isObject(color) && color.colorStops) {
  16774. color = (color.colorStops[0] || {}).color;
  16775. }
  16776. color = color || 'transparent';
  16777. var colorEl = formatUtil.getTooltipMarker(color);
  16778. var seriesName = this.name;
  16779. // FIXME
  16780. if (seriesName === '\0-') {
  16781. // Not show '-'
  16782. seriesName = '';
  16783. }
  16784. seriesName = seriesName
  16785. ? encodeHTML(seriesName) + (!multipleSeries ? '<br/>' : ': ')
  16786. : '';
  16787. return !multipleSeries
  16788. ? seriesName + colorEl
  16789. + (name
  16790. ? encodeHTML(name) + ': ' + formattedValue
  16791. : formattedValue
  16792. )
  16793. : colorEl + seriesName + formattedValue;
  16794. },
  16795. /**
  16796. * @return {boolean}
  16797. */
  16798. isAnimationEnabled: function () {
  16799. if (env.node) {
  16800. return false;
  16801. }
  16802. var animationEnabled = this.getShallow('animation');
  16803. if (animationEnabled) {
  16804. if (this.getData().count() > this.getShallow('animationThreshold')) {
  16805. animationEnabled = false;
  16806. }
  16807. }
  16808. return animationEnabled;
  16809. },
  16810. restoreData: function () {
  16811. set(this, 'data', get(this, 'dataBeforeProcessed').cloneShallow());
  16812. },
  16813. getColorFromPalette: function (name, scope) {
  16814. var ecModel = this.ecModel;
  16815. // PENDING
  16816. var color = colorPaletteMixin.getColorFromPalette.call(this, name, scope);
  16817. if (!color) {
  16818. color = ecModel.getColorFromPalette(name, scope);
  16819. }
  16820. return color;
  16821. },
  16822. /**
  16823. * Get data indices for show tooltip content. See tooltip.
  16824. * @abstract
  16825. * @param {Array.<string>|string} dim
  16826. * @param {Array.<number>} value
  16827. * @param {module:echarts/coord/single/SingleAxis} baseAxis
  16828. * @return {Object} {dataIndices, nestestValue}.
  16829. */
  16830. getAxisTooltipData: null,
  16831. /**
  16832. * See tooltip.
  16833. * @abstract
  16834. * @param {number} dataIndex
  16835. * @return {Array.<number>} Point of tooltip. null/undefined can be returned.
  16836. */
  16837. getTooltipPosition: null
  16838. });
  16839. zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin);
  16840. zrUtil.mixin(SeriesModel, colorPaletteMixin);
  16841. module.exports = SeriesModel;
  16842. /***/ }),
  16843. /* 84 */
  16844. /***/ (function(module, exports, __webpack_require__) {
  16845. var Group = __webpack_require__(51);
  16846. var componentUtil = __webpack_require__(73);
  16847. var clazzUtil = __webpack_require__(15);
  16848. var Component = function () {
  16849. /**
  16850. * @type {module:zrender/container/Group}
  16851. * @readOnly
  16852. */
  16853. this.group = new Group();
  16854. /**
  16855. * @type {string}
  16856. * @readOnly
  16857. */
  16858. this.uid = componentUtil.getUID('viewComponent');
  16859. };
  16860. Component.prototype = {
  16861. constructor: Component,
  16862. init: function (ecModel, api) {},
  16863. render: function (componentModel, ecModel, api, payload) {},
  16864. dispose: function () {}
  16865. };
  16866. var componentProto = Component.prototype;
  16867. componentProto.updateView
  16868. = componentProto.updateLayout
  16869. = componentProto.updateVisual
  16870. = function (seriesModel, ecModel, api, payload) {
  16871. // Do nothing;
  16872. };
  16873. // Enable Component.extend.
  16874. clazzUtil.enableClassExtend(Component);
  16875. // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  16876. clazzUtil.enableClassManagement(Component, {registerWhenExtend: true});
  16877. module.exports = Component;
  16878. /***/ }),
  16879. /* 85 */
  16880. /***/ (function(module, exports, __webpack_require__) {
  16881. var Group = __webpack_require__(51);
  16882. var componentUtil = __webpack_require__(73);
  16883. var clazzUtil = __webpack_require__(15);
  16884. var modelUtil = __webpack_require__(5);
  16885. var zrUtil = __webpack_require__(4);
  16886. function Chart() {
  16887. /**
  16888. * @type {module:zrender/container/Group}
  16889. * @readOnly
  16890. */
  16891. this.group = new Group();
  16892. /**
  16893. * @type {string}
  16894. * @readOnly
  16895. */
  16896. this.uid = componentUtil.getUID('viewChart');
  16897. }
  16898. Chart.prototype = {
  16899. type: 'chart',
  16900. /**
  16901. * Init the chart
  16902. * @param {module:echarts/model/Global} ecModel
  16903. * @param {module:echarts/ExtensionAPI} api
  16904. */
  16905. init: function (ecModel, api) {},
  16906. /**
  16907. * Render the chart
  16908. * @param {module:echarts/model/Series} seriesModel
  16909. * @param {module:echarts/model/Global} ecModel
  16910. * @param {module:echarts/ExtensionAPI} api
  16911. * @param {Object} payload
  16912. */
  16913. render: function (seriesModel, ecModel, api, payload) {},
  16914. /**
  16915. * Highlight series or specified data item
  16916. * @param {module:echarts/model/Series} seriesModel
  16917. * @param {module:echarts/model/Global} ecModel
  16918. * @param {module:echarts/ExtensionAPI} api
  16919. * @param {Object} payload
  16920. */
  16921. highlight: function (seriesModel, ecModel, api, payload) {
  16922. toggleHighlight(seriesModel.getData(), payload, 'emphasis');
  16923. },
  16924. /**
  16925. * Downplay series or specified data item
  16926. * @param {module:echarts/model/Series} seriesModel
  16927. * @param {module:echarts/model/Global} ecModel
  16928. * @param {module:echarts/ExtensionAPI} api
  16929. * @param {Object} payload
  16930. */
  16931. downplay: function (seriesModel, ecModel, api, payload) {
  16932. toggleHighlight(seriesModel.getData(), payload, 'normal');
  16933. },
  16934. /**
  16935. * Remove self
  16936. * @param {module:echarts/model/Global} ecModel
  16937. * @param {module:echarts/ExtensionAPI} api
  16938. */
  16939. remove: function (ecModel, api) {
  16940. this.group.removeAll();
  16941. },
  16942. /**
  16943. * Dispose self
  16944. * @param {module:echarts/model/Global} ecModel
  16945. * @param {module:echarts/ExtensionAPI} api
  16946. */
  16947. dispose: function () {}
  16948. /**
  16949. * The view contains the given point.
  16950. * @interface
  16951. * @param {Array.<number>} point
  16952. * @return {boolean}
  16953. */
  16954. // containPoint: function () {}
  16955. };
  16956. var chartProto = Chart.prototype;
  16957. chartProto.updateView
  16958. = chartProto.updateLayout
  16959. = chartProto.updateVisual
  16960. = function (seriesModel, ecModel, api, payload) {
  16961. this.render(seriesModel, ecModel, api, payload);
  16962. };
  16963. /**
  16964. * Set state of single element
  16965. * @param {module:zrender/Element} el
  16966. * @param {string} state
  16967. */
  16968. function elSetState(el, state) {
  16969. if (el) {
  16970. el.trigger(state);
  16971. if (el.type === 'group') {
  16972. for (var i = 0; i < el.childCount(); i++) {
  16973. elSetState(el.childAt(i), state);
  16974. }
  16975. }
  16976. }
  16977. }
  16978. /**
  16979. * @param {module:echarts/data/List} data
  16980. * @param {Object} payload
  16981. * @param {string} state 'normal'|'emphasis'
  16982. * @inner
  16983. */
  16984. function toggleHighlight(data, payload, state) {
  16985. var dataIndex = modelUtil.queryDataIndex(data, payload);
  16986. if (dataIndex != null) {
  16987. zrUtil.each(modelUtil.normalizeToArray(dataIndex), function (dataIdx) {
  16988. elSetState(data.getItemGraphicEl(dataIdx), state);
  16989. });
  16990. }
  16991. else {
  16992. data.eachItemGraphicEl(function (el) {
  16993. elSetState(el, state);
  16994. });
  16995. }
  16996. }
  16997. // Enable Chart.extend.
  16998. clazzUtil.enableClassExtend(Chart, ['dispose']);
  16999. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  17000. clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true});
  17001. module.exports = Chart;
  17002. /***/ }),
  17003. /* 86 */
  17004. /***/ (function(module, exports) {
  17005. var lib = {};
  17006. var ORIGIN_METHOD = '\0__throttleOriginMethod';
  17007. var RATE = '\0__throttleRate';
  17008. var THROTTLE_TYPE = '\0__throttleType';
  17009. /**
  17010. * @public
  17011. * @param {(Function)} fn
  17012. * @param {number} [delay=0] Unit: ms.
  17013. * @param {boolean} [debounce=false]
  17014. * true: If call interval less than `delay`, only the last call works.
  17015. * false: If call interval less than `delay, call works on fixed rate.
  17016. * @return {(Function)} throttled fn.
  17017. */
  17018. lib.throttle = function (fn, delay, debounce) {
  17019. var currCall;
  17020. var lastCall = 0;
  17021. var lastExec = 0;
  17022. var timer = null;
  17023. var diff;
  17024. var scope;
  17025. var args;
  17026. var debounceNextCall;
  17027. delay = delay || 0;
  17028. function exec() {
  17029. lastExec = (new Date()).getTime();
  17030. timer = null;
  17031. fn.apply(scope, args || []);
  17032. }
  17033. var cb = function () {
  17034. currCall = (new Date()).getTime();
  17035. scope = this;
  17036. args = arguments;
  17037. var thisDelay = debounceNextCall || delay;
  17038. var thisDebounce = debounceNextCall || debounce;
  17039. debounceNextCall = null;
  17040. diff = currCall - (thisDebounce ? lastCall : lastExec) - thisDelay;
  17041. clearTimeout(timer);
  17042. if (thisDebounce) {
  17043. timer = setTimeout(exec, thisDelay);
  17044. }
  17045. else {
  17046. if (diff >= 0) {
  17047. exec();
  17048. }
  17049. else {
  17050. timer = setTimeout(exec, -diff);
  17051. }
  17052. }
  17053. lastCall = currCall;
  17054. };
  17055. /**
  17056. * Clear throttle.
  17057. * @public
  17058. */
  17059. cb.clear = function () {
  17060. if (timer) {
  17061. clearTimeout(timer);
  17062. timer = null;
  17063. }
  17064. };
  17065. /**
  17066. * Enable debounce once.
  17067. */
  17068. cb.debounceNextCall = function (debounceDelay) {
  17069. debounceNextCall = debounceDelay;
  17070. };
  17071. return cb;
  17072. };
  17073. /**
  17074. * Create throttle method or update throttle rate.
  17075. *
  17076. * @example
  17077. * ComponentView.prototype.render = function () {
  17078. * ...
  17079. * throttle.createOrUpdate(
  17080. * this,
  17081. * '_dispatchAction',
  17082. * this.model.get('throttle'),
  17083. * 'fixRate'
  17084. * );
  17085. * };
  17086. * ComponentView.prototype.remove = function () {
  17087. * throttle.clear(this, '_dispatchAction');
  17088. * };
  17089. * ComponentView.prototype.dispose = function () {
  17090. * throttle.clear(this, '_dispatchAction');
  17091. * };
  17092. *
  17093. * @public
  17094. * @param {Object} obj
  17095. * @param {string} fnAttr
  17096. * @param {number} [rate]
  17097. * @param {string} [throttleType='fixRate'] 'fixRate' or 'debounce'
  17098. * @return {Function} throttled function.
  17099. */
  17100. lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) {
  17101. var fn = obj[fnAttr];
  17102. if (!fn) {
  17103. return;
  17104. }
  17105. var originFn = fn[ORIGIN_METHOD] || fn;
  17106. var lastThrottleType = fn[THROTTLE_TYPE];
  17107. var lastRate = fn[RATE];
  17108. if (lastRate !== rate || lastThrottleType !== throttleType) {
  17109. if (rate == null || !throttleType) {
  17110. return (obj[fnAttr] = originFn);
  17111. }
  17112. fn = obj[fnAttr] = lib.throttle(
  17113. originFn, rate, throttleType === 'debounce'
  17114. );
  17115. fn[ORIGIN_METHOD] = originFn;
  17116. fn[THROTTLE_TYPE] = throttleType;
  17117. fn[RATE] = rate;
  17118. }
  17119. return fn;
  17120. };
  17121. /**
  17122. * Clear throttle. Example see throttle.createOrUpdate.
  17123. *
  17124. * @public
  17125. * @param {Object} obj
  17126. * @param {string} fnAttr
  17127. */
  17128. lib.clear = function (obj, fnAttr) {
  17129. var fn = obj[fnAttr];
  17130. if (fn && fn[ORIGIN_METHOD]) {
  17131. obj[fnAttr] = fn[ORIGIN_METHOD];
  17132. }
  17133. };
  17134. module.exports = lib;
  17135. /***/ }),
  17136. /* 87 */
  17137. /***/ (function(module, exports, __webpack_require__) {
  17138. /*!
  17139. * ZRender, a high performance 2d drawing library.
  17140. *
  17141. * Copyright (c) 2013, Baidu Inc.
  17142. * All rights reserved.
  17143. *
  17144. * LICENSE
  17145. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  17146. */
  17147. // Global defines
  17148. var guid = __webpack_require__(26);
  17149. var env = __webpack_require__(2);
  17150. var zrUtil = __webpack_require__(4);
  17151. var Handler = __webpack_require__(88);
  17152. var Storage = __webpack_require__(90);
  17153. var Animation = __webpack_require__(92);
  17154. var HandlerProxy = __webpack_require__(95);
  17155. var useVML = !env.canvasSupported;
  17156. var painterCtors = {
  17157. canvas: __webpack_require__(97)
  17158. };
  17159. var instances = {}; // ZRender实例map索引
  17160. var zrender = {};
  17161. /**
  17162. * @type {string}
  17163. */
  17164. zrender.version = '3.6.2';
  17165. /**
  17166. * Initializing a zrender instance
  17167. * @param {HTMLElement} dom
  17168. * @param {Object} opts
  17169. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  17170. * @param {number} [opts.devicePixelRatio]
  17171. * @param {number|string} [opts.width] Can be 'auto' (the same as null/undefined)
  17172. * @param {number|string} [opts.height] Can be 'auto' (the same as null/undefined)
  17173. * @return {module:zrender/ZRender}
  17174. */
  17175. zrender.init = function (dom, opts) {
  17176. var zr = new ZRender(guid(), dom, opts);
  17177. instances[zr.id] = zr;
  17178. return zr;
  17179. };
  17180. /**
  17181. * Dispose zrender instance
  17182. * @param {module:zrender/ZRender} zr
  17183. */
  17184. zrender.dispose = function (zr) {
  17185. if (zr) {
  17186. zr.dispose();
  17187. }
  17188. else {
  17189. for (var key in instances) {
  17190. if (instances.hasOwnProperty(key)) {
  17191. instances[key].dispose();
  17192. }
  17193. }
  17194. instances = {};
  17195. }
  17196. return zrender;
  17197. };
  17198. /**
  17199. * Get zrender instance by id
  17200. * @param {string} id zrender instance id
  17201. * @return {module:zrender/ZRender}
  17202. */
  17203. zrender.getInstance = function (id) {
  17204. return instances[id];
  17205. };
  17206. zrender.registerPainter = function (name, Ctor) {
  17207. painterCtors[name] = Ctor;
  17208. };
  17209. function delInstance(id) {
  17210. delete instances[id];
  17211. }
  17212. /**
  17213. * @module zrender/ZRender
  17214. */
  17215. /**
  17216. * @constructor
  17217. * @alias module:zrender/ZRender
  17218. * @param {string} id
  17219. * @param {HTMLElement} dom
  17220. * @param {Object} opts
  17221. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  17222. * @param {number} [opts.devicePixelRatio]
  17223. * @param {number} [opts.width] Can be 'auto' (the same as null/undefined)
  17224. * @param {number} [opts.height] Can be 'auto' (the same as null/undefined)
  17225. */
  17226. var ZRender = function (id, dom, opts) {
  17227. opts = opts || {};
  17228. /**
  17229. * @type {HTMLDomElement}
  17230. */
  17231. this.dom = dom;
  17232. /**
  17233. * @type {string}
  17234. */
  17235. this.id = id;
  17236. var self = this;
  17237. var storage = new Storage();
  17238. var rendererType = opts.renderer;
  17239. // TODO WebGL
  17240. if (useVML) {
  17241. if (!painterCtors.vml) {
  17242. throw new Error('You need to require \'zrender/vml/vml\' to support IE8');
  17243. }
  17244. rendererType = 'vml';
  17245. }
  17246. else if (!rendererType || !painterCtors[rendererType]) {
  17247. rendererType = 'canvas';
  17248. }
  17249. var painter = new painterCtors[rendererType](dom, storage, opts);
  17250. this.storage = storage;
  17251. this.painter = painter;
  17252. var handerProxy = !env.node ? new HandlerProxy(painter.getViewportRoot()) : null;
  17253. this.handler = new Handler(storage, painter, handerProxy, painter.root);
  17254. /**
  17255. * @type {module:zrender/animation/Animation}
  17256. */
  17257. this.animation = new Animation({
  17258. stage: {
  17259. update: zrUtil.bind(this.flush, this)
  17260. }
  17261. });
  17262. this.animation.start();
  17263. /**
  17264. * @type {boolean}
  17265. * @private
  17266. */
  17267. this._needsRefresh;
  17268. // 修改 storage.delFromStorage, 每次删除元素之前删除动画
  17269. // FIXME 有点ugly
  17270. var oldDelFromStorage = storage.delFromStorage;
  17271. var oldAddToStorage = storage.addToStorage;
  17272. storage.delFromStorage = function (el) {
  17273. oldDelFromStorage.call(storage, el);
  17274. el && el.removeSelfFromZr(self);
  17275. };
  17276. storage.addToStorage = function (el) {
  17277. oldAddToStorage.call(storage, el);
  17278. el.addSelfToZr(self);
  17279. };
  17280. };
  17281. ZRender.prototype = {
  17282. constructor: ZRender,
  17283. /**
  17284. * 获取实例唯一标识
  17285. * @return {string}
  17286. */
  17287. getId: function () {
  17288. return this.id;
  17289. },
  17290. /**
  17291. * 添加元素
  17292. * @param {module:zrender/Element} el
  17293. */
  17294. add: function (el) {
  17295. this.storage.addRoot(el);
  17296. this._needsRefresh = true;
  17297. },
  17298. /**
  17299. * 删除元素
  17300. * @param {module:zrender/Element} el
  17301. */
  17302. remove: function (el) {
  17303. this.storage.delRoot(el);
  17304. this._needsRefresh = true;
  17305. },
  17306. /**
  17307. * Change configuration of layer
  17308. * @param {string} zLevel
  17309. * @param {Object} config
  17310. * @param {string} [config.clearColor=0] Clear color
  17311. * @param {string} [config.motionBlur=false] If enable motion blur
  17312. * @param {number} [config.lastFrameAlpha=0.7] Motion blur factor. Larger value cause longer trailer
  17313. */
  17314. configLayer: function (zLevel, config) {
  17315. this.painter.configLayer(zLevel, config);
  17316. this._needsRefresh = true;
  17317. },
  17318. /**
  17319. * Repaint the canvas immediately
  17320. */
  17321. refreshImmediately: function () {
  17322. // var start = new Date();
  17323. // Clear needsRefresh ahead to avoid something wrong happens in refresh
  17324. // Or it will cause zrender refreshes again and again.
  17325. this._needsRefresh = false;
  17326. this.painter.refresh();
  17327. /**
  17328. * Avoid trigger zr.refresh in Element#beforeUpdate hook
  17329. */
  17330. this._needsRefresh = false;
  17331. // var end = new Date();
  17332. // var log = document.getElementById('log');
  17333. // if (log) {
  17334. // log.innerHTML = log.innerHTML + '<br>' + (end - start);
  17335. // }
  17336. },
  17337. /**
  17338. * Mark and repaint the canvas in the next frame of browser
  17339. */
  17340. refresh: function() {
  17341. this._needsRefresh = true;
  17342. },
  17343. /**
  17344. * Perform all refresh
  17345. */
  17346. flush: function () {
  17347. if (this._needsRefresh) {
  17348. this.refreshImmediately();
  17349. }
  17350. if (this._needsRefreshHover) {
  17351. this.refreshHoverImmediately();
  17352. }
  17353. },
  17354. /**
  17355. * Add element to hover layer
  17356. * @param {module:zrender/Element} el
  17357. * @param {Object} style
  17358. */
  17359. addHover: function (el, style) {
  17360. if (this.painter.addHover) {
  17361. this.painter.addHover(el, style);
  17362. this.refreshHover();
  17363. }
  17364. },
  17365. /**
  17366. * Add element from hover layer
  17367. * @param {module:zrender/Element} el
  17368. */
  17369. removeHover: function (el) {
  17370. if (this.painter.removeHover) {
  17371. this.painter.removeHover(el);
  17372. this.refreshHover();
  17373. }
  17374. },
  17375. /**
  17376. * Clear all hover elements in hover layer
  17377. * @param {module:zrender/Element} el
  17378. */
  17379. clearHover: function () {
  17380. if (this.painter.clearHover) {
  17381. this.painter.clearHover();
  17382. this.refreshHover();
  17383. }
  17384. },
  17385. /**
  17386. * Refresh hover in next frame
  17387. */
  17388. refreshHover: function () {
  17389. this._needsRefreshHover = true;
  17390. },
  17391. /**
  17392. * Refresh hover immediately
  17393. */
  17394. refreshHoverImmediately: function () {
  17395. this._needsRefreshHover = false;
  17396. this.painter.refreshHover && this.painter.refreshHover();
  17397. },
  17398. /**
  17399. * Resize the canvas.
  17400. * Should be invoked when container size is changed
  17401. * @param {Object} [opts]
  17402. * @param {number|string} [opts.width] Can be 'auto' (the same as null/undefined)
  17403. * @param {number|string} [opts.height] Can be 'auto' (the same as null/undefined)
  17404. */
  17405. resize: function(opts) {
  17406. opts = opts || {};
  17407. this.painter.resize(opts.width, opts.height);
  17408. this.handler.resize();
  17409. },
  17410. /**
  17411. * Stop and clear all animation immediately
  17412. */
  17413. clearAnimation: function () {
  17414. this.animation.clear();
  17415. },
  17416. /**
  17417. * Get container width
  17418. */
  17419. getWidth: function() {
  17420. return this.painter.getWidth();
  17421. },
  17422. /**
  17423. * Get container height
  17424. */
  17425. getHeight: function() {
  17426. return this.painter.getHeight();
  17427. },
  17428. /**
  17429. * Export the canvas as Base64 URL
  17430. * @param {string} type
  17431. * @param {string} [backgroundColor='#fff']
  17432. * @return {string} Base64 URL
  17433. */
  17434. // toDataURL: function(type, backgroundColor) {
  17435. // return this.painter.getRenderedCanvas({
  17436. // backgroundColor: backgroundColor
  17437. // }).toDataURL(type);
  17438. // },
  17439. /**
  17440. * Converting a path to image.
  17441. * It has much better performance of drawing image rather than drawing a vector path.
  17442. * @param {module:zrender/graphic/Path} e
  17443. * @param {number} width
  17444. * @param {number} height
  17445. */
  17446. pathToImage: function(e, dpr) {
  17447. return this.painter.pathToImage(e, dpr);
  17448. },
  17449. /**
  17450. * Set default cursor
  17451. * @param {string} [cursorStyle='default'] 例如 crosshair
  17452. */
  17453. setCursorStyle: function (cursorStyle) {
  17454. this.handler.setCursorStyle(cursorStyle);
  17455. },
  17456. /**
  17457. * Find hovered element
  17458. * @param {number} x
  17459. * @param {number} y
  17460. * @return {Object} {target, topTarget}
  17461. */
  17462. findHover: function (x, y) {
  17463. return this.handler.findHover(x, y);
  17464. },
  17465. /**
  17466. * Bind event
  17467. *
  17468. * @param {string} eventName Event name
  17469. * @param {Function} eventHandler Handler function
  17470. * @param {Object} [context] Context object
  17471. */
  17472. on: function(eventName, eventHandler, context) {
  17473. this.handler.on(eventName, eventHandler, context);
  17474. },
  17475. /**
  17476. * Unbind event
  17477. * @param {string} eventName Event name
  17478. * @param {Function} [eventHandler] Handler function
  17479. */
  17480. off: function(eventName, eventHandler) {
  17481. this.handler.off(eventName, eventHandler);
  17482. },
  17483. /**
  17484. * Trigger event manually
  17485. *
  17486. * @param {string} eventName Event name
  17487. * @param {event=} event Event object
  17488. */
  17489. trigger: function (eventName, event) {
  17490. this.handler.trigger(eventName, event);
  17491. },
  17492. /**
  17493. * Clear all objects and the canvas.
  17494. */
  17495. clear: function () {
  17496. this.storage.delRoot();
  17497. this.painter.clear();
  17498. },
  17499. /**
  17500. * Dispose self.
  17501. */
  17502. dispose: function () {
  17503. this.animation.stop();
  17504. this.clear();
  17505. this.storage.dispose();
  17506. this.painter.dispose();
  17507. this.handler.dispose();
  17508. this.animation =
  17509. this.storage =
  17510. this.painter =
  17511. this.handler = null;
  17512. delInstance(this.id);
  17513. }
  17514. };
  17515. module.exports = zrender;
  17516. /***/ }),
  17517. /* 88 */
  17518. /***/ (function(module, exports, __webpack_require__) {
  17519. 'use strict';
  17520. /**
  17521. * Handler
  17522. * @module zrender/Handler
  17523. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  17524. * errorrik (errorrik@gmail.com)
  17525. * pissang (shenyi.914@gmail.com)
  17526. */
  17527. var util = __webpack_require__(4);
  17528. var vec2 = __webpack_require__(10);
  17529. var Draggable = __webpack_require__(89);
  17530. var Eventful = __webpack_require__(27);
  17531. var SILENT = 'silent';
  17532. function makeEventPacket(eveType, targetInfo, event) {
  17533. return {
  17534. type: eveType,
  17535. event: event,
  17536. // target can only be an element that is not silent.
  17537. target: targetInfo.target,
  17538. // topTarget can be a silent element.
  17539. topTarget: targetInfo.topTarget,
  17540. cancelBubble: false,
  17541. offsetX: event.zrX,
  17542. offsetY: event.zrY,
  17543. gestureEvent: event.gestureEvent,
  17544. pinchX: event.pinchX,
  17545. pinchY: event.pinchY,
  17546. pinchScale: event.pinchScale,
  17547. wheelDelta: event.zrDelta,
  17548. zrByTouch: event.zrByTouch,
  17549. which: event.which
  17550. };
  17551. }
  17552. function EmptyProxy () {}
  17553. EmptyProxy.prototype.dispose = function () {};
  17554. var handlerNames = [
  17555. 'click', 'dblclick', 'mousewheel', 'mouseout',
  17556. 'mouseup', 'mousedown', 'mousemove', 'contextmenu'
  17557. ];
  17558. /**
  17559. * @alias module:zrender/Handler
  17560. * @constructor
  17561. * @extends module:zrender/mixin/Eventful
  17562. * @param {module:zrender/Storage} storage Storage instance.
  17563. * @param {module:zrender/Painter} painter Painter instance.
  17564. * @param {module:zrender/dom/HandlerProxy} proxy HandlerProxy instance.
  17565. * @param {HTMLElement} painterRoot painter.root (not painter.getViewportRoot()).
  17566. */
  17567. var Handler = function(storage, painter, proxy, painterRoot) {
  17568. Eventful.call(this);
  17569. this.storage = storage;
  17570. this.painter = painter;
  17571. this.painterRoot = painterRoot;
  17572. proxy = proxy || new EmptyProxy();
  17573. /**
  17574. * Proxy of event. can be Dom, WebGLSurface, etc.
  17575. */
  17576. this.proxy = proxy;
  17577. // Attach handler
  17578. proxy.handler = this;
  17579. /**
  17580. * {target, topTarget, x, y}
  17581. * @private
  17582. * @type {Object}
  17583. */
  17584. this._hovered = {};
  17585. /**
  17586. * @private
  17587. * @type {Date}
  17588. */
  17589. this._lastTouchMoment;
  17590. /**
  17591. * @private
  17592. * @type {number}
  17593. */
  17594. this._lastX;
  17595. /**
  17596. * @private
  17597. * @type {number}
  17598. */
  17599. this._lastY;
  17600. Draggable.call(this);
  17601. util.each(handlerNames, function (name) {
  17602. proxy.on && proxy.on(name, this[name], this);
  17603. }, this);
  17604. };
  17605. Handler.prototype = {
  17606. constructor: Handler,
  17607. mousemove: function (event) {
  17608. var x = event.zrX;
  17609. var y = event.zrY;
  17610. var lastHovered = this._hovered;
  17611. var lastHoveredTarget = lastHovered.target;
  17612. // If lastHoveredTarget is removed from zr (detected by '__zr') by some API call
  17613. // (like 'setOption' or 'dispatchAction') in event handlers, we should find
  17614. // lastHovered again here. Otherwise 'mouseout' can not be triggered normally.
  17615. // See #6198.
  17616. if (lastHoveredTarget && !lastHoveredTarget.__zr) {
  17617. lastHovered = this.findHover(lastHovered.x, lastHovered.y);
  17618. lastHoveredTarget = lastHovered.target;
  17619. }
  17620. var hovered = this._hovered = this.findHover(x, y);
  17621. var hoveredTarget = hovered.target;
  17622. var proxy = this.proxy;
  17623. proxy.setCursor && proxy.setCursor(hoveredTarget ? hoveredTarget.cursor : 'default');
  17624. // Mouse out on previous hovered element
  17625. if (lastHoveredTarget && hoveredTarget !== lastHoveredTarget) {
  17626. this.dispatchToElement(lastHovered, 'mouseout', event);
  17627. }
  17628. // Mouse moving on one element
  17629. this.dispatchToElement(hovered, 'mousemove', event);
  17630. // Mouse over on a new element
  17631. if (hoveredTarget && hoveredTarget !== lastHoveredTarget) {
  17632. this.dispatchToElement(hovered, 'mouseover', event);
  17633. }
  17634. },
  17635. mouseout: function (event) {
  17636. this.dispatchToElement(this._hovered, 'mouseout', event);
  17637. // There might be some doms created by upper layer application
  17638. // at the same level of painter.getViewportRoot() (e.g., tooltip
  17639. // dom created by echarts), where 'globalout' event should not
  17640. // be triggered when mouse enters these doms. (But 'mouseout'
  17641. // should be triggered at the original hovered element as usual).
  17642. var element = event.toElement || event.relatedTarget;
  17643. var innerDom;
  17644. do {
  17645. element = element && element.parentNode;
  17646. }
  17647. while (element && element.nodeType != 9 && !(
  17648. innerDom = element === this.painterRoot
  17649. ));
  17650. !innerDom && this.trigger('globalout', {event: event});
  17651. },
  17652. /**
  17653. * Resize
  17654. */
  17655. resize: function (event) {
  17656. this._hovered = {};
  17657. },
  17658. /**
  17659. * Dispatch event
  17660. * @param {string} eventName
  17661. * @param {event=} eventArgs
  17662. */
  17663. dispatch: function (eventName, eventArgs) {
  17664. var handler = this[eventName];
  17665. handler && handler.call(this, eventArgs);
  17666. },
  17667. /**
  17668. * Dispose
  17669. */
  17670. dispose: function () {
  17671. this.proxy.dispose();
  17672. this.storage =
  17673. this.proxy =
  17674. this.painter = null;
  17675. },
  17676. /**
  17677. * 设置默认的cursor style
  17678. * @param {string} [cursorStyle='default'] 例如 crosshair
  17679. */
  17680. setCursorStyle: function (cursorStyle) {
  17681. var proxy = this.proxy;
  17682. proxy.setCursor && proxy.setCursor(cursorStyle);
  17683. },
  17684. /**
  17685. * 事件分发代理
  17686. *
  17687. * @private
  17688. * @param {Object} targetInfo {target, topTarget} 目标图形元素
  17689. * @param {string} eventName 事件名称
  17690. * @param {Object} event 事件对象
  17691. */
  17692. dispatchToElement: function (targetInfo, eventName, event) {
  17693. targetInfo = targetInfo || {};
  17694. var el = targetInfo.target;
  17695. if (el && el.silent) {
  17696. return;
  17697. }
  17698. var eventHandler = 'on' + eventName;
  17699. var eventPacket = makeEventPacket(eventName, targetInfo, event);
  17700. while (el) {
  17701. el[eventHandler]
  17702. && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket));
  17703. el.trigger(eventName, eventPacket);
  17704. el = el.parent;
  17705. if (eventPacket.cancelBubble) {
  17706. break;
  17707. }
  17708. }
  17709. if (!eventPacket.cancelBubble) {
  17710. // 冒泡到顶级 zrender 对象
  17711. this.trigger(eventName, eventPacket);
  17712. // 分发事件到用户自定义层
  17713. // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在
  17714. this.painter && this.painter.eachOtherLayer(function (layer) {
  17715. if (typeof(layer[eventHandler]) == 'function') {
  17716. layer[eventHandler].call(layer, eventPacket);
  17717. }
  17718. if (layer.trigger) {
  17719. layer.trigger(eventName, eventPacket);
  17720. }
  17721. });
  17722. }
  17723. },
  17724. /**
  17725. * @private
  17726. * @param {number} x
  17727. * @param {number} y
  17728. * @param {module:zrender/graphic/Displayable} exclude
  17729. * @return {model:zrender/Element}
  17730. * @method
  17731. */
  17732. findHover: function(x, y, exclude) {
  17733. var list = this.storage.getDisplayList();
  17734. var out = {x: x, y: y};
  17735. for (var i = list.length - 1; i >= 0 ; i--) {
  17736. var hoverCheckResult;
  17737. if (list[i] !== exclude
  17738. // getDisplayList may include ignored item in VML mode
  17739. && !list[i].ignore
  17740. && (hoverCheckResult = isHover(list[i], x, y))
  17741. ) {
  17742. !out.topTarget && (out.topTarget = list[i]);
  17743. if (hoverCheckResult !== SILENT) {
  17744. out.target = list[i];
  17745. break;
  17746. }
  17747. }
  17748. }
  17749. return out;
  17750. }
  17751. };
  17752. // Common handlers
  17753. util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
  17754. Handler.prototype[name] = function (event) {
  17755. // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover
  17756. var hovered = this.findHover(event.zrX, event.zrY);
  17757. var hoveredTarget = hovered.target;
  17758. if (name === 'mousedown') {
  17759. this._downEl = hoveredTarget;
  17760. this._downPoint = [event.zrX, event.zrY];
  17761. // In case click triggered before mouseup
  17762. this._upEl = hoveredTarget;
  17763. }
  17764. else if (name === 'mosueup') {
  17765. this._upEl = hoveredTarget;
  17766. }
  17767. else if (name === 'click') {
  17768. if (this._downEl !== this._upEl
  17769. // Original click event is triggered on the whole canvas element,
  17770. // including the case that `mousedown` - `mousemove` - `mouseup`,
  17771. // which should be filtered, otherwise it will bring trouble to
  17772. // pan and zoom.
  17773. || !this._downPoint
  17774. // Arbitrary value
  17775. || vec2.dist(this._downPoint, [event.zrX, event.zrY]) > 4
  17776. ) {
  17777. return;
  17778. }
  17779. this._downPoint = null;
  17780. }
  17781. this.dispatchToElement(hovered, name, event);
  17782. };
  17783. });
  17784. function isHover(displayable, x, y) {
  17785. if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) {
  17786. var el = displayable;
  17787. var isSilent;
  17788. while (el) {
  17789. // If clipped by ancestor.
  17790. // FIXME: If clipPath has neither stroke nor fill,
  17791. // el.clipPath.contain(x, y) will always return false.
  17792. if (el.clipPath && !el.clipPath.contain(x, y)) {
  17793. return false;
  17794. }
  17795. if (el.silent) {
  17796. isSilent = true;
  17797. }
  17798. el = el.parent;
  17799. }
  17800. return isSilent ? SILENT : true;
  17801. }
  17802. return false;
  17803. }
  17804. util.mixin(Handler, Eventful);
  17805. util.mixin(Handler, Draggable);
  17806. module.exports = Handler;
  17807. /***/ }),
  17808. /* 89 */
  17809. /***/ (function(module, exports) {
  17810. // TODO Draggable for group
  17811. // FIXME Draggable on element which has parent rotation or scale
  17812. function Draggable() {
  17813. this.on('mousedown', this._dragStart, this);
  17814. this.on('mousemove', this._drag, this);
  17815. this.on('mouseup', this._dragEnd, this);
  17816. this.on('globalout', this._dragEnd, this);
  17817. // this._dropTarget = null;
  17818. // this._draggingTarget = null;
  17819. // this._x = 0;
  17820. // this._y = 0;
  17821. }
  17822. Draggable.prototype = {
  17823. constructor: Draggable,
  17824. _dragStart: function (e) {
  17825. var draggingTarget = e.target;
  17826. if (draggingTarget && draggingTarget.draggable) {
  17827. this._draggingTarget = draggingTarget;
  17828. draggingTarget.dragging = true;
  17829. this._x = e.offsetX;
  17830. this._y = e.offsetY;
  17831. this.dispatchToElement(param(draggingTarget, e), 'dragstart', e.event);
  17832. }
  17833. },
  17834. _drag: function (e) {
  17835. var draggingTarget = this._draggingTarget;
  17836. if (draggingTarget) {
  17837. var x = e.offsetX;
  17838. var y = e.offsetY;
  17839. var dx = x - this._x;
  17840. var dy = y - this._y;
  17841. this._x = x;
  17842. this._y = y;
  17843. draggingTarget.drift(dx, dy, e);
  17844. this.dispatchToElement(param(draggingTarget, e), 'drag', e.event);
  17845. var dropTarget = this.findHover(x, y, draggingTarget).target;
  17846. var lastDropTarget = this._dropTarget;
  17847. this._dropTarget = dropTarget;
  17848. if (draggingTarget !== dropTarget) {
  17849. if (lastDropTarget && dropTarget !== lastDropTarget) {
  17850. this.dispatchToElement(param(lastDropTarget, e), 'dragleave', e.event);
  17851. }
  17852. if (dropTarget && dropTarget !== lastDropTarget) {
  17853. this.dispatchToElement(param(dropTarget, e), 'dragenter', e.event);
  17854. }
  17855. }
  17856. }
  17857. },
  17858. _dragEnd: function (e) {
  17859. var draggingTarget = this._draggingTarget;
  17860. if (draggingTarget) {
  17861. draggingTarget.dragging = false;
  17862. }
  17863. this.dispatchToElement(param(draggingTarget, e), 'dragend', e.event);
  17864. if (this._dropTarget) {
  17865. this.dispatchToElement(param(this._dropTarget, e), 'drop', e.event);
  17866. }
  17867. this._draggingTarget = null;
  17868. this._dropTarget = null;
  17869. }
  17870. };
  17871. function param(target, e) {
  17872. return {target: target, topTarget: e && e.topTarget};
  17873. }
  17874. module.exports = Draggable;
  17875. /***/ }),
  17876. /* 90 */
  17877. /***/ (function(module, exports, __webpack_require__) {
  17878. 'use strict';
  17879. /**
  17880. * Storage内容仓库模块
  17881. * @module zrender/Storage
  17882. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  17883. * @author errorrik (errorrik@gmail.com)
  17884. * @author pissang (https://github.com/pissang/)
  17885. */
  17886. var util = __webpack_require__(4);
  17887. var env = __webpack_require__(2);
  17888. var Group = __webpack_require__(51);
  17889. // Use timsort because in most case elements are partially sorted
  17890. // https://jsfiddle.net/pissang/jr4x7mdm/8/
  17891. var timsort = __webpack_require__(91);
  17892. function shapeCompareFunc(a, b) {
  17893. if (a.zlevel === b.zlevel) {
  17894. if (a.z === b.z) {
  17895. // if (a.z2 === b.z2) {
  17896. // // FIXME Slow has renderidx compare
  17897. // // http://stackoverflow.com/questions/20883421/sorting-in-javascript-should-every-compare-function-have-a-return-0-statement
  17898. // // https://github.com/v8/v8/blob/47cce544a31ed5577ffe2963f67acb4144ee0232/src/js/array.js#L1012
  17899. // return a.__renderidx - b.__renderidx;
  17900. // }
  17901. return a.z2 - b.z2;
  17902. }
  17903. return a.z - b.z;
  17904. }
  17905. return a.zlevel - b.zlevel;
  17906. }
  17907. /**
  17908. * 内容仓库 (M)
  17909. * @alias module:zrender/Storage
  17910. * @constructor
  17911. */
  17912. var Storage = function () {
  17913. this._roots = [];
  17914. this._displayList = [];
  17915. this._displayListLen = 0;
  17916. };
  17917. Storage.prototype = {
  17918. constructor: Storage,
  17919. /**
  17920. * @param {Function} cb
  17921. *
  17922. */
  17923. traverse: function (cb, context) {
  17924. for (var i = 0; i < this._roots.length; i++) {
  17925. this._roots[i].traverse(cb, context);
  17926. }
  17927. },
  17928. /**
  17929. * 返回所有图形的绘制队列
  17930. * @param {boolean} [update=false] 是否在返回前更新该数组
  17931. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效
  17932. *
  17933. * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList}
  17934. * @return {Array.<module:zrender/graphic/Displayable>}
  17935. */
  17936. getDisplayList: function (update, includeIgnore) {
  17937. includeIgnore = includeIgnore || false;
  17938. if (update) {
  17939. this.updateDisplayList(includeIgnore);
  17940. }
  17941. return this._displayList;
  17942. },
  17943. /**
  17944. * 更新图形的绘制队列。
  17945. * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中,
  17946. * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列
  17947. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组
  17948. */
  17949. updateDisplayList: function (includeIgnore) {
  17950. this._displayListLen = 0;
  17951. var roots = this._roots;
  17952. var displayList = this._displayList;
  17953. for (var i = 0, len = roots.length; i < len; i++) {
  17954. this._updateAndAddDisplayable(roots[i], null, includeIgnore);
  17955. }
  17956. displayList.length = this._displayListLen;
  17957. // for (var i = 0, len = displayList.length; i < len; i++) {
  17958. // displayList[i].__renderidx = i;
  17959. // }
  17960. // displayList.sort(shapeCompareFunc);
  17961. env.canvasSupported && timsort(displayList, shapeCompareFunc);
  17962. },
  17963. _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) {
  17964. if (el.ignore && !includeIgnore) {
  17965. return;
  17966. }
  17967. el.beforeUpdate();
  17968. if (el.__dirty) {
  17969. el.update();
  17970. }
  17971. el.afterUpdate();
  17972. var userSetClipPath = el.clipPath;
  17973. if (userSetClipPath) {
  17974. // FIXME 效率影响
  17975. if (clipPaths) {
  17976. clipPaths = clipPaths.slice();
  17977. }
  17978. else {
  17979. clipPaths = [];
  17980. }
  17981. var currentClipPath = userSetClipPath;
  17982. var parentClipPath = el;
  17983. // Recursively add clip path
  17984. while (currentClipPath) {
  17985. // clipPath 的变换是基于使用这个 clipPath 的元素
  17986. currentClipPath.parent = parentClipPath;
  17987. currentClipPath.updateTransform();
  17988. clipPaths.push(currentClipPath);
  17989. parentClipPath = currentClipPath;
  17990. currentClipPath = currentClipPath.clipPath;
  17991. }
  17992. }
  17993. if (el.isGroup) {
  17994. var children = el._children;
  17995. for (var i = 0; i < children.length; i++) {
  17996. var child = children[i];
  17997. // Force to mark as dirty if group is dirty
  17998. // FIXME __dirtyPath ?
  17999. if (el.__dirty) {
  18000. child.__dirty = true;
  18001. }
  18002. this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
  18003. }
  18004. // Mark group clean here
  18005. el.__dirty = false;
  18006. }
  18007. else {
  18008. el.__clipPaths = clipPaths;
  18009. this._displayList[this._displayListLen++] = el;
  18010. }
  18011. },
  18012. /**
  18013. * 添加图形(Shape)或者组(Group)到根节点
  18014. * @param {module:zrender/Element} el
  18015. */
  18016. addRoot: function (el) {
  18017. if (el.__storage === this) {
  18018. return;
  18019. }
  18020. if (el instanceof Group) {
  18021. el.addChildrenToStorage(this);
  18022. }
  18023. this.addToStorage(el);
  18024. this._roots.push(el);
  18025. },
  18026. /**
  18027. * 删除指定的图形(Shape)或者组(Group)
  18028. * @param {string|Array.<string>} [el] 如果为空清空整个Storage
  18029. */
  18030. delRoot: function (el) {
  18031. if (el == null) {
  18032. // 不指定el清空
  18033. for (var i = 0; i < this._roots.length; i++) {
  18034. var root = this._roots[i];
  18035. if (root instanceof Group) {
  18036. root.delChildrenFromStorage(this);
  18037. }
  18038. }
  18039. this._roots = [];
  18040. this._displayList = [];
  18041. this._displayListLen = 0;
  18042. return;
  18043. }
  18044. if (el instanceof Array) {
  18045. for (var i = 0, l = el.length; i < l; i++) {
  18046. this.delRoot(el[i]);
  18047. }
  18048. return;
  18049. }
  18050. var idx = util.indexOf(this._roots, el);
  18051. if (idx >= 0) {
  18052. this.delFromStorage(el);
  18053. this._roots.splice(idx, 1);
  18054. if (el instanceof Group) {
  18055. el.delChildrenFromStorage(this);
  18056. }
  18057. }
  18058. },
  18059. addToStorage: function (el) {
  18060. el.__storage = this;
  18061. el.dirty(false);
  18062. return this;
  18063. },
  18064. delFromStorage: function (el) {
  18065. if (el) {
  18066. el.__storage = null;
  18067. }
  18068. return this;
  18069. },
  18070. /**
  18071. * 清空并且释放Storage
  18072. */
  18073. dispose: function () {
  18074. this._renderList =
  18075. this._roots = null;
  18076. },
  18077. displayableSortFunc: shapeCompareFunc
  18078. };
  18079. module.exports = Storage;
  18080. /***/ }),
  18081. /* 91 */
  18082. /***/ (function(module, exports) {
  18083. // https://github.com/mziccard/node-timsort
  18084. var DEFAULT_MIN_MERGE = 32;
  18085. var DEFAULT_MIN_GALLOPING = 7;
  18086. var DEFAULT_TMP_STORAGE_LENGTH = 256;
  18087. function minRunLength(n) {
  18088. var r = 0;
  18089. while (n >= DEFAULT_MIN_MERGE) {
  18090. r |= n & 1;
  18091. n >>= 1;
  18092. }
  18093. return n + r;
  18094. }
  18095. function makeAscendingRun(array, lo, hi, compare) {
  18096. var runHi = lo + 1;
  18097. if (runHi === hi) {
  18098. return 1;
  18099. }
  18100. if (compare(array[runHi++], array[lo]) < 0) {
  18101. while (runHi < hi && compare(array[runHi], array[runHi - 1]) < 0) {
  18102. runHi++;
  18103. }
  18104. reverseRun(array, lo, runHi);
  18105. }
  18106. else {
  18107. while (runHi < hi && compare(array[runHi], array[runHi - 1]) >= 0) {
  18108. runHi++;
  18109. }
  18110. }
  18111. return runHi - lo;
  18112. }
  18113. function reverseRun(array, lo, hi) {
  18114. hi--;
  18115. while (lo < hi) {
  18116. var t = array[lo];
  18117. array[lo++] = array[hi];
  18118. array[hi--] = t;
  18119. }
  18120. }
  18121. function binaryInsertionSort(array, lo, hi, start, compare) {
  18122. if (start === lo) {
  18123. start++;
  18124. }
  18125. for (; start < hi; start++) {
  18126. var pivot = array[start];
  18127. var left = lo;
  18128. var right = start;
  18129. var mid;
  18130. while (left < right) {
  18131. mid = left + right >>> 1;
  18132. if (compare(pivot, array[mid]) < 0) {
  18133. right = mid;
  18134. }
  18135. else {
  18136. left = mid + 1;
  18137. }
  18138. }
  18139. var n = start - left;
  18140. switch (n) {
  18141. case 3:
  18142. array[left + 3] = array[left + 2];
  18143. case 2:
  18144. array[left + 2] = array[left + 1];
  18145. case 1:
  18146. array[left + 1] = array[left];
  18147. break;
  18148. default:
  18149. while (n > 0) {
  18150. array[left + n] = array[left + n - 1];
  18151. n--;
  18152. }
  18153. }
  18154. array[left] = pivot;
  18155. }
  18156. }
  18157. function gallopLeft(value, array, start, length, hint, compare) {
  18158. var lastOffset = 0;
  18159. var maxOffset = 0;
  18160. var offset = 1;
  18161. if (compare(value, array[start + hint]) > 0) {
  18162. maxOffset = length - hint;
  18163. while (offset < maxOffset && compare(value, array[start + hint + offset]) > 0) {
  18164. lastOffset = offset;
  18165. offset = (offset << 1) + 1;
  18166. if (offset <= 0) {
  18167. offset = maxOffset;
  18168. }
  18169. }
  18170. if (offset > maxOffset) {
  18171. offset = maxOffset;
  18172. }
  18173. lastOffset += hint;
  18174. offset += hint;
  18175. }
  18176. else {
  18177. maxOffset = hint + 1;
  18178. while (offset < maxOffset && compare(value, array[start + hint - offset]) <= 0) {
  18179. lastOffset = offset;
  18180. offset = (offset << 1) + 1;
  18181. if (offset <= 0) {
  18182. offset = maxOffset;
  18183. }
  18184. }
  18185. if (offset > maxOffset) {
  18186. offset = maxOffset;
  18187. }
  18188. var tmp = lastOffset;
  18189. lastOffset = hint - offset;
  18190. offset = hint - tmp;
  18191. }
  18192. lastOffset++;
  18193. while (lastOffset < offset) {
  18194. var m = lastOffset + (offset - lastOffset >>> 1);
  18195. if (compare(value, array[start + m]) > 0) {
  18196. lastOffset = m + 1;
  18197. }
  18198. else {
  18199. offset = m;
  18200. }
  18201. }
  18202. return offset;
  18203. }
  18204. function gallopRight(value, array, start, length, hint, compare) {
  18205. var lastOffset = 0;
  18206. var maxOffset = 0;
  18207. var offset = 1;
  18208. if (compare(value, array[start + hint]) < 0) {
  18209. maxOffset = hint + 1;
  18210. while (offset < maxOffset && compare(value, array[start + hint - offset]) < 0) {
  18211. lastOffset = offset;
  18212. offset = (offset << 1) + 1;
  18213. if (offset <= 0) {
  18214. offset = maxOffset;
  18215. }
  18216. }
  18217. if (offset > maxOffset) {
  18218. offset = maxOffset;
  18219. }
  18220. var tmp = lastOffset;
  18221. lastOffset = hint - offset;
  18222. offset = hint - tmp;
  18223. }
  18224. else {
  18225. maxOffset = length - hint;
  18226. while (offset < maxOffset && compare(value, array[start + hint + offset]) >= 0) {
  18227. lastOffset = offset;
  18228. offset = (offset << 1) + 1;
  18229. if (offset <= 0) {
  18230. offset = maxOffset;
  18231. }
  18232. }
  18233. if (offset > maxOffset) {
  18234. offset = maxOffset;
  18235. }
  18236. lastOffset += hint;
  18237. offset += hint;
  18238. }
  18239. lastOffset++;
  18240. while (lastOffset < offset) {
  18241. var m = lastOffset + (offset - lastOffset >>> 1);
  18242. if (compare(value, array[start + m]) < 0) {
  18243. offset = m;
  18244. }
  18245. else {
  18246. lastOffset = m + 1;
  18247. }
  18248. }
  18249. return offset;
  18250. }
  18251. function TimSort(array, compare) {
  18252. var minGallop = DEFAULT_MIN_GALLOPING;
  18253. var length = 0;
  18254. var tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH;
  18255. var stackLength = 0;
  18256. var runStart;
  18257. var runLength;
  18258. var stackSize = 0;
  18259. length = array.length;
  18260. if (length < 2 * DEFAULT_TMP_STORAGE_LENGTH) {
  18261. tmpStorageLength = length >>> 1;
  18262. }
  18263. var tmp = [];
  18264. stackLength = length < 120 ? 5 : length < 1542 ? 10 : length < 119151 ? 19 : 40;
  18265. runStart = [];
  18266. runLength = [];
  18267. function pushRun(_runStart, _runLength) {
  18268. runStart[stackSize] = _runStart;
  18269. runLength[stackSize] = _runLength;
  18270. stackSize += 1;
  18271. }
  18272. function mergeRuns() {
  18273. while (stackSize > 1) {
  18274. var n = stackSize - 2;
  18275. if (n >= 1 && runLength[n - 1] <= runLength[n] + runLength[n + 1] || n >= 2 && runLength[n - 2] <= runLength[n] + runLength[n - 1]) {
  18276. if (runLength[n - 1] < runLength[n + 1]) {
  18277. n--;
  18278. }
  18279. }
  18280. else if (runLength[n] > runLength[n + 1]) {
  18281. break;
  18282. }
  18283. mergeAt(n);
  18284. }
  18285. }
  18286. function forceMergeRuns() {
  18287. while (stackSize > 1) {
  18288. var n = stackSize - 2;
  18289. if (n > 0 && runLength[n - 1] < runLength[n + 1]) {
  18290. n--;
  18291. }
  18292. mergeAt(n);
  18293. }
  18294. }
  18295. function mergeAt(i) {
  18296. var start1 = runStart[i];
  18297. var length1 = runLength[i];
  18298. var start2 = runStart[i + 1];
  18299. var length2 = runLength[i + 1];
  18300. runLength[i] = length1 + length2;
  18301. if (i === stackSize - 3) {
  18302. runStart[i + 1] = runStart[i + 2];
  18303. runLength[i + 1] = runLength[i + 2];
  18304. }
  18305. stackSize--;
  18306. var k = gallopRight(array[start2], array, start1, length1, 0, compare);
  18307. start1 += k;
  18308. length1 -= k;
  18309. if (length1 === 0) {
  18310. return;
  18311. }
  18312. length2 = gallopLeft(array[start1 + length1 - 1], array, start2, length2, length2 - 1, compare);
  18313. if (length2 === 0) {
  18314. return;
  18315. }
  18316. if (length1 <= length2) {
  18317. mergeLow(start1, length1, start2, length2);
  18318. }
  18319. else {
  18320. mergeHigh(start1, length1, start2, length2);
  18321. }
  18322. }
  18323. function mergeLow(start1, length1, start2, length2) {
  18324. var i = 0;
  18325. for (i = 0; i < length1; i++) {
  18326. tmp[i] = array[start1 + i];
  18327. }
  18328. var cursor1 = 0;
  18329. var cursor2 = start2;
  18330. var dest = start1;
  18331. array[dest++] = array[cursor2++];
  18332. if (--length2 === 0) {
  18333. for (i = 0; i < length1; i++) {
  18334. array[dest + i] = tmp[cursor1 + i];
  18335. }
  18336. return;
  18337. }
  18338. if (length1 === 1) {
  18339. for (i = 0; i < length2; i++) {
  18340. array[dest + i] = array[cursor2 + i];
  18341. }
  18342. array[dest + length2] = tmp[cursor1];
  18343. return;
  18344. }
  18345. var _minGallop = minGallop;
  18346. var count1, count2, exit;
  18347. while (1) {
  18348. count1 = 0;
  18349. count2 = 0;
  18350. exit = false;
  18351. do {
  18352. if (compare(array[cursor2], tmp[cursor1]) < 0) {
  18353. array[dest++] = array[cursor2++];
  18354. count2++;
  18355. count1 = 0;
  18356. if (--length2 === 0) {
  18357. exit = true;
  18358. break;
  18359. }
  18360. }
  18361. else {
  18362. array[dest++] = tmp[cursor1++];
  18363. count1++;
  18364. count2 = 0;
  18365. if (--length1 === 1) {
  18366. exit = true;
  18367. break;
  18368. }
  18369. }
  18370. } while ((count1 | count2) < _minGallop);
  18371. if (exit) {
  18372. break;
  18373. }
  18374. do {
  18375. count1 = gallopRight(array[cursor2], tmp, cursor1, length1, 0, compare);
  18376. if (count1 !== 0) {
  18377. for (i = 0; i < count1; i++) {
  18378. array[dest + i] = tmp[cursor1 + i];
  18379. }
  18380. dest += count1;
  18381. cursor1 += count1;
  18382. length1 -= count1;
  18383. if (length1 <= 1) {
  18384. exit = true;
  18385. break;
  18386. }
  18387. }
  18388. array[dest++] = array[cursor2++];
  18389. if (--length2 === 0) {
  18390. exit = true;
  18391. break;
  18392. }
  18393. count2 = gallopLeft(tmp[cursor1], array, cursor2, length2, 0, compare);
  18394. if (count2 !== 0) {
  18395. for (i = 0; i < count2; i++) {
  18396. array[dest + i] = array[cursor2 + i];
  18397. }
  18398. dest += count2;
  18399. cursor2 += count2;
  18400. length2 -= count2;
  18401. if (length2 === 0) {
  18402. exit = true;
  18403. break;
  18404. }
  18405. }
  18406. array[dest++] = tmp[cursor1++];
  18407. if (--length1 === 1) {
  18408. exit = true;
  18409. break;
  18410. }
  18411. _minGallop--;
  18412. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  18413. if (exit) {
  18414. break;
  18415. }
  18416. if (_minGallop < 0) {
  18417. _minGallop = 0;
  18418. }
  18419. _minGallop += 2;
  18420. }
  18421. minGallop = _minGallop;
  18422. minGallop < 1 && (minGallop = 1);
  18423. if (length1 === 1) {
  18424. for (i = 0; i < length2; i++) {
  18425. array[dest + i] = array[cursor2 + i];
  18426. }
  18427. array[dest + length2] = tmp[cursor1];
  18428. }
  18429. else if (length1 === 0) {
  18430. throw new Error();
  18431. // throw new Error('mergeLow preconditions were not respected');
  18432. }
  18433. else {
  18434. for (i = 0; i < length1; i++) {
  18435. array[dest + i] = tmp[cursor1 + i];
  18436. }
  18437. }
  18438. }
  18439. function mergeHigh (start1, length1, start2, length2) {
  18440. var i = 0;
  18441. for (i = 0; i < length2; i++) {
  18442. tmp[i] = array[start2 + i];
  18443. }
  18444. var cursor1 = start1 + length1 - 1;
  18445. var cursor2 = length2 - 1;
  18446. var dest = start2 + length2 - 1;
  18447. var customCursor = 0;
  18448. var customDest = 0;
  18449. array[dest--] = array[cursor1--];
  18450. if (--length1 === 0) {
  18451. customCursor = dest - (length2 - 1);
  18452. for (i = 0; i < length2; i++) {
  18453. array[customCursor + i] = tmp[i];
  18454. }
  18455. return;
  18456. }
  18457. if (length2 === 1) {
  18458. dest -= length1;
  18459. cursor1 -= length1;
  18460. customDest = dest + 1;
  18461. customCursor = cursor1 + 1;
  18462. for (i = length1 - 1; i >= 0; i--) {
  18463. array[customDest + i] = array[customCursor + i];
  18464. }
  18465. array[dest] = tmp[cursor2];
  18466. return;
  18467. }
  18468. var _minGallop = minGallop;
  18469. while (true) {
  18470. var count1 = 0;
  18471. var count2 = 0;
  18472. var exit = false;
  18473. do {
  18474. if (compare(tmp[cursor2], array[cursor1]) < 0) {
  18475. array[dest--] = array[cursor1--];
  18476. count1++;
  18477. count2 = 0;
  18478. if (--length1 === 0) {
  18479. exit = true;
  18480. break;
  18481. }
  18482. }
  18483. else {
  18484. array[dest--] = tmp[cursor2--];
  18485. count2++;
  18486. count1 = 0;
  18487. if (--length2 === 1) {
  18488. exit = true;
  18489. break;
  18490. }
  18491. }
  18492. } while ((count1 | count2) < _minGallop);
  18493. if (exit) {
  18494. break;
  18495. }
  18496. do {
  18497. count1 = length1 - gallopRight(tmp[cursor2], array, start1, length1, length1 - 1, compare);
  18498. if (count1 !== 0) {
  18499. dest -= count1;
  18500. cursor1 -= count1;
  18501. length1 -= count1;
  18502. customDest = dest + 1;
  18503. customCursor = cursor1 + 1;
  18504. for (i = count1 - 1; i >= 0; i--) {
  18505. array[customDest + i] = array[customCursor + i];
  18506. }
  18507. if (length1 === 0) {
  18508. exit = true;
  18509. break;
  18510. }
  18511. }
  18512. array[dest--] = tmp[cursor2--];
  18513. if (--length2 === 1) {
  18514. exit = true;
  18515. break;
  18516. }
  18517. count2 = length2 - gallopLeft(array[cursor1], tmp, 0, length2, length2 - 1, compare);
  18518. if (count2 !== 0) {
  18519. dest -= count2;
  18520. cursor2 -= count2;
  18521. length2 -= count2;
  18522. customDest = dest + 1;
  18523. customCursor = cursor2 + 1;
  18524. for (i = 0; i < count2; i++) {
  18525. array[customDest + i] = tmp[customCursor + i];
  18526. }
  18527. if (length2 <= 1) {
  18528. exit = true;
  18529. break;
  18530. }
  18531. }
  18532. array[dest--] = array[cursor1--];
  18533. if (--length1 === 0) {
  18534. exit = true;
  18535. break;
  18536. }
  18537. _minGallop--;
  18538. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  18539. if (exit) {
  18540. break;
  18541. }
  18542. if (_minGallop < 0) {
  18543. _minGallop = 0;
  18544. }
  18545. _minGallop += 2;
  18546. }
  18547. minGallop = _minGallop;
  18548. if (minGallop < 1) {
  18549. minGallop = 1;
  18550. }
  18551. if (length2 === 1) {
  18552. dest -= length1;
  18553. cursor1 -= length1;
  18554. customDest = dest + 1;
  18555. customCursor = cursor1 + 1;
  18556. for (i = length1 - 1; i >= 0; i--) {
  18557. array[customDest + i] = array[customCursor + i];
  18558. }
  18559. array[dest] = tmp[cursor2];
  18560. }
  18561. else if (length2 === 0) {
  18562. throw new Error();
  18563. // throw new Error('mergeHigh preconditions were not respected');
  18564. }
  18565. else {
  18566. customCursor = dest - (length2 - 1);
  18567. for (i = 0; i < length2; i++) {
  18568. array[customCursor + i] = tmp[i];
  18569. }
  18570. }
  18571. }
  18572. this.mergeRuns = mergeRuns;
  18573. this.forceMergeRuns = forceMergeRuns;
  18574. this.pushRun = pushRun;
  18575. }
  18576. function sort(array, compare, lo, hi) {
  18577. if (!lo) {
  18578. lo = 0;
  18579. }
  18580. if (!hi) {
  18581. hi = array.length;
  18582. }
  18583. var remaining = hi - lo;
  18584. if (remaining < 2) {
  18585. return;
  18586. }
  18587. var runLength = 0;
  18588. if (remaining < DEFAULT_MIN_MERGE) {
  18589. runLength = makeAscendingRun(array, lo, hi, compare);
  18590. binaryInsertionSort(array, lo, hi, lo + runLength, compare);
  18591. return;
  18592. }
  18593. var ts = new TimSort(array, compare);
  18594. var minRun = minRunLength(remaining);
  18595. do {
  18596. runLength = makeAscendingRun(array, lo, hi, compare);
  18597. if (runLength < minRun) {
  18598. var force = remaining;
  18599. if (force > minRun) {
  18600. force = minRun;
  18601. }
  18602. binaryInsertionSort(array, lo, lo + force, lo + runLength, compare);
  18603. runLength = force;
  18604. }
  18605. ts.pushRun(lo, runLength);
  18606. ts.mergeRuns();
  18607. remaining -= runLength;
  18608. lo += runLength;
  18609. } while (remaining !== 0);
  18610. ts.forceMergeRuns();
  18611. }
  18612. module.exports = sort;
  18613. /***/ }),
  18614. /* 92 */
  18615. /***/ (function(module, exports, __webpack_require__) {
  18616. 'use strict';
  18617. /**
  18618. * 动画主类, 调度和管理所有动画控制器
  18619. *
  18620. * @module zrender/animation/Animation
  18621. * @author pissang(https://github.com/pissang)
  18622. */
  18623. // TODO Additive animation
  18624. // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/
  18625. // https://developer.apple.com/videos/wwdc2014/#236
  18626. var util = __webpack_require__(4);
  18627. var Dispatcher = __webpack_require__(93).Dispatcher;
  18628. var requestAnimationFrame = __webpack_require__(94);
  18629. var Animator = __webpack_require__(30);
  18630. /**
  18631. * @typedef {Object} IZRenderStage
  18632. * @property {Function} update
  18633. */
  18634. /**
  18635. * @alias module:zrender/animation/Animation
  18636. * @constructor
  18637. * @param {Object} [options]
  18638. * @param {Function} [options.onframe]
  18639. * @param {IZRenderStage} [options.stage]
  18640. * @example
  18641. * var animation = new Animation();
  18642. * var obj = {
  18643. * x: 100,
  18644. * y: 100
  18645. * };
  18646. * animation.animate(node.position)
  18647. * .when(1000, {
  18648. * x: 500,
  18649. * y: 500
  18650. * })
  18651. * .when(2000, {
  18652. * x: 100,
  18653. * y: 100
  18654. * })
  18655. * .start('spline');
  18656. */
  18657. var Animation = function (options) {
  18658. options = options || {};
  18659. this.stage = options.stage || {};
  18660. this.onframe = options.onframe || function() {};
  18661. // private properties
  18662. this._clips = [];
  18663. this._running = false;
  18664. this._time;
  18665. this._pausedTime;
  18666. this._pauseStart;
  18667. this._paused = false;
  18668. Dispatcher.call(this);
  18669. };
  18670. Animation.prototype = {
  18671. constructor: Animation,
  18672. /**
  18673. * 添加 clip
  18674. * @param {module:zrender/animation/Clip} clip
  18675. */
  18676. addClip: function (clip) {
  18677. this._clips.push(clip);
  18678. },
  18679. /**
  18680. * 添加 animator
  18681. * @param {module:zrender/animation/Animator} animator
  18682. */
  18683. addAnimator: function (animator) {
  18684. animator.animation = this;
  18685. var clips = animator.getClips();
  18686. for (var i = 0; i < clips.length; i++) {
  18687. this.addClip(clips[i]);
  18688. }
  18689. },
  18690. /**
  18691. * 删除动画片段
  18692. * @param {module:zrender/animation/Clip} clip
  18693. */
  18694. removeClip: function(clip) {
  18695. var idx = util.indexOf(this._clips, clip);
  18696. if (idx >= 0) {
  18697. this._clips.splice(idx, 1);
  18698. }
  18699. },
  18700. /**
  18701. * 删除动画片段
  18702. * @param {module:zrender/animation/Animator} animator
  18703. */
  18704. removeAnimator: function (animator) {
  18705. var clips = animator.getClips();
  18706. for (var i = 0; i < clips.length; i++) {
  18707. this.removeClip(clips[i]);
  18708. }
  18709. animator.animation = null;
  18710. },
  18711. _update: function() {
  18712. var time = new Date().getTime() - this._pausedTime;
  18713. var delta = time - this._time;
  18714. var clips = this._clips;
  18715. var len = clips.length;
  18716. var deferredEvents = [];
  18717. var deferredClips = [];
  18718. for (var i = 0; i < len; i++) {
  18719. var clip = clips[i];
  18720. var e = clip.step(time, delta);
  18721. // Throw out the events need to be called after
  18722. // stage.update, like destroy
  18723. if (e) {
  18724. deferredEvents.push(e);
  18725. deferredClips.push(clip);
  18726. }
  18727. }
  18728. // Remove the finished clip
  18729. for (var i = 0; i < len;) {
  18730. if (clips[i]._needsRemove) {
  18731. clips[i] = clips[len - 1];
  18732. clips.pop();
  18733. len--;
  18734. }
  18735. else {
  18736. i++;
  18737. }
  18738. }
  18739. len = deferredEvents.length;
  18740. for (var i = 0; i < len; i++) {
  18741. deferredClips[i].fire(deferredEvents[i]);
  18742. }
  18743. this._time = time;
  18744. this.onframe(delta);
  18745. this.trigger('frame', delta);
  18746. if (this.stage.update) {
  18747. this.stage.update();
  18748. }
  18749. },
  18750. _startLoop: function () {
  18751. var self = this;
  18752. this._running = true;
  18753. function step() {
  18754. if (self._running) {
  18755. requestAnimationFrame(step);
  18756. !self._paused && self._update();
  18757. }
  18758. }
  18759. requestAnimationFrame(step);
  18760. },
  18761. /**
  18762. * 开始运行动画
  18763. */
  18764. start: function () {
  18765. this._time = new Date().getTime();
  18766. this._pausedTime = 0;
  18767. this._startLoop();
  18768. },
  18769. /**
  18770. * 停止运行动画
  18771. */
  18772. stop: function () {
  18773. this._running = false;
  18774. },
  18775. /**
  18776. * Pause
  18777. */
  18778. pause: function () {
  18779. if (!this._paused) {
  18780. this._pauseStart = new Date().getTime();
  18781. this._paused = true;
  18782. }
  18783. },
  18784. /**
  18785. * Resume
  18786. */
  18787. resume: function () {
  18788. if (this._paused) {
  18789. this._pausedTime += (new Date().getTime()) - this._pauseStart;
  18790. this._paused = false;
  18791. }
  18792. },
  18793. /**
  18794. * 清除所有动画片段
  18795. */
  18796. clear: function () {
  18797. this._clips = [];
  18798. },
  18799. /**
  18800. * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画
  18801. * @param {Object} target
  18802. * @param {Object} options
  18803. * @param {boolean} [options.loop=false] 是否循环播放动画
  18804. * @param {Function} [options.getter=null]
  18805. * 如果指定getter函数,会通过getter函数取属性值
  18806. * @param {Function} [options.setter=null]
  18807. * 如果指定setter函数,会通过setter函数设置属性值
  18808. * @return {module:zrender/animation/Animation~Animator}
  18809. */
  18810. // TODO Gap
  18811. animate: function (target, options) {
  18812. options = options || {};
  18813. var animator = new Animator(
  18814. target,
  18815. options.loop,
  18816. options.getter,
  18817. options.setter
  18818. );
  18819. this.addAnimator(animator);
  18820. return animator;
  18821. }
  18822. };
  18823. util.mixin(Animation, Dispatcher);
  18824. module.exports = Animation;
  18825. /***/ }),
  18826. /* 93 */
  18827. /***/ (function(module, exports, __webpack_require__) {
  18828. 'use strict';
  18829. /**
  18830. * 事件辅助类
  18831. * @module zrender/core/event
  18832. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  18833. */
  18834. var Eventful = __webpack_require__(27);
  18835. var env = __webpack_require__(2);
  18836. var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
  18837. var MOUSE_EVENT_REG = /^(?:mouse|pointer|contextmenu|drag|drop)|click/;
  18838. function getBoundingClientRect(el) {
  18839. // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect
  18840. return el.getBoundingClientRect ? el.getBoundingClientRect() : {left: 0, top: 0};
  18841. }
  18842. // `calculate` is optional, default false
  18843. function clientToLocal(el, e, out, calculate) {
  18844. out = out || {};
  18845. // According to the W3C Working Draft, offsetX and offsetY should be relative
  18846. // to the padding edge of the target element. The only browser using this convention
  18847. // is IE. Webkit uses the border edge, Opera uses the content edge, and FireFox does
  18848. // not support the properties.
  18849. // (see http://www.jacklmoore.com/notes/mouse-position/)
  18850. // In zr painter.dom, padding edge equals to border edge.
  18851. // FIXME
  18852. // When mousemove event triggered on ec tooltip, target is not zr painter.dom, and
  18853. // offsetX/Y is relative to e.target, where the calculation of zrX/Y via offsetX/Y
  18854. // is too complex. So css-transfrom dont support in this case temporarily.
  18855. if (calculate || !env.canvasSupported) {
  18856. defaultGetZrXY(el, e, out);
  18857. }
  18858. // Caution: In FireFox, layerX/layerY Mouse position relative to the closest positioned
  18859. // ancestor element, so we should make sure el is positioned (e.g., not position:static).
  18860. // BTW1, Webkit don't return the same results as FF in non-simple cases (like add
  18861. // zoom-factor, overflow / opacity layers, transforms ...)
  18862. // BTW2, (ev.offsetY || ev.pageY - $(ev.target).offset().top) is not correct in preserve-3d.
  18863. // <https://bugs.jquery.com/ticket/8523#comment:14>
  18864. // BTW3, In ff, offsetX/offsetY is always 0.
  18865. else if (env.browser.firefox && e.layerX != null && e.layerX !== e.offsetX) {
  18866. out.zrX = e.layerX;
  18867. out.zrY = e.layerY;
  18868. }
  18869. // For IE6+, chrome, safari, opera. (When will ff support offsetX?)
  18870. else if (e.offsetX != null) {
  18871. out.zrX = e.offsetX;
  18872. out.zrY = e.offsetY;
  18873. }
  18874. // For some other device, e.g., IOS safari.
  18875. else {
  18876. defaultGetZrXY(el, e, out);
  18877. }
  18878. return out;
  18879. }
  18880. function defaultGetZrXY(el, e, out) {
  18881. // This well-known method below does not support css transform.
  18882. var box = getBoundingClientRect(el);
  18883. out.zrX = e.clientX - box.left;
  18884. out.zrY = e.clientY - box.top;
  18885. }
  18886. /**
  18887. * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标.
  18888. * `calculate` is optional, default false.
  18889. */
  18890. function normalizeEvent(el, e, calculate) {
  18891. e = e || window.event;
  18892. if (e.zrX != null) {
  18893. return e;
  18894. }
  18895. var eventType = e.type;
  18896. var isTouch = eventType && eventType.indexOf('touch') >= 0;
  18897. if (!isTouch) {
  18898. clientToLocal(el, e, e, calculate);
  18899. e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3;
  18900. }
  18901. else {
  18902. var touch = eventType != 'touchend'
  18903. ? e.targetTouches[0]
  18904. : e.changedTouches[0];
  18905. touch && clientToLocal(el, touch, e, calculate);
  18906. }
  18907. // Add which for click: 1 === left; 2 === middle; 3 === right; otherwise: 0;
  18908. // See jQuery: https://github.com/jquery/jquery/blob/master/src/event.js
  18909. // If e.which has been defined, if may be readonly,
  18910. // see: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
  18911. var button = e.button;
  18912. if (e.which == null && button !== undefined && MOUSE_EVENT_REG.test(e.type)) {
  18913. e.which = (button & 1 ? 1 : (button & 2 ? 3 : (button & 4 ? 2 : 0)));
  18914. }
  18915. return e;
  18916. }
  18917. function addEventListener(el, name, handler) {
  18918. if (isDomLevel2) {
  18919. el.addEventListener(name, handler);
  18920. }
  18921. else {
  18922. el.attachEvent('on' + name, handler);
  18923. }
  18924. }
  18925. function removeEventListener(el, name, handler) {
  18926. if (isDomLevel2) {
  18927. el.removeEventListener(name, handler);
  18928. }
  18929. else {
  18930. el.detachEvent('on' + name, handler);
  18931. }
  18932. }
  18933. /**
  18934. * preventDefault and stopPropagation.
  18935. * Notice: do not do that in zrender. Upper application
  18936. * do that if necessary.
  18937. *
  18938. * @memberOf module:zrender/core/event
  18939. * @method
  18940. * @param {Event} e : event对象
  18941. */
  18942. var stop = isDomLevel2
  18943. ? function (e) {
  18944. e.preventDefault();
  18945. e.stopPropagation();
  18946. e.cancelBubble = true;
  18947. }
  18948. : function (e) {
  18949. e.returnValue = false;
  18950. e.cancelBubble = true;
  18951. };
  18952. function notLeftMouse(e) {
  18953. // If e.which is undefined, considered as left mouse event.
  18954. return e.which > 1;
  18955. }
  18956. module.exports = {
  18957. clientToLocal: clientToLocal,
  18958. normalizeEvent: normalizeEvent,
  18959. addEventListener: addEventListener,
  18960. removeEventListener: removeEventListener,
  18961. notLeftMouse: notLeftMouse,
  18962. stop: stop,
  18963. // 做向上兼容
  18964. Dispatcher: Eventful
  18965. };
  18966. /***/ }),
  18967. /* 94 */
  18968. /***/ (function(module, exports) {
  18969. module.exports = (typeof window !== 'undefined' &&
  18970. ((window.requestAnimationFrame && window.requestAnimationFrame.bind(window))
  18971. // https://github.com/ecomfe/zrender/issues/189#issuecomment-224919809
  18972. || (window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window))
  18973. || window.mozRequestAnimationFrame
  18974. || window.webkitRequestAnimationFrame)
  18975. )
  18976. || function (func) {
  18977. setTimeout(func, 16);
  18978. };
  18979. /***/ }),
  18980. /* 95 */
  18981. /***/ (function(module, exports, __webpack_require__) {
  18982. var eventTool = __webpack_require__(93);
  18983. var zrUtil = __webpack_require__(4);
  18984. var Eventful = __webpack_require__(27);
  18985. var env = __webpack_require__(2);
  18986. var GestureMgr = __webpack_require__(96);
  18987. var addEventListener = eventTool.addEventListener;
  18988. var removeEventListener = eventTool.removeEventListener;
  18989. var normalizeEvent = eventTool.normalizeEvent;
  18990. var TOUCH_CLICK_DELAY = 300;
  18991. var mouseHandlerNames = [
  18992. 'click', 'dblclick', 'mousewheel', 'mouseout',
  18993. 'mouseup', 'mousedown', 'mousemove', 'contextmenu'
  18994. ];
  18995. var touchHandlerNames = [
  18996. 'touchstart', 'touchend', 'touchmove'
  18997. ];
  18998. var pointerEventNames = {
  18999. pointerdown: 1, pointerup: 1, pointermove: 1, pointerout: 1
  19000. };
  19001. var pointerHandlerNames = zrUtil.map(mouseHandlerNames, function (name) {
  19002. var nm = name.replace('mouse', 'pointer');
  19003. return pointerEventNames[nm] ? nm : name;
  19004. });
  19005. function eventNameFix(name) {
  19006. return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name;
  19007. }
  19008. function processGesture(proxy, event, stage) {
  19009. var gestureMgr = proxy._gestureMgr;
  19010. stage === 'start' && gestureMgr.clear();
  19011. var gestureInfo = gestureMgr.recognize(
  19012. event,
  19013. proxy.handler.findHover(event.zrX, event.zrY, null).target,
  19014. proxy.dom
  19015. );
  19016. stage === 'end' && gestureMgr.clear();
  19017. // Do not do any preventDefault here. Upper application do that if necessary.
  19018. if (gestureInfo) {
  19019. var type = gestureInfo.type;
  19020. event.gestureEvent = type;
  19021. proxy.handler.dispatchToElement({target: gestureInfo.target}, type, gestureInfo.event);
  19022. }
  19023. }
  19024. // function onMSGestureChange(proxy, event) {
  19025. // if (event.translationX || event.translationY) {
  19026. // // mousemove is carried by MSGesture to reduce the sensitivity.
  19027. // proxy.handler.dispatchToElement(event.target, 'mousemove', event);
  19028. // }
  19029. // if (event.scale !== 1) {
  19030. // event.pinchX = event.offsetX;
  19031. // event.pinchY = event.offsetY;
  19032. // event.pinchScale = event.scale;
  19033. // proxy.handler.dispatchToElement(event.target, 'pinch', event);
  19034. // }
  19035. // }
  19036. /**
  19037. * Prevent mouse event from being dispatched after Touch Events action
  19038. * @see <https://github.com/deltakosh/handjs/blob/master/src/hand.base.js>
  19039. * 1. Mobile browsers dispatch mouse events 300ms after touchend.
  19040. * 2. Chrome for Android dispatch mousedown for long-touch about 650ms
  19041. * Result: Blocking Mouse Events for 700ms.
  19042. */
  19043. function setTouchTimer(instance) {
  19044. instance._touching = true;
  19045. clearTimeout(instance._touchTimer);
  19046. instance._touchTimer = setTimeout(function () {
  19047. instance._touching = false;
  19048. }, 700);
  19049. }
  19050. var domHandlers = {
  19051. /**
  19052. * Mouse move handler
  19053. * @inner
  19054. * @param {Event} event
  19055. */
  19056. mousemove: function (event) {
  19057. event = normalizeEvent(this.dom, event);
  19058. this.trigger('mousemove', event);
  19059. },
  19060. /**
  19061. * Mouse out handler
  19062. * @inner
  19063. * @param {Event} event
  19064. */
  19065. mouseout: function (event) {
  19066. event = normalizeEvent(this.dom, event);
  19067. var element = event.toElement || event.relatedTarget;
  19068. if (element != this.dom) {
  19069. while (element && element.nodeType != 9) {
  19070. // 忽略包含在root中的dom引起的mouseOut
  19071. if (element === this.dom) {
  19072. return;
  19073. }
  19074. element = element.parentNode;
  19075. }
  19076. }
  19077. this.trigger('mouseout', event);
  19078. },
  19079. /**
  19080. * Touch开始响应函数
  19081. * @inner
  19082. * @param {Event} event
  19083. */
  19084. touchstart: function (event) {
  19085. // Default mouse behaviour should not be disabled here.
  19086. // For example, page may needs to be slided.
  19087. event = normalizeEvent(this.dom, event);
  19088. // Mark touch, which is useful in distinguish touch and
  19089. // mouse event in upper applicatoin.
  19090. event.zrByTouch = true;
  19091. this._lastTouchMoment = new Date();
  19092. processGesture(this, event, 'start');
  19093. // In touch device, trigger `mousemove`(`mouseover`) should
  19094. // be triggered, and must before `mousedown` triggered.
  19095. domHandlers.mousemove.call(this, event);
  19096. domHandlers.mousedown.call(this, event);
  19097. setTouchTimer(this);
  19098. },
  19099. /**
  19100. * Touch移动响应函数
  19101. * @inner
  19102. * @param {Event} event
  19103. */
  19104. touchmove: function (event) {
  19105. event = normalizeEvent(this.dom, event);
  19106. // Mark touch, which is useful in distinguish touch and
  19107. // mouse event in upper applicatoin.
  19108. event.zrByTouch = true;
  19109. processGesture(this, event, 'change');
  19110. // Mouse move should always be triggered no matter whether
  19111. // there is gestrue event, because mouse move and pinch may
  19112. // be used at the same time.
  19113. domHandlers.mousemove.call(this, event);
  19114. setTouchTimer(this);
  19115. },
  19116. /**
  19117. * Touch结束响应函数
  19118. * @inner
  19119. * @param {Event} event
  19120. */
  19121. touchend: function (event) {
  19122. event = normalizeEvent(this.dom, event);
  19123. // Mark touch, which is useful in distinguish touch and
  19124. // mouse event in upper applicatoin.
  19125. event.zrByTouch = true;
  19126. processGesture(this, event, 'end');
  19127. domHandlers.mouseup.call(this, event);
  19128. // Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
  19129. // triggered in `touchstart`. This seems to be illogical, but by this mechanism,
  19130. // we can conveniently implement "hover style" in both PC and touch device just
  19131. // by listening to `mouseover` to add "hover style" and listening to `mouseout`
  19132. // to remove "hover style" on an element, without any additional code for
  19133. // compatibility. (`mouseout` will not be triggered in `touchend`, so "hover
  19134. // style" will remain for user view)
  19135. // click event should always be triggered no matter whether
  19136. // there is gestrue event. System click can not be prevented.
  19137. if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
  19138. domHandlers.click.call(this, event);
  19139. }
  19140. setTouchTimer(this);
  19141. },
  19142. pointerdown: function (event) {
  19143. domHandlers.mousedown.call(this, event);
  19144. // if (useMSGuesture(this, event)) {
  19145. // this._msGesture.addPointer(event.pointerId);
  19146. // }
  19147. },
  19148. pointermove: function (event) {
  19149. // FIXME
  19150. // pointermove is so sensitive that it always triggered when
  19151. // tap(click) on touch screen, which affect some judgement in
  19152. // upper application. So, we dont support mousemove on MS touch
  19153. // device yet.
  19154. if (!isPointerFromTouch(event)) {
  19155. domHandlers.mousemove.call(this, event);
  19156. }
  19157. },
  19158. pointerup: function (event) {
  19159. domHandlers.mouseup.call(this, event);
  19160. },
  19161. pointerout: function (event) {
  19162. // pointerout will be triggered when tap on touch screen
  19163. // (IE11+/Edge on MS Surface) after click event triggered,
  19164. // which is inconsistent with the mousout behavior we defined
  19165. // in touchend. So we unify them.
  19166. // (check domHandlers.touchend for detailed explanation)
  19167. if (!isPointerFromTouch(event)) {
  19168. domHandlers.mouseout.call(this, event);
  19169. }
  19170. }
  19171. };
  19172. function isPointerFromTouch(event) {
  19173. var pointerType = event.pointerType;
  19174. return pointerType === 'pen' || pointerType === 'touch';
  19175. }
  19176. // function useMSGuesture(handlerProxy, event) {
  19177. // return isPointerFromTouch(event) && !!handlerProxy._msGesture;
  19178. // }
  19179. // Common handlers
  19180. zrUtil.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
  19181. domHandlers[name] = function (event) {
  19182. event = normalizeEvent(this.dom, event);
  19183. this.trigger(name, event);
  19184. };
  19185. });
  19186. /**
  19187. * 为控制类实例初始化dom 事件处理函数
  19188. *
  19189. * @inner
  19190. * @param {module:zrender/Handler} instance 控制类实例
  19191. */
  19192. function initDomHandler(instance) {
  19193. zrUtil.each(touchHandlerNames, function (name) {
  19194. instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
  19195. });
  19196. zrUtil.each(pointerHandlerNames, function (name) {
  19197. instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
  19198. });
  19199. zrUtil.each(mouseHandlerNames, function (name) {
  19200. instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
  19201. });
  19202. function makeMouseHandler(fn, instance) {
  19203. return function () {
  19204. if (instance._touching) {
  19205. return;
  19206. }
  19207. return fn.apply(instance, arguments);
  19208. };
  19209. }
  19210. }
  19211. function HandlerDomProxy(dom) {
  19212. Eventful.call(this);
  19213. this.dom = dom;
  19214. /**
  19215. * @private
  19216. * @type {boolean}
  19217. */
  19218. this._touching = false;
  19219. /**
  19220. * @private
  19221. * @type {number}
  19222. */
  19223. this._touchTimer;
  19224. /**
  19225. * @private
  19226. * @type {module:zrender/core/GestureMgr}
  19227. */
  19228. this._gestureMgr = new GestureMgr();
  19229. this._handlers = {};
  19230. initDomHandler(this);
  19231. if (env.pointerEventsSupported) { // Only IE11+/Edge
  19232. // 1. On devices that both enable touch and mouse (e.g., MS Surface and lenovo X240),
  19233. // IE11+/Edge do not trigger touch event, but trigger pointer event and mouse event
  19234. // at the same time.
  19235. // 2. On MS Surface, it probablely only trigger mousedown but no mouseup when tap on
  19236. // screen, which do not occurs in pointer event.
  19237. // So we use pointer event to both detect touch gesture and mouse behavior.
  19238. mountHandlers(pointerHandlerNames, this);
  19239. // FIXME
  19240. // Note: MS Gesture require CSS touch-action set. But touch-action is not reliable,
  19241. // which does not prevent defuault behavior occasionally (which may cause view port
  19242. // zoomed in but use can not zoom it back). And event.preventDefault() does not work.
  19243. // So we have to not to use MSGesture and not to support touchmove and pinch on MS
  19244. // touch screen. And we only support click behavior on MS touch screen now.
  19245. // MS Gesture Event is only supported on IE11+/Edge and on Windows 8+.
  19246. // We dont support touch on IE on win7.
  19247. // See <https://msdn.microsoft.com/en-us/library/dn433243(v=vs.85).aspx>
  19248. // if (typeof MSGesture === 'function') {
  19249. // (this._msGesture = new MSGesture()).target = dom; // jshint ignore:line
  19250. // dom.addEventListener('MSGestureChange', onMSGestureChange);
  19251. // }
  19252. }
  19253. else {
  19254. if (env.touchEventsSupported) {
  19255. mountHandlers(touchHandlerNames, this);
  19256. // Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
  19257. // addEventListener(root, 'mouseout', this._mouseoutHandler);
  19258. }
  19259. // 1. Considering some devices that both enable touch and mouse event (like on MS Surface
  19260. // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise
  19261. // mouse event can not be handle in those devices.
  19262. // 2. On MS Surface, Chrome will trigger both touch event and mouse event. How to prevent
  19263. // mouseevent after touch event triggered, see `setTouchTimer`.
  19264. mountHandlers(mouseHandlerNames, this);
  19265. }
  19266. function mountHandlers(handlerNames, instance) {
  19267. zrUtil.each(handlerNames, function (name) {
  19268. addEventListener(dom, eventNameFix(name), instance._handlers[name]);
  19269. }, instance);
  19270. }
  19271. }
  19272. var handlerDomProxyProto = HandlerDomProxy.prototype;
  19273. handlerDomProxyProto.dispose = function () {
  19274. var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
  19275. for (var i = 0; i < handlerNames.length; i++) {
  19276. var name = handlerNames[i];
  19277. removeEventListener(this.dom, eventNameFix(name), this._handlers[name]);
  19278. }
  19279. };
  19280. handlerDomProxyProto.setCursor = function (cursorStyle) {
  19281. this.dom.style.cursor = cursorStyle || 'default';
  19282. };
  19283. zrUtil.mixin(HandlerDomProxy, Eventful);
  19284. module.exports = HandlerDomProxy;
  19285. /***/ }),
  19286. /* 96 */
  19287. /***/ (function(module, exports, __webpack_require__) {
  19288. 'use strict';
  19289. /**
  19290. * Only implements needed gestures for mobile.
  19291. */
  19292. var eventUtil = __webpack_require__(93);
  19293. var GestureMgr = function () {
  19294. /**
  19295. * @private
  19296. * @type {Array.<Object>}
  19297. */
  19298. this._track = [];
  19299. };
  19300. GestureMgr.prototype = {
  19301. constructor: GestureMgr,
  19302. recognize: function (event, target, root) {
  19303. this._doTrack(event, target, root);
  19304. return this._recognize(event);
  19305. },
  19306. clear: function () {
  19307. this._track.length = 0;
  19308. return this;
  19309. },
  19310. _doTrack: function (event, target, root) {
  19311. var touches = event.touches;
  19312. if (!touches) {
  19313. return;
  19314. }
  19315. var trackItem = {
  19316. points: [],
  19317. touches: [],
  19318. target: target,
  19319. event: event
  19320. };
  19321. for (var i = 0, len = touches.length; i < len; i++) {
  19322. var touch = touches[i];
  19323. var pos = eventUtil.clientToLocal(root, touch, {});
  19324. trackItem.points.push([pos.zrX, pos.zrY]);
  19325. trackItem.touches.push(touch);
  19326. }
  19327. this._track.push(trackItem);
  19328. },
  19329. _recognize: function (event) {
  19330. for (var eventName in recognizers) {
  19331. if (recognizers.hasOwnProperty(eventName)) {
  19332. var gestureInfo = recognizers[eventName](this._track, event);
  19333. if (gestureInfo) {
  19334. return gestureInfo;
  19335. }
  19336. }
  19337. }
  19338. }
  19339. };
  19340. function dist(pointPair) {
  19341. var dx = pointPair[1][0] - pointPair[0][0];
  19342. var dy = pointPair[1][1] - pointPair[0][1];
  19343. return Math.sqrt(dx * dx + dy * dy);
  19344. }
  19345. function center(pointPair) {
  19346. return [
  19347. (pointPair[0][0] + pointPair[1][0]) / 2,
  19348. (pointPair[0][1] + pointPair[1][1]) / 2
  19349. ];
  19350. }
  19351. var recognizers = {
  19352. pinch: function (track, event) {
  19353. var trackLen = track.length;
  19354. if (!trackLen) {
  19355. return;
  19356. }
  19357. var pinchEnd = (track[trackLen - 1] || {}).points;
  19358. var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd;
  19359. if (pinchPre
  19360. && pinchPre.length > 1
  19361. && pinchEnd
  19362. && pinchEnd.length > 1
  19363. ) {
  19364. var pinchScale = dist(pinchEnd) / dist(pinchPre);
  19365. !isFinite(pinchScale) && (pinchScale = 1);
  19366. event.pinchScale = pinchScale;
  19367. var pinchCenter = center(pinchEnd);
  19368. event.pinchX = pinchCenter[0];
  19369. event.pinchY = pinchCenter[1];
  19370. return {
  19371. type: 'pinch',
  19372. target: track[0].target,
  19373. event: event
  19374. };
  19375. }
  19376. }
  19377. // Only pinch currently.
  19378. };
  19379. module.exports = GestureMgr;
  19380. /***/ }),
  19381. /* 97 */
  19382. /***/ (function(module, exports, __webpack_require__) {
  19383. 'use strict';
  19384. /**
  19385. * Default canvas painter
  19386. * @module zrender/Painter
  19387. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  19388. * errorrik (errorrik@gmail.com)
  19389. * pissang (https://www.github.com/pissang)
  19390. */
  19391. var config = __webpack_require__(35);
  19392. var util = __webpack_require__(4);
  19393. var log = __webpack_require__(34);
  19394. var BoundingRect = __webpack_require__(9);
  19395. var timsort = __webpack_require__(91);
  19396. var Layer = __webpack_require__(98);
  19397. var requestAnimationFrame = __webpack_require__(94);
  19398. // PENDIGN
  19399. // Layer exceeds MAX_PROGRESSIVE_LAYER_NUMBER may have some problem when flush directly second time.
  19400. //
  19401. // Maximum progressive layer. When exceeding this number. All elements will be drawed in the last layer.
  19402. var MAX_PROGRESSIVE_LAYER_NUMBER = 5;
  19403. function parseInt10(val) {
  19404. return parseInt(val, 10);
  19405. }
  19406. function isLayerValid(layer) {
  19407. if (!layer) {
  19408. return false;
  19409. }
  19410. if (layer.__builtin__) {
  19411. return true;
  19412. }
  19413. if (typeof(layer.resize) !== 'function'
  19414. || typeof(layer.refresh) !== 'function'
  19415. ) {
  19416. return false;
  19417. }
  19418. return true;
  19419. }
  19420. function preProcessLayer(layer) {
  19421. layer.__unusedCount++;
  19422. }
  19423. function postProcessLayer(layer) {
  19424. if (layer.__unusedCount == 1) {
  19425. layer.clear();
  19426. }
  19427. }
  19428. var tmpRect = new BoundingRect(0, 0, 0, 0);
  19429. var viewRect = new BoundingRect(0, 0, 0, 0);
  19430. function isDisplayableCulled(el, width, height) {
  19431. tmpRect.copy(el.getBoundingRect());
  19432. if (el.transform) {
  19433. tmpRect.applyTransform(el.transform);
  19434. }
  19435. viewRect.width = width;
  19436. viewRect.height = height;
  19437. return !tmpRect.intersect(viewRect);
  19438. }
  19439. function isClipPathChanged(clipPaths, prevClipPaths) {
  19440. if (clipPaths == prevClipPaths) { // Can both be null or undefined
  19441. return false;
  19442. }
  19443. if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) {
  19444. return true;
  19445. }
  19446. for (var i = 0; i < clipPaths.length; i++) {
  19447. if (clipPaths[i] !== prevClipPaths[i]) {
  19448. return true;
  19449. }
  19450. }
  19451. }
  19452. function doClip(clipPaths, ctx) {
  19453. for (var i = 0; i < clipPaths.length; i++) {
  19454. var clipPath = clipPaths[i];
  19455. clipPath.setTransform(ctx);
  19456. ctx.beginPath();
  19457. clipPath.buildPath(ctx, clipPath.shape);
  19458. ctx.clip();
  19459. // Transform back
  19460. clipPath.restoreTransform(ctx);
  19461. }
  19462. }
  19463. function createRoot(width, height) {
  19464. var domRoot = document.createElement('div');
  19465. // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬
  19466. domRoot.style.cssText = [
  19467. 'position:relative',
  19468. 'overflow:hidden',
  19469. 'width:' + width + 'px',
  19470. 'height:' + height + 'px',
  19471. 'padding:0',
  19472. 'margin:0',
  19473. 'border-width:0'
  19474. ].join(';') + ';';
  19475. return domRoot;
  19476. }
  19477. /**
  19478. * @alias module:zrender/Painter
  19479. * @constructor
  19480. * @param {HTMLElement} root 绘图容器
  19481. * @param {module:zrender/Storage} storage
  19482. * @param {Object} opts
  19483. */
  19484. var Painter = function (root, storage, opts) {
  19485. this.type = 'canvas';
  19486. // In node environment using node-canvas
  19487. var singleCanvas = !root.nodeName // In node ?
  19488. || root.nodeName.toUpperCase() === 'CANVAS';
  19489. this._opts = opts = util.extend({}, opts || {});
  19490. /**
  19491. * @type {number}
  19492. */
  19493. this.dpr = opts.devicePixelRatio || config.devicePixelRatio;
  19494. /**
  19495. * @type {boolean}
  19496. * @private
  19497. */
  19498. this._singleCanvas = singleCanvas;
  19499. /**
  19500. * 绘图容器
  19501. * @type {HTMLElement}
  19502. */
  19503. this.root = root;
  19504. var rootStyle = root.style;
  19505. if (rootStyle) {
  19506. rootStyle['-webkit-tap-highlight-color'] = 'transparent';
  19507. rootStyle['-webkit-user-select'] =
  19508. rootStyle['user-select'] =
  19509. rootStyle['-webkit-touch-callout'] = 'none';
  19510. root.innerHTML = '';
  19511. }
  19512. /**
  19513. * @type {module:zrender/Storage}
  19514. */
  19515. this.storage = storage;
  19516. /**
  19517. * @type {Array.<number>}
  19518. * @private
  19519. */
  19520. var zlevelList = this._zlevelList = [];
  19521. /**
  19522. * @type {Object.<string, module:zrender/Layer>}
  19523. * @private
  19524. */
  19525. var layers = this._layers = {};
  19526. /**
  19527. * @type {Object.<string, Object>}
  19528. * @type {private}
  19529. */
  19530. this._layerConfig = {};
  19531. if (!singleCanvas) {
  19532. this._width = this._getSize(0);
  19533. this._height = this._getSize(1);
  19534. var domRoot = this._domRoot = createRoot(
  19535. this._width, this._height
  19536. );
  19537. root.appendChild(domRoot);
  19538. }
  19539. else {
  19540. if (opts.width != null) {
  19541. root.width = opts.width;
  19542. }
  19543. if (opts.height != null) {
  19544. root.height = opts.height;
  19545. }
  19546. // Use canvas width and height directly
  19547. var width = root.width;
  19548. var height = root.height;
  19549. this._width = width;
  19550. this._height = height;
  19551. // Create layer if only one given canvas
  19552. // Device pixel ratio is fixed to 1 because given canvas has its specified width and height
  19553. var mainLayer = new Layer(root, this, 1);
  19554. mainLayer.initContext();
  19555. // FIXME Use canvas width and height
  19556. // mainLayer.resize(width, height);
  19557. layers[0] = mainLayer;
  19558. zlevelList.push(0);
  19559. this._domRoot = root;
  19560. }
  19561. // Layers for progressive rendering
  19562. this._progressiveLayers = [];
  19563. /**
  19564. * @type {module:zrender/Layer}
  19565. * @private
  19566. */
  19567. this._hoverlayer;
  19568. this._hoverElements = [];
  19569. };
  19570. Painter.prototype = {
  19571. constructor: Painter,
  19572. getType: function () {
  19573. return 'canvas';
  19574. },
  19575. /**
  19576. * If painter use a single canvas
  19577. * @return {boolean}
  19578. */
  19579. isSingleCanvas: function () {
  19580. return this._singleCanvas;
  19581. },
  19582. /**
  19583. * @return {HTMLDivElement}
  19584. */
  19585. getViewportRoot: function () {
  19586. return this._domRoot;
  19587. },
  19588. getViewportRootOffset: function () {
  19589. var viewportRoot = this.getViewportRoot();
  19590. if (viewportRoot) {
  19591. return {
  19592. offsetLeft: viewportRoot.offsetLeft || 0,
  19593. offsetTop: viewportRoot.offsetTop || 0
  19594. };
  19595. }
  19596. },
  19597. /**
  19598. * 刷新
  19599. * @param {boolean} [paintAll=false] 强制绘制所有displayable
  19600. */
  19601. refresh: function (paintAll) {
  19602. var list = this.storage.getDisplayList(true);
  19603. var zlevelList = this._zlevelList;
  19604. this._paintList(list, paintAll);
  19605. // Paint custum layers
  19606. for (var i = 0; i < zlevelList.length; i++) {
  19607. var z = zlevelList[i];
  19608. var layer = this._layers[z];
  19609. if (!layer.__builtin__ && layer.refresh) {
  19610. layer.refresh();
  19611. }
  19612. }
  19613. this.refreshHover();
  19614. if (this._progressiveLayers.length) {
  19615. this._startProgessive();
  19616. }
  19617. return this;
  19618. },
  19619. addHover: function (el, hoverStyle) {
  19620. if (el.__hoverMir) {
  19621. return;
  19622. }
  19623. var elMirror = new el.constructor({
  19624. style: el.style,
  19625. shape: el.shape
  19626. });
  19627. elMirror.__from = el;
  19628. el.__hoverMir = elMirror;
  19629. elMirror.setStyle(hoverStyle);
  19630. this._hoverElements.push(elMirror);
  19631. },
  19632. removeHover: function (el) {
  19633. var elMirror = el.__hoverMir;
  19634. var hoverElements = this._hoverElements;
  19635. var idx = util.indexOf(hoverElements, elMirror);
  19636. if (idx >= 0) {
  19637. hoverElements.splice(idx, 1);
  19638. }
  19639. el.__hoverMir = null;
  19640. },
  19641. clearHover: function (el) {
  19642. var hoverElements = this._hoverElements;
  19643. for (var i = 0; i < hoverElements.length; i++) {
  19644. var from = hoverElements[i].__from;
  19645. if (from) {
  19646. from.__hoverMir = null;
  19647. }
  19648. }
  19649. hoverElements.length = 0;
  19650. },
  19651. refreshHover: function () {
  19652. var hoverElements = this._hoverElements;
  19653. var len = hoverElements.length;
  19654. var hoverLayer = this._hoverlayer;
  19655. hoverLayer && hoverLayer.clear();
  19656. if (!len) {
  19657. return;
  19658. }
  19659. timsort(hoverElements, this.storage.displayableSortFunc);
  19660. // Use a extream large zlevel
  19661. // FIXME?
  19662. if (!hoverLayer) {
  19663. hoverLayer = this._hoverlayer = this.getLayer(1e5);
  19664. }
  19665. var scope = {};
  19666. hoverLayer.ctx.save();
  19667. for (var i = 0; i < len;) {
  19668. var el = hoverElements[i];
  19669. var originalEl = el.__from;
  19670. // Original el is removed
  19671. // PENDING
  19672. if (!(originalEl && originalEl.__zr)) {
  19673. hoverElements.splice(i, 1);
  19674. originalEl.__hoverMir = null;
  19675. len--;
  19676. continue;
  19677. }
  19678. i++;
  19679. // Use transform
  19680. // FIXME style and shape ?
  19681. if (!originalEl.invisible) {
  19682. el.transform = originalEl.transform;
  19683. el.invTransform = originalEl.invTransform;
  19684. el.__clipPaths = originalEl.__clipPaths;
  19685. // el.
  19686. this._doPaintEl(el, hoverLayer, true, scope);
  19687. }
  19688. }
  19689. hoverLayer.ctx.restore();
  19690. },
  19691. _startProgessive: function () {
  19692. var self = this;
  19693. if (!self._furtherProgressive) {
  19694. return;
  19695. }
  19696. // Use a token to stop progress steps triggered by
  19697. // previous zr.refresh calling.
  19698. var token = self._progressiveToken = +new Date();
  19699. self._progress++;
  19700. requestAnimationFrame(step);
  19701. function step() {
  19702. // In case refreshed or disposed
  19703. if (token === self._progressiveToken && self.storage) {
  19704. self._doPaintList(self.storage.getDisplayList());
  19705. if (self._furtherProgressive) {
  19706. self._progress++;
  19707. requestAnimationFrame(step);
  19708. }
  19709. else {
  19710. self._progressiveToken = -1;
  19711. }
  19712. }
  19713. }
  19714. },
  19715. _clearProgressive: function () {
  19716. this._progressiveToken = -1;
  19717. this._progress = 0;
  19718. util.each(this._progressiveLayers, function (layer) {
  19719. layer.__dirty && layer.clear();
  19720. });
  19721. },
  19722. _paintList: function (list, paintAll) {
  19723. if (paintAll == null) {
  19724. paintAll = false;
  19725. }
  19726. this._updateLayerStatus(list);
  19727. this._clearProgressive();
  19728. this.eachBuiltinLayer(preProcessLayer);
  19729. this._doPaintList(list, paintAll);
  19730. this.eachBuiltinLayer(postProcessLayer);
  19731. },
  19732. _doPaintList: function (list, paintAll) {
  19733. var currentLayer;
  19734. var currentZLevel;
  19735. var ctx;
  19736. // var invTransform = [];
  19737. var scope;
  19738. var progressiveLayerIdx = 0;
  19739. var currentProgressiveLayer;
  19740. var width = this._width;
  19741. var height = this._height;
  19742. var layerProgress;
  19743. var frame = this._progress;
  19744. function flushProgressiveLayer(layer) {
  19745. var dpr = ctx.dpr || 1;
  19746. ctx.save();
  19747. ctx.globalAlpha = 1;
  19748. ctx.shadowBlur = 0;
  19749. // Avoid layer don't clear in next progressive frame
  19750. currentLayer.__dirty = true;
  19751. ctx.setTransform(1, 0, 0, 1, 0, 0);
  19752. ctx.drawImage(layer.dom, 0, 0, width * dpr, height * dpr);
  19753. ctx.restore();
  19754. }
  19755. for (var i = 0, l = list.length; i < l; i++) {
  19756. var el = list[i];
  19757. var elZLevel = this._singleCanvas ? 0 : el.zlevel;
  19758. var elFrame = el.__frame;
  19759. // Flush at current context
  19760. // PENDING
  19761. if (elFrame < 0 && currentProgressiveLayer) {
  19762. flushProgressiveLayer(currentProgressiveLayer);
  19763. currentProgressiveLayer = null;
  19764. }
  19765. // Change draw layer
  19766. if (currentZLevel !== elZLevel) {
  19767. if (ctx) {
  19768. ctx.restore();
  19769. }
  19770. // Reset scope
  19771. scope = {};
  19772. // Only 0 zlevel if only has one canvas
  19773. currentZLevel = elZLevel;
  19774. currentLayer = this.getLayer(currentZLevel);
  19775. if (!currentLayer.__builtin__) {
  19776. log(
  19777. 'ZLevel ' + currentZLevel
  19778. + ' has been used by unkown layer ' + currentLayer.id
  19779. );
  19780. }
  19781. ctx = currentLayer.ctx;
  19782. ctx.save();
  19783. // Reset the count
  19784. currentLayer.__unusedCount = 0;
  19785. if (currentLayer.__dirty || paintAll) {
  19786. currentLayer.clear();
  19787. }
  19788. }
  19789. if (!(currentLayer.__dirty || paintAll)) {
  19790. continue;
  19791. }
  19792. if (elFrame >= 0) {
  19793. // Progressive layer changed
  19794. if (!currentProgressiveLayer) {
  19795. currentProgressiveLayer = this._progressiveLayers[
  19796. Math.min(progressiveLayerIdx++, MAX_PROGRESSIVE_LAYER_NUMBER - 1)
  19797. ];
  19798. currentProgressiveLayer.ctx.save();
  19799. currentProgressiveLayer.renderScope = {};
  19800. if (currentProgressiveLayer
  19801. && (currentProgressiveLayer.__progress > currentProgressiveLayer.__maxProgress)
  19802. ) {
  19803. // flushProgressiveLayer(currentProgressiveLayer);
  19804. // Quick jump all progressive elements
  19805. // All progressive element are not dirty, jump over and flush directly
  19806. i = currentProgressiveLayer.__nextIdxNotProg - 1;
  19807. // currentProgressiveLayer = null;
  19808. continue;
  19809. }
  19810. layerProgress = currentProgressiveLayer.__progress;
  19811. if (!currentProgressiveLayer.__dirty) {
  19812. // Keep rendering
  19813. frame = layerProgress;
  19814. }
  19815. currentProgressiveLayer.__progress = frame + 1;
  19816. }
  19817. if (elFrame === frame) {
  19818. this._doPaintEl(el, currentProgressiveLayer, true, currentProgressiveLayer.renderScope);
  19819. }
  19820. }
  19821. else {
  19822. this._doPaintEl(el, currentLayer, paintAll, scope);
  19823. }
  19824. el.__dirty = false;
  19825. }
  19826. if (currentProgressiveLayer) {
  19827. flushProgressiveLayer(currentProgressiveLayer);
  19828. }
  19829. // Restore the lastLayer ctx
  19830. ctx && ctx.restore();
  19831. // If still has clipping state
  19832. // if (scope.prevElClipPaths) {
  19833. // ctx.restore();
  19834. // }
  19835. this._furtherProgressive = false;
  19836. util.each(this._progressiveLayers, function (layer) {
  19837. if (layer.__maxProgress >= layer.__progress) {
  19838. this._furtherProgressive = true;
  19839. }
  19840. }, this);
  19841. },
  19842. _doPaintEl: function (el, currentLayer, forcePaint, scope) {
  19843. var ctx = currentLayer.ctx;
  19844. var m = el.transform;
  19845. if (
  19846. (currentLayer.__dirty || forcePaint)
  19847. // Ignore invisible element
  19848. && !el.invisible
  19849. // Ignore transparent element
  19850. && el.style.opacity !== 0
  19851. // Ignore scale 0 element, in some environment like node-canvas
  19852. // Draw a scale 0 element can cause all following draw wrong
  19853. // And setTransform with scale 0 will cause set back transform failed.
  19854. && !(m && !m[0] && !m[3])
  19855. // Ignore culled element
  19856. && !(el.culling && isDisplayableCulled(el, this._width, this._height))
  19857. ) {
  19858. var clipPaths = el.__clipPaths;
  19859. // Optimize when clipping on group with several elements
  19860. if (scope.prevClipLayer !== currentLayer
  19861. || isClipPathChanged(clipPaths, scope.prevElClipPaths)
  19862. ) {
  19863. // If has previous clipping state, restore from it
  19864. if (scope.prevElClipPaths) {
  19865. scope.prevClipLayer.ctx.restore();
  19866. scope.prevClipLayer = scope.prevElClipPaths = null;
  19867. // Reset prevEl since context has been restored
  19868. scope.prevEl = null;
  19869. }
  19870. // New clipping state
  19871. if (clipPaths) {
  19872. ctx.save();
  19873. doClip(clipPaths, ctx);
  19874. scope.prevClipLayer = currentLayer;
  19875. scope.prevElClipPaths = clipPaths;
  19876. }
  19877. }
  19878. el.beforeBrush && el.beforeBrush(ctx);
  19879. el.brush(ctx, scope.prevEl || null);
  19880. scope.prevEl = el;
  19881. el.afterBrush && el.afterBrush(ctx);
  19882. }
  19883. },
  19884. /**
  19885. * 获取 zlevel 所在层,如果不存在则会创建一个新的层
  19886. * @param {number} zlevel
  19887. * @return {module:zrender/Layer}
  19888. */
  19889. getLayer: function (zlevel) {
  19890. if (this._singleCanvas) {
  19891. return this._layers[0];
  19892. }
  19893. var layer = this._layers[zlevel];
  19894. if (!layer) {
  19895. // Create a new layer
  19896. layer = new Layer('zr_' + zlevel, this, this.dpr);
  19897. layer.__builtin__ = true;
  19898. if (this._layerConfig[zlevel]) {
  19899. util.merge(layer, this._layerConfig[zlevel], true);
  19900. }
  19901. this.insertLayer(zlevel, layer);
  19902. // Context is created after dom inserted to document
  19903. // Or excanvas will get 0px clientWidth and clientHeight
  19904. layer.initContext();
  19905. }
  19906. return layer;
  19907. },
  19908. insertLayer: function (zlevel, layer) {
  19909. var layersMap = this._layers;
  19910. var zlevelList = this._zlevelList;
  19911. var len = zlevelList.length;
  19912. var prevLayer = null;
  19913. var i = -1;
  19914. var domRoot = this._domRoot;
  19915. if (layersMap[zlevel]) {
  19916. log('ZLevel ' + zlevel + ' has been used already');
  19917. return;
  19918. }
  19919. // Check if is a valid layer
  19920. if (!isLayerValid(layer)) {
  19921. log('Layer of zlevel ' + zlevel + ' is not valid');
  19922. return;
  19923. }
  19924. if (len > 0 && zlevel > zlevelList[0]) {
  19925. for (i = 0; i < len - 1; i++) {
  19926. if (
  19927. zlevelList[i] < zlevel
  19928. && zlevelList[i + 1] > zlevel
  19929. ) {
  19930. break;
  19931. }
  19932. }
  19933. prevLayer = layersMap[zlevelList[i]];
  19934. }
  19935. zlevelList.splice(i + 1, 0, zlevel);
  19936. layersMap[zlevel] = layer;
  19937. // Vitual layer will not directly show on the screen.
  19938. // (It can be a WebGL layer and assigned to a ZImage element)
  19939. // But it still under management of zrender.
  19940. if (!layer.virtual) {
  19941. if (prevLayer) {
  19942. var prevDom = prevLayer.dom;
  19943. if (prevDom.nextSibling) {
  19944. domRoot.insertBefore(
  19945. layer.dom,
  19946. prevDom.nextSibling
  19947. );
  19948. }
  19949. else {
  19950. domRoot.appendChild(layer.dom);
  19951. }
  19952. }
  19953. else {
  19954. if (domRoot.firstChild) {
  19955. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  19956. }
  19957. else {
  19958. domRoot.appendChild(layer.dom);
  19959. }
  19960. }
  19961. }
  19962. },
  19963. // Iterate each layer
  19964. eachLayer: function (cb, context) {
  19965. var zlevelList = this._zlevelList;
  19966. var z;
  19967. var i;
  19968. for (i = 0; i < zlevelList.length; i++) {
  19969. z = zlevelList[i];
  19970. cb.call(context, this._layers[z], z);
  19971. }
  19972. },
  19973. // Iterate each buildin layer
  19974. eachBuiltinLayer: function (cb, context) {
  19975. var zlevelList = this._zlevelList;
  19976. var layer;
  19977. var z;
  19978. var i;
  19979. for (i = 0; i < zlevelList.length; i++) {
  19980. z = zlevelList[i];
  19981. layer = this._layers[z];
  19982. if (layer.__builtin__) {
  19983. cb.call(context, layer, z);
  19984. }
  19985. }
  19986. },
  19987. // Iterate each other layer except buildin layer
  19988. eachOtherLayer: function (cb, context) {
  19989. var zlevelList = this._zlevelList;
  19990. var layer;
  19991. var z;
  19992. var i;
  19993. for (i = 0; i < zlevelList.length; i++) {
  19994. z = zlevelList[i];
  19995. layer = this._layers[z];
  19996. if (!layer.__builtin__) {
  19997. cb.call(context, layer, z);
  19998. }
  19999. }
  20000. },
  20001. /**
  20002. * 获取所有已创建的层
  20003. * @param {Array.<module:zrender/Layer>} [prevLayer]
  20004. */
  20005. getLayers: function () {
  20006. return this._layers;
  20007. },
  20008. _updateLayerStatus: function (list) {
  20009. var layers = this._layers;
  20010. var progressiveLayers = this._progressiveLayers;
  20011. var elCountsLastFrame = {};
  20012. var progressiveElCountsLastFrame = {};
  20013. this.eachBuiltinLayer(function (layer, z) {
  20014. elCountsLastFrame[z] = layer.elCount;
  20015. layer.elCount = 0;
  20016. layer.__dirty = false;
  20017. });
  20018. util.each(progressiveLayers, function (layer, idx) {
  20019. progressiveElCountsLastFrame[idx] = layer.elCount;
  20020. layer.elCount = 0;
  20021. layer.__dirty = false;
  20022. });
  20023. var progressiveLayerCount = 0;
  20024. var currentProgressiveLayer;
  20025. var lastProgressiveKey;
  20026. var frameCount = 0;
  20027. for (var i = 0, l = list.length; i < l; i++) {
  20028. var el = list[i];
  20029. var zlevel = this._singleCanvas ? 0 : el.zlevel;
  20030. var layer = layers[zlevel];
  20031. var elProgress = el.progressive;
  20032. if (layer) {
  20033. layer.elCount++;
  20034. layer.__dirty = layer.__dirty || el.__dirty;
  20035. }
  20036. /////// Update progressive
  20037. if (elProgress >= 0) {
  20038. // Fix wrong progressive sequence problem.
  20039. if (lastProgressiveKey !== elProgress) {
  20040. lastProgressiveKey = elProgress;
  20041. frameCount++;
  20042. }
  20043. var elFrame = el.__frame = frameCount - 1;
  20044. if (!currentProgressiveLayer) {
  20045. var idx = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER - 1);
  20046. currentProgressiveLayer = progressiveLayers[idx];
  20047. if (!currentProgressiveLayer) {
  20048. currentProgressiveLayer = progressiveLayers[idx] = new Layer(
  20049. 'progressive', this, this.dpr
  20050. );
  20051. currentProgressiveLayer.initContext();
  20052. }
  20053. currentProgressiveLayer.__maxProgress = 0;
  20054. }
  20055. currentProgressiveLayer.__dirty = currentProgressiveLayer.__dirty || el.__dirty;
  20056. currentProgressiveLayer.elCount++;
  20057. currentProgressiveLayer.__maxProgress = Math.max(
  20058. currentProgressiveLayer.__maxProgress, elFrame
  20059. );
  20060. if (currentProgressiveLayer.__maxProgress >= currentProgressiveLayer.__progress) {
  20061. // Should keep rendering this layer because progressive rendering is not finished yet
  20062. layer.__dirty = true;
  20063. }
  20064. }
  20065. else {
  20066. el.__frame = -1;
  20067. if (currentProgressiveLayer) {
  20068. currentProgressiveLayer.__nextIdxNotProg = i;
  20069. progressiveLayerCount++;
  20070. currentProgressiveLayer = null;
  20071. }
  20072. }
  20073. }
  20074. if (currentProgressiveLayer) {
  20075. progressiveLayerCount++;
  20076. currentProgressiveLayer.__nextIdxNotProg = i;
  20077. }
  20078. // 层中的元素数量有发生变化
  20079. this.eachBuiltinLayer(function (layer, z) {
  20080. if (elCountsLastFrame[z] !== layer.elCount) {
  20081. layer.__dirty = true;
  20082. }
  20083. });
  20084. progressiveLayers.length = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER);
  20085. util.each(progressiveLayers, function (layer, idx) {
  20086. if (progressiveElCountsLastFrame[idx] !== layer.elCount) {
  20087. el.__dirty = true;
  20088. }
  20089. if (layer.__dirty) {
  20090. layer.__progress = 0;
  20091. }
  20092. });
  20093. },
  20094. /**
  20095. * 清除hover层外所有内容
  20096. */
  20097. clear: function () {
  20098. this.eachBuiltinLayer(this._clearLayer);
  20099. return this;
  20100. },
  20101. _clearLayer: function (layer) {
  20102. layer.clear();
  20103. },
  20104. /**
  20105. * 修改指定zlevel的绘制参数
  20106. *
  20107. * @param {string} zlevel
  20108. * @param {Object} config 配置对象
  20109. * @param {string} [config.clearColor=0] 每次清空画布的颜色
  20110. * @param {string} [config.motionBlur=false] 是否开启动态模糊
  20111. * @param {number} [config.lastFrameAlpha=0.7]
  20112. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  20113. */
  20114. configLayer: function (zlevel, config) {
  20115. if (config) {
  20116. var layerConfig = this._layerConfig;
  20117. if (!layerConfig[zlevel]) {
  20118. layerConfig[zlevel] = config;
  20119. }
  20120. else {
  20121. util.merge(layerConfig[zlevel], config, true);
  20122. }
  20123. var layer = this._layers[zlevel];
  20124. if (layer) {
  20125. util.merge(layer, layerConfig[zlevel], true);
  20126. }
  20127. }
  20128. },
  20129. /**
  20130. * 删除指定层
  20131. * @param {number} zlevel 层所在的zlevel
  20132. */
  20133. delLayer: function (zlevel) {
  20134. var layers = this._layers;
  20135. var zlevelList = this._zlevelList;
  20136. var layer = layers[zlevel];
  20137. if (!layer) {
  20138. return;
  20139. }
  20140. layer.dom.parentNode.removeChild(layer.dom);
  20141. delete layers[zlevel];
  20142. zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
  20143. },
  20144. /**
  20145. * 区域大小变化后重绘
  20146. */
  20147. resize: function (width, height) {
  20148. var domRoot = this._domRoot;
  20149. // FIXME Why ?
  20150. domRoot.style.display = 'none';
  20151. // Save input w/h
  20152. var opts = this._opts;
  20153. width != null && (opts.width = width);
  20154. height != null && (opts.height = height);
  20155. width = this._getSize(0);
  20156. height = this._getSize(1);
  20157. domRoot.style.display = '';
  20158. // 优化没有实际改变的resize
  20159. if (this._width != width || height != this._height) {
  20160. domRoot.style.width = width + 'px';
  20161. domRoot.style.height = height + 'px';
  20162. for (var id in this._layers) {
  20163. if (this._layers.hasOwnProperty(id)) {
  20164. this._layers[id].resize(width, height);
  20165. }
  20166. }
  20167. util.each(this._progressiveLayers, function (layer) {
  20168. layer.resize(width, height);
  20169. });
  20170. this.refresh(true);
  20171. }
  20172. this._width = width;
  20173. this._height = height;
  20174. return this;
  20175. },
  20176. /**
  20177. * 清除单独的一个层
  20178. * @param {number} zlevel
  20179. */
  20180. clearLayer: function (zlevel) {
  20181. var layer = this._layers[zlevel];
  20182. if (layer) {
  20183. layer.clear();
  20184. }
  20185. },
  20186. /**
  20187. * 释放
  20188. */
  20189. dispose: function () {
  20190. this.root.innerHTML = '';
  20191. this.root =
  20192. this.storage =
  20193. this._domRoot =
  20194. this._layers = null;
  20195. },
  20196. /**
  20197. * Get canvas which has all thing rendered
  20198. * @param {Object} opts
  20199. * @param {string} [opts.backgroundColor]
  20200. */
  20201. getRenderedCanvas: function (opts) {
  20202. opts = opts || {};
  20203. if (this._singleCanvas) {
  20204. return this._layers[0].dom;
  20205. }
  20206. var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
  20207. imageLayer.initContext();
  20208. imageLayer.clearColor = opts.backgroundColor;
  20209. imageLayer.clear();
  20210. var displayList = this.storage.getDisplayList(true);
  20211. var scope = {};
  20212. var zlevel;
  20213. var self = this;
  20214. function findAndDrawOtherLayer(smaller, larger) {
  20215. var zlevelList = self._zlevelList;
  20216. if (smaller == null) {
  20217. smaller = -Infinity;
  20218. }
  20219. var intermediateLayer;
  20220. for (var i = 0; i < zlevelList.length; i++) {
  20221. var z = zlevelList[i];
  20222. var layer = self._layers[z];
  20223. if (!layer.__builtin__ && z > smaller && z < larger) {
  20224. intermediateLayer = layer;
  20225. break;
  20226. }
  20227. }
  20228. if (intermediateLayer && intermediateLayer.renderToCanvas) {
  20229. imageLayer.ctx.save();
  20230. intermediateLayer.renderToCanvas(imageLayer.ctx);
  20231. imageLayer.ctx.restore();
  20232. }
  20233. }
  20234. for (var i = 0; i < displayList.length; i++) {
  20235. var el = displayList[i];
  20236. if (el.zlevel !== zlevel) {
  20237. findAndDrawOtherLayer(zlevel, el.zlevel);
  20238. zlevel = el.zlevel;
  20239. }
  20240. this._doPaintEl(el, imageLayer, true, scope);
  20241. }
  20242. findAndDrawOtherLayer(zlevel, Infinity);
  20243. return imageLayer.dom;
  20244. },
  20245. /**
  20246. * 获取绘图区域宽度
  20247. */
  20248. getWidth: function () {
  20249. return this._width;
  20250. },
  20251. /**
  20252. * 获取绘图区域高度
  20253. */
  20254. getHeight: function () {
  20255. return this._height;
  20256. },
  20257. _getSize: function (whIdx) {
  20258. var opts = this._opts;
  20259. var wh = ['width', 'height'][whIdx];
  20260. var cwh = ['clientWidth', 'clientHeight'][whIdx];
  20261. var plt = ['paddingLeft', 'paddingTop'][whIdx];
  20262. var prb = ['paddingRight', 'paddingBottom'][whIdx];
  20263. if (opts[wh] != null && opts[wh] !== 'auto') {
  20264. return parseFloat(opts[wh]);
  20265. }
  20266. var root = this.root;
  20267. // IE8 does not support getComputedStyle, but it use VML.
  20268. var stl = document.defaultView.getComputedStyle(root);
  20269. return (
  20270. (root[cwh] || parseInt10(stl[wh]) || parseInt10(root.style[wh]))
  20271. - (parseInt10(stl[plt]) || 0)
  20272. - (parseInt10(stl[prb]) || 0)
  20273. ) | 0;
  20274. },
  20275. pathToImage: function (path, dpr) {
  20276. dpr = dpr || this.dpr;
  20277. var canvas = document.createElement('canvas');
  20278. var ctx = canvas.getContext('2d');
  20279. var rect = path.getBoundingRect();
  20280. var style = path.style;
  20281. var shadowBlurSize = style.shadowBlur;
  20282. var shadowOffsetX = style.shadowOffsetX;
  20283. var shadowOffsetY = style.shadowOffsetY;
  20284. var lineWidth = style.hasStroke() ? style.lineWidth : 0;
  20285. var leftMargin = Math.max(lineWidth / 2, -shadowOffsetX + shadowBlurSize);
  20286. var rightMargin = Math.max(lineWidth / 2, shadowOffsetX + shadowBlurSize);
  20287. var topMargin = Math.max(lineWidth / 2, -shadowOffsetY + shadowBlurSize);
  20288. var bottomMargin = Math.max(lineWidth / 2, shadowOffsetY + shadowBlurSize);
  20289. var width = rect.width + leftMargin + rightMargin;
  20290. var height = rect.height + topMargin + bottomMargin;
  20291. canvas.width = width * dpr;
  20292. canvas.height = height * dpr;
  20293. ctx.scale(dpr, dpr);
  20294. ctx.clearRect(0, 0, width, height);
  20295. ctx.dpr = dpr;
  20296. var pathTransform = {
  20297. position: path.position,
  20298. rotation: path.rotation,
  20299. scale: path.scale
  20300. };
  20301. path.position = [leftMargin - rect.x, topMargin - rect.y];
  20302. path.rotation = 0;
  20303. path.scale = [1, 1];
  20304. path.updateTransform();
  20305. if (path) {
  20306. path.brush(ctx);
  20307. }
  20308. var ImageShape = __webpack_require__(52);
  20309. var imgShape = new ImageShape({
  20310. style: {
  20311. x: 0,
  20312. y: 0,
  20313. image: canvas
  20314. }
  20315. });
  20316. if (pathTransform.position != null) {
  20317. imgShape.position = path.position = pathTransform.position;
  20318. }
  20319. if (pathTransform.rotation != null) {
  20320. imgShape.rotation = path.rotation = pathTransform.rotation;
  20321. }
  20322. if (pathTransform.scale != null) {
  20323. imgShape.scale = path.scale = pathTransform.scale;
  20324. }
  20325. return imgShape;
  20326. }
  20327. };
  20328. module.exports = Painter;
  20329. /***/ }),
  20330. /* 98 */
  20331. /***/ (function(module, exports, __webpack_require__) {
  20332. /**
  20333. * @module zrender/Layer
  20334. * @author pissang(https://www.github.com/pissang)
  20335. */
  20336. var util = __webpack_require__(4);
  20337. var config = __webpack_require__(35);
  20338. var Style = __webpack_require__(24);
  20339. var Pattern = __webpack_require__(49);
  20340. function returnFalse() {
  20341. return false;
  20342. }
  20343. /**
  20344. * 创建dom
  20345. *
  20346. * @inner
  20347. * @param {string} id dom id 待用
  20348. * @param {string} type dom type,such as canvas, div etc.
  20349. * @param {Painter} painter painter instance
  20350. * @param {number} number
  20351. */
  20352. function createDom(id, type, painter, dpr) {
  20353. var newDom = document.createElement(type);
  20354. var width = painter.getWidth();
  20355. var height = painter.getHeight();
  20356. var newDomStyle = newDom.style;
  20357. // 没append呢,请原谅我这样写,清晰~
  20358. newDomStyle.position = 'absolute';
  20359. newDomStyle.left = 0;
  20360. newDomStyle.top = 0;
  20361. newDomStyle.width = width + 'px';
  20362. newDomStyle.height = height + 'px';
  20363. newDom.width = width * dpr;
  20364. newDom.height = height * dpr;
  20365. // id不作为索引用,避免可能造成的重名,定义为私有属性
  20366. newDom.setAttribute('data-zr-dom-id', id);
  20367. return newDom;
  20368. }
  20369. /**
  20370. * @alias module:zrender/Layer
  20371. * @constructor
  20372. * @extends module:zrender/mixin/Transformable
  20373. * @param {string} id
  20374. * @param {module:zrender/Painter} painter
  20375. * @param {number} [dpr]
  20376. */
  20377. var Layer = function(id, painter, dpr) {
  20378. var dom;
  20379. dpr = dpr || config.devicePixelRatio;
  20380. if (typeof id === 'string') {
  20381. dom = createDom(id, 'canvas', painter, dpr);
  20382. }
  20383. // Not using isDom because in node it will return false
  20384. else if (util.isObject(id)) {
  20385. dom = id;
  20386. id = dom.id;
  20387. }
  20388. this.id = id;
  20389. this.dom = dom;
  20390. var domStyle = dom.style;
  20391. if (domStyle) { // Not in node
  20392. dom.onselectstart = returnFalse; // 避免页面选中的尴尬
  20393. domStyle['-webkit-user-select'] = 'none';
  20394. domStyle['user-select'] = 'none';
  20395. domStyle['-webkit-touch-callout'] = 'none';
  20396. domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)';
  20397. domStyle['padding'] = 0;
  20398. domStyle['margin'] = 0;
  20399. domStyle['border-width'] = 0;
  20400. }
  20401. this.domBack = null;
  20402. this.ctxBack = null;
  20403. this.painter = painter;
  20404. this.config = null;
  20405. // Configs
  20406. /**
  20407. * 每次清空画布的颜色
  20408. * @type {string}
  20409. * @default 0
  20410. */
  20411. this.clearColor = 0;
  20412. /**
  20413. * 是否开启动态模糊
  20414. * @type {boolean}
  20415. * @default false
  20416. */
  20417. this.motionBlur = false;
  20418. /**
  20419. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  20420. * @type {number}
  20421. * @default 0.7
  20422. */
  20423. this.lastFrameAlpha = 0.7;
  20424. /**
  20425. * Layer dpr
  20426. * @type {number}
  20427. */
  20428. this.dpr = dpr;
  20429. };
  20430. Layer.prototype = {
  20431. constructor: Layer,
  20432. elCount: 0,
  20433. __dirty: true,
  20434. initContext: function () {
  20435. this.ctx = this.dom.getContext('2d');
  20436. this.ctx.__currentValues = {};
  20437. this.ctx.dpr = this.dpr;
  20438. },
  20439. createBackBuffer: function () {
  20440. var dpr = this.dpr;
  20441. this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr);
  20442. this.ctxBack = this.domBack.getContext('2d');
  20443. this.ctxBack.__currentValues = {};
  20444. if (dpr != 1) {
  20445. this.ctxBack.scale(dpr, dpr);
  20446. }
  20447. },
  20448. /**
  20449. * @param {number} width
  20450. * @param {number} height
  20451. */
  20452. resize: function (width, height) {
  20453. var dpr = this.dpr;
  20454. var dom = this.dom;
  20455. var domStyle = dom.style;
  20456. var domBack = this.domBack;
  20457. domStyle.width = width + 'px';
  20458. domStyle.height = height + 'px';
  20459. dom.width = width * dpr;
  20460. dom.height = height * dpr;
  20461. if (domBack) {
  20462. domBack.width = width * dpr;
  20463. domBack.height = height * dpr;
  20464. if (dpr != 1) {
  20465. this.ctxBack.scale(dpr, dpr);
  20466. }
  20467. }
  20468. },
  20469. /**
  20470. * 清空该层画布
  20471. * @param {boolean} clearAll Clear all with out motion blur
  20472. */
  20473. clear: function (clearAll) {
  20474. var dom = this.dom;
  20475. var ctx = this.ctx;
  20476. var width = dom.width;
  20477. var height = dom.height;
  20478. var clearColor = this.clearColor;
  20479. var haveMotionBLur = this.motionBlur && !clearAll;
  20480. var lastFrameAlpha = this.lastFrameAlpha;
  20481. var dpr = this.dpr;
  20482. if (haveMotionBLur) {
  20483. if (!this.domBack) {
  20484. this.createBackBuffer();
  20485. }
  20486. this.ctxBack.globalCompositeOperation = 'copy';
  20487. this.ctxBack.drawImage(
  20488. dom, 0, 0,
  20489. width / dpr,
  20490. height / dpr
  20491. );
  20492. }
  20493. ctx.clearRect(0, 0, width, height);
  20494. if (clearColor) {
  20495. var clearColorGradientOrPattern;
  20496. // Gradient
  20497. if (clearColor.colorStops) {
  20498. // Cache canvas gradient
  20499. clearColorGradientOrPattern = clearColor.__canvasGradient || Style.getGradient(ctx, clearColor, {
  20500. x: 0,
  20501. y: 0,
  20502. width: width,
  20503. height: height
  20504. });
  20505. clearColor.__canvasGradient = clearColorGradientOrPattern;
  20506. }
  20507. // Pattern
  20508. else if (clearColor.image) {
  20509. clearColorGradientOrPattern = Pattern.prototype.getCanvasPattern.call(clearColor, ctx);
  20510. }
  20511. ctx.save();
  20512. ctx.fillStyle = clearColorGradientOrPattern || clearColor;
  20513. ctx.fillRect(0, 0, width, height);
  20514. ctx.restore();
  20515. }
  20516. if (haveMotionBLur) {
  20517. var domBack = this.domBack;
  20518. ctx.save();
  20519. ctx.globalAlpha = lastFrameAlpha;
  20520. ctx.drawImage(domBack, 0, 0, width, height);
  20521. ctx.restore();
  20522. }
  20523. }
  20524. };
  20525. module.exports = Layer;
  20526. /***/ }),
  20527. /* 99 */
  20528. /***/ (function(module, exports, __webpack_require__) {
  20529. var Gradient = __webpack_require__(69);
  20530. module.exports = function (ecModel) {
  20531. function encodeColor(seriesModel) {
  20532. var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.normal.color').split('.');
  20533. var data = seriesModel.getData();
  20534. var color = seriesModel.get(colorAccessPath) // Set in itemStyle
  20535. || seriesModel.getColorFromPalette(seriesModel.get('name')); // Default color
  20536. // FIXME Set color function or use the platte color
  20537. data.setVisual('color', color);
  20538. // Only visible series has each data be visual encoded
  20539. if (!ecModel.isSeriesFiltered(seriesModel)) {
  20540. if (typeof color === 'function' && !(color instanceof Gradient)) {
  20541. data.each(function (idx) {
  20542. data.setItemVisual(
  20543. idx, 'color', color(seriesModel.getDataParams(idx))
  20544. );
  20545. });
  20546. }
  20547. // itemStyle in each data item
  20548. data.each(function (idx) {
  20549. var itemModel = data.getItemModel(idx);
  20550. var color = itemModel.get(colorAccessPath, true);
  20551. if (color != null) {
  20552. data.setItemVisual(idx, 'color', color);
  20553. }
  20554. });
  20555. }
  20556. }
  20557. ecModel.eachRawSeries(encodeColor);
  20558. };
  20559. /***/ }),
  20560. /* 100 */
  20561. /***/ (function(module, exports, __webpack_require__) {
  20562. var graphic = __webpack_require__(20);
  20563. var zrUtil = __webpack_require__(4);
  20564. var PI = Math.PI;
  20565. /**
  20566. * @param {module:echarts/ExtensionAPI} api
  20567. * @param {Object} [opts]
  20568. * @param {string} [opts.text]
  20569. * @param {string} [opts.color]
  20570. * @param {string} [opts.textColor]
  20571. * @return {module:zrender/Element}
  20572. */
  20573. module.exports = function (api, opts) {
  20574. opts = opts || {};
  20575. zrUtil.defaults(opts, {
  20576. text: 'loading',
  20577. color: '#c23531',
  20578. textColor: '#000',
  20579. maskColor: 'rgba(255, 255, 255, 0.8)',
  20580. zlevel: 0
  20581. });
  20582. var mask = new graphic.Rect({
  20583. style: {
  20584. fill: opts.maskColor
  20585. },
  20586. zlevel: opts.zlevel,
  20587. z: 10000
  20588. });
  20589. var arc = new graphic.Arc({
  20590. shape: {
  20591. startAngle: -PI / 2,
  20592. endAngle: -PI / 2 + 0.1,
  20593. r: 10
  20594. },
  20595. style: {
  20596. stroke: opts.color,
  20597. lineCap: 'round',
  20598. lineWidth: 5
  20599. },
  20600. zlevel: opts.zlevel,
  20601. z: 10001
  20602. });
  20603. var labelRect = new graphic.Rect({
  20604. style: {
  20605. fill: 'none',
  20606. text: opts.text,
  20607. textPosition: 'right',
  20608. textDistance: 10,
  20609. textFill: opts.textColor
  20610. },
  20611. zlevel: opts.zlevel,
  20612. z: 10001
  20613. });
  20614. arc.animateShape(true)
  20615. .when(1000, {
  20616. endAngle: PI * 3 / 2
  20617. })
  20618. .start('circularInOut');
  20619. arc.animateShape(true)
  20620. .when(1000, {
  20621. startAngle: PI * 3 / 2
  20622. })
  20623. .delay(300)
  20624. .start('circularInOut');
  20625. var group = new graphic.Group();
  20626. group.add(arc);
  20627. group.add(labelRect);
  20628. group.add(mask);
  20629. // Inject resize
  20630. group.resize = function () {
  20631. var cx = api.getWidth() / 2;
  20632. var cy = api.getHeight() / 2;
  20633. arc.setShape({
  20634. cx: cx,
  20635. cy: cy
  20636. });
  20637. var r = arc.shape.r;
  20638. labelRect.setShape({
  20639. x: cx - r,
  20640. y: cy - r,
  20641. width: r * 2,
  20642. height: r * 2
  20643. });
  20644. mask.setShape({
  20645. x: 0,
  20646. y: 0,
  20647. width: api.getWidth(),
  20648. height: api.getHeight()
  20649. });
  20650. };
  20651. group.resize();
  20652. return group;
  20653. };
  20654. /***/ }),
  20655. /* 101 */
  20656. /***/ (function(module, exports, __webpack_require__) {
  20657. /* WEBPACK VAR INJECTION */(function(global) {/**
  20658. * List for data storage
  20659. * @module echarts/data/List
  20660. */
  20661. var UNDEFINED = 'undefined';
  20662. var globalObj = typeof window === 'undefined' ? global : window;
  20663. var Float64Array = typeof globalObj.Float64Array === UNDEFINED
  20664. ? Array : globalObj.Float64Array;
  20665. var Int32Array = typeof globalObj.Int32Array === UNDEFINED
  20666. ? Array : globalObj.Int32Array;
  20667. var dataCtors = {
  20668. 'float': Float64Array,
  20669. 'int': Int32Array,
  20670. // Ordinal data type can be string or int
  20671. 'ordinal': Array,
  20672. 'number': Array,
  20673. 'time': Array
  20674. };
  20675. var Model = __webpack_require__(14);
  20676. var DataDiffer = __webpack_require__(102);
  20677. var zrUtil = __webpack_require__(4);
  20678. var modelUtil = __webpack_require__(5);
  20679. var isObject = zrUtil.isObject;
  20680. var TRANSFERABLE_PROPERTIES = [
  20681. 'stackedOn', 'hasItemOption', '_nameList', '_idList', '_rawData'
  20682. ];
  20683. function transferProperties(a, b) {
  20684. zrUtil.each(TRANSFERABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
  20685. if (b.hasOwnProperty(propName)) {
  20686. a[propName] = b[propName];
  20687. }
  20688. });
  20689. a.__wrappedMethods = b.__wrappedMethods;
  20690. }
  20691. function DefaultDataProvider(dataArray) {
  20692. this._array = dataArray || [];
  20693. }
  20694. DefaultDataProvider.prototype.pure = false;
  20695. DefaultDataProvider.prototype.count = function () {
  20696. return this._array.length;
  20697. };
  20698. DefaultDataProvider.prototype.getItem = function (idx) {
  20699. return this._array[idx];
  20700. };
  20701. /**
  20702. * @constructor
  20703. * @alias module:echarts/data/List
  20704. *
  20705. * @param {Array.<string|Object>} dimensions
  20706. * For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
  20707. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  20708. * @param {module:echarts/model/Model} hostModel
  20709. */
  20710. var List = function (dimensions, hostModel) {
  20711. dimensions = dimensions || ['x', 'y'];
  20712. var dimensionInfos = {};
  20713. var dimensionNames = [];
  20714. for (var i = 0; i < dimensions.length; i++) {
  20715. var dimensionName;
  20716. var dimensionInfo = {};
  20717. if (typeof dimensions[i] === 'string') {
  20718. dimensionName = dimensions[i];
  20719. dimensionInfo = {
  20720. name: dimensionName,
  20721. coordDim: dimensionName,
  20722. coordDimIndex: 0,
  20723. stackable: false,
  20724. // Type can be 'float', 'int', 'number'
  20725. // Default is number, Precision of float may not enough
  20726. type: 'number'
  20727. };
  20728. }
  20729. else {
  20730. dimensionInfo = dimensions[i];
  20731. dimensionName = dimensionInfo.name;
  20732. dimensionInfo.type = dimensionInfo.type || 'number';
  20733. if (!dimensionInfo.coordDim) {
  20734. dimensionInfo.coordDim = dimensionName;
  20735. dimensionInfo.coordDimIndex = 0;
  20736. }
  20737. }
  20738. dimensionInfo.otherDims = dimensionInfo.otherDims || {};
  20739. dimensionNames.push(dimensionName);
  20740. dimensionInfos[dimensionName] = dimensionInfo;
  20741. }
  20742. /**
  20743. * @readOnly
  20744. * @type {Array.<string>}
  20745. */
  20746. this.dimensions = dimensionNames;
  20747. /**
  20748. * Infomation of each data dimension, like data type.
  20749. * @type {Object}
  20750. */
  20751. this._dimensionInfos = dimensionInfos;
  20752. /**
  20753. * @type {module:echarts/model/Model}
  20754. */
  20755. this.hostModel = hostModel;
  20756. /**
  20757. * @type {module:echarts/model/Model}
  20758. */
  20759. this.dataType;
  20760. /**
  20761. * Indices stores the indices of data subset after filtered.
  20762. * This data subset will be used in chart.
  20763. * @type {Array.<number>}
  20764. * @readOnly
  20765. */
  20766. this.indices = [];
  20767. /**
  20768. * Data storage
  20769. * @type {Object.<key, TypedArray|Array>}
  20770. * @private
  20771. */
  20772. this._storage = {};
  20773. /**
  20774. * @type {Array.<string>}
  20775. */
  20776. this._nameList = [];
  20777. /**
  20778. * @type {Array.<string>}
  20779. */
  20780. this._idList = [];
  20781. /**
  20782. * Models of data option is stored sparse for optimizing memory cost
  20783. * @type {Array.<module:echarts/model/Model>}
  20784. * @private
  20785. */
  20786. this._optionModels = [];
  20787. /**
  20788. * @param {module:echarts/data/List}
  20789. */
  20790. this.stackedOn = null;
  20791. /**
  20792. * Global visual properties after visual coding
  20793. * @type {Object}
  20794. * @private
  20795. */
  20796. this._visual = {};
  20797. /**
  20798. * Globel layout properties.
  20799. * @type {Object}
  20800. * @private
  20801. */
  20802. this._layout = {};
  20803. /**
  20804. * Item visual properties after visual coding
  20805. * @type {Array.<Object>}
  20806. * @private
  20807. */
  20808. this._itemVisuals = [];
  20809. /**
  20810. * Item layout properties after layout
  20811. * @type {Array.<Object>}
  20812. * @private
  20813. */
  20814. this._itemLayouts = [];
  20815. /**
  20816. * Graphic elemnents
  20817. * @type {Array.<module:zrender/Element>}
  20818. * @private
  20819. */
  20820. this._graphicEls = [];
  20821. /**
  20822. * @type {Array.<Array|Object>}
  20823. * @private
  20824. */
  20825. this._rawData;
  20826. /**
  20827. * @type {Object}
  20828. * @private
  20829. */
  20830. this._extent;
  20831. };
  20832. var listProto = List.prototype;
  20833. listProto.type = 'list';
  20834. /**
  20835. * If each data item has it's own option
  20836. * @type {boolean}
  20837. */
  20838. listProto.hasItemOption = true;
  20839. /**
  20840. * Get dimension name
  20841. * @param {string|number} dim
  20842. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  20843. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  20844. * @return {string} Concrete dim name.
  20845. */
  20846. listProto.getDimension = function (dim) {
  20847. if (!isNaN(dim)) {
  20848. dim = this.dimensions[dim] || dim;
  20849. }
  20850. return dim;
  20851. };
  20852. /**
  20853. * Get type and stackable info of particular dimension
  20854. * @param {string|number} dim
  20855. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  20856. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  20857. */
  20858. listProto.getDimensionInfo = function (dim) {
  20859. return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]);
  20860. };
  20861. /**
  20862. * Initialize from data
  20863. * @param {Array.<Object|number|Array>} data
  20864. * @param {Array.<string>} [nameList]
  20865. * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number
  20866. */
  20867. listProto.initData = function (data, nameList, dimValueGetter) {
  20868. data = data || [];
  20869. var isDataArray = zrUtil.isArray(data);
  20870. if (isDataArray) {
  20871. data = new DefaultDataProvider(data);
  20872. }
  20873. if (true) {
  20874. if (!isDataArray && (typeof data.getItem != 'function' || typeof data.count != 'function')) {
  20875. throw new Error('Inavlid data provider.');
  20876. }
  20877. }
  20878. this._rawData = data;
  20879. // Clear
  20880. var storage = this._storage = {};
  20881. var indices = this.indices = [];
  20882. var dimensions = this.dimensions;
  20883. var dimensionInfoMap = this._dimensionInfos;
  20884. var size = data.count();
  20885. var idList = [];
  20886. var nameRepeatCount = {};
  20887. var nameDimIdx;
  20888. nameList = nameList || [];
  20889. // Init storage
  20890. for (var i = 0; i < dimensions.length; i++) {
  20891. var dimInfo = dimensionInfoMap[dimensions[i]];
  20892. dimInfo.otherDims.itemName === 0 && (nameDimIdx = i);
  20893. var DataCtor = dataCtors[dimInfo.type];
  20894. storage[dimensions[i]] = new DataCtor(size);
  20895. }
  20896. var self = this;
  20897. if (!dimValueGetter) {
  20898. self.hasItemOption = false;
  20899. }
  20900. // Default dim value getter
  20901. dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) {
  20902. var value = modelUtil.getDataItemValue(dataItem);
  20903. // If any dataItem is like { value: 10 }
  20904. if (modelUtil.isDataItemOption(dataItem)) {
  20905. self.hasItemOption = true;
  20906. }
  20907. return modelUtil.converDataValue(
  20908. (value instanceof Array)
  20909. ? value[dimIndex]
  20910. // If value is a single number or something else not array.
  20911. : value,
  20912. dimensionInfoMap[dimName]
  20913. );
  20914. };
  20915. for (var i = 0; i < size; i++) {
  20916. // NOTICE: Try not to write things into dataItem
  20917. var dataItem = data.getItem(i);
  20918. // Each data item is value
  20919. // [1, 2]
  20920. // 2
  20921. // Bar chart, line chart which uses category axis
  20922. // only gives the 'y' value. 'x' value is the indices of cateogry
  20923. // Use a tempValue to normalize the value to be a (x, y) value
  20924. // Store the data by dimensions
  20925. for (var k = 0; k < dimensions.length; k++) {
  20926. var dim = dimensions[k];
  20927. var dimStorage = storage[dim];
  20928. // PENDING NULL is empty or zero
  20929. dimStorage[i] = dimValueGetter(dataItem, dim, i, k);
  20930. }
  20931. indices.push(i);
  20932. }
  20933. // Use the name in option and create id
  20934. for (var i = 0; i < size; i++) {
  20935. var dataItem = data.getItem(i);
  20936. if (!nameList[i] && dataItem) {
  20937. if (dataItem.name != null) {
  20938. nameList[i] = dataItem.name;
  20939. }
  20940. else if (nameDimIdx != null) {
  20941. nameList[i] = storage[dimensions[nameDimIdx]][i];
  20942. }
  20943. }
  20944. var name = nameList[i] || '';
  20945. // Try using the id in option
  20946. var id = dataItem && dataItem.id;
  20947. if (!id && name) {
  20948. // Use name as id and add counter to avoid same name
  20949. nameRepeatCount[name] = nameRepeatCount[name] || 0;
  20950. id = name;
  20951. if (nameRepeatCount[name] > 0) {
  20952. id += '__ec__' + nameRepeatCount[name];
  20953. }
  20954. nameRepeatCount[name]++;
  20955. }
  20956. id && (idList[i] = id);
  20957. }
  20958. this._nameList = nameList;
  20959. this._idList = idList;
  20960. };
  20961. /**
  20962. * @return {number}
  20963. */
  20964. listProto.count = function () {
  20965. return this.indices.length;
  20966. };
  20967. /**
  20968. * Get value. Return NaN if idx is out of range.
  20969. * @param {string} dim Dim must be concrete name.
  20970. * @param {number} idx
  20971. * @param {boolean} stack
  20972. * @return {number}
  20973. */
  20974. listProto.get = function (dim, idx, stack) {
  20975. var storage = this._storage;
  20976. var dataIndex = this.indices[idx];
  20977. // If value not exists
  20978. if (dataIndex == null || !storage[dim]) {
  20979. return NaN;
  20980. }
  20981. var value = storage[dim][dataIndex];
  20982. // FIXME ordinal data type is not stackable
  20983. if (stack) {
  20984. var dimensionInfo = this._dimensionInfos[dim];
  20985. if (dimensionInfo && dimensionInfo.stackable) {
  20986. var stackedOn = this.stackedOn;
  20987. while (stackedOn) {
  20988. // Get no stacked data of stacked on
  20989. var stackedValue = stackedOn.get(dim, idx);
  20990. // Considering positive stack, negative stack and empty data
  20991. if ((value >= 0 && stackedValue > 0) // Positive stack
  20992. || (value <= 0 && stackedValue < 0) // Negative stack
  20993. ) {
  20994. value += stackedValue;
  20995. }
  20996. stackedOn = stackedOn.stackedOn;
  20997. }
  20998. }
  20999. }
  21000. return value;
  21001. };
  21002. /**
  21003. * Get value for multi dimensions.
  21004. * @param {Array.<string>} [dimensions] If ignored, using all dimensions.
  21005. * @param {number} idx
  21006. * @param {boolean} stack
  21007. * @return {number}
  21008. */
  21009. listProto.getValues = function (dimensions, idx, stack) {
  21010. var values = [];
  21011. if (!zrUtil.isArray(dimensions)) {
  21012. stack = idx;
  21013. idx = dimensions;
  21014. dimensions = this.dimensions;
  21015. }
  21016. for (var i = 0, len = dimensions.length; i < len; i++) {
  21017. values.push(this.get(dimensions[i], idx, stack));
  21018. }
  21019. return values;
  21020. };
  21021. /**
  21022. * If value is NaN. Inlcuding '-'
  21023. * @param {string} dim
  21024. * @param {number} idx
  21025. * @return {number}
  21026. */
  21027. listProto.hasValue = function (idx) {
  21028. var dimensions = this.dimensions;
  21029. var dimensionInfos = this._dimensionInfos;
  21030. for (var i = 0, len = dimensions.length; i < len; i++) {
  21031. if (
  21032. // Ordinal type can be string or number
  21033. dimensionInfos[dimensions[i]].type !== 'ordinal'
  21034. && isNaN(this.get(dimensions[i], idx))
  21035. ) {
  21036. return false;
  21037. }
  21038. }
  21039. return true;
  21040. };
  21041. /**
  21042. * Get extent of data in one dimension
  21043. * @param {string} dim
  21044. * @param {boolean} stack
  21045. * @param {Function} filter
  21046. */
  21047. listProto.getDataExtent = function (dim, stack, filter) {
  21048. dim = this.getDimension(dim);
  21049. var dimData = this._storage[dim];
  21050. var dimInfo = this.getDimensionInfo(dim);
  21051. stack = (dimInfo && dimInfo.stackable) && stack;
  21052. var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)];
  21053. var value;
  21054. if (dimExtent) {
  21055. return dimExtent;
  21056. }
  21057. // var dimInfo = this._dimensionInfos[dim];
  21058. if (dimData) {
  21059. var min = Infinity;
  21060. var max = -Infinity;
  21061. // var isOrdinal = dimInfo.type === 'ordinal';
  21062. for (var i = 0, len = this.count(); i < len; i++) {
  21063. value = this.get(dim, i, stack);
  21064. // FIXME
  21065. // if (isOrdinal && typeof value === 'string') {
  21066. // value = zrUtil.indexOf(dimData, value);
  21067. // }
  21068. if (!filter || filter(value, dim, i)) {
  21069. value < min && (min = value);
  21070. value > max && (max = value);
  21071. }
  21072. }
  21073. return (this._extent[dim + !!stack] = [min, max]);
  21074. }
  21075. else {
  21076. return [Infinity, -Infinity];
  21077. }
  21078. };
  21079. /**
  21080. * Get sum of data in one dimension
  21081. * @param {string} dim
  21082. * @param {boolean} stack
  21083. */
  21084. listProto.getSum = function (dim, stack) {
  21085. var dimData = this._storage[dim];
  21086. var sum = 0;
  21087. if (dimData) {
  21088. for (var i = 0, len = this.count(); i < len; i++) {
  21089. var value = this.get(dim, i, stack);
  21090. if (!isNaN(value)) {
  21091. sum += value;
  21092. }
  21093. }
  21094. }
  21095. return sum;
  21096. };
  21097. /**
  21098. * Retreive the index with given value
  21099. * @param {number} idx
  21100. * @param {number} value
  21101. * @return {number}
  21102. */
  21103. // FIXME Precision of float value
  21104. listProto.indexOf = function (dim, value) {
  21105. var storage = this._storage;
  21106. var dimData = storage[dim];
  21107. var indices = this.indices;
  21108. if (dimData) {
  21109. for (var i = 0, len = indices.length; i < len; i++) {
  21110. var rawIndex = indices[i];
  21111. if (dimData[rawIndex] === value) {
  21112. return i;
  21113. }
  21114. }
  21115. }
  21116. return -1;
  21117. };
  21118. /**
  21119. * Retreive the index with given name
  21120. * @param {number} idx
  21121. * @param {number} name
  21122. * @return {number}
  21123. */
  21124. listProto.indexOfName = function (name) {
  21125. var indices = this.indices;
  21126. var nameList = this._nameList;
  21127. for (var i = 0, len = indices.length; i < len; i++) {
  21128. var rawIndex = indices[i];
  21129. if (nameList[rawIndex] === name) {
  21130. return i;
  21131. }
  21132. }
  21133. return -1;
  21134. };
  21135. /**
  21136. * Retreive the index with given raw data index
  21137. * @param {number} idx
  21138. * @param {number} name
  21139. * @return {number}
  21140. */
  21141. listProto.indexOfRawIndex = function (rawIndex) {
  21142. // Indices are ascending
  21143. var indices = this.indices;
  21144. // If rawIndex === dataIndex
  21145. var rawDataIndex = indices[rawIndex];
  21146. if (rawDataIndex != null && rawDataIndex === rawIndex) {
  21147. return rawIndex;
  21148. }
  21149. var left = 0;
  21150. var right = indices.length - 1;
  21151. while (left <= right) {
  21152. var mid = (left + right) / 2 | 0;
  21153. if (indices[mid] < rawIndex) {
  21154. left = mid + 1;
  21155. }
  21156. else if (indices[mid] > rawIndex) {
  21157. right = mid - 1;
  21158. }
  21159. else {
  21160. return mid;
  21161. }
  21162. }
  21163. return -1;
  21164. };
  21165. /**
  21166. * Retreive the index of nearest value
  21167. * @param {string} dim
  21168. * @param {number} value
  21169. * @param {boolean} stack If given value is after stacked
  21170. * @param {number} [maxDistance=Infinity]
  21171. * @return {Array.<number>} Considere multiple points has the same value.
  21172. */
  21173. listProto.indicesOfNearest = function (dim, value, stack, maxDistance) {
  21174. var storage = this._storage;
  21175. var dimData = storage[dim];
  21176. var nearestIndices = [];
  21177. if (!dimData) {
  21178. return nearestIndices;
  21179. }
  21180. if (maxDistance == null) {
  21181. maxDistance = Infinity;
  21182. }
  21183. var minDist = Number.MAX_VALUE;
  21184. var minDiff = -1;
  21185. for (var i = 0, len = this.count(); i < len; i++) {
  21186. var diff = value - this.get(dim, i, stack);
  21187. var dist = Math.abs(diff);
  21188. if (diff <= maxDistance && dist <= minDist) {
  21189. // For the case of two data are same on xAxis, which has sequence data.
  21190. // Show the nearest index
  21191. // https://github.com/ecomfe/echarts/issues/2869
  21192. if (dist < minDist || (diff >= 0 && minDiff < 0)) {
  21193. minDist = dist;
  21194. minDiff = diff;
  21195. nearestIndices.length = 0;
  21196. }
  21197. nearestIndices.push(i);
  21198. }
  21199. }
  21200. return nearestIndices;
  21201. };
  21202. /**
  21203. * Get raw data index
  21204. * @param {number} idx
  21205. * @return {number}
  21206. */
  21207. listProto.getRawIndex = function (idx) {
  21208. var rawIdx = this.indices[idx];
  21209. return rawIdx == null ? -1 : rawIdx;
  21210. };
  21211. /**
  21212. * Get raw data item
  21213. * @param {number} idx
  21214. * @return {number}
  21215. */
  21216. listProto.getRawDataItem = function (idx) {
  21217. return this._rawData.getItem(this.getRawIndex(idx));
  21218. };
  21219. /**
  21220. * @param {number} idx
  21221. * @param {boolean} [notDefaultIdx=false]
  21222. * @return {string}
  21223. */
  21224. listProto.getName = function (idx) {
  21225. return this._nameList[this.indices[idx]] || '';
  21226. };
  21227. /**
  21228. * @param {number} idx
  21229. * @param {boolean} [notDefaultIdx=false]
  21230. * @return {string}
  21231. */
  21232. listProto.getId = function (idx) {
  21233. return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + '');
  21234. };
  21235. function normalizeDimensions(dimensions) {
  21236. if (!zrUtil.isArray(dimensions)) {
  21237. dimensions = [dimensions];
  21238. }
  21239. return dimensions;
  21240. }
  21241. /**
  21242. * Data iteration
  21243. * @param {string|Array.<string>}
  21244. * @param {Function} cb
  21245. * @param {boolean} [stack=false]
  21246. * @param {*} [context=this]
  21247. *
  21248. * @example
  21249. * list.each('x', function (x, idx) {});
  21250. * list.each(['x', 'y'], function (x, y, idx) {});
  21251. * list.each(function (idx) {})
  21252. */
  21253. listProto.each = function (dims, cb, stack, context) {
  21254. if (typeof dims === 'function') {
  21255. context = stack;
  21256. stack = cb;
  21257. cb = dims;
  21258. dims = [];
  21259. }
  21260. dims = zrUtil.map(normalizeDimensions(dims), this.getDimension, this);
  21261. var value = [];
  21262. var dimSize = dims.length;
  21263. var indices = this.indices;
  21264. context = context || this;
  21265. for (var i = 0; i < indices.length; i++) {
  21266. // Simple optimization
  21267. switch (dimSize) {
  21268. case 0:
  21269. cb.call(context, i);
  21270. break;
  21271. case 1:
  21272. cb.call(context, this.get(dims[0], i, stack), i);
  21273. break;
  21274. case 2:
  21275. cb.call(context, this.get(dims[0], i, stack), this.get(dims[1], i, stack), i);
  21276. break;
  21277. default:
  21278. for (var k = 0; k < dimSize; k++) {
  21279. value[k] = this.get(dims[k], i, stack);
  21280. }
  21281. // Index
  21282. value[k] = i;
  21283. cb.apply(context, value);
  21284. }
  21285. }
  21286. };
  21287. /**
  21288. * Data filter
  21289. * @param {string|Array.<string>}
  21290. * @param {Function} cb
  21291. * @param {boolean} [stack=false]
  21292. * @param {*} [context=this]
  21293. */
  21294. listProto.filterSelf = function (dimensions, cb, stack, context) {
  21295. if (typeof dimensions === 'function') {
  21296. context = stack;
  21297. stack = cb;
  21298. cb = dimensions;
  21299. dimensions = [];
  21300. }
  21301. dimensions = zrUtil.map(
  21302. normalizeDimensions(dimensions), this.getDimension, this
  21303. );
  21304. var newIndices = [];
  21305. var value = [];
  21306. var dimSize = dimensions.length;
  21307. var indices = this.indices;
  21308. context = context || this;
  21309. for (var i = 0; i < indices.length; i++) {
  21310. var keep;
  21311. // Simple optimization
  21312. if (!dimSize) {
  21313. keep = cb.call(context, i);
  21314. }
  21315. else if (dimSize === 1) {
  21316. keep = cb.call(
  21317. context, this.get(dimensions[0], i, stack), i
  21318. );
  21319. }
  21320. else {
  21321. for (var k = 0; k < dimSize; k++) {
  21322. value[k] = this.get(dimensions[k], i, stack);
  21323. }
  21324. value[k] = i;
  21325. keep = cb.apply(context, value);
  21326. }
  21327. if (keep) {
  21328. newIndices.push(indices[i]);
  21329. }
  21330. }
  21331. this.indices = newIndices;
  21332. // Reset data extent
  21333. this._extent = {};
  21334. return this;
  21335. };
  21336. /**
  21337. * Data mapping to a plain array
  21338. * @param {string|Array.<string>} [dimensions]
  21339. * @param {Function} cb
  21340. * @param {boolean} [stack=false]
  21341. * @param {*} [context=this]
  21342. * @return {Array}
  21343. */
  21344. listProto.mapArray = function (dimensions, cb, stack, context) {
  21345. if (typeof dimensions === 'function') {
  21346. context = stack;
  21347. stack = cb;
  21348. cb = dimensions;
  21349. dimensions = [];
  21350. }
  21351. var result = [];
  21352. this.each(dimensions, function () {
  21353. result.push(cb && cb.apply(this, arguments));
  21354. }, stack, context);
  21355. return result;
  21356. };
  21357. function cloneListForMapAndSample(original, excludeDimensions) {
  21358. var allDimensions = original.dimensions;
  21359. var list = new List(
  21360. zrUtil.map(allDimensions, original.getDimensionInfo, original),
  21361. original.hostModel
  21362. );
  21363. // FIXME If needs stackedOn, value may already been stacked
  21364. transferProperties(list, original);
  21365. var storage = list._storage = {};
  21366. var originalStorage = original._storage;
  21367. // Init storage
  21368. for (var i = 0; i < allDimensions.length; i++) {
  21369. var dim = allDimensions[i];
  21370. var dimStore = originalStorage[dim];
  21371. if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {
  21372. storage[dim] = new dimStore.constructor(
  21373. originalStorage[dim].length
  21374. );
  21375. }
  21376. else {
  21377. // Direct reference for other dimensions
  21378. storage[dim] = originalStorage[dim];
  21379. }
  21380. }
  21381. return list;
  21382. }
  21383. /**
  21384. * Data mapping to a new List with given dimensions
  21385. * @param {string|Array.<string>} dimensions
  21386. * @param {Function} cb
  21387. * @param {boolean} [stack=false]
  21388. * @param {*} [context=this]
  21389. * @return {Array}
  21390. */
  21391. listProto.map = function (dimensions, cb, stack, context) {
  21392. dimensions = zrUtil.map(
  21393. normalizeDimensions(dimensions), this.getDimension, this
  21394. );
  21395. var list = cloneListForMapAndSample(this, dimensions);
  21396. // Following properties are all immutable.
  21397. // So we can reference to the same value
  21398. var indices = list.indices = this.indices;
  21399. var storage = list._storage;
  21400. var tmpRetValue = [];
  21401. this.each(dimensions, function () {
  21402. var idx = arguments[arguments.length - 1];
  21403. var retValue = cb && cb.apply(this, arguments);
  21404. if (retValue != null) {
  21405. // a number
  21406. if (typeof retValue === 'number') {
  21407. tmpRetValue[0] = retValue;
  21408. retValue = tmpRetValue;
  21409. }
  21410. for (var i = 0; i < retValue.length; i++) {
  21411. var dim = dimensions[i];
  21412. var dimStore = storage[dim];
  21413. var rawIdx = indices[idx];
  21414. if (dimStore) {
  21415. dimStore[rawIdx] = retValue[i];
  21416. }
  21417. }
  21418. }
  21419. }, stack, context);
  21420. return list;
  21421. };
  21422. /**
  21423. * Large data down sampling on given dimension
  21424. * @param {string} dimension
  21425. * @param {number} rate
  21426. * @param {Function} sampleValue
  21427. * @param {Function} sampleIndex Sample index for name and id
  21428. */
  21429. listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) {
  21430. var list = cloneListForMapAndSample(this, [dimension]);
  21431. var storage = this._storage;
  21432. var targetStorage = list._storage;
  21433. var originalIndices = this.indices;
  21434. var indices = list.indices = [];
  21435. var frameValues = [];
  21436. var frameIndices = [];
  21437. var frameSize = Math.floor(1 / rate);
  21438. var dimStore = targetStorage[dimension];
  21439. var len = this.count();
  21440. // Copy data from original data
  21441. for (var i = 0; i < storage[dimension].length; i++) {
  21442. targetStorage[dimension][i] = storage[dimension][i];
  21443. }
  21444. for (var i = 0; i < len; i += frameSize) {
  21445. // Last frame
  21446. if (frameSize > len - i) {
  21447. frameSize = len - i;
  21448. frameValues.length = frameSize;
  21449. }
  21450. for (var k = 0; k < frameSize; k++) {
  21451. var idx = originalIndices[i + k];
  21452. frameValues[k] = dimStore[idx];
  21453. frameIndices[k] = idx;
  21454. }
  21455. var value = sampleValue(frameValues);
  21456. var idx = frameIndices[sampleIndex(frameValues, value) || 0];
  21457. // Only write value on the filtered data
  21458. dimStore[idx] = value;
  21459. indices.push(idx);
  21460. }
  21461. return list;
  21462. };
  21463. /**
  21464. * Get model of one data item.
  21465. *
  21466. * @param {number} idx
  21467. */
  21468. // FIXME Model proxy ?
  21469. listProto.getItemModel = function (idx) {
  21470. var hostModel = this.hostModel;
  21471. idx = this.indices[idx];
  21472. return new Model(this._rawData.getItem(idx), hostModel, hostModel && hostModel.ecModel);
  21473. };
  21474. /**
  21475. * Create a data differ
  21476. * @param {module:echarts/data/List} otherList
  21477. * @return {module:echarts/data/DataDiffer}
  21478. */
  21479. listProto.diff = function (otherList) {
  21480. var idList = this._idList;
  21481. var otherIdList = otherList && otherList._idList;
  21482. var val;
  21483. // Use prefix to avoid index to be the same as otherIdList[idx],
  21484. // which will cause weird udpate animation.
  21485. var prefix = 'e\0\0';
  21486. return new DataDiffer(
  21487. otherList ? otherList.indices : [],
  21488. this.indices,
  21489. function (idx) {
  21490. return (val = otherIdList[idx]) != null ? val : prefix + idx;
  21491. },
  21492. function (idx) {
  21493. return (val = idList[idx]) != null ? val : prefix + idx;
  21494. }
  21495. );
  21496. };
  21497. /**
  21498. * Get visual property.
  21499. * @param {string} key
  21500. */
  21501. listProto.getVisual = function (key) {
  21502. var visual = this._visual;
  21503. return visual && visual[key];
  21504. };
  21505. /**
  21506. * Set visual property
  21507. * @param {string|Object} key
  21508. * @param {*} [value]
  21509. *
  21510. * @example
  21511. * setVisual('color', color);
  21512. * setVisual({
  21513. * 'color': color
  21514. * });
  21515. */
  21516. listProto.setVisual = function (key, val) {
  21517. if (isObject(key)) {
  21518. for (var name in key) {
  21519. if (key.hasOwnProperty(name)) {
  21520. this.setVisual(name, key[name]);
  21521. }
  21522. }
  21523. return;
  21524. }
  21525. this._visual = this._visual || {};
  21526. this._visual[key] = val;
  21527. };
  21528. /**
  21529. * Set layout property.
  21530. * @param {string|Object} key
  21531. * @param {*} [val]
  21532. */
  21533. listProto.setLayout = function (key, val) {
  21534. if (isObject(key)) {
  21535. for (var name in key) {
  21536. if (key.hasOwnProperty(name)) {
  21537. this.setLayout(name, key[name]);
  21538. }
  21539. }
  21540. return;
  21541. }
  21542. this._layout[key] = val;
  21543. };
  21544. /**
  21545. * Get layout property.
  21546. * @param {string} key.
  21547. * @return {*}
  21548. */
  21549. listProto.getLayout = function (key) {
  21550. return this._layout[key];
  21551. };
  21552. /**
  21553. * Get layout of single data item
  21554. * @param {number} idx
  21555. */
  21556. listProto.getItemLayout = function (idx) {
  21557. return this._itemLayouts[idx];
  21558. };
  21559. /**
  21560. * Set layout of single data item
  21561. * @param {number} idx
  21562. * @param {Object} layout
  21563. * @param {boolean=} [merge=false]
  21564. */
  21565. listProto.setItemLayout = function (idx, layout, merge) {
  21566. this._itemLayouts[idx] = merge
  21567. ? zrUtil.extend(this._itemLayouts[idx] || {}, layout)
  21568. : layout;
  21569. };
  21570. /**
  21571. * Clear all layout of single data item
  21572. */
  21573. listProto.clearItemLayouts = function () {
  21574. this._itemLayouts.length = 0;
  21575. };
  21576. /**
  21577. * Get visual property of single data item
  21578. * @param {number} idx
  21579. * @param {string} key
  21580. * @param {boolean} [ignoreParent=false]
  21581. */
  21582. listProto.getItemVisual = function (idx, key, ignoreParent) {
  21583. var itemVisual = this._itemVisuals[idx];
  21584. var val = itemVisual && itemVisual[key];
  21585. if (val == null && !ignoreParent) {
  21586. // Use global visual property
  21587. return this.getVisual(key);
  21588. }
  21589. return val;
  21590. };
  21591. /**
  21592. * Set visual property of single data item
  21593. *
  21594. * @param {number} idx
  21595. * @param {string|Object} key
  21596. * @param {*} [value]
  21597. *
  21598. * @example
  21599. * setItemVisual(0, 'color', color);
  21600. * setItemVisual(0, {
  21601. * 'color': color
  21602. * });
  21603. */
  21604. listProto.setItemVisual = function (idx, key, value) {
  21605. var itemVisual = this._itemVisuals[idx] || {};
  21606. this._itemVisuals[idx] = itemVisual;
  21607. if (isObject(key)) {
  21608. for (var name in key) {
  21609. if (key.hasOwnProperty(name)) {
  21610. itemVisual[name] = key[name];
  21611. }
  21612. }
  21613. return;
  21614. }
  21615. itemVisual[key] = value;
  21616. };
  21617. /**
  21618. * Clear itemVisuals and list visual.
  21619. */
  21620. listProto.clearAllVisual = function () {
  21621. this._visual = {};
  21622. this._itemVisuals = [];
  21623. };
  21624. var setItemDataAndSeriesIndex = function (child) {
  21625. child.seriesIndex = this.seriesIndex;
  21626. child.dataIndex = this.dataIndex;
  21627. child.dataType = this.dataType;
  21628. };
  21629. /**
  21630. * Set graphic element relative to data. It can be set as null
  21631. * @param {number} idx
  21632. * @param {module:zrender/Element} [el]
  21633. */
  21634. listProto.setItemGraphicEl = function (idx, el) {
  21635. var hostModel = this.hostModel;
  21636. if (el) {
  21637. // Add data index and series index for indexing the data by element
  21638. // Useful in tooltip
  21639. el.dataIndex = idx;
  21640. el.dataType = this.dataType;
  21641. el.seriesIndex = hostModel && hostModel.seriesIndex;
  21642. if (el.type === 'group') {
  21643. el.traverse(setItemDataAndSeriesIndex, el);
  21644. }
  21645. }
  21646. this._graphicEls[idx] = el;
  21647. };
  21648. /**
  21649. * @param {number} idx
  21650. * @return {module:zrender/Element}
  21651. */
  21652. listProto.getItemGraphicEl = function (idx) {
  21653. return this._graphicEls[idx];
  21654. };
  21655. /**
  21656. * @param {Function} cb
  21657. * @param {*} context
  21658. */
  21659. listProto.eachItemGraphicEl = function (cb, context) {
  21660. zrUtil.each(this._graphicEls, function (el, idx) {
  21661. if (el) {
  21662. cb && cb.call(context, el, idx);
  21663. }
  21664. });
  21665. };
  21666. /**
  21667. * Shallow clone a new list except visual and layout properties, and graph elements.
  21668. * New list only change the indices.
  21669. */
  21670. listProto.cloneShallow = function () {
  21671. var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this);
  21672. var list = new List(dimensionInfoList, this.hostModel);
  21673. // FIXME
  21674. list._storage = this._storage;
  21675. transferProperties(list, this);
  21676. // Clone will not change the data extent and indices
  21677. list.indices = this.indices.slice();
  21678. if (this._extent) {
  21679. list._extent = zrUtil.extend({}, this._extent);
  21680. }
  21681. return list;
  21682. };
  21683. /**
  21684. * Wrap some method to add more feature
  21685. * @param {string} methodName
  21686. * @param {Function} injectFunction
  21687. */
  21688. listProto.wrapMethod = function (methodName, injectFunction) {
  21689. var originalMethod = this[methodName];
  21690. if (typeof originalMethod !== 'function') {
  21691. return;
  21692. }
  21693. this.__wrappedMethods = this.__wrappedMethods || [];
  21694. this.__wrappedMethods.push(methodName);
  21695. this[methodName] = function () {
  21696. var res = originalMethod.apply(this, arguments);
  21697. return injectFunction.apply(this, [res].concat(zrUtil.slice(arguments)));
  21698. };
  21699. };
  21700. // Methods that create a new list based on this list should be listed here.
  21701. // Notice that those method should `RETURN` the new list.
  21702. listProto.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'map'];
  21703. // Methods that change indices of this list should be listed here.
  21704. listProto.CHANGABLE_METHODS = ['filterSelf'];
  21705. module.exports = List;
  21706. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  21707. /***/ }),
  21708. /* 102 */
  21709. /***/ (function(module, exports) {
  21710. 'use strict';
  21711. function defaultKeyGetter(item) {
  21712. return item;
  21713. }
  21714. /**
  21715. * @param {Array} oldArr
  21716. * @param {Array} newArr
  21717. * @param {Function} oldKeyGetter
  21718. * @param {Function} newKeyGetter
  21719. * @param {Object} [context] Can be visited by this.context in callback.
  21720. */
  21721. function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter, context) {
  21722. this._old = oldArr;
  21723. this._new = newArr;
  21724. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
  21725. this._newKeyGetter = newKeyGetter || defaultKeyGetter;
  21726. this.context = context;
  21727. }
  21728. DataDiffer.prototype = {
  21729. constructor: DataDiffer,
  21730. /**
  21731. * Callback function when add a data
  21732. */
  21733. add: function (func) {
  21734. this._add = func;
  21735. return this;
  21736. },
  21737. /**
  21738. * Callback function when update a data
  21739. */
  21740. update: function (func) {
  21741. this._update = func;
  21742. return this;
  21743. },
  21744. /**
  21745. * Callback function when remove a data
  21746. */
  21747. remove: function (func) {
  21748. this._remove = func;
  21749. return this;
  21750. },
  21751. execute: function () {
  21752. var oldArr = this._old;
  21753. var newArr = this._new;
  21754. var oldDataIndexMap = {};
  21755. var newDataIndexMap = {};
  21756. var oldDataKeyArr = [];
  21757. var newDataKeyArr = [];
  21758. var i;
  21759. initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, '_oldKeyGetter', this);
  21760. initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter', this);
  21761. // Travel by inverted order to make sure order consistency
  21762. // when duplicate keys exists (consider newDataIndex.pop() below).
  21763. // For performance consideration, these code below do not look neat.
  21764. for (i = 0; i < oldArr.length; i++) {
  21765. var key = oldDataKeyArr[i];
  21766. var idx = newDataIndexMap[key];
  21767. // idx can never be empty array here. see 'set null' logic below.
  21768. if (idx != null) {
  21769. // Consider there is duplicate key (for example, use dataItem.name as key).
  21770. // We should make sure every item in newArr and oldArr can be visited.
  21771. var len = idx.length;
  21772. if (len) {
  21773. len === 1 && (newDataIndexMap[key] = null);
  21774. idx = idx.unshift();
  21775. }
  21776. else {
  21777. newDataIndexMap[key] = null;
  21778. }
  21779. this._update && this._update(idx, i);
  21780. }
  21781. else {
  21782. this._remove && this._remove(i);
  21783. }
  21784. }
  21785. for (var i = 0; i < newDataKeyArr.length; i++) {
  21786. var key = newDataKeyArr[i];
  21787. if (newDataIndexMap.hasOwnProperty(key)) {
  21788. var idx = newDataIndexMap[key];
  21789. if (idx == null) {
  21790. continue;
  21791. }
  21792. // idx can never be empty array here. see 'set null' logic above.
  21793. if (!idx.length) {
  21794. this._add && this._add(idx);
  21795. }
  21796. else {
  21797. for (var j = 0, len = idx.length; j < len; j++) {
  21798. this._add && this._add(idx[j]);
  21799. }
  21800. }
  21801. }
  21802. }
  21803. }
  21804. };
  21805. function initIndexMap(arr, map, keyArr, keyGetterName, dataDiffer) {
  21806. for (var i = 0; i < arr.length; i++) {
  21807. // Add prefix to avoid conflict with Object.prototype.
  21808. var key = '_ec_' + dataDiffer[keyGetterName](arr[i], i);
  21809. var existence = map[key];
  21810. if (existence == null) {
  21811. keyArr.push(key);
  21812. map[key] = i;
  21813. }
  21814. else {
  21815. if (!existence.length) {
  21816. map[key] = existence = [existence];
  21817. }
  21818. existence.push(i);
  21819. }
  21820. }
  21821. }
  21822. module.exports = DataDiffer;
  21823. /***/ }),
  21824. /* 103 */
  21825. /***/ (function(module, exports, __webpack_require__) {
  21826. var numberUtil = __webpack_require__(7);
  21827. var linearMap = numberUtil.linearMap;
  21828. var zrUtil = __webpack_require__(4);
  21829. var axisHelper = __webpack_require__(104);
  21830. function fixExtentWithBands(extent, nTick) {
  21831. var size = extent[1] - extent[0];
  21832. var len = nTick;
  21833. var margin = size / len / 2;
  21834. extent[0] += margin;
  21835. extent[1] -= margin;
  21836. }
  21837. var normalizedExtent = [0, 1];
  21838. /**
  21839. * @name module:echarts/coord/CartesianAxis
  21840. * @constructor
  21841. */
  21842. var Axis = function (dim, scale, extent) {
  21843. /**
  21844. * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'
  21845. * @type {string}
  21846. */
  21847. this.dim = dim;
  21848. /**
  21849. * Axis scale
  21850. * @type {module:echarts/coord/scale/*}
  21851. */
  21852. this.scale = scale;
  21853. /**
  21854. * @type {Array.<number>}
  21855. * @private
  21856. */
  21857. this._extent = extent || [0, 0];
  21858. /**
  21859. * @type {boolean}
  21860. */
  21861. this.inverse = false;
  21862. /**
  21863. * Usually true when axis has a ordinal scale
  21864. * @type {boolean}
  21865. */
  21866. this.onBand = false;
  21867. /**
  21868. * @private
  21869. * @type {number}
  21870. */
  21871. this._labelInterval;
  21872. };
  21873. Axis.prototype = {
  21874. constructor: Axis,
  21875. /**
  21876. * If axis extent contain given coord
  21877. * @param {number} coord
  21878. * @return {boolean}
  21879. */
  21880. contain: function (coord) {
  21881. var extent = this._extent;
  21882. var min = Math.min(extent[0], extent[1]);
  21883. var max = Math.max(extent[0], extent[1]);
  21884. return coord >= min && coord <= max;
  21885. },
  21886. /**
  21887. * If axis extent contain given data
  21888. * @param {number} data
  21889. * @return {boolean}
  21890. */
  21891. containData: function (data) {
  21892. return this.contain(this.dataToCoord(data));
  21893. },
  21894. /**
  21895. * Get coord extent.
  21896. * @return {Array.<number>}
  21897. */
  21898. getExtent: function () {
  21899. return this._extent.slice();
  21900. },
  21901. /**
  21902. * Get precision used for formatting
  21903. * @param {Array.<number>} [dataExtent]
  21904. * @return {number}
  21905. */
  21906. getPixelPrecision: function (dataExtent) {
  21907. return numberUtil.getPixelPrecision(
  21908. dataExtent || this.scale.getExtent(),
  21909. this._extent
  21910. );
  21911. },
  21912. /**
  21913. * Set coord extent
  21914. * @param {number} start
  21915. * @param {number} end
  21916. */
  21917. setExtent: function (start, end) {
  21918. var extent = this._extent;
  21919. extent[0] = start;
  21920. extent[1] = end;
  21921. },
  21922. /**
  21923. * Convert data to coord. Data is the rank if it has a ordinal scale
  21924. * @param {number} data
  21925. * @param {boolean} clamp
  21926. * @return {number}
  21927. */
  21928. dataToCoord: function (data, clamp) {
  21929. var extent = this._extent;
  21930. var scale = this.scale;
  21931. data = scale.normalize(data);
  21932. if (this.onBand && scale.type === 'ordinal') {
  21933. extent = extent.slice();
  21934. fixExtentWithBands(extent, scale.count());
  21935. }
  21936. return linearMap(data, normalizedExtent, extent, clamp);
  21937. },
  21938. /**
  21939. * Convert coord to data. Data is the rank if it has a ordinal scale
  21940. * @param {number} coord
  21941. * @param {boolean} clamp
  21942. * @return {number}
  21943. */
  21944. coordToData: function (coord, clamp) {
  21945. var extent = this._extent;
  21946. var scale = this.scale;
  21947. if (this.onBand && scale.type === 'ordinal') {
  21948. extent = extent.slice();
  21949. fixExtentWithBands(extent, scale.count());
  21950. }
  21951. var t = linearMap(coord, extent, normalizedExtent, clamp);
  21952. return this.scale.scale(t);
  21953. },
  21954. /**
  21955. * Convert pixel point to data in axis
  21956. * @param {Array.<number>} point
  21957. * @param {boolean} clamp
  21958. * @return {number} data
  21959. */
  21960. pointToData: function (point, clamp) {
  21961. // Should be implemented in derived class if necessary.
  21962. },
  21963. /**
  21964. * @return {Array.<number>}
  21965. */
  21966. getTicksCoords: function (alignWithLabel) {
  21967. if (this.onBand && !alignWithLabel) {
  21968. var bands = this.getBands();
  21969. var coords = [];
  21970. for (var i = 0; i < bands.length; i++) {
  21971. coords.push(bands[i][0]);
  21972. }
  21973. if (bands[i - 1]) {
  21974. coords.push(bands[i - 1][1]);
  21975. }
  21976. return coords;
  21977. }
  21978. else {
  21979. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  21980. }
  21981. },
  21982. /**
  21983. * Coords of labels are on the ticks or on the middle of bands
  21984. * @return {Array.<number>}
  21985. */
  21986. getLabelsCoords: function () {
  21987. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  21988. },
  21989. /**
  21990. * Get bands.
  21991. *
  21992. * If axis has labels [1, 2, 3, 4]. Bands on the axis are
  21993. * |---1---|---2---|---3---|---4---|.
  21994. *
  21995. * @return {Array}
  21996. */
  21997. // FIXME Situation when labels is on ticks
  21998. getBands: function () {
  21999. var extent = this.getExtent();
  22000. var bands = [];
  22001. var len = this.scale.count();
  22002. var start = extent[0];
  22003. var end = extent[1];
  22004. var span = end - start;
  22005. for (var i = 0; i < len; i++) {
  22006. bands.push([
  22007. span * i / len + start,
  22008. span * (i + 1) / len + start
  22009. ]);
  22010. }
  22011. return bands;
  22012. },
  22013. /**
  22014. * Get width of band
  22015. * @return {number}
  22016. */
  22017. getBandWidth: function () {
  22018. var axisExtent = this._extent;
  22019. var dataExtent = this.scale.getExtent();
  22020. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
  22021. // Fix #2728, avoid NaN when only one data.
  22022. len === 0 && (len = 1);
  22023. var size = Math.abs(axisExtent[1] - axisExtent[0]);
  22024. return Math.abs(size) / len;
  22025. },
  22026. /**
  22027. * Get interval of the axis label.
  22028. * @return {number}
  22029. */
  22030. getLabelInterval: function () {
  22031. var labelInterval = this._labelInterval;
  22032. if (!labelInterval) {
  22033. var axisModel = this.model;
  22034. var labelModel = axisModel.getModel('axisLabel');
  22035. var interval = labelModel.get('interval');
  22036. if (!(this.type === 'category' && interval === 'auto')) {
  22037. labelInterval = interval === 'auto' ? 0 : interval;
  22038. }
  22039. else if (this.isHorizontal){
  22040. labelInterval = axisHelper.getAxisLabelInterval(
  22041. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  22042. axisModel.getFormattedLabels(),
  22043. labelModel.getFont(),
  22044. this.isHorizontal()
  22045. );
  22046. }
  22047. this._labelInterval = labelInterval;
  22048. }
  22049. return labelInterval;
  22050. }
  22051. };
  22052. module.exports = Axis;
  22053. /***/ }),
  22054. /* 104 */
  22055. /***/ (function(module, exports, __webpack_require__) {
  22056. var OrdinalScale = __webpack_require__(105);
  22057. var IntervalScale = __webpack_require__(107);
  22058. __webpack_require__(109);
  22059. __webpack_require__(110);
  22060. var Scale = __webpack_require__(106);
  22061. var numberUtil = __webpack_require__(7);
  22062. var zrUtil = __webpack_require__(4);
  22063. var textContain = __webpack_require__(8);
  22064. var axisHelper = {};
  22065. /**
  22066. * Get axis scale extent before niced.
  22067. * Item of returned array can only be number (including Infinity and NaN).
  22068. */
  22069. axisHelper.getScaleExtent = function (scale, model) {
  22070. var scaleType = scale.type;
  22071. var min = model.getMin();
  22072. var max = model.getMax();
  22073. var fixMin = min != null;
  22074. var fixMax = max != null;
  22075. var originalExtent = scale.getExtent();
  22076. var axisDataLen;
  22077. var boundaryGap;
  22078. var span;
  22079. if (scaleType === 'ordinal') {
  22080. axisDataLen = (model.get('data') || []).length;
  22081. }
  22082. else {
  22083. boundaryGap = model.get('boundaryGap');
  22084. if (!zrUtil.isArray(boundaryGap)) {
  22085. boundaryGap = [boundaryGap || 0, boundaryGap || 0];
  22086. }
  22087. if (typeof boundaryGap[0] === 'boolean') {
  22088. if (true) {
  22089. console.warn('Boolean type for boundaryGap is only '
  22090. + 'allowed for ordinal axis. Please use string in '
  22091. + 'percentage instead, e.g., "20%". Currently, '
  22092. + 'boundaryGap is set to be 0.');
  22093. }
  22094. boundaryGap = [0, 0];
  22095. }
  22096. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1);
  22097. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1);
  22098. span = (originalExtent[1] - originalExtent[0])
  22099. || Math.abs(originalExtent[0]);
  22100. }
  22101. // Notice: When min/max is not set (that is, when there are null/undefined,
  22102. // which is the most common case), these cases should be ensured:
  22103. // (1) For 'ordinal', show all axis.data.
  22104. // (2) For others:
  22105. // + `boundaryGap` is applied (if min/max set, boundaryGap is
  22106. // disabled).
  22107. // + If `needCrossZero`, min/max should be zero, otherwise, min/max should
  22108. // be the result that originalExtent enlarged by boundaryGap.
  22109. // (3) If no data, it should be ensured that `scale.setBlank` is set.
  22110. // FIXME
  22111. // (1) When min/max is 'dataMin' or 'dataMax', should boundaryGap be able to used?
  22112. // (2) When `needCrossZero` and all data is positive/negative, should it be ensured
  22113. // that the results processed by boundaryGap are positive/negative?
  22114. if (min == null) {
  22115. min = scaleType === 'ordinal'
  22116. ? (axisDataLen ? 0 : NaN)
  22117. : originalExtent[0] - boundaryGap[0] * span;
  22118. }
  22119. if (max == null) {
  22120. max = scaleType === 'ordinal'
  22121. ? (axisDataLen ? axisDataLen - 1 : NaN)
  22122. : originalExtent[1] + boundaryGap[1] * span;
  22123. }
  22124. if (min === 'dataMin') {
  22125. min = originalExtent[0];
  22126. }
  22127. else if (typeof min === 'function') {
  22128. min = min({
  22129. min: originalExtent[0],
  22130. max: originalExtent[1]
  22131. });
  22132. }
  22133. if (max === 'dataMax') {
  22134. max = originalExtent[1];
  22135. }
  22136. else if (typeof max === 'function') {
  22137. max = max({
  22138. min: originalExtent[0],
  22139. max: originalExtent[1]
  22140. });
  22141. }
  22142. (min == null || !isFinite(min)) && (min = NaN);
  22143. (max == null || !isFinite(max)) && (max = NaN);
  22144. scale.setBlank(zrUtil.eqNaN(min) || zrUtil.eqNaN(max));
  22145. // Evaluate if axis needs cross zero
  22146. if (model.getNeedCrossZero()) {
  22147. // Axis is over zero and min is not set
  22148. if (min > 0 && max > 0 && !fixMin) {
  22149. min = 0;
  22150. }
  22151. // Axis is under zero and max is not set
  22152. if (min < 0 && max < 0 && !fixMax) {
  22153. max = 0;
  22154. }
  22155. }
  22156. return [min, max];
  22157. };
  22158. axisHelper.niceScaleExtent = function (scale, model) {
  22159. var extent = axisHelper.getScaleExtent(scale, model);
  22160. var fixMin = model.getMin() != null;
  22161. var fixMax = model.getMax() != null;
  22162. var splitNumber = model.get('splitNumber');
  22163. if (scale.type === 'log') {
  22164. scale.base = model.get('logBase');
  22165. }
  22166. var scaleType = scale.type;
  22167. scale.setExtent(extent[0], extent[1]);
  22168. scale.niceExtent({
  22169. splitNumber: splitNumber,
  22170. fixMin: fixMin,
  22171. fixMax: fixMax,
  22172. minInterval: (scaleType === 'interval' || scaleType === 'time')
  22173. ? model.get('minInterval') : null,
  22174. maxInterval: (scaleType === 'interval' || scaleType === 'time')
  22175. ? model.get('maxInterval') : null
  22176. });
  22177. // If some one specified the min, max. And the default calculated interval
  22178. // is not good enough. He can specify the interval. It is often appeared
  22179. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  22180. // to be 60.
  22181. // FIXME
  22182. var interval = model.get('interval');
  22183. if (interval != null) {
  22184. scale.setInterval && scale.setInterval(interval);
  22185. }
  22186. };
  22187. /**
  22188. * @param {module:echarts/model/Model} model
  22189. * @param {string} [axisType] Default retrieve from model.type
  22190. * @return {module:echarts/scale/*}
  22191. */
  22192. axisHelper.createScaleByModel = function(model, axisType) {
  22193. axisType = axisType || model.get('type');
  22194. if (axisType) {
  22195. switch (axisType) {
  22196. // Buildin scale
  22197. case 'category':
  22198. return new OrdinalScale(
  22199. model.getCategories(), [Infinity, -Infinity]
  22200. );
  22201. case 'value':
  22202. return new IntervalScale();
  22203. // Extended scale, like time and log
  22204. default:
  22205. return (Scale.getClass(axisType) || IntervalScale).create(model);
  22206. }
  22207. }
  22208. };
  22209. /**
  22210. * Check if the axis corss 0
  22211. */
  22212. axisHelper.ifAxisCrossZero = function (axis) {
  22213. var dataExtent = axis.scale.getExtent();
  22214. var min = dataExtent[0];
  22215. var max = dataExtent[1];
  22216. return !((min > 0 && max > 0) || (min < 0 && max < 0));
  22217. };
  22218. /**
  22219. * @param {Array.<number>} tickCoords In axis self coordinate.
  22220. * @param {Array.<string>} labels
  22221. * @param {string} font
  22222. * @param {boolean} isAxisHorizontal
  22223. * @return {number}
  22224. */
  22225. axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) {
  22226. // FIXME
  22227. // 不同角的axis和label,不只是horizontal和vertical.
  22228. var textSpaceTakenRect;
  22229. var autoLabelInterval = 0;
  22230. var accumulatedLabelInterval = 0;
  22231. var step = 1;
  22232. if (labels.length > 40) {
  22233. // Simple optimization for large amount of labels
  22234. step = Math.floor(labels.length / 40);
  22235. }
  22236. for (var i = 0; i < tickCoords.length; i += step) {
  22237. var tickCoord = tickCoords[i];
  22238. var rect = textContain.getBoundingRect(
  22239. labels[i], font, 'center', 'top'
  22240. );
  22241. rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord;
  22242. // FIXME Magic number 1.5
  22243. rect[isAxisHorizontal ? 'width' : 'height'] *= 1.3;
  22244. if (!textSpaceTakenRect) {
  22245. textSpaceTakenRect = rect.clone();
  22246. }
  22247. // There is no space for current label;
  22248. else if (textSpaceTakenRect.intersect(rect)) {
  22249. accumulatedLabelInterval++;
  22250. autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval);
  22251. }
  22252. else {
  22253. textSpaceTakenRect.union(rect);
  22254. // Reset
  22255. accumulatedLabelInterval = 0;
  22256. }
  22257. }
  22258. if (autoLabelInterval === 0 && step > 1) {
  22259. return step;
  22260. }
  22261. return (autoLabelInterval + 1) * step - 1;
  22262. };
  22263. /**
  22264. * @param {Object} axis
  22265. * @param {Function} labelFormatter
  22266. * @return {Array.<string>}
  22267. */
  22268. axisHelper.getFormattedLabels = function (axis, labelFormatter) {
  22269. var scale = axis.scale;
  22270. var labels = scale.getTicksLabels();
  22271. var ticks = scale.getTicks();
  22272. if (typeof labelFormatter === 'string') {
  22273. labelFormatter = (function (tpl) {
  22274. return function (val) {
  22275. return tpl.replace('{value}', val != null ? val : '');
  22276. };
  22277. })(labelFormatter);
  22278. // Consider empty array
  22279. return zrUtil.map(labels, labelFormatter);
  22280. }
  22281. else if (typeof labelFormatter === 'function') {
  22282. return zrUtil.map(ticks, function (tick, idx) {
  22283. return labelFormatter(
  22284. axisHelper.getAxisRawValue(axis, tick),
  22285. idx
  22286. );
  22287. }, this);
  22288. }
  22289. else {
  22290. return labels;
  22291. }
  22292. };
  22293. axisHelper.getAxisRawValue = function (axis, value) {
  22294. // In category axis with data zoom, tick is not the original
  22295. // index of axis.data. So tick should not be exposed to user
  22296. // in category axis.
  22297. return axis.type === 'category' ? axis.scale.getLabel(value) : value;
  22298. };
  22299. module.exports = axisHelper;
  22300. /***/ }),
  22301. /* 105 */
  22302. /***/ (function(module, exports, __webpack_require__) {
  22303. /**
  22304. * Linear continuous scale
  22305. * @module echarts/coord/scale/Ordinal
  22306. *
  22307. * http://en.wikipedia.org/wiki/Level_of_measurement
  22308. */
  22309. // FIXME only one data
  22310. var zrUtil = __webpack_require__(4);
  22311. var Scale = __webpack_require__(106);
  22312. var scaleProto = Scale.prototype;
  22313. var OrdinalScale = Scale.extend({
  22314. type: 'ordinal',
  22315. init: function (data, extent) {
  22316. this._data = data;
  22317. this._extent = extent || [0, data.length - 1];
  22318. },
  22319. parse: function (val) {
  22320. return typeof val === 'string'
  22321. ? zrUtil.indexOf(this._data, val)
  22322. // val might be float.
  22323. : Math.round(val);
  22324. },
  22325. contain: function (rank) {
  22326. rank = this.parse(rank);
  22327. return scaleProto.contain.call(this, rank)
  22328. && this._data[rank] != null;
  22329. },
  22330. /**
  22331. * Normalize given rank or name to linear [0, 1]
  22332. * @param {number|string} [val]
  22333. * @return {number}
  22334. */
  22335. normalize: function (val) {
  22336. return scaleProto.normalize.call(this, this.parse(val));
  22337. },
  22338. scale: function (val) {
  22339. return Math.round(scaleProto.scale.call(this, val));
  22340. },
  22341. /**
  22342. * @return {Array}
  22343. */
  22344. getTicks: function () {
  22345. var ticks = [];
  22346. var extent = this._extent;
  22347. var rank = extent[0];
  22348. while (rank <= extent[1]) {
  22349. ticks.push(rank);
  22350. rank++;
  22351. }
  22352. return ticks;
  22353. },
  22354. /**
  22355. * Get item on rank n
  22356. * @param {number} n
  22357. * @return {string}
  22358. */
  22359. getLabel: function (n) {
  22360. return this._data[n];
  22361. },
  22362. /**
  22363. * @return {number}
  22364. */
  22365. count: function () {
  22366. return this._extent[1] - this._extent[0] + 1;
  22367. },
  22368. /**
  22369. * @override
  22370. */
  22371. unionExtentFromData: function (data, dim) {
  22372. this.unionExtent(data.getDataExtent(dim, false));
  22373. },
  22374. niceTicks: zrUtil.noop,
  22375. niceExtent: zrUtil.noop
  22376. });
  22377. /**
  22378. * @return {module:echarts/scale/Time}
  22379. */
  22380. OrdinalScale.create = function () {
  22381. return new OrdinalScale();
  22382. };
  22383. module.exports = OrdinalScale;
  22384. /***/ }),
  22385. /* 106 */
  22386. /***/ (function(module, exports, __webpack_require__) {
  22387. /**
  22388. * // Scale class management
  22389. * @module echarts/scale/Scale
  22390. */
  22391. var clazzUtil = __webpack_require__(15);
  22392. /**
  22393. * @param {Object} [setting]
  22394. */
  22395. function Scale(setting) {
  22396. this._setting = setting || {};
  22397. /**
  22398. * Extent
  22399. * @type {Array.<number>}
  22400. * @protected
  22401. */
  22402. this._extent = [Infinity, -Infinity];
  22403. /**
  22404. * Step is calculated in adjustExtent
  22405. * @type {Array.<number>}
  22406. * @protected
  22407. */
  22408. this._interval = 0;
  22409. this.init && this.init.apply(this, arguments);
  22410. }
  22411. var scaleProto = Scale.prototype;
  22412. /**
  22413. * Parse input val to valid inner number.
  22414. * @param {*} val
  22415. * @return {number}
  22416. */
  22417. scaleProto.parse = function (val) {
  22418. // Notice: This would be a trap here, If the implementation
  22419. // of this method depends on extent, and this method is used
  22420. // before extent set (like in dataZoom), it would be wrong.
  22421. // Nevertheless, parse does not depend on extent generally.
  22422. return val;
  22423. };
  22424. scaleProto.getSetting = function (name) {
  22425. return this._setting[name];
  22426. };
  22427. scaleProto.contain = function (val) {
  22428. var extent = this._extent;
  22429. return val >= extent[0] && val <= extent[1];
  22430. };
  22431. /**
  22432. * Normalize value to linear [0, 1], return 0.5 if extent span is 0
  22433. * @param {number} val
  22434. * @return {number}
  22435. */
  22436. scaleProto.normalize = function (val) {
  22437. var extent = this._extent;
  22438. if (extent[1] === extent[0]) {
  22439. return 0.5;
  22440. }
  22441. return (val - extent[0]) / (extent[1] - extent[0]);
  22442. };
  22443. /**
  22444. * Scale normalized value
  22445. * @param {number} val
  22446. * @return {number}
  22447. */
  22448. scaleProto.scale = function (val) {
  22449. var extent = this._extent;
  22450. return val * (extent[1] - extent[0]) + extent[0];
  22451. };
  22452. /**
  22453. * Set extent from data
  22454. * @param {Array.<number>} other
  22455. */
  22456. scaleProto.unionExtent = function (other) {
  22457. var extent = this._extent;
  22458. other[0] < extent[0] && (extent[0] = other[0]);
  22459. other[1] > extent[1] && (extent[1] = other[1]);
  22460. // not setExtent because in log axis it may transformed to power
  22461. // this.setExtent(extent[0], extent[1]);
  22462. };
  22463. /**
  22464. * Set extent from data
  22465. * @param {module:echarts/data/List} data
  22466. * @param {string} dim
  22467. */
  22468. scaleProto.unionExtentFromData = function (data, dim) {
  22469. this.unionExtent(data.getDataExtent(dim, true));
  22470. };
  22471. /**
  22472. * Get extent
  22473. * @return {Array.<number>}
  22474. */
  22475. scaleProto.getExtent = function () {
  22476. return this._extent.slice();
  22477. };
  22478. /**
  22479. * Set extent
  22480. * @param {number} start
  22481. * @param {number} end
  22482. */
  22483. scaleProto.setExtent = function (start, end) {
  22484. var thisExtent = this._extent;
  22485. if (!isNaN(start)) {
  22486. thisExtent[0] = start;
  22487. }
  22488. if (!isNaN(end)) {
  22489. thisExtent[1] = end;
  22490. }
  22491. };
  22492. /**
  22493. * @return {Array.<string>}
  22494. */
  22495. scaleProto.getTicksLabels = function () {
  22496. var labels = [];
  22497. var ticks = this.getTicks();
  22498. for (var i = 0; i < ticks.length; i++) {
  22499. labels.push(this.getLabel(ticks[i]));
  22500. }
  22501. return labels;
  22502. };
  22503. /**
  22504. * When axis extent depends on data and no data exists,
  22505. * axis ticks should not be drawn, which is named 'blank'.
  22506. */
  22507. scaleProto.isBlank = function () {
  22508. return this._isBlank;
  22509. },
  22510. /**
  22511. * When axis extent depends on data and no data exists,
  22512. * axis ticks should not be drawn, which is named 'blank'.
  22513. */
  22514. scaleProto.setBlank = function (isBlank) {
  22515. this._isBlank = isBlank;
  22516. };
  22517. clazzUtil.enableClassExtend(Scale);
  22518. clazzUtil.enableClassManagement(Scale, {
  22519. registerWhenExtend: true
  22520. });
  22521. module.exports = Scale;
  22522. /***/ }),
  22523. /* 107 */
  22524. /***/ (function(module, exports, __webpack_require__) {
  22525. /**
  22526. * Interval scale
  22527. * @module echarts/scale/Interval
  22528. */
  22529. var numberUtil = __webpack_require__(7);
  22530. var formatUtil = __webpack_require__(6);
  22531. var Scale = __webpack_require__(106);
  22532. var helper = __webpack_require__(108);
  22533. var roundNumber = numberUtil.round;
  22534. /**
  22535. * @alias module:echarts/coord/scale/Interval
  22536. * @constructor
  22537. */
  22538. var IntervalScale = Scale.extend({
  22539. type: 'interval',
  22540. _interval: 0,
  22541. _intervalPrecision: 2,
  22542. setExtent: function (start, end) {
  22543. var thisExtent = this._extent;
  22544. //start,end may be a Number like '25',so...
  22545. if (!isNaN(start)) {
  22546. thisExtent[0] = parseFloat(start);
  22547. }
  22548. if (!isNaN(end)) {
  22549. thisExtent[1] = parseFloat(end);
  22550. }
  22551. },
  22552. unionExtent: function (other) {
  22553. var extent = this._extent;
  22554. other[0] < extent[0] && (extent[0] = other[0]);
  22555. other[1] > extent[1] && (extent[1] = other[1]);
  22556. // unionExtent may called by it's sub classes
  22557. IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]);
  22558. },
  22559. /**
  22560. * Get interval
  22561. */
  22562. getInterval: function () {
  22563. return this._interval;
  22564. },
  22565. /**
  22566. * Set interval
  22567. */
  22568. setInterval: function (interval) {
  22569. this._interval = interval;
  22570. // Dropped auto calculated niceExtent and use user setted extent
  22571. // We assume user wan't to set both interval, min, max to get a better result
  22572. this._niceExtent = this._extent.slice();
  22573. this._intervalPrecision = helper.getIntervalPrecision(interval);
  22574. },
  22575. /**
  22576. * @return {Array.<number>}
  22577. */
  22578. getTicks: function () {
  22579. return helper.intervalScaleGetTicks(
  22580. this._interval, this._extent, this._niceExtent, this._intervalPrecision
  22581. );
  22582. },
  22583. /**
  22584. * @return {Array.<string>}
  22585. */
  22586. getTicksLabels: function () {
  22587. var labels = [];
  22588. var ticks = this.getTicks();
  22589. for (var i = 0; i < ticks.length; i++) {
  22590. labels.push(this.getLabel(ticks[i]));
  22591. }
  22592. return labels;
  22593. },
  22594. /**
  22595. * @param {number} data
  22596. * @param {Object} [opt]
  22597. * @param {number|string} [opt.precision] If 'auto', use nice presision.
  22598. * @param {boolean} [opt.pad] returns 1.50 but not 1.5 if precision is 2.
  22599. * @return {string}
  22600. */
  22601. getLabel: function (data, opt) {
  22602. if (data == null) {
  22603. return '';
  22604. }
  22605. var precision = opt && opt.precision;
  22606. if (precision == null) {
  22607. precision = numberUtil.getPrecisionSafe(data) || 0;
  22608. }
  22609. else if (precision === 'auto') {
  22610. // Should be more precise then tick.
  22611. precision = this._intervalPrecision;
  22612. }
  22613. // (1) If `precision` is set, 12.005 should be display as '12.00500'.
  22614. // (2) Use roundNumber (toFixed) to avoid scientific notation like '3.5e-7'.
  22615. data = roundNumber(data, precision, true);
  22616. return formatUtil.addCommas(data);
  22617. },
  22618. /**
  22619. * Update interval and extent of intervals for nice ticks
  22620. *
  22621. * @param {number} [splitNumber = 5] Desired number of ticks
  22622. * @param {number} [minInterval]
  22623. * @param {number} [maxInterval]
  22624. */
  22625. niceTicks: function (splitNumber, minInterval, maxInterval) {
  22626. splitNumber = splitNumber || 5;
  22627. var extent = this._extent;
  22628. var span = extent[1] - extent[0];
  22629. if (!isFinite(span)) {
  22630. return;
  22631. }
  22632. // User may set axis min 0 and data are all negative
  22633. // FIXME If it needs to reverse ?
  22634. if (span < 0) {
  22635. span = -span;
  22636. extent.reverse();
  22637. }
  22638. var result = helper.intervalScaleNiceTicks(
  22639. extent, splitNumber, minInterval, maxInterval
  22640. );
  22641. this._intervalPrecision = result.intervalPrecision;
  22642. this._interval = result.interval;
  22643. this._niceExtent = result.niceTickExtent;
  22644. },
  22645. /**
  22646. * Nice extent.
  22647. * @param {Object} opt
  22648. * @param {number} [opt.splitNumber = 5] Given approx tick number
  22649. * @param {boolean} [opt.fixMin=false]
  22650. * @param {boolean} [opt.fixMax=false]
  22651. * @param {boolean} [opt.minInterval]
  22652. * @param {boolean} [opt.maxInterval]
  22653. */
  22654. niceExtent: function (opt) {
  22655. var extent = this._extent;
  22656. // If extent start and end are same, expand them
  22657. if (extent[0] === extent[1]) {
  22658. if (extent[0] !== 0) {
  22659. // Expand extent
  22660. var expandSize = extent[0];
  22661. // In the fowllowing case
  22662. // Axis has been fixed max 100
  22663. // Plus data are all 100 and axis extent are [100, 100].
  22664. // Extend to the both side will cause expanded max is larger than fixed max.
  22665. // So only expand to the smaller side.
  22666. if (!opt.fixMax) {
  22667. extent[1] += expandSize / 2;
  22668. extent[0] -= expandSize / 2;
  22669. }
  22670. else {
  22671. extent[0] -= expandSize / 2;
  22672. }
  22673. }
  22674. else {
  22675. extent[1] = 1;
  22676. }
  22677. }
  22678. var span = extent[1] - extent[0];
  22679. // If there are no data and extent are [Infinity, -Infinity]
  22680. if (!isFinite(span)) {
  22681. extent[0] = 0;
  22682. extent[1] = 1;
  22683. }
  22684. this.niceTicks(opt.splitNumber, opt.minInterval, opt.maxInterval);
  22685. // var extent = this._extent;
  22686. var interval = this._interval;
  22687. if (!opt.fixMin) {
  22688. extent[0] = roundNumber(Math.floor(extent[0] / interval) * interval);
  22689. }
  22690. if (!opt.fixMax) {
  22691. extent[1] = roundNumber(Math.ceil(extent[1] / interval) * interval);
  22692. }
  22693. }
  22694. });
  22695. /**
  22696. * @return {module:echarts/scale/Time}
  22697. */
  22698. IntervalScale.create = function () {
  22699. return new IntervalScale();
  22700. };
  22701. module.exports = IntervalScale;
  22702. /***/ }),
  22703. /* 108 */
  22704. /***/ (function(module, exports, __webpack_require__) {
  22705. /**
  22706. * For testable.
  22707. */
  22708. var numberUtil = __webpack_require__(7);
  22709. var roundNumber = numberUtil.round;
  22710. var helper = {};
  22711. /**
  22712. * @param {Array.<number>} extent Both extent[0] and extent[1] should be valid number.
  22713. * Should be extent[0] < extent[1].
  22714. * @param {number} splitNumber splitNumber should be >= 1.
  22715. * @param {number} [minInterval]
  22716. * @param {number} [maxInterval]
  22717. * @return {Object} {interval, intervalPrecision, niceTickExtent}
  22718. */
  22719. helper.intervalScaleNiceTicks = function (extent, splitNumber, minInterval, maxInterval) {
  22720. var result = {};
  22721. var span = extent[1] - extent[0];
  22722. var interval = result.interval = numberUtil.nice(span / splitNumber, true);
  22723. if (minInterval != null && interval < minInterval) {
  22724. interval = result.interval = minInterval;
  22725. }
  22726. if (maxInterval != null && interval > maxInterval) {
  22727. interval = result.interval = maxInterval;
  22728. }
  22729. // Tow more digital for tick.
  22730. var precision = result.intervalPrecision = helper.getIntervalPrecision(interval);
  22731. // Niced extent inside original extent
  22732. var niceTickExtent = result.niceTickExtent = [
  22733. roundNumber(Math.ceil(extent[0] / interval) * interval, precision),
  22734. roundNumber(Math.floor(extent[1] / interval) * interval, precision)
  22735. ];
  22736. helper.fixExtent(niceTickExtent, extent);
  22737. return result;
  22738. };
  22739. /**
  22740. * @param {number} interval
  22741. * @return {number} interval precision
  22742. */
  22743. helper.getIntervalPrecision = function (interval) {
  22744. // Tow more digital for tick.
  22745. return numberUtil.getPrecisionSafe(interval) + 2;
  22746. };
  22747. function clamp(niceTickExtent, idx, extent) {
  22748. niceTickExtent[idx] = Math.max(Math.min(niceTickExtent[idx], extent[1]), extent[0]);
  22749. }
  22750. // In some cases (e.g., splitNumber is 1), niceTickExtent may be out of extent.
  22751. helper.fixExtent = function (niceTickExtent, extent) {
  22752. !isFinite(niceTickExtent[0]) && (niceTickExtent[0] = extent[0]);
  22753. !isFinite(niceTickExtent[1]) && (niceTickExtent[1] = extent[1]);
  22754. clamp(niceTickExtent, 0, extent);
  22755. clamp(niceTickExtent, 1, extent);
  22756. if (niceTickExtent[0] > niceTickExtent[1]) {
  22757. niceTickExtent[0] = niceTickExtent[1];
  22758. }
  22759. };
  22760. helper.intervalScaleGetTicks = function (interval, extent, niceTickExtent, intervalPrecision) {
  22761. var ticks = [];
  22762. // If interval is 0, return [];
  22763. if (!interval) {
  22764. return ticks;
  22765. }
  22766. // Consider this case: using dataZoom toolbox, zoom and zoom.
  22767. var safeLimit = 10000;
  22768. if (extent[0] < niceTickExtent[0]) {
  22769. ticks.push(extent[0]);
  22770. }
  22771. var tick = niceTickExtent[0];
  22772. while (tick <= niceTickExtent[1]) {
  22773. ticks.push(tick);
  22774. // Avoid rounding error
  22775. tick = roundNumber(tick + interval, intervalPrecision);
  22776. if (tick === ticks[ticks.length - 1]) {
  22777. // Consider out of safe float point, e.g.,
  22778. // -3711126.9907707 + 2e-10 === -3711126.9907707
  22779. break;
  22780. }
  22781. if (ticks.length > safeLimit) {
  22782. return [];
  22783. }
  22784. }
  22785. // Consider this case: the last item of ticks is smaller
  22786. // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
  22787. if (extent[1] > (ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1])) {
  22788. ticks.push(extent[1]);
  22789. }
  22790. return ticks;
  22791. };
  22792. module.exports = helper;
  22793. /***/ }),
  22794. /* 109 */
  22795. /***/ (function(module, exports, __webpack_require__) {
  22796. /**
  22797. * Interval scale
  22798. * @module echarts/coord/scale/Time
  22799. */
  22800. // [About UTC and local time zone]:
  22801. // In most cases, `number.parseDate` will treat input data string as local time
  22802. // (except time zone is specified in time string). And `format.formateTime` returns
  22803. // local time by default. option.useUTC is false by default. This design have
  22804. // concidered these common case:
  22805. // (1) Time that is persistent in server is in UTC, but it is needed to be diplayed
  22806. // in local time by default.
  22807. // (2) By default, the input data string (e.g., '2011-01-02') should be displayed
  22808. // as its original time, without any time difference.
  22809. var zrUtil = __webpack_require__(4);
  22810. var numberUtil = __webpack_require__(7);
  22811. var formatUtil = __webpack_require__(6);
  22812. var scaleHelper = __webpack_require__(108);
  22813. var IntervalScale = __webpack_require__(107);
  22814. var intervalScaleProto = IntervalScale.prototype;
  22815. var mathCeil = Math.ceil;
  22816. var mathFloor = Math.floor;
  22817. var ONE_SECOND = 1000;
  22818. var ONE_MINUTE = ONE_SECOND * 60;
  22819. var ONE_HOUR = ONE_MINUTE * 60;
  22820. var ONE_DAY = ONE_HOUR * 24;
  22821. // FIXME 公用?
  22822. var bisect = function (a, x, lo, hi) {
  22823. while (lo < hi) {
  22824. var mid = lo + hi >>> 1;
  22825. if (a[mid][2] < x) {
  22826. lo = mid + 1;
  22827. }
  22828. else {
  22829. hi = mid;
  22830. }
  22831. }
  22832. return lo;
  22833. };
  22834. /**
  22835. * @alias module:echarts/coord/scale/Time
  22836. * @constructor
  22837. */
  22838. var TimeScale = IntervalScale.extend({
  22839. type: 'time',
  22840. /**
  22841. * @override
  22842. */
  22843. getLabel: function (val) {
  22844. var stepLvl = this._stepLvl;
  22845. var date = new Date(val);
  22846. return formatUtil.formatTime(stepLvl[0], date, this.getSetting('useUTC'));
  22847. },
  22848. /**
  22849. * @override
  22850. */
  22851. niceExtent: function (opt) {
  22852. var extent = this._extent;
  22853. // If extent start and end are same, expand them
  22854. if (extent[0] === extent[1]) {
  22855. // Expand extent
  22856. extent[0] -= ONE_DAY;
  22857. extent[1] += ONE_DAY;
  22858. }
  22859. // If there are no data and extent are [Infinity, -Infinity]
  22860. if (extent[1] === -Infinity && extent[0] === Infinity) {
  22861. var d = new Date();
  22862. extent[1] = +new Date(d.getFullYear(), d.getMonth(), d.getDate());
  22863. extent[0] = extent[1] - ONE_DAY;
  22864. }
  22865. this.niceTicks(opt.splitNumber, opt.minInterval, opt.maxInterval);
  22866. // var extent = this._extent;
  22867. var interval = this._interval;
  22868. if (!opt.fixMin) {
  22869. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  22870. }
  22871. if (!opt.fixMax) {
  22872. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  22873. }
  22874. },
  22875. /**
  22876. * @override
  22877. */
  22878. niceTicks: function (approxTickNum, minInterval, maxInterval) {
  22879. approxTickNum = approxTickNum || 10;
  22880. var extent = this._extent;
  22881. var span = extent[1] - extent[0];
  22882. var approxInterval = span / approxTickNum;
  22883. if (minInterval != null && approxInterval < minInterval) {
  22884. approxInterval = minInterval;
  22885. }
  22886. if (maxInterval != null && approxInterval > maxInterval) {
  22887. approxInterval = maxInterval;
  22888. }
  22889. var scaleLevelsLen = scaleLevels.length;
  22890. var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen);
  22891. var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)];
  22892. var interval = level[2];
  22893. // Same with interval scale if span is much larger than 1 year
  22894. if (level[0] === 'year') {
  22895. var yearSpan = span / interval;
  22896. // From "Nice Numbers for Graph Labels" of Graphic Gems
  22897. // var niceYearSpan = numberUtil.nice(yearSpan, false);
  22898. var yearStep = numberUtil.nice(yearSpan / approxTickNum, true);
  22899. interval *= yearStep;
  22900. }
  22901. var timezoneOffset = this.getSetting('useUTC')
  22902. ? 0 : (new Date(+extent[0] || +extent[1])).getTimezoneOffset() * 60 * 1000;
  22903. var niceExtent = [
  22904. Math.round(mathCeil((extent[0] - timezoneOffset) / interval) * interval + timezoneOffset),
  22905. Math.round(mathFloor((extent[1] - timezoneOffset) / interval) * interval + timezoneOffset)
  22906. ];
  22907. scaleHelper.fixExtent(niceExtent, extent);
  22908. this._stepLvl = level;
  22909. // Interval will be used in getTicks
  22910. this._interval = interval;
  22911. this._niceExtent = niceExtent;
  22912. },
  22913. parse: function (val) {
  22914. // val might be float.
  22915. return +numberUtil.parseDate(val);
  22916. }
  22917. });
  22918. zrUtil.each(['contain', 'normalize'], function (methodName) {
  22919. TimeScale.prototype[methodName] = function (val) {
  22920. return intervalScaleProto[methodName].call(this, this.parse(val));
  22921. };
  22922. });
  22923. // Steps from d3
  22924. var scaleLevels = [
  22925. // Format step interval
  22926. ['hh:mm:ss', 1, ONE_SECOND], // 1s
  22927. ['hh:mm:ss', 5, ONE_SECOND * 5], // 5s
  22928. ['hh:mm:ss', 10, ONE_SECOND * 10], // 10s
  22929. ['hh:mm:ss', 15, ONE_SECOND * 15], // 15s
  22930. ['hh:mm:ss', 30, ONE_SECOND * 30], // 30s
  22931. ['hh:mm\nMM-dd',1, ONE_MINUTE], // 1m
  22932. ['hh:mm\nMM-dd',5, ONE_MINUTE * 5], // 5m
  22933. ['hh:mm\nMM-dd',10, ONE_MINUTE * 10], // 10m
  22934. ['hh:mm\nMM-dd',15, ONE_MINUTE * 15], // 15m
  22935. ['hh:mm\nMM-dd',30, ONE_MINUTE * 30], // 30m
  22936. ['hh:mm\nMM-dd',1, ONE_HOUR], // 1h
  22937. ['hh:mm\nMM-dd',2, ONE_HOUR * 2], // 2h
  22938. ['hh:mm\nMM-dd',6, ONE_HOUR * 6], // 6h
  22939. ['hh:mm\nMM-dd',12, ONE_HOUR * 12], // 12h
  22940. ['MM-dd\nyyyy', 1, ONE_DAY], // 1d
  22941. ['week', 7, ONE_DAY * 7], // 7d
  22942. ['month', 1, ONE_DAY * 31], // 1M
  22943. ['quarter', 3, ONE_DAY * 380 / 4], // 3M
  22944. ['half-year', 6, ONE_DAY * 380 / 2], // 6M
  22945. ['year', 1, ONE_DAY * 380] // 1Y
  22946. ];
  22947. /**
  22948. * @param {module:echarts/model/Model}
  22949. * @return {module:echarts/scale/Time}
  22950. */
  22951. TimeScale.create = function (model) {
  22952. return new TimeScale({useUTC: model.ecModel.get('useUTC')});
  22953. };
  22954. module.exports = TimeScale;
  22955. /***/ }),
  22956. /* 110 */
  22957. /***/ (function(module, exports, __webpack_require__) {
  22958. /**
  22959. * Log scale
  22960. * @module echarts/scale/Log
  22961. */
  22962. var zrUtil = __webpack_require__(4);
  22963. var Scale = __webpack_require__(106);
  22964. var numberUtil = __webpack_require__(7);
  22965. // Use some method of IntervalScale
  22966. var IntervalScale = __webpack_require__(107);
  22967. var scaleProto = Scale.prototype;
  22968. var intervalScaleProto = IntervalScale.prototype;
  22969. var getPrecisionSafe = numberUtil.getPrecisionSafe;
  22970. var roundingErrorFix = numberUtil.round;
  22971. var mathFloor = Math.floor;
  22972. var mathCeil = Math.ceil;
  22973. var mathPow = Math.pow;
  22974. var mathLog = Math.log;
  22975. var LogScale = Scale.extend({
  22976. type: 'log',
  22977. base: 10,
  22978. $constructor: function () {
  22979. Scale.apply(this, arguments);
  22980. this._originalScale = new IntervalScale();
  22981. },
  22982. /**
  22983. * @return {Array.<number>}
  22984. */
  22985. getTicks: function () {
  22986. var originalScale = this._originalScale;
  22987. var extent = this._extent;
  22988. var originalExtent = originalScale.getExtent();
  22989. return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
  22990. var powVal = numberUtil.round(mathPow(this.base, val));
  22991. // Fix #4158
  22992. powVal = (val === extent[0] && originalScale.__fixMin)
  22993. ? fixRoundingError(powVal, originalExtent[0])
  22994. : powVal;
  22995. powVal = (val === extent[1] && originalScale.__fixMax)
  22996. ? fixRoundingError(powVal, originalExtent[1])
  22997. : powVal;
  22998. return powVal;
  22999. }, this);
  23000. },
  23001. /**
  23002. * @param {number} val
  23003. * @return {string}
  23004. */
  23005. getLabel: intervalScaleProto.getLabel,
  23006. /**
  23007. * @param {number} val
  23008. * @return {number}
  23009. */
  23010. scale: function (val) {
  23011. val = scaleProto.scale.call(this, val);
  23012. return mathPow(this.base, val);
  23013. },
  23014. /**
  23015. * @param {number} start
  23016. * @param {number} end
  23017. */
  23018. setExtent: function (start, end) {
  23019. var base = this.base;
  23020. start = mathLog(start) / mathLog(base);
  23021. end = mathLog(end) / mathLog(base);
  23022. intervalScaleProto.setExtent.call(this, start, end);
  23023. },
  23024. /**
  23025. * @return {number} end
  23026. */
  23027. getExtent: function () {
  23028. var base = this.base;
  23029. var extent = scaleProto.getExtent.call(this);
  23030. extent[0] = mathPow(base, extent[0]);
  23031. extent[1] = mathPow(base, extent[1]);
  23032. // Fix #4158
  23033. var originalScale = this._originalScale;
  23034. var originalExtent = originalScale.getExtent();
  23035. originalScale.__fixMin && (extent[0] = fixRoundingError(extent[0], originalExtent[0]));
  23036. originalScale.__fixMax && (extent[1] = fixRoundingError(extent[1], originalExtent[1]));
  23037. return extent;
  23038. },
  23039. /**
  23040. * @param {Array.<number>} extent
  23041. */
  23042. unionExtent: function (extent) {
  23043. this._originalScale.unionExtent(extent);
  23044. var base = this.base;
  23045. extent[0] = mathLog(extent[0]) / mathLog(base);
  23046. extent[1] = mathLog(extent[1]) / mathLog(base);
  23047. scaleProto.unionExtent.call(this, extent);
  23048. },
  23049. /**
  23050. * @override
  23051. */
  23052. unionExtentFromData: function (data, dim) {
  23053. this.unionExtent(data.getDataExtent(dim, true, function (val) {
  23054. return val > 0;
  23055. }));
  23056. },
  23057. /**
  23058. * Update interval and extent of intervals for nice ticks
  23059. * @param {number} [approxTickNum = 10] Given approx tick number
  23060. */
  23061. niceTicks: function (approxTickNum) {
  23062. approxTickNum = approxTickNum || 10;
  23063. var extent = this._extent;
  23064. var span = extent[1] - extent[0];
  23065. if (span === Infinity || span <= 0) {
  23066. return;
  23067. }
  23068. var interval = numberUtil.quantity(span);
  23069. var err = approxTickNum / span * interval;
  23070. // Filter ticks to get closer to the desired count.
  23071. if (err <= 0.5) {
  23072. interval *= 10;
  23073. }
  23074. // Interval should be integer
  23075. while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
  23076. interval *= 10;
  23077. }
  23078. var niceExtent = [
  23079. numberUtil.round(mathCeil(extent[0] / interval) * interval),
  23080. numberUtil.round(mathFloor(extent[1] / interval) * interval)
  23081. ];
  23082. this._interval = interval;
  23083. this._niceExtent = niceExtent;
  23084. },
  23085. /**
  23086. * Nice extent.
  23087. * @override
  23088. */
  23089. niceExtent: function (opt) {
  23090. intervalScaleProto.niceExtent.call(this, opt);
  23091. var originalScale = this._originalScale;
  23092. originalScale.__fixMin = opt.fixMin;
  23093. originalScale.__fixMax = opt.fixMax;
  23094. }
  23095. });
  23096. zrUtil.each(['contain', 'normalize'], function (methodName) {
  23097. LogScale.prototype[methodName] = function (val) {
  23098. val = mathLog(val) / mathLog(this.base);
  23099. return scaleProto[methodName].call(this, val);
  23100. };
  23101. });
  23102. LogScale.create = function () {
  23103. return new LogScale();
  23104. };
  23105. function fixRoundingError(val, originalVal) {
  23106. return roundingErrorFix(val, getPrecisionSafe(originalVal));
  23107. }
  23108. module.exports = LogScale;
  23109. /***/ }),
  23110. /* 111 */
  23111. /***/ (function(module, exports, __webpack_require__) {
  23112. var createListFromArray = __webpack_require__(112);
  23113. var symbolUtil = __webpack_require__(114);
  23114. var axisHelper = __webpack_require__(104);
  23115. var axisModelCommonMixin = __webpack_require__(115);
  23116. var Model = __webpack_require__(14);
  23117. var util = __webpack_require__(4);
  23118. module.exports = {
  23119. /**
  23120. * Create a muti dimension List structure from seriesModel.
  23121. * @param {module:echarts/model/Model} seriesModel
  23122. * @return {module:echarts/data/List} list
  23123. */
  23124. createList: function (seriesModel) {
  23125. var data = seriesModel.get('data');
  23126. return createListFromArray(data, seriesModel, seriesModel.ecModel);
  23127. },
  23128. /**
  23129. * @see {module:echarts/data/helper/completeDimensions}
  23130. */
  23131. completeDimensions: __webpack_require__(113),
  23132. /**
  23133. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  23134. * @see http://echarts.baidu.com/option.html#series-scatter.symbol
  23135. * @param {string} symbolDesc
  23136. * @param {number} x
  23137. * @param {number} y
  23138. * @param {number} w
  23139. * @param {number} h
  23140. * @param {string} color
  23141. */
  23142. createSymbol: symbolUtil.createSymbol,
  23143. /**
  23144. * Create scale
  23145. * @param {Array.<number>} dataExtent
  23146. * @param {Object|module:echarts/Model} option
  23147. */
  23148. createScale: function (dataExtent, option) {
  23149. var axisModel = option;
  23150. if (!(option instanceof Model)) {
  23151. axisModel = new Model(option);
  23152. util.mixin(axisModel, axisModelCommonMixin);
  23153. }
  23154. var scale = axisHelper.createScaleByModel(axisModel);
  23155. scale.setExtent(dataExtent[0], dataExtent[1]);
  23156. axisHelper.niceScaleExtent(scale, axisModel);
  23157. return scale;
  23158. },
  23159. /**
  23160. * Mixin common methods to axis model,
  23161. *
  23162. * Inlcude methods
  23163. * `getFormattedLabels() => Array.<string>`
  23164. * `getCategories() => Array.<string>`
  23165. * `getMin(origin: boolean) => number`
  23166. * `getMax(origin: boolean) => number`
  23167. * `getNeedCrossZero() => boolean`
  23168. * `setRange(start: number, end: number)`
  23169. * `resetRange()`
  23170. */
  23171. mixinAxisModelCommonMethods: function (Model) {
  23172. util.mixin(Model, axisModelCommonMixin);
  23173. }
  23174. };
  23175. /***/ }),
  23176. /* 112 */
  23177. /***/ (function(module, exports, __webpack_require__) {
  23178. 'use strict';
  23179. var List = __webpack_require__(101);
  23180. var completeDimensions = __webpack_require__(113);
  23181. var zrUtil = __webpack_require__(4);
  23182. var modelUtil = __webpack_require__(5);
  23183. var CoordinateSystem = __webpack_require__(79);
  23184. var getDataItemValue = modelUtil.getDataItemValue;
  23185. var converDataValue = modelUtil.converDataValue;
  23186. function firstDataNotNull(data) {
  23187. var i = 0;
  23188. while (i < data.length && data[i] == null) {
  23189. i++;
  23190. }
  23191. return data[i];
  23192. }
  23193. function ifNeedCompleteOrdinalData(data) {
  23194. var sampleItem = firstDataNotNull(data);
  23195. return sampleItem != null
  23196. && !zrUtil.isArray(getDataItemValue(sampleItem));
  23197. }
  23198. /**
  23199. * Helper function to create a list from option data
  23200. */
  23201. function createListFromArray(data, seriesModel, ecModel) {
  23202. // If data is undefined
  23203. data = data || [];
  23204. if (true) {
  23205. if (!zrUtil.isArray(data)) {
  23206. throw new Error('Invalid data.');
  23207. }
  23208. }
  23209. var coordSysName = seriesModel.get('coordinateSystem');
  23210. var creator = creators[coordSysName];
  23211. var registeredCoordSys = CoordinateSystem.get(coordSysName);
  23212. var completeDimOpt = {
  23213. encodeDef: seriesModel.get('encode'),
  23214. dimsDef: seriesModel.get('dimensions')
  23215. };
  23216. // FIXME
  23217. var axesInfo = creator && creator(data, seriesModel, ecModel, completeDimOpt);
  23218. var dimensions = axesInfo && axesInfo.dimensions;
  23219. if (!dimensions) {
  23220. // Get dimensions from registered coordinate system
  23221. dimensions = (registeredCoordSys && (
  23222. registeredCoordSys.getDimensionsInfo
  23223. ? registeredCoordSys.getDimensionsInfo()
  23224. : registeredCoordSys.dimensions.slice()
  23225. )) || ['x', 'y'];
  23226. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  23227. }
  23228. var categoryIndex = axesInfo ? axesInfo.categoryIndex : -1;
  23229. var list = new List(dimensions, seriesModel);
  23230. var nameList = createNameList(axesInfo, data);
  23231. var categories = {};
  23232. var dimValueGetter = (categoryIndex >= 0 && ifNeedCompleteOrdinalData(data))
  23233. ? function (itemOpt, dimName, dataIndex, dimIndex) {
  23234. // If any dataItem is like { value: 10 }
  23235. if (modelUtil.isDataItemOption(itemOpt)) {
  23236. list.hasItemOption = true;
  23237. }
  23238. // Use dataIndex as ordinal value in categoryAxis
  23239. return dimIndex === categoryIndex
  23240. ? dataIndex
  23241. : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]);
  23242. }
  23243. : function (itemOpt, dimName, dataIndex, dimIndex) {
  23244. var value = getDataItemValue(itemOpt);
  23245. var val = converDataValue(value && value[dimIndex], dimensions[dimIndex]);
  23246. // If any dataItem is like { value: 10 }
  23247. if (modelUtil.isDataItemOption(itemOpt)) {
  23248. list.hasItemOption = true;
  23249. }
  23250. var categoryAxesModels = axesInfo && axesInfo.categoryAxesModels;
  23251. if (categoryAxesModels && categoryAxesModels[dimName]) {
  23252. // If given value is a category string
  23253. if (typeof val === 'string') {
  23254. // Lazy get categories
  23255. categories[dimName] = categories[dimName]
  23256. || categoryAxesModels[dimName].getCategories();
  23257. val = zrUtil.indexOf(categories[dimName], val);
  23258. if (val < 0 && !isNaN(val)) {
  23259. // In case some one write '1', '2' istead of 1, 2
  23260. val = +val;
  23261. }
  23262. }
  23263. }
  23264. return val;
  23265. };
  23266. list.hasItemOption = false;
  23267. list.initData(data, nameList, dimValueGetter);
  23268. return list;
  23269. }
  23270. function isStackable(axisType) {
  23271. return axisType !== 'category' && axisType !== 'time';
  23272. }
  23273. function getDimTypeByAxis(axisType) {
  23274. return axisType === 'category'
  23275. ? 'ordinal'
  23276. : axisType === 'time'
  23277. ? 'time'
  23278. : 'float';
  23279. }
  23280. /**
  23281. * Creaters for each coord system.
  23282. */
  23283. var creators = {
  23284. cartesian2d: function (data, seriesModel, ecModel, completeDimOpt) {
  23285. var axesModels = zrUtil.map(['xAxis', 'yAxis'], function (name) {
  23286. return ecModel.queryComponents({
  23287. mainType: name,
  23288. index: seriesModel.get(name + 'Index'),
  23289. id: seriesModel.get(name + 'Id')
  23290. })[0];
  23291. });
  23292. var xAxisModel = axesModels[0];
  23293. var yAxisModel = axesModels[1];
  23294. if (true) {
  23295. if (!xAxisModel) {
  23296. throw new Error('xAxis "' + zrUtil.retrieve(
  23297. seriesModel.get('xAxisIndex'),
  23298. seriesModel.get('xAxisId'),
  23299. 0
  23300. ) + '" not found');
  23301. }
  23302. if (!yAxisModel) {
  23303. throw new Error('yAxis "' + zrUtil.retrieve(
  23304. seriesModel.get('xAxisIndex'),
  23305. seriesModel.get('yAxisId'),
  23306. 0
  23307. ) + '" not found');
  23308. }
  23309. }
  23310. var xAxisType = xAxisModel.get('type');
  23311. var yAxisType = yAxisModel.get('type');
  23312. var dimensions = [
  23313. {
  23314. name: 'x',
  23315. type: getDimTypeByAxis(xAxisType),
  23316. stackable: isStackable(xAxisType)
  23317. },
  23318. {
  23319. name: 'y',
  23320. // If two category axes
  23321. type: getDimTypeByAxis(yAxisType),
  23322. stackable: isStackable(yAxisType)
  23323. }
  23324. ];
  23325. var isXAxisCateogry = xAxisType === 'category';
  23326. var isYAxisCategory = yAxisType === 'category';
  23327. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  23328. var categoryAxesModels = {};
  23329. if (isXAxisCateogry) {
  23330. categoryAxesModels.x = xAxisModel;
  23331. }
  23332. if (isYAxisCategory) {
  23333. categoryAxesModels.y = yAxisModel;
  23334. }
  23335. return {
  23336. dimensions: dimensions,
  23337. categoryIndex: isXAxisCateogry ? 0 : (isYAxisCategory ? 1 : -1),
  23338. categoryAxesModels: categoryAxesModels
  23339. };
  23340. },
  23341. singleAxis: function (data, seriesModel, ecModel, completeDimOpt) {
  23342. var singleAxisModel = ecModel.queryComponents({
  23343. mainType: 'singleAxis',
  23344. index: seriesModel.get('singleAxisIndex'),
  23345. id: seriesModel.get('singleAxisId')
  23346. })[0];
  23347. if (true) {
  23348. if (!singleAxisModel) {
  23349. throw new Error('singleAxis should be specified.');
  23350. }
  23351. }
  23352. var singleAxisType = singleAxisModel.get('type');
  23353. var isCategory = singleAxisType === 'category';
  23354. var dimensions = [{
  23355. name: 'single',
  23356. type: getDimTypeByAxis(singleAxisType),
  23357. stackable: isStackable(singleAxisType)
  23358. }];
  23359. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  23360. var categoryAxesModels = {};
  23361. if (isCategory) {
  23362. categoryAxesModels.single = singleAxisModel;
  23363. }
  23364. return {
  23365. dimensions: dimensions,
  23366. categoryIndex: isCategory ? 0 : -1,
  23367. categoryAxesModels: categoryAxesModels
  23368. };
  23369. },
  23370. polar: function (data, seriesModel, ecModel, completeDimOpt) {
  23371. var polarModel = ecModel.queryComponents({
  23372. mainType: 'polar',
  23373. index: seriesModel.get('polarIndex'),
  23374. id: seriesModel.get('polarId')
  23375. })[0];
  23376. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  23377. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  23378. if (true) {
  23379. if (!angleAxisModel) {
  23380. throw new Error('angleAxis option not found');
  23381. }
  23382. if (!radiusAxisModel) {
  23383. throw new Error('radiusAxis option not found');
  23384. }
  23385. }
  23386. var radiusAxisType = radiusAxisModel.get('type');
  23387. var angleAxisType = angleAxisModel.get('type');
  23388. var dimensions = [
  23389. {
  23390. name: 'radius',
  23391. type: getDimTypeByAxis(radiusAxisType),
  23392. stackable: isStackable(radiusAxisType)
  23393. },
  23394. {
  23395. name: 'angle',
  23396. type: getDimTypeByAxis(angleAxisType),
  23397. stackable: isStackable(angleAxisType)
  23398. }
  23399. ];
  23400. var isAngleAxisCateogry = angleAxisType === 'category';
  23401. var isRadiusAxisCateogry = radiusAxisType === 'category';
  23402. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  23403. var categoryAxesModels = {};
  23404. if (isRadiusAxisCateogry) {
  23405. categoryAxesModels.radius = radiusAxisModel;
  23406. }
  23407. if (isAngleAxisCateogry) {
  23408. categoryAxesModels.angle = angleAxisModel;
  23409. }
  23410. return {
  23411. dimensions: dimensions,
  23412. categoryIndex: isAngleAxisCateogry ? 1 : (isRadiusAxisCateogry ? 0 : -1),
  23413. categoryAxesModels: categoryAxesModels
  23414. };
  23415. },
  23416. geo: function (data, seriesModel, ecModel, completeDimOpt) {
  23417. // TODO Region
  23418. // 多个散点图系列在同一个地区的时候
  23419. return {
  23420. dimensions: completeDimensions([
  23421. {name: 'lng'},
  23422. {name: 'lat'}
  23423. ], data, completeDimOpt)
  23424. };
  23425. }
  23426. };
  23427. function createNameList(result, data) {
  23428. var nameList = [];
  23429. var categoryDim = result && result.dimensions[result.categoryIndex];
  23430. var categoryAxisModel;
  23431. if (categoryDim) {
  23432. categoryAxisModel = result.categoryAxesModels[categoryDim.name];
  23433. }
  23434. if (categoryAxisModel) {
  23435. // FIXME Two category axis
  23436. var categories = categoryAxisModel.getCategories();
  23437. if (categories) {
  23438. var dataLen = data.length;
  23439. // Ordered data is given explicitly like
  23440. // [[3, 0.2], [1, 0.3], [2, 0.15]]
  23441. // or given scatter data,
  23442. // pick the category
  23443. if (zrUtil.isArray(data[0]) && data[0].length > 1) {
  23444. nameList = [];
  23445. for (var i = 0; i < dataLen; i++) {
  23446. nameList[i] = categories[data[i][result.categoryIndex || 0]];
  23447. }
  23448. }
  23449. else {
  23450. nameList = categories.slice(0);
  23451. }
  23452. }
  23453. }
  23454. return nameList;
  23455. }
  23456. module.exports = createListFromArray;
  23457. /***/ }),
  23458. /* 113 */
  23459. /***/ (function(module, exports, __webpack_require__) {
  23460. /**
  23461. * Complete dimensions by data (guess dimension).
  23462. */
  23463. var zrUtil = __webpack_require__(4);
  23464. var modelUtil = __webpack_require__(5);
  23465. var each = zrUtil.each;
  23466. var isString = zrUtil.isString;
  23467. var defaults = zrUtil.defaults;
  23468. var normalizeToArray = modelUtil.normalizeToArray;
  23469. var OTHER_DIMS = {tooltip: 1, label: 1, itemName: 1};
  23470. /**
  23471. * Complete the dimensions array, by user defined `dimension` and `encode`,
  23472. * and guessing from the data structure.
  23473. * If no 'value' dimension specified, the first no-named dimension will be
  23474. * named as 'value'.
  23475. *
  23476. * @param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
  23477. * provides not only dim template, but also default order.
  23478. * `name` of each item provides default coord name.
  23479. * [{dimsDef: []}, ...] can be specified to give names.
  23480. * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]].
  23481. * @param {Object} [opt]
  23482. * @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
  23483. * For example: ['asdf', {name, type}, ...].
  23484. * @param {Object} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
  23485. * @param {string} [opt.extraPrefix] Prefix of name when filling the left dimensions.
  23486. * @param {string} [opt.extraFromZero] If specified, extra dim names will be:
  23487. * extraPrefix + 0, extraPrefix + extraBaseIndex + 1 ...
  23488. * If not specified, extra dim names will be:
  23489. * extraPrefix, extraPrefix + 0, extraPrefix + 1 ...
  23490. * @param {number} [opt.dimCount] If not specified, guess by the first data item.
  23491. * @return {Array.<Object>} [{
  23492. * name: string mandatory,
  23493. * coordDim: string mandatory,
  23494. * coordDimIndex: number mandatory,
  23495. * type: string optional,
  23496. * tooltipName: string optional,
  23497. * otherDims: {
  23498. * tooltip: number optional,
  23499. * label: number optional
  23500. * },
  23501. * isExtraCoord: boolean true or undefined.
  23502. * other props ...
  23503. * }]
  23504. */
  23505. function completeDimensions(sysDims, data, opt) {
  23506. data = data || [];
  23507. opt = opt || {};
  23508. sysDims = (sysDims || []).slice();
  23509. var dimsDef = (opt.dimsDef || []).slice();
  23510. var encodeDef = zrUtil.createHashMap(opt.encodeDef);
  23511. var dataDimNameMap = zrUtil.createHashMap();
  23512. var coordDimNameMap = zrUtil.createHashMap();
  23513. // var valueCandidate;
  23514. var result = [];
  23515. var dimCount = opt.dimCount;
  23516. if (dimCount == null) {
  23517. var value0 = retrieveValue(data[0]);
  23518. dimCount = Math.max(
  23519. zrUtil.isArray(value0) && value0.length || 1,
  23520. sysDims.length,
  23521. dimsDef.length
  23522. );
  23523. each(sysDims, function (sysDimItem) {
  23524. var sysDimItemDimsDef = sysDimItem.dimsDef;
  23525. sysDimItemDimsDef && (dimCount = Math.max(dimCount, sysDimItemDimsDef.length));
  23526. });
  23527. }
  23528. // Apply user defined dims (`name` and `type`) and init result.
  23529. for (var i = 0; i < dimCount; i++) {
  23530. var dimDefItem = isString(dimsDef[i]) ? {name: dimsDef[i]} : (dimsDef[i] || {});
  23531. var userDimName = dimDefItem.name;
  23532. var resultItem = result[i] = {otherDims: {}};
  23533. // Name will be applied later for avoiding duplication.
  23534. if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
  23535. // Only if `series.dimensions` is defined in option, tooltipName
  23536. // will be set, and dimension will be diplayed vertically in
  23537. // tooltip by default.
  23538. resultItem.name = resultItem.tooltipName = userDimName;
  23539. dataDimNameMap.set(userDimName, i);
  23540. }
  23541. dimDefItem.type != null && (resultItem.type = dimDefItem.type);
  23542. }
  23543. // Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
  23544. encodeDef.each(function (dataDims, coordDim) {
  23545. dataDims = encodeDef.set(coordDim, normalizeToArray(dataDims).slice());
  23546. each(dataDims, function (resultDimIdx, coordDimIndex) {
  23547. // The input resultDimIdx can be dim name or index.
  23548. isString(resultDimIdx) && (resultDimIdx = dataDimNameMap.get(resultDimIdx));
  23549. if (resultDimIdx != null && resultDimIdx < dimCount) {
  23550. dataDims[coordDimIndex] = resultDimIdx;
  23551. applyDim(result[resultDimIdx], coordDim, coordDimIndex);
  23552. }
  23553. });
  23554. });
  23555. // Apply templetes and default order from `sysDims`.
  23556. var availDimIdx = 0;
  23557. each(sysDims, function (sysDimItem, sysDimIndex) {
  23558. var coordDim;
  23559. var sysDimItem;
  23560. var sysDimItemDimsDef;
  23561. var sysDimItemOtherDims;
  23562. if (isString(sysDimItem)) {
  23563. coordDim = sysDimItem;
  23564. sysDimItem = {};
  23565. }
  23566. else {
  23567. coordDim = sysDimItem.name;
  23568. sysDimItem = zrUtil.clone(sysDimItem);
  23569. // `coordDimIndex` should not be set directly.
  23570. sysDimItemDimsDef = sysDimItem.dimsDef;
  23571. sysDimItemOtherDims = sysDimItem.otherDims;
  23572. sysDimItem.name = sysDimItem.coordDim = sysDimItem.coordDimIndex
  23573. = sysDimItem.dimsDef = sysDimItem.otherDims = null;
  23574. }
  23575. var dataDims = normalizeToArray(encodeDef.get(coordDim));
  23576. // dimensions provides default dim sequences.
  23577. if (!dataDims.length) {
  23578. for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
  23579. while (availDimIdx < result.length && result[availDimIdx].coordDim != null) {
  23580. availDimIdx++;
  23581. }
  23582. availDimIdx < result.length && dataDims.push(availDimIdx++);
  23583. }
  23584. }
  23585. // Apply templates.
  23586. each(dataDims, function (resultDimIdx, coordDimIndex) {
  23587. var resultItem = result[resultDimIdx];
  23588. applyDim(defaults(resultItem, sysDimItem), coordDim, coordDimIndex);
  23589. if (resultItem.name == null && sysDimItemDimsDef) {
  23590. resultItem.name = resultItem.tooltipName = sysDimItemDimsDef[coordDimIndex];
  23591. }
  23592. sysDimItemOtherDims && defaults(resultItem.otherDims, sysDimItemOtherDims);
  23593. });
  23594. });
  23595. // Make sure the first extra dim is 'value'.
  23596. var extra = opt.extraPrefix || 'value';
  23597. // Set dim `name` and other `coordDim` and other props.
  23598. for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
  23599. var resultItem = result[resultDimIdx] = result[resultDimIdx] || {};
  23600. var coordDim = resultItem.coordDim;
  23601. coordDim == null && (
  23602. resultItem.coordDim = genName(extra, coordDimNameMap, opt.extraFromZero),
  23603. resultItem.coordDimIndex = 0,
  23604. resultItem.isExtraCoord = true
  23605. );
  23606. resultItem.name == null && (resultItem.name = genName(
  23607. resultItem.coordDim,
  23608. dataDimNameMap
  23609. ));
  23610. resultItem.type == null && guessOrdinal(data, resultDimIdx)
  23611. && (resultItem.type = 'ordinal');
  23612. }
  23613. return result;
  23614. function applyDim(resultItem, coordDim, coordDimIndex) {
  23615. if (OTHER_DIMS[coordDim]) {
  23616. resultItem.otherDims[coordDim] = coordDimIndex;
  23617. }
  23618. else {
  23619. resultItem.coordDim = coordDim;
  23620. resultItem.coordDimIndex = coordDimIndex;
  23621. coordDimNameMap.set(coordDim, true);
  23622. }
  23623. }
  23624. function genName(name, map, fromZero) {
  23625. if (fromZero || map.get(name) != null) {
  23626. var i = 0;
  23627. while (map.get(name + i) != null) {
  23628. i++;
  23629. }
  23630. name += i;
  23631. }
  23632. map.set(name, true);
  23633. return name;
  23634. }
  23635. }
  23636. // The rule should not be complex, otherwise user might not
  23637. // be able to known where the data is wrong.
  23638. var guessOrdinal = completeDimensions.guessOrdinal = function (data, dimIndex) {
  23639. for (var i = 0, len = data.length; i < len; i++) {
  23640. var value = retrieveValue(data[i]);
  23641. if (!zrUtil.isArray(value)) {
  23642. return false;
  23643. }
  23644. var value = value[dimIndex];
  23645. // Consider usage convenience, '1', '2' will be treated as "number".
  23646. // `isFinit('')` get `true`.
  23647. if (value != null && isFinite(value) && value !== '') {
  23648. return false;
  23649. }
  23650. else if (isString(value) && value !== '-') {
  23651. return true;
  23652. }
  23653. }
  23654. return false;
  23655. };
  23656. function retrieveValue(o) {
  23657. return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o;
  23658. }
  23659. module.exports = completeDimensions;
  23660. /***/ }),
  23661. /* 114 */
  23662. /***/ (function(module, exports, __webpack_require__) {
  23663. 'use strict';
  23664. // Symbol factory
  23665. var graphic = __webpack_require__(20);
  23666. var BoundingRect = __webpack_require__(9);
  23667. /**
  23668. * Triangle shape
  23669. * @inner
  23670. */
  23671. var Triangle = graphic.extendShape({
  23672. type: 'triangle',
  23673. shape: {
  23674. cx: 0,
  23675. cy: 0,
  23676. width: 0,
  23677. height: 0
  23678. },
  23679. buildPath: function (path, shape) {
  23680. var cx = shape.cx;
  23681. var cy = shape.cy;
  23682. var width = shape.width / 2;
  23683. var height = shape.height / 2;
  23684. path.moveTo(cx, cy - height);
  23685. path.lineTo(cx + width, cy + height);
  23686. path.lineTo(cx - width, cy + height);
  23687. path.closePath();
  23688. }
  23689. });
  23690. /**
  23691. * Diamond shape
  23692. * @inner
  23693. */
  23694. var Diamond = graphic.extendShape({
  23695. type: 'diamond',
  23696. shape: {
  23697. cx: 0,
  23698. cy: 0,
  23699. width: 0,
  23700. height: 0
  23701. },
  23702. buildPath: function (path, shape) {
  23703. var cx = shape.cx;
  23704. var cy = shape.cy;
  23705. var width = shape.width / 2;
  23706. var height = shape.height / 2;
  23707. path.moveTo(cx, cy - height);
  23708. path.lineTo(cx + width, cy);
  23709. path.lineTo(cx, cy + height);
  23710. path.lineTo(cx - width, cy);
  23711. path.closePath();
  23712. }
  23713. });
  23714. /**
  23715. * Pin shape
  23716. * @inner
  23717. */
  23718. var Pin = graphic.extendShape({
  23719. type: 'pin',
  23720. shape: {
  23721. // x, y on the cusp
  23722. x: 0,
  23723. y: 0,
  23724. width: 0,
  23725. height: 0
  23726. },
  23727. buildPath: function (path, shape) {
  23728. var x = shape.x;
  23729. var y = shape.y;
  23730. var w = shape.width / 5 * 3;
  23731. // Height must be larger than width
  23732. var h = Math.max(w, shape.height);
  23733. var r = w / 2;
  23734. // Dist on y with tangent point and circle center
  23735. var dy = r * r / (h - r);
  23736. var cy = y - h + r + dy;
  23737. var angle = Math.asin(dy / r);
  23738. // Dist on x with tangent point and circle center
  23739. var dx = Math.cos(angle) * r;
  23740. var tanX = Math.sin(angle);
  23741. var tanY = Math.cos(angle);
  23742. path.arc(
  23743. x, cy, r,
  23744. Math.PI - angle,
  23745. Math.PI * 2 + angle
  23746. );
  23747. var cpLen = r * 0.6;
  23748. var cpLen2 = r * 0.7;
  23749. path.bezierCurveTo(
  23750. x + dx - tanX * cpLen, cy + dy + tanY * cpLen,
  23751. x, y - cpLen2,
  23752. x, y
  23753. );
  23754. path.bezierCurveTo(
  23755. x, y - cpLen2,
  23756. x - dx + tanX * cpLen, cy + dy + tanY * cpLen,
  23757. x - dx, cy + dy
  23758. );
  23759. path.closePath();
  23760. }
  23761. });
  23762. /**
  23763. * Arrow shape
  23764. * @inner
  23765. */
  23766. var Arrow = graphic.extendShape({
  23767. type: 'arrow',
  23768. shape: {
  23769. x: 0,
  23770. y: 0,
  23771. width: 0,
  23772. height: 0
  23773. },
  23774. buildPath: function (ctx, shape) {
  23775. var height = shape.height;
  23776. var width = shape.width;
  23777. var x = shape.x;
  23778. var y = shape.y;
  23779. var dx = width / 3 * 2;
  23780. ctx.moveTo(x, y);
  23781. ctx.lineTo(x + dx, y + height);
  23782. ctx.lineTo(x, y + height / 4 * 3);
  23783. ctx.lineTo(x - dx, y + height);
  23784. ctx.lineTo(x, y);
  23785. ctx.closePath();
  23786. }
  23787. });
  23788. /**
  23789. * Map of path contructors
  23790. * @type {Object.<string, module:zrender/graphic/Path>}
  23791. */
  23792. var symbolCtors = {
  23793. line: graphic.Line,
  23794. rect: graphic.Rect,
  23795. roundRect: graphic.Rect,
  23796. square: graphic.Rect,
  23797. circle: graphic.Circle,
  23798. diamond: Diamond,
  23799. pin: Pin,
  23800. arrow: Arrow,
  23801. triangle: Triangle
  23802. };
  23803. var symbolShapeMakers = {
  23804. line: function (x, y, w, h, shape) {
  23805. // FIXME
  23806. shape.x1 = x;
  23807. shape.y1 = y + h / 2;
  23808. shape.x2 = x + w;
  23809. shape.y2 = y + h / 2;
  23810. },
  23811. rect: function (x, y, w, h, shape) {
  23812. shape.x = x;
  23813. shape.y = y;
  23814. shape.width = w;
  23815. shape.height = h;
  23816. },
  23817. roundRect: function (x, y, w, h, shape) {
  23818. shape.x = x;
  23819. shape.y = y;
  23820. shape.width = w;
  23821. shape.height = h;
  23822. shape.r = Math.min(w, h) / 4;
  23823. },
  23824. square: function (x, y, w, h, shape) {
  23825. var size = Math.min(w, h);
  23826. shape.x = x;
  23827. shape.y = y;
  23828. shape.width = size;
  23829. shape.height = size;
  23830. },
  23831. circle: function (x, y, w, h, shape) {
  23832. // Put circle in the center of square
  23833. shape.cx = x + w / 2;
  23834. shape.cy = y + h / 2;
  23835. shape.r = Math.min(w, h) / 2;
  23836. },
  23837. diamond: function (x, y, w, h, shape) {
  23838. shape.cx = x + w / 2;
  23839. shape.cy = y + h / 2;
  23840. shape.width = w;
  23841. shape.height = h;
  23842. },
  23843. pin: function (x, y, w, h, shape) {
  23844. shape.x = x + w / 2;
  23845. shape.y = y + h / 2;
  23846. shape.width = w;
  23847. shape.height = h;
  23848. },
  23849. arrow: function (x, y, w, h, shape) {
  23850. shape.x = x + w / 2;
  23851. shape.y = y + h / 2;
  23852. shape.width = w;
  23853. shape.height = h;
  23854. },
  23855. triangle: function (x, y, w, h, shape) {
  23856. shape.cx = x + w / 2;
  23857. shape.cy = y + h / 2;
  23858. shape.width = w;
  23859. shape.height = h;
  23860. }
  23861. };
  23862. var symbolBuildProxies = {};
  23863. for (var name in symbolCtors) {
  23864. if (symbolCtors.hasOwnProperty(name)) {
  23865. symbolBuildProxies[name] = new symbolCtors[name]();
  23866. }
  23867. }
  23868. var Symbol = graphic.extendShape({
  23869. type: 'symbol',
  23870. shape: {
  23871. symbolType: '',
  23872. x: 0,
  23873. y: 0,
  23874. width: 0,
  23875. height: 0
  23876. },
  23877. beforeBrush: function () {
  23878. var style = this.style;
  23879. var shape = this.shape;
  23880. // FIXME
  23881. if (shape.symbolType === 'pin' && style.textPosition === 'inside') {
  23882. style.textPosition = ['50%', '40%'];
  23883. style.textAlign = 'center';
  23884. style.textVerticalAlign = 'middle';
  23885. }
  23886. },
  23887. buildPath: function (ctx, shape, inBundle) {
  23888. var symbolType = shape.symbolType;
  23889. var proxySymbol = symbolBuildProxies[symbolType];
  23890. if (shape.symbolType !== 'none') {
  23891. if (!proxySymbol) {
  23892. // Default rect
  23893. symbolType = 'rect';
  23894. proxySymbol = symbolBuildProxies[symbolType];
  23895. }
  23896. symbolShapeMakers[symbolType](
  23897. shape.x, shape.y, shape.width, shape.height, proxySymbol.shape
  23898. );
  23899. proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle);
  23900. }
  23901. }
  23902. });
  23903. // Provide setColor helper method to avoid determine if set the fill or stroke outside
  23904. var symbolPathSetColor = function (color) {
  23905. if (this.type !== 'image') {
  23906. var symbolStyle = this.style;
  23907. var symbolShape = this.shape;
  23908. if (symbolShape && symbolShape.symbolType === 'line') {
  23909. symbolStyle.stroke = color;
  23910. }
  23911. else if (this.__isEmptyBrush) {
  23912. symbolStyle.stroke = color;
  23913. symbolStyle.fill = '#fff';
  23914. }
  23915. else {
  23916. // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
  23917. symbolStyle.fill && (symbolStyle.fill = color);
  23918. symbolStyle.stroke && (symbolStyle.stroke = color);
  23919. }
  23920. this.dirty(false);
  23921. }
  23922. };
  23923. var symbolUtil = {
  23924. /**
  23925. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  23926. * @param {string} symbolType
  23927. * @param {number} x
  23928. * @param {number} y
  23929. * @param {number} w
  23930. * @param {number} h
  23931. * @param {string} color
  23932. */
  23933. createSymbol: function (symbolType, x, y, w, h, color) {
  23934. // TODO Support image object, DynamicImage.
  23935. var isEmpty = symbolType.indexOf('empty') === 0;
  23936. if (isEmpty) {
  23937. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  23938. }
  23939. var symbolPath;
  23940. if (symbolType.indexOf('image://') === 0) {
  23941. symbolPath = new graphic.Image({
  23942. style: {
  23943. image: symbolType.slice(8),
  23944. x: x,
  23945. y: y,
  23946. width: w,
  23947. height: h
  23948. }
  23949. });
  23950. }
  23951. else if (symbolType.indexOf('path://') === 0) {
  23952. symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
  23953. }
  23954. else {
  23955. symbolPath = new Symbol({
  23956. shape: {
  23957. symbolType: symbolType,
  23958. x: x,
  23959. y: y,
  23960. width: w,
  23961. height: h
  23962. }
  23963. });
  23964. }
  23965. symbolPath.__isEmptyBrush = isEmpty;
  23966. symbolPath.setColor = symbolPathSetColor;
  23967. symbolPath.setColor(color);
  23968. return symbolPath;
  23969. }
  23970. };
  23971. module.exports = symbolUtil;
  23972. /***/ }),
  23973. /* 115 */
  23974. /***/ (function(module, exports, __webpack_require__) {
  23975. var zrUtil = __webpack_require__(4);
  23976. var axisHelper = __webpack_require__(104);
  23977. function getName(obj) {
  23978. if (zrUtil.isObject(obj) && obj.value != null) {
  23979. return obj.value;
  23980. }
  23981. else {
  23982. return obj + '';
  23983. }
  23984. }
  23985. module.exports = {
  23986. /**
  23987. * Format labels
  23988. * @return {Array.<string>}
  23989. */
  23990. getFormattedLabels: function () {
  23991. return axisHelper.getFormattedLabels(
  23992. this.axis,
  23993. this.get('axisLabel.formatter')
  23994. );
  23995. },
  23996. /**
  23997. * Get categories
  23998. */
  23999. getCategories: function () {
  24000. return this.get('type') === 'category'
  24001. && zrUtil.map(this.get('data'), getName);
  24002. },
  24003. /**
  24004. * @param {boolean} origin
  24005. * @return {number|string} min value or 'dataMin' or null/undefined (means auto) or NaN
  24006. */
  24007. getMin: function (origin) {
  24008. var option = this.option;
  24009. var min = (!origin && option.rangeStart != null)
  24010. ? option.rangeStart : option.min;
  24011. if (this.axis
  24012. && min != null
  24013. && min !== 'dataMin'
  24014. && typeof min !== 'function'
  24015. && !zrUtil.eqNaN(min)
  24016. ) {
  24017. min = this.axis.scale.parse(min);
  24018. }
  24019. return min;
  24020. },
  24021. /**
  24022. * @param {boolean} origin
  24023. * @return {number|string} max value or 'dataMax' or null/undefined (means auto) or NaN
  24024. */
  24025. getMax: function (origin) {
  24026. var option = this.option;
  24027. var max = (!origin && option.rangeEnd != null)
  24028. ? option.rangeEnd : option.max;
  24029. if (this.axis
  24030. && max != null
  24031. && max !== 'dataMax'
  24032. && typeof max !== 'function'
  24033. && !zrUtil.eqNaN(max)
  24034. ) {
  24035. max = this.axis.scale.parse(max);
  24036. }
  24037. return max;
  24038. },
  24039. /**
  24040. * @return {boolean}
  24041. */
  24042. getNeedCrossZero: function () {
  24043. var option = this.option;
  24044. return (option.rangeStart != null || option.rangeEnd != null)
  24045. ? false : !option.scale;
  24046. },
  24047. /**
  24048. * Should be implemented by each axis model if necessary.
  24049. * @return {module:echarts/model/Component} coordinate system model
  24050. */
  24051. getCoordSysModel: zrUtil.noop,
  24052. /**
  24053. * @param {number} rangeStart Can only be finite number or null/undefined or NaN.
  24054. * @param {number} rangeEnd Can only be finite number or null/undefined or NaN.
  24055. */
  24056. setRange: function (rangeStart, rangeEnd) {
  24057. this.option.rangeStart = rangeStart;
  24058. this.option.rangeEnd = rangeEnd;
  24059. },
  24060. /**
  24061. * Reset range
  24062. */
  24063. resetRange: function () {
  24064. // rangeStart and rangeEnd is readonly.
  24065. this.option.rangeStart = this.option.rangeEnd = null;
  24066. }
  24067. };
  24068. /***/ }),
  24069. /* 116 */
  24070. /***/ (function(module, exports, __webpack_require__) {
  24071. var zrUtil = __webpack_require__(4);
  24072. var echarts = __webpack_require__(1);
  24073. var PRIORITY = echarts.PRIORITY;
  24074. __webpack_require__(117);
  24075. __webpack_require__(118);
  24076. echarts.registerVisual(zrUtil.curry(
  24077. __webpack_require__(124), 'line', 'circle', 'line'
  24078. ));
  24079. echarts.registerLayout(zrUtil.curry(
  24080. __webpack_require__(125), 'line'
  24081. ));
  24082. // Down sample after filter
  24083. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, zrUtil.curry(
  24084. __webpack_require__(126), 'line'
  24085. ));
  24086. // In case developer forget to include grid component
  24087. __webpack_require__(127);
  24088. /***/ }),
  24089. /* 117 */
  24090. /***/ (function(module, exports, __webpack_require__) {
  24091. 'use strict';
  24092. var createListFromArray = __webpack_require__(112);
  24093. var SeriesModel = __webpack_require__(83);
  24094. module.exports = SeriesModel.extend({
  24095. type: 'series.line',
  24096. dependencies: ['grid', 'polar'],
  24097. getInitialData: function (option, ecModel) {
  24098. if (true) {
  24099. var coordSys = option.coordinateSystem;
  24100. if (coordSys !== 'polar' && coordSys !== 'cartesian2d') {
  24101. throw new Error('Line not support coordinateSystem besides cartesian and polar');
  24102. }
  24103. }
  24104. return createListFromArray(option.data, this, ecModel);
  24105. },
  24106. defaultOption: {
  24107. zlevel: 0, // 一级层叠
  24108. z: 2, // 二级层叠
  24109. coordinateSystem: 'cartesian2d',
  24110. legendHoverLink: true,
  24111. hoverAnimation: true,
  24112. // stack: null
  24113. // xAxisIndex: 0,
  24114. // yAxisIndex: 0,
  24115. // polarIndex: 0,
  24116. // If clip the overflow value
  24117. clipOverflow: true,
  24118. // cursor: null,
  24119. label: {
  24120. normal: {
  24121. position: 'top'
  24122. }
  24123. },
  24124. // itemStyle: {
  24125. // normal: {},
  24126. // emphasis: {}
  24127. // },
  24128. lineStyle: {
  24129. normal: {
  24130. width: 2,
  24131. type: 'solid'
  24132. }
  24133. },
  24134. // areaStyle: {},
  24135. // false, 'start', 'end', 'middle'
  24136. step: false,
  24137. // Disabled if step is true
  24138. smooth: false,
  24139. smoothMonotone: null,
  24140. // 拐点图形类型
  24141. symbol: 'emptyCircle',
  24142. // 拐点图形大小
  24143. symbolSize: 4,
  24144. // 拐点图形旋转控制
  24145. symbolRotate: null,
  24146. // 是否显示 symbol, 只有在 tooltip hover 的时候显示
  24147. showSymbol: true,
  24148. // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略)
  24149. showAllSymbol: false,
  24150. // 是否连接断点
  24151. connectNulls: false,
  24152. // 数据过滤,'average', 'max', 'min', 'sum'
  24153. sampling: 'none',
  24154. animationEasing: 'linear',
  24155. // Disable progressive
  24156. progressive: 0,
  24157. hoverLayerThreshold: Infinity
  24158. }
  24159. });
  24160. /***/ }),
  24161. /* 118 */
  24162. /***/ (function(module, exports, __webpack_require__) {
  24163. 'use strict';
  24164. // FIXME step not support polar
  24165. var zrUtil = __webpack_require__(4);
  24166. var SymbolDraw = __webpack_require__(119);
  24167. var Symbol = __webpack_require__(120);
  24168. var lineAnimationDiff = __webpack_require__(122);
  24169. var graphic = __webpack_require__(20);
  24170. var modelUtil = __webpack_require__(5);
  24171. var polyHelper = __webpack_require__(123);
  24172. var ChartView = __webpack_require__(85);
  24173. function isPointsSame(points1, points2) {
  24174. if (points1.length !== points2.length) {
  24175. return;
  24176. }
  24177. for (var i = 0; i < points1.length; i++) {
  24178. var p1 = points1[i];
  24179. var p2 = points2[i];
  24180. if (p1[0] !== p2[0] || p1[1] !== p2[1]) {
  24181. return;
  24182. }
  24183. }
  24184. return true;
  24185. }
  24186. function getSmooth(smooth) {
  24187. return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0);
  24188. }
  24189. function getAxisExtentWithGap(axis) {
  24190. var extent = axis.getGlobalExtent();
  24191. if (axis.onBand) {
  24192. // Remove extra 1px to avoid line miter in clipped edge
  24193. var halfBandWidth = axis.getBandWidth() / 2 - 1;
  24194. var dir = extent[1] > extent[0] ? 1 : -1;
  24195. extent[0] += dir * halfBandWidth;
  24196. extent[1] -= dir * halfBandWidth;
  24197. }
  24198. return extent;
  24199. }
  24200. function sign(val) {
  24201. return val >= 0 ? 1 : -1;
  24202. }
  24203. /**
  24204. * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
  24205. * @param {module:echarts/data/List} data
  24206. * @param {Array.<Array.<number>>} points
  24207. * @private
  24208. */
  24209. function getStackedOnPoints(coordSys, data) {
  24210. var baseAxis = coordSys.getBaseAxis();
  24211. var valueAxis = coordSys.getOtherAxis(baseAxis);
  24212. var valueStart = 0;
  24213. if (!baseAxis.onZero) {
  24214. var extent = valueAxis.scale.getExtent();
  24215. if (extent[0] > 0) {
  24216. // Both positive
  24217. valueStart = extent[0];
  24218. }
  24219. else if (extent[1] < 0) {
  24220. // Both negative
  24221. valueStart = extent[1];
  24222. }
  24223. // If is one positive, and one negative, onZero shall be true
  24224. }
  24225. var valueDim = valueAxis.dim;
  24226. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  24227. return data.mapArray([valueDim], function (val, idx) {
  24228. var stackedOnSameSign;
  24229. var stackedOn = data.stackedOn;
  24230. // Find first stacked value with same sign
  24231. while (stackedOn &&
  24232. sign(stackedOn.get(valueDim, idx)) === sign(val)
  24233. ) {
  24234. stackedOnSameSign = stackedOn;
  24235. break;
  24236. }
  24237. var stackedData = [];
  24238. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  24239. stackedData[1 - baseDataOffset] = stackedOnSameSign
  24240. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  24241. return coordSys.dataToPoint(stackedData);
  24242. }, true);
  24243. }
  24244. function createGridClipShape(cartesian, hasAnimation, seriesModel) {
  24245. var xExtent = getAxisExtentWithGap(cartesian.getAxis('x'));
  24246. var yExtent = getAxisExtentWithGap(cartesian.getAxis('y'));
  24247. var isHorizontal = cartesian.getBaseAxis().isHorizontal();
  24248. var x = Math.min(xExtent[0], xExtent[1]);
  24249. var y = Math.min(yExtent[0], yExtent[1]);
  24250. var width = Math.max(xExtent[0], xExtent[1]) - x;
  24251. var height = Math.max(yExtent[0], yExtent[1]) - y;
  24252. var lineWidth = seriesModel.get('lineStyle.normal.width') || 2;
  24253. // Expand clip shape to avoid clipping when line value exceeds axis
  24254. var expandSize = seriesModel.get('clipOverflow') ? lineWidth / 2 : Math.max(width, height);
  24255. if (isHorizontal) {
  24256. y -= expandSize;
  24257. height += expandSize * 2;
  24258. }
  24259. else {
  24260. x -= expandSize;
  24261. width += expandSize * 2;
  24262. }
  24263. var clipPath = new graphic.Rect({
  24264. shape: {
  24265. x: x,
  24266. y: y,
  24267. width: width,
  24268. height: height
  24269. }
  24270. });
  24271. if (hasAnimation) {
  24272. clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
  24273. graphic.initProps(clipPath, {
  24274. shape: {
  24275. width: width,
  24276. height: height
  24277. }
  24278. }, seriesModel);
  24279. }
  24280. return clipPath;
  24281. }
  24282. function createPolarClipShape(polar, hasAnimation, seriesModel) {
  24283. var angleAxis = polar.getAngleAxis();
  24284. var radiusAxis = polar.getRadiusAxis();
  24285. var radiusExtent = radiusAxis.getExtent();
  24286. var angleExtent = angleAxis.getExtent();
  24287. var RADIAN = Math.PI / 180;
  24288. var clipPath = new graphic.Sector({
  24289. shape: {
  24290. cx: polar.cx,
  24291. cy: polar.cy,
  24292. r0: radiusExtent[0],
  24293. r: radiusExtent[1],
  24294. startAngle: -angleExtent[0] * RADIAN,
  24295. endAngle: -angleExtent[1] * RADIAN,
  24296. clockwise: angleAxis.inverse
  24297. }
  24298. });
  24299. if (hasAnimation) {
  24300. clipPath.shape.endAngle = -angleExtent[0] * RADIAN;
  24301. graphic.initProps(clipPath, {
  24302. shape: {
  24303. endAngle: -angleExtent[1] * RADIAN
  24304. }
  24305. }, seriesModel);
  24306. }
  24307. return clipPath;
  24308. }
  24309. function createClipShape(coordSys, hasAnimation, seriesModel) {
  24310. return coordSys.type === 'polar'
  24311. ? createPolarClipShape(coordSys, hasAnimation, seriesModel)
  24312. : createGridClipShape(coordSys, hasAnimation, seriesModel);
  24313. }
  24314. function turnPointsIntoStep(points, coordSys, stepTurnAt) {
  24315. var baseAxis = coordSys.getBaseAxis();
  24316. var baseIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
  24317. var stepPoints = [];
  24318. for (var i = 0; i < points.length - 1; i++) {
  24319. var nextPt = points[i + 1];
  24320. var pt = points[i];
  24321. stepPoints.push(pt);
  24322. var stepPt = [];
  24323. switch (stepTurnAt) {
  24324. case 'end':
  24325. stepPt[baseIndex] = nextPt[baseIndex];
  24326. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  24327. // default is start
  24328. stepPoints.push(stepPt);
  24329. break;
  24330. case 'middle':
  24331. // default is start
  24332. var middle = (pt[baseIndex] + nextPt[baseIndex]) / 2;
  24333. var stepPt2 = [];
  24334. stepPt[baseIndex] = stepPt2[baseIndex] = middle;
  24335. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  24336. stepPt2[1 - baseIndex] = nextPt[1 - baseIndex];
  24337. stepPoints.push(stepPt);
  24338. stepPoints.push(stepPt2);
  24339. break;
  24340. default:
  24341. stepPt[baseIndex] = pt[baseIndex];
  24342. stepPt[1 - baseIndex] = nextPt[1 - baseIndex];
  24343. // default is start
  24344. stepPoints.push(stepPt);
  24345. }
  24346. }
  24347. // Last points
  24348. points[i] && stepPoints.push(points[i]);
  24349. return stepPoints;
  24350. }
  24351. function getVisualGradient(data, coordSys) {
  24352. var visualMetaList = data.getVisual('visualMeta');
  24353. if (!visualMetaList || !visualMetaList.length || !data.count()) {
  24354. // When data.count() is 0, gradient range can not be calculated.
  24355. return;
  24356. }
  24357. var visualMeta;
  24358. for (var i = visualMetaList.length - 1; i >= 0; i--) {
  24359. // Can only be x or y
  24360. if (visualMetaList[i].dimension < 2) {
  24361. visualMeta = visualMetaList[i];
  24362. break;
  24363. }
  24364. }
  24365. if (!visualMeta || coordSys.type !== 'cartesian2d') {
  24366. if (true) {
  24367. console.warn('Visual map on line style only support x or y dimension.');
  24368. }
  24369. return;
  24370. }
  24371. // If the area to be rendered is bigger than area defined by LinearGradient,
  24372. // the canvas spec prescribes that the color of the first stop and the last
  24373. // stop should be used. But if two stops are added at offset 0, in effect
  24374. // browsers use the color of the second stop to render area outside
  24375. // LinearGradient. So we can only infinitesimally extend area defined in
  24376. // LinearGradient to render `outerColors`.
  24377. var dimension = visualMeta.dimension;
  24378. var dimName = data.dimensions[dimension];
  24379. var axis = coordSys.getAxis(dimName);
  24380. // dataToCoor mapping may not be linear, but must be monotonic.
  24381. var colorStops = zrUtil.map(visualMeta.stops, function (stop) {
  24382. return {
  24383. coord: axis.toGlobalCoord(axis.dataToCoord(stop.value)),
  24384. color: stop.color
  24385. };
  24386. });
  24387. var stopLen = colorStops.length;
  24388. var outerColors = visualMeta.outerColors.slice();
  24389. if (stopLen && colorStops[0].coord > colorStops[stopLen - 1].coord) {
  24390. colorStops.reverse();
  24391. outerColors.reverse();
  24392. }
  24393. var tinyExtent = 10; // Arbitrary value: 10px
  24394. var minCoord = colorStops[0].coord - tinyExtent;
  24395. var maxCoord = colorStops[stopLen - 1].coord + tinyExtent;
  24396. var coordSpan = maxCoord - minCoord;
  24397. if (coordSpan < 1e-3) {
  24398. return 'transparent';
  24399. }
  24400. zrUtil.each(colorStops, function (stop) {
  24401. stop.offset = (stop.coord - minCoord) / coordSpan;
  24402. });
  24403. colorStops.push({
  24404. offset: stopLen ? colorStops[stopLen - 1].offset : 0.5,
  24405. color: outerColors[1] || 'transparent'
  24406. });
  24407. colorStops.unshift({ // notice colorStops.length have been changed.
  24408. offset: stopLen ? colorStops[0].offset : 0.5,
  24409. color: outerColors[0] || 'transparent'
  24410. });
  24411. // zrUtil.each(colorStops, function (colorStop) {
  24412. // // Make sure each offset has rounded px to avoid not sharp edge
  24413. // colorStop.offset = (Math.round(colorStop.offset * (end - start) + start) - start) / (end - start);
  24414. // });
  24415. var gradient = new graphic.LinearGradient(0, 0, 0, 0, colorStops, true);
  24416. gradient[dimName] = minCoord;
  24417. gradient[dimName + '2'] = maxCoord;
  24418. return gradient;
  24419. }
  24420. module.exports = ChartView.extend({
  24421. type: 'line',
  24422. init: function () {
  24423. var lineGroup = new graphic.Group();
  24424. var symbolDraw = new SymbolDraw();
  24425. this.group.add(symbolDraw.group);
  24426. this._symbolDraw = symbolDraw;
  24427. this._lineGroup = lineGroup;
  24428. },
  24429. render: function (seriesModel, ecModel, api) {
  24430. var coordSys = seriesModel.coordinateSystem;
  24431. var group = this.group;
  24432. var data = seriesModel.getData();
  24433. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  24434. var areaStyleModel = seriesModel.getModel('areaStyle.normal');
  24435. var points = data.mapArray(data.getItemLayout, true);
  24436. var isCoordSysPolar = coordSys.type === 'polar';
  24437. var prevCoordSys = this._coordSys;
  24438. var symbolDraw = this._symbolDraw;
  24439. var polyline = this._polyline;
  24440. var polygon = this._polygon;
  24441. var lineGroup = this._lineGroup;
  24442. var hasAnimation = seriesModel.get('animation');
  24443. var isAreaChart = !areaStyleModel.isEmpty();
  24444. var stackedOnPoints = getStackedOnPoints(coordSys, data);
  24445. var showSymbol = seriesModel.get('showSymbol');
  24446. var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol')
  24447. && this._getSymbolIgnoreFunc(data, coordSys);
  24448. // Remove temporary symbols
  24449. var oldData = this._data;
  24450. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  24451. if (el.__temp) {
  24452. group.remove(el);
  24453. oldData.setItemGraphicEl(idx, null);
  24454. }
  24455. });
  24456. // Remove previous created symbols if showSymbol changed to false
  24457. if (!showSymbol) {
  24458. symbolDraw.remove();
  24459. }
  24460. group.add(lineGroup);
  24461. // FIXME step not support polar
  24462. var step = !isCoordSysPolar && seriesModel.get('step');
  24463. // Initialization animation or coordinate system changed
  24464. if (
  24465. !(polyline && prevCoordSys.type === coordSys.type && step === this._step)
  24466. ) {
  24467. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  24468. if (step) {
  24469. // TODO If stacked series is not step
  24470. points = turnPointsIntoStep(points, coordSys, step);
  24471. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  24472. }
  24473. polyline = this._newPolyline(points, coordSys, hasAnimation);
  24474. if (isAreaChart) {
  24475. polygon = this._newPolygon(
  24476. points, stackedOnPoints,
  24477. coordSys, hasAnimation
  24478. );
  24479. }
  24480. lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel));
  24481. }
  24482. else {
  24483. if (isAreaChart && !polygon) {
  24484. // If areaStyle is added
  24485. polygon = this._newPolygon(
  24486. points, stackedOnPoints,
  24487. coordSys, hasAnimation
  24488. );
  24489. }
  24490. else if (polygon && !isAreaChart) {
  24491. // If areaStyle is removed
  24492. lineGroup.remove(polygon);
  24493. polygon = this._polygon = null;
  24494. }
  24495. // Update clipPath
  24496. lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel));
  24497. // Always update, or it is wrong in the case turning on legend
  24498. // because points are not changed
  24499. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  24500. // Stop symbol animation and sync with line points
  24501. // FIXME performance?
  24502. data.eachItemGraphicEl(function (el) {
  24503. el.stopAnimation(true);
  24504. });
  24505. // In the case data zoom triggerred refreshing frequently
  24506. // Data may not change if line has a category axis. So it should animate nothing
  24507. if (!isPointsSame(this._stackedOnPoints, stackedOnPoints)
  24508. || !isPointsSame(this._points, points)
  24509. ) {
  24510. if (hasAnimation) {
  24511. this._updateAnimation(
  24512. data, stackedOnPoints, coordSys, api, step
  24513. );
  24514. }
  24515. else {
  24516. // Not do it in update with animation
  24517. if (step) {
  24518. // TODO If stacked series is not step
  24519. points = turnPointsIntoStep(points, coordSys, step);
  24520. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  24521. }
  24522. polyline.setShape({
  24523. points: points
  24524. });
  24525. polygon && polygon.setShape({
  24526. points: points,
  24527. stackedOnPoints: stackedOnPoints
  24528. });
  24529. }
  24530. }
  24531. }
  24532. var visualColor = getVisualGradient(data, coordSys) || data.getVisual('color');
  24533. polyline.useStyle(zrUtil.defaults(
  24534. // Use color in lineStyle first
  24535. lineStyleModel.getLineStyle(),
  24536. {
  24537. fill: 'none',
  24538. stroke: visualColor,
  24539. lineJoin: 'bevel'
  24540. }
  24541. ));
  24542. var smooth = seriesModel.get('smooth');
  24543. smooth = getSmooth(seriesModel.get('smooth'));
  24544. polyline.setShape({
  24545. smooth: smooth,
  24546. smoothMonotone: seriesModel.get('smoothMonotone'),
  24547. connectNulls: seriesModel.get('connectNulls')
  24548. });
  24549. if (polygon) {
  24550. var stackedOn = data.stackedOn;
  24551. var stackedOnSmooth = 0;
  24552. polygon.useStyle(zrUtil.defaults(
  24553. areaStyleModel.getAreaStyle(),
  24554. {
  24555. fill: visualColor,
  24556. opacity: 0.7,
  24557. lineJoin: 'bevel'
  24558. }
  24559. ));
  24560. if (stackedOn) {
  24561. var stackedOnSeries = stackedOn.hostModel;
  24562. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'));
  24563. }
  24564. polygon.setShape({
  24565. smooth: smooth,
  24566. stackedOnSmooth: stackedOnSmooth,
  24567. smoothMonotone: seriesModel.get('smoothMonotone'),
  24568. connectNulls: seriesModel.get('connectNulls')
  24569. });
  24570. }
  24571. this._data = data;
  24572. // Save the coordinate system for transition animation when data changed
  24573. this._coordSys = coordSys;
  24574. this._stackedOnPoints = stackedOnPoints;
  24575. this._points = points;
  24576. this._step = step;
  24577. },
  24578. dispose: function () {},
  24579. highlight: function (seriesModel, ecModel, api, payload) {
  24580. var data = seriesModel.getData();
  24581. var dataIndex = modelUtil.queryDataIndex(data, payload);
  24582. if (!(dataIndex instanceof Array) && dataIndex != null && dataIndex >= 0) {
  24583. var symbol = data.getItemGraphicEl(dataIndex);
  24584. if (!symbol) {
  24585. // Create a temporary symbol if it is not exists
  24586. var pt = data.getItemLayout(dataIndex);
  24587. if (!pt) {
  24588. // Null data
  24589. return;
  24590. }
  24591. symbol = new Symbol(data, dataIndex);
  24592. symbol.position = pt;
  24593. symbol.setZ(
  24594. seriesModel.get('zlevel'),
  24595. seriesModel.get('z')
  24596. );
  24597. symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]);
  24598. symbol.__temp = true;
  24599. data.setItemGraphicEl(dataIndex, symbol);
  24600. // Stop scale animation
  24601. symbol.stopSymbolAnimation(true);
  24602. this.group.add(symbol);
  24603. }
  24604. symbol.highlight();
  24605. }
  24606. else {
  24607. // Highlight whole series
  24608. ChartView.prototype.highlight.call(
  24609. this, seriesModel, ecModel, api, payload
  24610. );
  24611. }
  24612. },
  24613. downplay: function (seriesModel, ecModel, api, payload) {
  24614. var data = seriesModel.getData();
  24615. var dataIndex = modelUtil.queryDataIndex(data, payload);
  24616. if (dataIndex != null && dataIndex >= 0) {
  24617. var symbol = data.getItemGraphicEl(dataIndex);
  24618. if (symbol) {
  24619. if (symbol.__temp) {
  24620. data.setItemGraphicEl(dataIndex, null);
  24621. this.group.remove(symbol);
  24622. }
  24623. else {
  24624. symbol.downplay();
  24625. }
  24626. }
  24627. }
  24628. else {
  24629. // FIXME
  24630. // can not downplay completely.
  24631. // Downplay whole series
  24632. ChartView.prototype.downplay.call(
  24633. this, seriesModel, ecModel, api, payload
  24634. );
  24635. }
  24636. },
  24637. /**
  24638. * @param {module:zrender/container/Group} group
  24639. * @param {Array.<Array.<number>>} points
  24640. * @private
  24641. */
  24642. _newPolyline: function (points) {
  24643. var polyline = this._polyline;
  24644. // Remove previous created polyline
  24645. if (polyline) {
  24646. this._lineGroup.remove(polyline);
  24647. }
  24648. polyline = new polyHelper.Polyline({
  24649. shape: {
  24650. points: points
  24651. },
  24652. silent: true,
  24653. z2: 10
  24654. });
  24655. this._lineGroup.add(polyline);
  24656. this._polyline = polyline;
  24657. return polyline;
  24658. },
  24659. /**
  24660. * @param {module:zrender/container/Group} group
  24661. * @param {Array.<Array.<number>>} stackedOnPoints
  24662. * @param {Array.<Array.<number>>} points
  24663. * @private
  24664. */
  24665. _newPolygon: function (points, stackedOnPoints) {
  24666. var polygon = this._polygon;
  24667. // Remove previous created polygon
  24668. if (polygon) {
  24669. this._lineGroup.remove(polygon);
  24670. }
  24671. polygon = new polyHelper.Polygon({
  24672. shape: {
  24673. points: points,
  24674. stackedOnPoints: stackedOnPoints
  24675. },
  24676. silent: true
  24677. });
  24678. this._lineGroup.add(polygon);
  24679. this._polygon = polygon;
  24680. return polygon;
  24681. },
  24682. /**
  24683. * @private
  24684. */
  24685. _getSymbolIgnoreFunc: function (data, coordSys) {
  24686. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  24687. // `getLabelInterval` is provided by echarts/component/axis
  24688. if (categoryAxis && categoryAxis.isLabelIgnored) {
  24689. return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis);
  24690. }
  24691. },
  24692. /**
  24693. * @private
  24694. */
  24695. // FIXME Two value axis
  24696. _updateAnimation: function (data, stackedOnPoints, coordSys, api, step) {
  24697. var polyline = this._polyline;
  24698. var polygon = this._polygon;
  24699. var seriesModel = data.hostModel;
  24700. var diff = lineAnimationDiff(
  24701. this._data, data,
  24702. this._stackedOnPoints, stackedOnPoints,
  24703. this._coordSys, coordSys
  24704. );
  24705. var current = diff.current;
  24706. var stackedOnCurrent = diff.stackedOnCurrent;
  24707. var next = diff.next;
  24708. var stackedOnNext = diff.stackedOnNext;
  24709. if (step) {
  24710. // TODO If stacked series is not step
  24711. current = turnPointsIntoStep(diff.current, coordSys, step);
  24712. stackedOnCurrent = turnPointsIntoStep(diff.stackedOnCurrent, coordSys, step);
  24713. next = turnPointsIntoStep(diff.next, coordSys, step);
  24714. stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step);
  24715. }
  24716. // `diff.current` is subset of `current` (which should be ensured by
  24717. // turnPointsIntoStep), so points in `__points` can be updated when
  24718. // points in `current` are update during animation.
  24719. polyline.shape.__points = diff.current;
  24720. polyline.shape.points = current;
  24721. graphic.updateProps(polyline, {
  24722. shape: {
  24723. points: next
  24724. }
  24725. }, seriesModel);
  24726. if (polygon) {
  24727. polygon.setShape({
  24728. points: current,
  24729. stackedOnPoints: stackedOnCurrent
  24730. });
  24731. graphic.updateProps(polygon, {
  24732. shape: {
  24733. points: next,
  24734. stackedOnPoints: stackedOnNext
  24735. }
  24736. }, seriesModel);
  24737. }
  24738. var updatedDataInfo = [];
  24739. var diffStatus = diff.status;
  24740. for (var i = 0; i < diffStatus.length; i++) {
  24741. var cmd = diffStatus[i].cmd;
  24742. if (cmd === '=') {
  24743. var el = data.getItemGraphicEl(diffStatus[i].idx1);
  24744. if (el) {
  24745. updatedDataInfo.push({
  24746. el: el,
  24747. ptIdx: i // Index of points
  24748. });
  24749. }
  24750. }
  24751. }
  24752. if (polyline.animators && polyline.animators.length) {
  24753. polyline.animators[0].during(function () {
  24754. for (var i = 0; i < updatedDataInfo.length; i++) {
  24755. var el = updatedDataInfo[i].el;
  24756. el.attr('position', polyline.shape.__points[updatedDataInfo[i].ptIdx]);
  24757. }
  24758. });
  24759. }
  24760. },
  24761. remove: function (ecModel) {
  24762. var group = this.group;
  24763. var oldData = this._data;
  24764. this._lineGroup.removeAll();
  24765. this._symbolDraw.remove(true);
  24766. // Remove temporary created elements when highlighting
  24767. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  24768. if (el.__temp) {
  24769. group.remove(el);
  24770. oldData.setItemGraphicEl(idx, null);
  24771. }
  24772. });
  24773. this._polyline =
  24774. this._polygon =
  24775. this._coordSys =
  24776. this._points =
  24777. this._stackedOnPoints =
  24778. this._data = null;
  24779. }
  24780. });
  24781. /***/ }),
  24782. /* 119 */
  24783. /***/ (function(module, exports, __webpack_require__) {
  24784. /**
  24785. * @module echarts/chart/helper/SymbolDraw
  24786. */
  24787. var graphic = __webpack_require__(20);
  24788. var Symbol = __webpack_require__(120);
  24789. /**
  24790. * @constructor
  24791. * @alias module:echarts/chart/helper/SymbolDraw
  24792. * @param {module:zrender/graphic/Group} [symbolCtor]
  24793. */
  24794. function SymbolDraw(symbolCtor) {
  24795. this.group = new graphic.Group();
  24796. this._symbolCtor = symbolCtor || Symbol;
  24797. }
  24798. var symbolDrawProto = SymbolDraw.prototype;
  24799. function symbolNeedsDraw(data, idx, isIgnore) {
  24800. var point = data.getItemLayout(idx);
  24801. // Is an object
  24802. // if (point && point.hasOwnProperty('point')) {
  24803. // point = point.point;
  24804. // }
  24805. return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx))
  24806. && data.getItemVisual(idx, 'symbol') !== 'none';
  24807. }
  24808. /**
  24809. * Update symbols draw by new data
  24810. * @param {module:echarts/data/List} data
  24811. * @param {Array.<boolean>} [isIgnore]
  24812. */
  24813. symbolDrawProto.updateData = function (data, isIgnore) {
  24814. var group = this.group;
  24815. var seriesModel = data.hostModel;
  24816. var oldData = this._data;
  24817. var SymbolCtor = this._symbolCtor;
  24818. var seriesScope = {
  24819. itemStyle: seriesModel.getModel('itemStyle.normal').getItemStyle(['color']),
  24820. hoverItemStyle: seriesModel.getModel('itemStyle.emphasis').getItemStyle(),
  24821. symbolRotate: seriesModel.get('symbolRotate'),
  24822. symbolOffset: seriesModel.get('symbolOffset'),
  24823. hoverAnimation: seriesModel.get('hoverAnimation'),
  24824. labelModel: seriesModel.getModel('label.normal'),
  24825. hoverLabelModel: seriesModel.getModel('label.emphasis'),
  24826. cursorStyle: seriesModel.get('cursor')
  24827. };
  24828. data.diff(oldData)
  24829. .add(function (newIdx) {
  24830. var point = data.getItemLayout(newIdx);
  24831. if (symbolNeedsDraw(data, newIdx, isIgnore)) {
  24832. var symbolEl = new SymbolCtor(data, newIdx, seriesScope);
  24833. symbolEl.attr('position', point);
  24834. data.setItemGraphicEl(newIdx, symbolEl);
  24835. group.add(symbolEl);
  24836. }
  24837. })
  24838. .update(function (newIdx, oldIdx) {
  24839. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  24840. var point = data.getItemLayout(newIdx);
  24841. if (!symbolNeedsDraw(data, newIdx, isIgnore)) {
  24842. group.remove(symbolEl);
  24843. return;
  24844. }
  24845. if (!symbolEl) {
  24846. symbolEl = new SymbolCtor(data, newIdx);
  24847. symbolEl.attr('position', point);
  24848. }
  24849. else {
  24850. symbolEl.updateData(data, newIdx, seriesScope);
  24851. graphic.updateProps(symbolEl, {
  24852. position: point
  24853. }, seriesModel);
  24854. }
  24855. // Add back
  24856. group.add(symbolEl);
  24857. data.setItemGraphicEl(newIdx, symbolEl);
  24858. })
  24859. .remove(function (oldIdx) {
  24860. var el = oldData.getItemGraphicEl(oldIdx);
  24861. el && el.fadeOut(function () {
  24862. group.remove(el);
  24863. });
  24864. })
  24865. .execute();
  24866. this._data = data;
  24867. };
  24868. symbolDrawProto.updateLayout = function () {
  24869. var data = this._data;
  24870. if (data) {
  24871. // Not use animation
  24872. data.eachItemGraphicEl(function (el, idx) {
  24873. var point = data.getItemLayout(idx);
  24874. el.attr('position', point);
  24875. });
  24876. }
  24877. };
  24878. symbolDrawProto.remove = function (enableAnimation) {
  24879. var group = this.group;
  24880. var data = this._data;
  24881. if (data) {
  24882. if (enableAnimation) {
  24883. data.eachItemGraphicEl(function (el) {
  24884. el.fadeOut(function () {
  24885. group.remove(el);
  24886. });
  24887. });
  24888. }
  24889. else {
  24890. group.removeAll();
  24891. }
  24892. }
  24893. };
  24894. module.exports = SymbolDraw;
  24895. /***/ }),
  24896. /* 120 */
  24897. /***/ (function(module, exports, __webpack_require__) {
  24898. /**
  24899. * @module echarts/chart/helper/Symbol
  24900. */
  24901. var zrUtil = __webpack_require__(4);
  24902. var symbolUtil = __webpack_require__(114);
  24903. var graphic = __webpack_require__(20);
  24904. var numberUtil = __webpack_require__(7);
  24905. var labelHelper = __webpack_require__(121);
  24906. function getSymbolSize(data, idx) {
  24907. var symbolSize = data.getItemVisual(idx, 'symbolSize');
  24908. return symbolSize instanceof Array
  24909. ? symbolSize.slice()
  24910. : [+symbolSize, +symbolSize];
  24911. }
  24912. function getScale(symbolSize) {
  24913. return [symbolSize[0] / 2, symbolSize[1] / 2];
  24914. }
  24915. /**
  24916. * @constructor
  24917. * @alias {module:echarts/chart/helper/Symbol}
  24918. * @param {module:echarts/data/List} data
  24919. * @param {number} idx
  24920. * @extends {module:zrender/graphic/Group}
  24921. */
  24922. function Symbol(data, idx, seriesScope) {
  24923. graphic.Group.call(this);
  24924. this.updateData(data, idx, seriesScope);
  24925. }
  24926. var symbolProto = Symbol.prototype;
  24927. function driftSymbol(dx, dy) {
  24928. this.parent.drift(dx, dy);
  24929. }
  24930. symbolProto._createSymbol = function (symbolType, data, idx, symbolSize) {
  24931. // Remove paths created before
  24932. this.removeAll();
  24933. var seriesModel = data.hostModel;
  24934. var color = data.getItemVisual(idx, 'color');
  24935. // var symbolPath = symbolUtil.createSymbol(
  24936. // symbolType, -0.5, -0.5, 1, 1, color
  24937. // );
  24938. // If width/height are set too small (e.g., set to 1) on ios10
  24939. // and macOS Sierra, a circle stroke become a rect, no matter what
  24940. // the scale is set. So we set width/height as 2. See #4150.
  24941. var symbolPath = symbolUtil.createSymbol(
  24942. symbolType, -1, -1, 2, 2, color
  24943. );
  24944. symbolPath.attr({
  24945. z2: 100,
  24946. culling: true,
  24947. scale: [0, 0]
  24948. });
  24949. // Rewrite drift method
  24950. symbolPath.drift = driftSymbol;
  24951. graphic.initProps(symbolPath, {
  24952. scale: getScale(symbolSize)
  24953. }, seriesModel, idx);
  24954. this._symbolType = symbolType;
  24955. this.add(symbolPath);
  24956. };
  24957. /**
  24958. * Stop animation
  24959. * @param {boolean} toLastFrame
  24960. */
  24961. symbolProto.stopSymbolAnimation = function (toLastFrame) {
  24962. this.childAt(0).stopAnimation(toLastFrame);
  24963. };
  24964. /**
  24965. * Get symbol path element
  24966. */
  24967. symbolProto.getSymbolPath = function () {
  24968. return this.childAt(0);
  24969. };
  24970. /**
  24971. * Get scale(aka, current symbol size).
  24972. * Including the change caused by animation
  24973. */
  24974. symbolProto.getScale = function () {
  24975. return this.childAt(0).scale;
  24976. };
  24977. /**
  24978. * Highlight symbol
  24979. */
  24980. symbolProto.highlight = function () {
  24981. this.childAt(0).trigger('emphasis');
  24982. };
  24983. /**
  24984. * Downplay symbol
  24985. */
  24986. symbolProto.downplay = function () {
  24987. this.childAt(0).trigger('normal');
  24988. };
  24989. /**
  24990. * @param {number} zlevel
  24991. * @param {number} z
  24992. */
  24993. symbolProto.setZ = function (zlevel, z) {
  24994. var symbolPath = this.childAt(0);
  24995. symbolPath.zlevel = zlevel;
  24996. symbolPath.z = z;
  24997. };
  24998. symbolProto.setDraggable = function (draggable) {
  24999. var symbolPath = this.childAt(0);
  25000. symbolPath.draggable = draggable;
  25001. symbolPath.cursor = draggable ? 'move' : 'pointer';
  25002. };
  25003. /**
  25004. * Update symbol properties
  25005. * @param {module:echarts/data/List} data
  25006. * @param {number} idx
  25007. */
  25008. symbolProto.updateData = function (data, idx, seriesScope) {
  25009. this.silent = false;
  25010. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  25011. var seriesModel = data.hostModel;
  25012. var symbolSize = getSymbolSize(data, idx);
  25013. if (symbolType !== this._symbolType) {
  25014. this._createSymbol(symbolType, data, idx, symbolSize);
  25015. }
  25016. else {
  25017. var symbolPath = this.childAt(0);
  25018. symbolPath.silent = false;
  25019. graphic.updateProps(symbolPath, {
  25020. scale: getScale(symbolSize)
  25021. }, seriesModel, idx);
  25022. }
  25023. this._updateCommon(data, idx, symbolSize, seriesScope);
  25024. this._seriesModel = seriesModel;
  25025. };
  25026. // Update common properties
  25027. var normalStyleAccessPath = ['itemStyle', 'normal'];
  25028. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  25029. var normalLabelAccessPath = ['label', 'normal'];
  25030. var emphasisLabelAccessPath = ['label', 'emphasis'];
  25031. symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
  25032. var symbolPath = this.childAt(0);
  25033. var seriesModel = data.hostModel;
  25034. var color = data.getItemVisual(idx, 'color');
  25035. // Reset style
  25036. if (symbolPath.type !== 'image') {
  25037. symbolPath.useStyle({
  25038. strokeNoScale: true
  25039. });
  25040. }
  25041. seriesScope = seriesScope || null;
  25042. var itemStyle = seriesScope && seriesScope.itemStyle;
  25043. var hoverItemStyle = seriesScope && seriesScope.hoverItemStyle;
  25044. var symbolRotate = seriesScope && seriesScope.symbolRotate;
  25045. var symbolOffset = seriesScope && seriesScope.symbolOffset;
  25046. var labelModel = seriesScope && seriesScope.labelModel;
  25047. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  25048. var hoverAnimation = seriesScope && seriesScope.hoverAnimation;
  25049. var cursorStyle = seriesScope && seriesScope.cursorStyle;
  25050. if (!seriesScope || data.hasItemOption) {
  25051. var itemModel = data.getItemModel(idx);
  25052. // Color must be excluded.
  25053. // Because symbol provide setColor individually to set fill and stroke
  25054. itemStyle = itemModel.getModel(normalStyleAccessPath).getItemStyle(['color']);
  25055. hoverItemStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  25056. symbolRotate = itemModel.getShallow('symbolRotate');
  25057. symbolOffset = itemModel.getShallow('symbolOffset');
  25058. labelModel = itemModel.getModel(normalLabelAccessPath);
  25059. hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath);
  25060. hoverAnimation = itemModel.getShallow('hoverAnimation');
  25061. cursorStyle = itemModel.getShallow('cursor');
  25062. }
  25063. else {
  25064. hoverItemStyle = zrUtil.extend({}, hoverItemStyle);
  25065. }
  25066. var elStyle = symbolPath.style;
  25067. symbolPath.attr('rotation', (symbolRotate || 0) * Math.PI / 180 || 0);
  25068. if (symbolOffset) {
  25069. symbolPath.attr('position', [
  25070. numberUtil.parsePercent(symbolOffset[0], symbolSize[0]),
  25071. numberUtil.parsePercent(symbolOffset[1], symbolSize[1])
  25072. ]);
  25073. }
  25074. cursorStyle && symbolPath.attr('cursor', cursorStyle);
  25075. // PENDING setColor before setStyle!!!
  25076. symbolPath.setColor(color);
  25077. symbolPath.setStyle(itemStyle);
  25078. var opacity = data.getItemVisual(idx, 'opacity');
  25079. if (opacity != null) {
  25080. elStyle.opacity = opacity;
  25081. }
  25082. var valueDim = labelHelper.findLabelValueDim(data);
  25083. if (valueDim != null) {
  25084. graphic.setLabelStyle(
  25085. elStyle, hoverItemStyle, labelModel, hoverLabelModel,
  25086. {
  25087. labelFetcher: seriesModel,
  25088. labelDataIndex: idx,
  25089. defaultText: data.get(valueDim, idx),
  25090. isRectText: true,
  25091. autoColor: color
  25092. }
  25093. );
  25094. }
  25095. symbolPath.off('mouseover')
  25096. .off('mouseout')
  25097. .off('emphasis')
  25098. .off('normal');
  25099. symbolPath.hoverStyle = hoverItemStyle;
  25100. // FIXME
  25101. // Do not use symbol.trigger('emphasis'), but use symbol.highlight() instead.
  25102. graphic.setHoverStyle(symbolPath);
  25103. var scale = getScale(symbolSize);
  25104. if (hoverAnimation && seriesModel.isAnimationEnabled()) {
  25105. var onEmphasis = function() {
  25106. var ratio = scale[1] / scale[0];
  25107. this.animateTo({
  25108. scale: [
  25109. Math.max(scale[0] * 1.1, scale[0] + 3),
  25110. Math.max(scale[1] * 1.1, scale[1] + 3 * ratio)
  25111. ]
  25112. }, 400, 'elasticOut');
  25113. };
  25114. var onNormal = function() {
  25115. this.animateTo({
  25116. scale: scale
  25117. }, 400, 'elasticOut');
  25118. };
  25119. symbolPath.on('mouseover', onEmphasis)
  25120. .on('mouseout', onNormal)
  25121. .on('emphasis', onEmphasis)
  25122. .on('normal', onNormal);
  25123. }
  25124. };
  25125. symbolProto.fadeOut = function (cb) {
  25126. var symbolPath = this.childAt(0);
  25127. // Avoid mistaken hover when fading out
  25128. this.silent = symbolPath.silent = true;
  25129. // Not show text when animating
  25130. symbolPath.style.text = null;
  25131. graphic.updateProps(symbolPath, {
  25132. scale: [0, 0]
  25133. }, this._seriesModel, this.dataIndex, cb);
  25134. };
  25135. zrUtil.inherits(Symbol, graphic.Group);
  25136. module.exports = Symbol;
  25137. /***/ }),
  25138. /* 121 */
  25139. /***/ (function(module, exports, __webpack_require__) {
  25140. /**
  25141. * @module echarts/chart/helper/Symbol
  25142. */
  25143. var modelUtil = __webpack_require__(5);
  25144. var helper = {};
  25145. helper.findLabelValueDim = function (data) {
  25146. var valueDim;
  25147. var labelDims = modelUtil.otherDimToDataDim(data, 'label');
  25148. if (labelDims.length) {
  25149. valueDim = labelDims[0];
  25150. }
  25151. else {
  25152. // Get last value dim
  25153. var dimensions = data.dimensions.slice();
  25154. var dataType;
  25155. while (dimensions.length && (
  25156. valueDim = dimensions.pop(),
  25157. dataType = data.getDimensionInfo(valueDim).type,
  25158. dataType === 'ordinal' || dataType === 'time'
  25159. )) {} // jshint ignore:line
  25160. }
  25161. return valueDim;
  25162. };
  25163. module.exports = helper;
  25164. /***/ }),
  25165. /* 122 */
  25166. /***/ (function(module, exports) {
  25167. // var arrayDiff = require('zrender/lib/core/arrayDiff');
  25168. // 'zrender/core/arrayDiff' has been used before, but it did
  25169. // not do well in performance when roam with fixed dataZoom window.
  25170. function sign(val) {
  25171. return val >= 0 ? 1 : -1;
  25172. }
  25173. function getStackedOnPoint(coordSys, data, idx) {
  25174. var baseAxis = coordSys.getBaseAxis();
  25175. var valueAxis = coordSys.getOtherAxis(baseAxis);
  25176. var valueStart = baseAxis.onZero
  25177. ? 0 : valueAxis.scale.getExtent()[0];
  25178. var valueDim = valueAxis.dim;
  25179. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  25180. var stackedOnSameSign;
  25181. var stackedOn = data.stackedOn;
  25182. var val = data.get(valueDim, idx);
  25183. // Find first stacked value with same sign
  25184. while (stackedOn &&
  25185. sign(stackedOn.get(valueDim, idx)) === sign(val)
  25186. ) {
  25187. stackedOnSameSign = stackedOn;
  25188. break;
  25189. }
  25190. var stackedData = [];
  25191. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  25192. stackedData[1 - baseDataOffset] = stackedOnSameSign
  25193. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  25194. return coordSys.dataToPoint(stackedData);
  25195. }
  25196. // function convertToIntId(newIdList, oldIdList) {
  25197. // // Generate int id instead of string id.
  25198. // // Compare string maybe slow in score function of arrDiff
  25199. // // Assume id in idList are all unique
  25200. // var idIndicesMap = {};
  25201. // var idx = 0;
  25202. // for (var i = 0; i < newIdList.length; i++) {
  25203. // idIndicesMap[newIdList[i]] = idx;
  25204. // newIdList[i] = idx++;
  25205. // }
  25206. // for (var i = 0; i < oldIdList.length; i++) {
  25207. // var oldId = oldIdList[i];
  25208. // // Same with newIdList
  25209. // if (idIndicesMap[oldId]) {
  25210. // oldIdList[i] = idIndicesMap[oldId];
  25211. // }
  25212. // else {
  25213. // oldIdList[i] = idx++;
  25214. // }
  25215. // }
  25216. // }
  25217. function diffData(oldData, newData) {
  25218. var diffResult = [];
  25219. newData.diff(oldData)
  25220. .add(function (idx) {
  25221. diffResult.push({cmd: '+', idx: idx});
  25222. })
  25223. .update(function (newIdx, oldIdx) {
  25224. diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx});
  25225. })
  25226. .remove(function (idx) {
  25227. diffResult.push({cmd: '-', idx: idx});
  25228. })
  25229. .execute();
  25230. return diffResult;
  25231. }
  25232. module.exports = function (
  25233. oldData, newData,
  25234. oldStackedOnPoints, newStackedOnPoints,
  25235. oldCoordSys, newCoordSys
  25236. ) {
  25237. var diff = diffData(oldData, newData);
  25238. // var newIdList = newData.mapArray(newData.getId);
  25239. // var oldIdList = oldData.mapArray(oldData.getId);
  25240. // convertToIntId(newIdList, oldIdList);
  25241. // // FIXME One data ?
  25242. // diff = arrayDiff(oldIdList, newIdList);
  25243. var currPoints = [];
  25244. var nextPoints = [];
  25245. // Points for stacking base line
  25246. var currStackedPoints = [];
  25247. var nextStackedPoints = [];
  25248. var status = [];
  25249. var sortedIndices = [];
  25250. var rawIndices = [];
  25251. var dims = newCoordSys.dimensions;
  25252. for (var i = 0; i < diff.length; i++) {
  25253. var diffItem = diff[i];
  25254. var pointAdded = true;
  25255. // FIXME, animation is not so perfect when dataZoom window moves fast
  25256. // Which is in case remvoing or add more than one data in the tail or head
  25257. switch (diffItem.cmd) {
  25258. case '=':
  25259. var currentPt = oldData.getItemLayout(diffItem.idx);
  25260. var nextPt = newData.getItemLayout(diffItem.idx1);
  25261. // If previous data is NaN, use next point directly
  25262. if (isNaN(currentPt[0]) || isNaN(currentPt[1])) {
  25263. currentPt = nextPt.slice();
  25264. }
  25265. currPoints.push(currentPt);
  25266. nextPoints.push(nextPt);
  25267. currStackedPoints.push(oldStackedOnPoints[diffItem.idx]);
  25268. nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]);
  25269. rawIndices.push(newData.getRawIndex(diffItem.idx1));
  25270. break;
  25271. case '+':
  25272. var idx = diffItem.idx;
  25273. currPoints.push(
  25274. oldCoordSys.dataToPoint([
  25275. newData.get(dims[0], idx, true), newData.get(dims[1], idx, true)
  25276. ])
  25277. );
  25278. nextPoints.push(newData.getItemLayout(idx).slice());
  25279. currStackedPoints.push(
  25280. getStackedOnPoint(oldCoordSys, newData, idx)
  25281. );
  25282. nextStackedPoints.push(newStackedOnPoints[idx]);
  25283. rawIndices.push(newData.getRawIndex(idx));
  25284. break;
  25285. case '-':
  25286. var idx = diffItem.idx;
  25287. var rawIndex = oldData.getRawIndex(idx);
  25288. // Data is replaced. In the case of dynamic data queue
  25289. // FIXME FIXME FIXME
  25290. if (rawIndex !== idx) {
  25291. currPoints.push(oldData.getItemLayout(idx));
  25292. nextPoints.push(newCoordSys.dataToPoint([
  25293. oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true)
  25294. ]));
  25295. currStackedPoints.push(oldStackedOnPoints[idx]);
  25296. nextStackedPoints.push(
  25297. getStackedOnPoint(
  25298. newCoordSys, oldData, idx
  25299. )
  25300. );
  25301. rawIndices.push(rawIndex);
  25302. }
  25303. else {
  25304. pointAdded = false;
  25305. }
  25306. }
  25307. // Original indices
  25308. if (pointAdded) {
  25309. status.push(diffItem);
  25310. sortedIndices.push(sortedIndices.length);
  25311. }
  25312. }
  25313. // Diff result may be crossed if all items are changed
  25314. // Sort by data index
  25315. sortedIndices.sort(function (a, b) {
  25316. return rawIndices[a] - rawIndices[b];
  25317. });
  25318. var sortedCurrPoints = [];
  25319. var sortedNextPoints = [];
  25320. var sortedCurrStackedPoints = [];
  25321. var sortedNextStackedPoints = [];
  25322. var sortedStatus = [];
  25323. for (var i = 0; i < sortedIndices.length; i++) {
  25324. var idx = sortedIndices[i];
  25325. sortedCurrPoints[i] = currPoints[idx];
  25326. sortedNextPoints[i] = nextPoints[idx];
  25327. sortedCurrStackedPoints[i] = currStackedPoints[idx];
  25328. sortedNextStackedPoints[i] = nextStackedPoints[idx];
  25329. sortedStatus[i] = status[idx];
  25330. }
  25331. return {
  25332. current: sortedCurrPoints,
  25333. next: sortedNextPoints,
  25334. stackedOnCurrent: sortedCurrStackedPoints,
  25335. stackedOnNext: sortedNextStackedPoints,
  25336. status: sortedStatus
  25337. };
  25338. };
  25339. /***/ }),
  25340. /* 123 */
  25341. /***/ (function(module, exports, __webpack_require__) {
  25342. // Poly path support NaN point
  25343. var Path = __webpack_require__(22);
  25344. var vec2 = __webpack_require__(10);
  25345. var fixClipWithShadow = __webpack_require__(56);
  25346. var vec2Min = vec2.min;
  25347. var vec2Max = vec2.max;
  25348. var scaleAndAdd = vec2.scaleAndAdd;
  25349. var v2Copy = vec2.copy;
  25350. // Temporary variable
  25351. var v = [];
  25352. var cp0 = [];
  25353. var cp1 = [];
  25354. function isPointNull(p) {
  25355. return isNaN(p[0]) || isNaN(p[1]);
  25356. }
  25357. function drawSegment(
  25358. ctx, points, start, segLen, allLen,
  25359. dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
  25360. ) {
  25361. var prevIdx = 0;
  25362. var idx = start;
  25363. for (var k = 0; k < segLen; k++) {
  25364. var p = points[idx];
  25365. if (idx >= allLen || idx < 0) {
  25366. break;
  25367. }
  25368. if (isPointNull(p)) {
  25369. if (connectNulls) {
  25370. idx += dir;
  25371. continue;
  25372. }
  25373. break;
  25374. }
  25375. if (idx === start) {
  25376. ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
  25377. v2Copy(cp0, p);
  25378. }
  25379. else {
  25380. if (smooth > 0) {
  25381. var nextIdx = idx + dir;
  25382. var nextP = points[nextIdx];
  25383. if (connectNulls) {
  25384. // Find next point not null
  25385. while (nextP && isPointNull(points[nextIdx])) {
  25386. nextIdx += dir;
  25387. nextP = points[nextIdx];
  25388. }
  25389. }
  25390. var ratioNextSeg = 0.5;
  25391. var prevP = points[prevIdx];
  25392. var nextP = points[nextIdx];
  25393. // Last point
  25394. if (!nextP || isPointNull(nextP)) {
  25395. v2Copy(cp1, p);
  25396. }
  25397. else {
  25398. // If next data is null in not connect case
  25399. if (isPointNull(nextP) && !connectNulls) {
  25400. nextP = p;
  25401. }
  25402. vec2.sub(v, nextP, prevP);
  25403. var lenPrevSeg;
  25404. var lenNextSeg;
  25405. if (smoothMonotone === 'x' || smoothMonotone === 'y') {
  25406. var dim = smoothMonotone === 'x' ? 0 : 1;
  25407. lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
  25408. lenNextSeg = Math.abs(p[dim] - nextP[dim]);
  25409. }
  25410. else {
  25411. lenPrevSeg = vec2.dist(p, prevP);
  25412. lenNextSeg = vec2.dist(p, nextP);
  25413. }
  25414. // Use ratio of seg length
  25415. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
  25416. scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg));
  25417. }
  25418. // Smooth constraint
  25419. vec2Min(cp0, cp0, smoothMax);
  25420. vec2Max(cp0, cp0, smoothMin);
  25421. vec2Min(cp1, cp1, smoothMax);
  25422. vec2Max(cp1, cp1, smoothMin);
  25423. ctx.bezierCurveTo(
  25424. cp0[0], cp0[1],
  25425. cp1[0], cp1[1],
  25426. p[0], p[1]
  25427. );
  25428. // cp0 of next segment
  25429. scaleAndAdd(cp0, p, v, smooth * ratioNextSeg);
  25430. }
  25431. else {
  25432. ctx.lineTo(p[0], p[1]);
  25433. }
  25434. }
  25435. prevIdx = idx;
  25436. idx += dir;
  25437. }
  25438. return k;
  25439. }
  25440. function getBoundingBox(points, smoothConstraint) {
  25441. var ptMin = [Infinity, Infinity];
  25442. var ptMax = [-Infinity, -Infinity];
  25443. if (smoothConstraint) {
  25444. for (var i = 0; i < points.length; i++) {
  25445. var pt = points[i];
  25446. if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; }
  25447. if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; }
  25448. if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; }
  25449. if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; }
  25450. }
  25451. }
  25452. return {
  25453. min: smoothConstraint ? ptMin : ptMax,
  25454. max: smoothConstraint ? ptMax : ptMin
  25455. };
  25456. }
  25457. module.exports = {
  25458. Polyline: Path.extend({
  25459. type: 'ec-polyline',
  25460. shape: {
  25461. points: [],
  25462. smooth: 0,
  25463. smoothConstraint: true,
  25464. smoothMonotone: null,
  25465. connectNulls: false
  25466. },
  25467. style: {
  25468. fill: null,
  25469. stroke: '#000'
  25470. },
  25471. brush: fixClipWithShadow(Path.prototype.brush),
  25472. buildPath: function (ctx, shape) {
  25473. var points = shape.points;
  25474. var i = 0;
  25475. var len = points.length;
  25476. var result = getBoundingBox(points, shape.smoothConstraint);
  25477. if (shape.connectNulls) {
  25478. // Must remove first and last null values avoid draw error in polygon
  25479. for (; len > 0; len--) {
  25480. if (!isPointNull(points[len - 1])) {
  25481. break;
  25482. }
  25483. }
  25484. for (; i < len; i++) {
  25485. if (!isPointNull(points[i])) {
  25486. break;
  25487. }
  25488. }
  25489. }
  25490. while (i < len) {
  25491. i += drawSegment(
  25492. ctx, points, i, len, len,
  25493. 1, result.min, result.max, shape.smooth,
  25494. shape.smoothMonotone, shape.connectNulls
  25495. ) + 1;
  25496. }
  25497. }
  25498. }),
  25499. Polygon: Path.extend({
  25500. type: 'ec-polygon',
  25501. shape: {
  25502. points: [],
  25503. // Offset between stacked base points and points
  25504. stackedOnPoints: [],
  25505. smooth: 0,
  25506. stackedOnSmooth: 0,
  25507. smoothConstraint: true,
  25508. smoothMonotone: null,
  25509. connectNulls: false
  25510. },
  25511. brush: fixClipWithShadow(Path.prototype.brush),
  25512. buildPath: function (ctx, shape) {
  25513. var points = shape.points;
  25514. var stackedOnPoints = shape.stackedOnPoints;
  25515. var i = 0;
  25516. var len = points.length;
  25517. var smoothMonotone = shape.smoothMonotone;
  25518. var bbox = getBoundingBox(points, shape.smoothConstraint);
  25519. var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint);
  25520. if (shape.connectNulls) {
  25521. // Must remove first and last null values avoid draw error in polygon
  25522. for (; len > 0; len--) {
  25523. if (!isPointNull(points[len - 1])) {
  25524. break;
  25525. }
  25526. }
  25527. for (; i < len; i++) {
  25528. if (!isPointNull(points[i])) {
  25529. break;
  25530. }
  25531. }
  25532. }
  25533. while (i < len) {
  25534. var k = drawSegment(
  25535. ctx, points, i, len, len,
  25536. 1, bbox.min, bbox.max, shape.smooth,
  25537. smoothMonotone, shape.connectNulls
  25538. );
  25539. drawSegment(
  25540. ctx, stackedOnPoints, i + k - 1, k, len,
  25541. -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth,
  25542. smoothMonotone, shape.connectNulls
  25543. );
  25544. i += k + 1;
  25545. ctx.closePath();
  25546. }
  25547. }
  25548. })
  25549. };
  25550. /***/ }),
  25551. /* 124 */
  25552. /***/ (function(module, exports) {
  25553. module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) {
  25554. // Encoding visual for all series include which is filtered for legend drawing
  25555. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  25556. var data = seriesModel.getData();
  25557. var symbolType = seriesModel.get('symbol') || defaultSymbolType;
  25558. var symbolSize = seriesModel.get('symbolSize');
  25559. data.setVisual({
  25560. legendSymbol: legendSymbol || symbolType,
  25561. symbol: symbolType,
  25562. symbolSize: symbolSize
  25563. });
  25564. // Only visible series has each data be visual encoded
  25565. if (!ecModel.isSeriesFiltered(seriesModel)) {
  25566. if (typeof symbolSize === 'function') {
  25567. data.each(function (idx) {
  25568. var rawValue = seriesModel.getRawValue(idx);
  25569. // FIXME
  25570. var params = seriesModel.getDataParams(idx);
  25571. data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
  25572. });
  25573. }
  25574. data.each(function (idx) {
  25575. var itemModel = data.getItemModel(idx);
  25576. var itemSymbolType = itemModel.getShallow('symbol', true);
  25577. var itemSymbolSize = itemModel.getShallow('symbolSize', true);
  25578. // If has item symbol
  25579. if (itemSymbolType != null) {
  25580. data.setItemVisual(idx, 'symbol', itemSymbolType);
  25581. }
  25582. if (itemSymbolSize != null) {
  25583. // PENDING Transform symbolSize ?
  25584. data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
  25585. }
  25586. });
  25587. }
  25588. });
  25589. };
  25590. /***/ }),
  25591. /* 125 */
  25592. /***/ (function(module, exports) {
  25593. module.exports = function (seriesType, ecModel) {
  25594. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  25595. var data = seriesModel.getData();
  25596. var coordSys = seriesModel.coordinateSystem;
  25597. if (!coordSys) {
  25598. return;
  25599. }
  25600. var dims = [];
  25601. var coordDims = coordSys.dimensions;
  25602. for (var i = 0; i < coordDims.length; i++) {
  25603. dims.push(seriesModel.coordDimToDataDim(coordSys.dimensions[i])[0]);
  25604. }
  25605. if (dims.length === 1) {
  25606. data.each(dims[0], function (x, idx) {
  25607. // Also {Array.<number>}, not undefined to avoid if...else... statement
  25608. data.setItemLayout(idx, isNaN(x) ? [NaN, NaN] : coordSys.dataToPoint(x));
  25609. });
  25610. }
  25611. else if (dims.length === 2) {
  25612. data.each(dims, function (x, y, idx) {
  25613. // Also {Array.<number>}, not undefined to avoid if...else... statement
  25614. data.setItemLayout(
  25615. idx, (isNaN(x) || isNaN(y)) ? [NaN, NaN] : coordSys.dataToPoint([x, y])
  25616. );
  25617. }, true);
  25618. }
  25619. });
  25620. };
  25621. /***/ }),
  25622. /* 126 */
  25623. /***/ (function(module, exports) {
  25624. var samplers = {
  25625. average: function (frame) {
  25626. var sum = 0;
  25627. var count = 0;
  25628. for (var i = 0; i < frame.length; i++) {
  25629. if (!isNaN(frame[i])) {
  25630. sum += frame[i];
  25631. count++;
  25632. }
  25633. }
  25634. // Return NaN if count is 0
  25635. return count === 0 ? NaN : sum / count;
  25636. },
  25637. sum: function (frame) {
  25638. var sum = 0;
  25639. for (var i = 0; i < frame.length; i++) {
  25640. // Ignore NaN
  25641. sum += frame[i] || 0;
  25642. }
  25643. return sum;
  25644. },
  25645. max: function (frame) {
  25646. var max = -Infinity;
  25647. for (var i = 0; i < frame.length; i++) {
  25648. frame[i] > max && (max = frame[i]);
  25649. }
  25650. return max;
  25651. },
  25652. min: function (frame) {
  25653. var min = Infinity;
  25654. for (var i = 0; i < frame.length; i++) {
  25655. frame[i] < min && (min = frame[i]);
  25656. }
  25657. return min;
  25658. },
  25659. // TODO
  25660. // Median
  25661. nearest: function (frame) {
  25662. return frame[0];
  25663. }
  25664. };
  25665. var indexSampler = function (frame, value) {
  25666. return Math.round(frame.length / 2);
  25667. };
  25668. module.exports = function (seriesType, ecModel, api) {
  25669. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  25670. var data = seriesModel.getData();
  25671. var sampling = seriesModel.get('sampling');
  25672. var coordSys = seriesModel.coordinateSystem;
  25673. // Only cartesian2d support down sampling
  25674. if (coordSys.type === 'cartesian2d' && sampling) {
  25675. var baseAxis = coordSys.getBaseAxis();
  25676. var valueAxis = coordSys.getOtherAxis(baseAxis);
  25677. var extent = baseAxis.getExtent();
  25678. // Coordinste system has been resized
  25679. var size = extent[1] - extent[0];
  25680. var rate = Math.round(data.count() / size);
  25681. if (rate > 1) {
  25682. var sampler;
  25683. if (typeof sampling === 'string') {
  25684. sampler = samplers[sampling];
  25685. }
  25686. else if (typeof sampling === 'function') {
  25687. sampler = sampling;
  25688. }
  25689. if (sampler) {
  25690. data = data.downSample(
  25691. valueAxis.dim, 1 / rate, sampler, indexSampler
  25692. );
  25693. seriesModel.setData(data);
  25694. }
  25695. }
  25696. }
  25697. }, this);
  25698. };
  25699. /***/ }),
  25700. /* 127 */
  25701. /***/ (function(module, exports, __webpack_require__) {
  25702. 'use strict';
  25703. var graphic = __webpack_require__(20);
  25704. var zrUtil = __webpack_require__(4);
  25705. var echarts = __webpack_require__(1);
  25706. __webpack_require__(128);
  25707. __webpack_require__(136);
  25708. // Grid view
  25709. echarts.extendComponentView({
  25710. type: 'grid',
  25711. render: function (gridModel, ecModel) {
  25712. this.group.removeAll();
  25713. if (gridModel.get('show')) {
  25714. this.group.add(new graphic.Rect({
  25715. shape: gridModel.coordinateSystem.getRect(),
  25716. style: zrUtil.defaults({
  25717. fill: gridModel.get('backgroundColor')
  25718. }, gridModel.getItemStyle()),
  25719. silent: true,
  25720. z2: -1
  25721. }));
  25722. }
  25723. }
  25724. });
  25725. echarts.registerPreprocessor(function (option) {
  25726. // Only create grid when need
  25727. if (option.xAxis && option.yAxis && !option.grid) {
  25728. option.grid = {};
  25729. }
  25730. });
  25731. /***/ }),
  25732. /* 128 */
  25733. /***/ (function(module, exports, __webpack_require__) {
  25734. /**
  25735. * Grid is a region which contains at most 4 cartesian systems
  25736. *
  25737. * TODO Default cartesian
  25738. */
  25739. var factory = exports;
  25740. var layout = __webpack_require__(74);
  25741. var axisHelper = __webpack_require__(104);
  25742. var zrUtil = __webpack_require__(4);
  25743. var Cartesian2D = __webpack_require__(129);
  25744. var Axis2D = __webpack_require__(131);
  25745. var each = zrUtil.each;
  25746. var ifAxisCrossZero = axisHelper.ifAxisCrossZero;
  25747. var niceScaleExtent = axisHelper.niceScaleExtent;
  25748. // 依赖 GridModel, AxisModel 做预处理
  25749. __webpack_require__(132);
  25750. /**
  25751. * Check if the axis is used in the specified grid
  25752. * @inner
  25753. */
  25754. function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) {
  25755. return axisModel.getCoordSysModel() === gridModel;
  25756. }
  25757. function getLabelUnionRect(axis) {
  25758. var axisModel = axis.model;
  25759. var labels = axisModel.getFormattedLabels();
  25760. var axisLabelModel = axisModel.getModel('axisLabel');
  25761. var rect;
  25762. var step = 1;
  25763. var labelCount = labels.length;
  25764. if (labelCount > 40) {
  25765. // Simple optimization for large amount of labels
  25766. step = Math.ceil(labelCount / 40);
  25767. }
  25768. for (var i = 0; i < labelCount; i += step) {
  25769. if (!axis.isLabelIgnored(i)) {
  25770. var singleRect = axisLabelModel.getTextRect(labels[i]);
  25771. // FIXME consider label rotate
  25772. rect ? rect.union(singleRect) : (rect = singleRect);
  25773. }
  25774. }
  25775. return rect;
  25776. }
  25777. function Grid(gridModel, ecModel, api) {
  25778. /**
  25779. * @type {Object.<string, module:echarts/coord/cartesian/Cartesian2D>}
  25780. * @private
  25781. */
  25782. this._coordsMap = {};
  25783. /**
  25784. * @type {Array.<module:echarts/coord/cartesian/Cartesian>}
  25785. * @private
  25786. */
  25787. this._coordsList = [];
  25788. /**
  25789. * @type {Object.<string, module:echarts/coord/cartesian/Axis2D>}
  25790. * @private
  25791. */
  25792. this._axesMap = {};
  25793. /**
  25794. * @type {Array.<module:echarts/coord/cartesian/Axis2D>}
  25795. * @private
  25796. */
  25797. this._axesList = [];
  25798. this._initCartesian(gridModel, ecModel, api);
  25799. this.model = gridModel;
  25800. }
  25801. var gridProto = Grid.prototype;
  25802. gridProto.type = 'grid';
  25803. gridProto.axisPointerEnabled = true;
  25804. gridProto.getRect = function () {
  25805. return this._rect;
  25806. };
  25807. gridProto.update = function (ecModel, api) {
  25808. var axesMap = this._axesMap;
  25809. this._updateScale(ecModel, this.model);
  25810. each(axesMap.x, function (xAxis) {
  25811. niceScaleExtent(xAxis.scale, xAxis.model);
  25812. });
  25813. each(axesMap.y, function (yAxis) {
  25814. niceScaleExtent(yAxis.scale, yAxis.model);
  25815. });
  25816. each(axesMap.x, function (xAxis) {
  25817. fixAxisOnZero(axesMap, 'y', xAxis);
  25818. });
  25819. each(axesMap.y, function (yAxis) {
  25820. fixAxisOnZero(axesMap, 'x', yAxis);
  25821. });
  25822. // Resize again if containLabel is enabled
  25823. // FIXME It may cause getting wrong grid size in data processing stage
  25824. this.resize(this.model, api);
  25825. };
  25826. function fixAxisOnZero(axesMap, otherAxisDim, axis) {
  25827. // onZero can not be enabled in these two situations:
  25828. // 1. When any other axis is a category axis.
  25829. // 2. When no axis is cross 0 point.
  25830. var axes = axesMap[otherAxisDim];
  25831. if (!axis.onZero) {
  25832. return;
  25833. }
  25834. var onZeroAxisIndex = axis.onZeroAxisIndex;
  25835. // If target axis is specified.
  25836. if (onZeroAxisIndex != null) {
  25837. var otherAxis = axes[onZeroAxisIndex];
  25838. if (otherAxis && canNotOnZeroToAxis(otherAxis)) {
  25839. axis.onZero = false;
  25840. }
  25841. return;
  25842. }
  25843. for (var idx in axes) {
  25844. if (axes.hasOwnProperty(idx)) {
  25845. var otherAxis = axes[idx];
  25846. if (otherAxis && !canNotOnZeroToAxis(otherAxis)) {
  25847. onZeroAxisIndex = +idx;
  25848. break;
  25849. }
  25850. }
  25851. }
  25852. if (onZeroAxisIndex == null) {
  25853. axis.onZero = false;
  25854. }
  25855. axis.onZeroAxisIndex = onZeroAxisIndex;
  25856. }
  25857. function canNotOnZeroToAxis(axis) {
  25858. return axis.type === 'category' || axis.type === 'time' || !ifAxisCrossZero(axis);
  25859. }
  25860. /**
  25861. * Resize the grid
  25862. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  25863. * @param {module:echarts/ExtensionAPI} api
  25864. */
  25865. gridProto.resize = function (gridModel, api, ignoreContainLabel) {
  25866. var gridRect = layout.getLayoutRect(
  25867. gridModel.getBoxLayoutParams(), {
  25868. width: api.getWidth(),
  25869. height: api.getHeight()
  25870. });
  25871. this._rect = gridRect;
  25872. var axesList = this._axesList;
  25873. adjustAxes();
  25874. // Minus label size
  25875. if (!ignoreContainLabel && gridModel.get('containLabel')) {
  25876. each(axesList, function (axis) {
  25877. if (!axis.model.get('axisLabel.inside')) {
  25878. var labelUnionRect = getLabelUnionRect(axis);
  25879. if (labelUnionRect) {
  25880. var dim = axis.isHorizontal() ? 'height' : 'width';
  25881. var margin = axis.model.get('axisLabel.margin');
  25882. gridRect[dim] -= labelUnionRect[dim] + margin;
  25883. if (axis.position === 'top') {
  25884. gridRect.y += labelUnionRect.height + margin;
  25885. }
  25886. else if (axis.position === 'left') {
  25887. gridRect.x += labelUnionRect.width + margin;
  25888. }
  25889. }
  25890. }
  25891. });
  25892. adjustAxes();
  25893. }
  25894. function adjustAxes() {
  25895. each(axesList, function (axis) {
  25896. var isHorizontal = axis.isHorizontal();
  25897. var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
  25898. var idx = axis.inverse ? 1 : 0;
  25899. axis.setExtent(extent[idx], extent[1 - idx]);
  25900. updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y);
  25901. });
  25902. }
  25903. };
  25904. /**
  25905. * @param {string} axisType
  25906. * @param {number} [axisIndex]
  25907. */
  25908. gridProto.getAxis = function (axisType, axisIndex) {
  25909. var axesMapOnDim = this._axesMap[axisType];
  25910. if (axesMapOnDim != null) {
  25911. if (axisIndex == null) {
  25912. // Find first axis
  25913. for (var name in axesMapOnDim) {
  25914. if (axesMapOnDim.hasOwnProperty(name)) {
  25915. return axesMapOnDim[name];
  25916. }
  25917. }
  25918. }
  25919. return axesMapOnDim[axisIndex];
  25920. }
  25921. };
  25922. /**
  25923. * @return {Array.<module:echarts/coord/Axis>}
  25924. */
  25925. gridProto.getAxes = function () {
  25926. return this._axesList.slice();
  25927. };
  25928. /**
  25929. * Usage:
  25930. * grid.getCartesian(xAxisIndex, yAxisIndex);
  25931. * grid.getCartesian(xAxisIndex);
  25932. * grid.getCartesian(null, yAxisIndex);
  25933. * grid.getCartesian({xAxisIndex: ..., yAxisIndex: ...});
  25934. *
  25935. * @param {number|Object} [xAxisIndex]
  25936. * @param {number} [yAxisIndex]
  25937. */
  25938. gridProto.getCartesian = function (xAxisIndex, yAxisIndex) {
  25939. if (xAxisIndex != null && yAxisIndex != null) {
  25940. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  25941. return this._coordsMap[key];
  25942. }
  25943. if (zrUtil.isObject(xAxisIndex)) {
  25944. yAxisIndex = xAxisIndex.yAxisIndex;
  25945. xAxisIndex = xAxisIndex.xAxisIndex;
  25946. }
  25947. // When only xAxisIndex or yAxisIndex given, find its first cartesian.
  25948. for (var i = 0, coordList = this._coordsList; i < coordList.length; i++) {
  25949. if (coordList[i].getAxis('x').index === xAxisIndex
  25950. || coordList[i].getAxis('y').index === yAxisIndex
  25951. ) {
  25952. return coordList[i];
  25953. }
  25954. }
  25955. };
  25956. gridProto.getCartesians = function () {
  25957. return this._coordsList.slice();
  25958. };
  25959. /**
  25960. * @implements
  25961. * see {module:echarts/CoodinateSystem}
  25962. */
  25963. gridProto.convertToPixel = function (ecModel, finder, value) {
  25964. var target = this._findConvertTarget(ecModel, finder);
  25965. return target.cartesian
  25966. ? target.cartesian.dataToPoint(value)
  25967. : target.axis
  25968. ? target.axis.toGlobalCoord(target.axis.dataToCoord(value))
  25969. : null;
  25970. };
  25971. /**
  25972. * @implements
  25973. * see {module:echarts/CoodinateSystem}
  25974. */
  25975. gridProto.convertFromPixel = function (ecModel, finder, value) {
  25976. var target = this._findConvertTarget(ecModel, finder);
  25977. return target.cartesian
  25978. ? target.cartesian.pointToData(value)
  25979. : target.axis
  25980. ? target.axis.coordToData(target.axis.toLocalCoord(value))
  25981. : null;
  25982. };
  25983. /**
  25984. * @inner
  25985. */
  25986. gridProto._findConvertTarget = function (ecModel, finder) {
  25987. var seriesModel = finder.seriesModel;
  25988. var xAxisModel = finder.xAxisModel
  25989. || (seriesModel && seriesModel.getReferringComponents('xAxis')[0]);
  25990. var yAxisModel = finder.yAxisModel
  25991. || (seriesModel && seriesModel.getReferringComponents('yAxis')[0]);
  25992. var gridModel = finder.gridModel;
  25993. var coordsList = this._coordsList;
  25994. var cartesian;
  25995. var axis;
  25996. if (seriesModel) {
  25997. cartesian = seriesModel.coordinateSystem;
  25998. zrUtil.indexOf(coordsList, cartesian) < 0 && (cartesian = null);
  25999. }
  26000. else if (xAxisModel && yAxisModel) {
  26001. cartesian = this.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
  26002. }
  26003. else if (xAxisModel) {
  26004. axis = this.getAxis('x', xAxisModel.componentIndex);
  26005. }
  26006. else if (yAxisModel) {
  26007. axis = this.getAxis('y', yAxisModel.componentIndex);
  26008. }
  26009. // Lowest priority.
  26010. else if (gridModel) {
  26011. var grid = gridModel.coordinateSystem;
  26012. if (grid === this) {
  26013. cartesian = this._coordsList[0];
  26014. }
  26015. }
  26016. return {cartesian: cartesian, axis: axis};
  26017. };
  26018. /**
  26019. * @implements
  26020. * see {module:echarts/CoodinateSystem}
  26021. */
  26022. gridProto.containPoint = function (point) {
  26023. var coord = this._coordsList[0];
  26024. if (coord) {
  26025. return coord.containPoint(point);
  26026. }
  26027. };
  26028. /**
  26029. * Initialize cartesian coordinate systems
  26030. * @private
  26031. */
  26032. gridProto._initCartesian = function (gridModel, ecModel, api) {
  26033. var axisPositionUsed = {
  26034. left: false,
  26035. right: false,
  26036. top: false,
  26037. bottom: false
  26038. };
  26039. var axesMap = {
  26040. x: {},
  26041. y: {}
  26042. };
  26043. var axesCount = {
  26044. x: 0,
  26045. y: 0
  26046. };
  26047. /// Create axis
  26048. ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
  26049. ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
  26050. if (!axesCount.x || !axesCount.y) {
  26051. // Roll back when there no either x or y axis
  26052. this._axesMap = {};
  26053. this._axesList = [];
  26054. return;
  26055. }
  26056. this._axesMap = axesMap;
  26057. /// Create cartesian2d
  26058. each(axesMap.x, function (xAxis, xAxisIndex) {
  26059. each(axesMap.y, function (yAxis, yAxisIndex) {
  26060. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  26061. var cartesian = new Cartesian2D(key);
  26062. cartesian.grid = this;
  26063. cartesian.model = gridModel;
  26064. this._coordsMap[key] = cartesian;
  26065. this._coordsList.push(cartesian);
  26066. cartesian.addAxis(xAxis);
  26067. cartesian.addAxis(yAxis);
  26068. }, this);
  26069. }, this);
  26070. function createAxisCreator(axisType) {
  26071. return function (axisModel, idx) {
  26072. if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) {
  26073. return;
  26074. }
  26075. var axisPosition = axisModel.get('position');
  26076. if (axisType === 'x') {
  26077. // Fix position
  26078. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  26079. // Default bottom of X
  26080. axisPosition = 'bottom';
  26081. if (axisPositionUsed[axisPosition]) {
  26082. axisPosition = axisPosition === 'top' ? 'bottom' : 'top';
  26083. }
  26084. }
  26085. }
  26086. else {
  26087. // Fix position
  26088. if (axisPosition !== 'left' && axisPosition !== 'right') {
  26089. // Default left of Y
  26090. axisPosition = 'left';
  26091. if (axisPositionUsed[axisPosition]) {
  26092. axisPosition = axisPosition === 'left' ? 'right' : 'left';
  26093. }
  26094. }
  26095. }
  26096. axisPositionUsed[axisPosition] = true;
  26097. var axis = new Axis2D(
  26098. axisType, axisHelper.createScaleByModel(axisModel),
  26099. [0, 0],
  26100. axisModel.get('type'),
  26101. axisPosition
  26102. );
  26103. var isCategory = axis.type === 'category';
  26104. axis.onBand = isCategory && axisModel.get('boundaryGap');
  26105. axis.inverse = axisModel.get('inverse');
  26106. axis.onZero = axisModel.get('axisLine.onZero');
  26107. axis.onZeroAxisIndex = axisModel.get('axisLine.onZeroAxisIndex');
  26108. // Inject axis into axisModel
  26109. axisModel.axis = axis;
  26110. // Inject axisModel into axis
  26111. axis.model = axisModel;
  26112. // Inject grid info axis
  26113. axis.grid = this;
  26114. // Index of axis, can be used as key
  26115. axis.index = idx;
  26116. this._axesList.push(axis);
  26117. axesMap[axisType][idx] = axis;
  26118. axesCount[axisType]++;
  26119. };
  26120. }
  26121. };
  26122. /**
  26123. * Update cartesian properties from series
  26124. * @param {module:echarts/model/Option} option
  26125. * @private
  26126. */
  26127. gridProto._updateScale = function (ecModel, gridModel) {
  26128. // Reset scale
  26129. zrUtil.each(this._axesList, function (axis) {
  26130. axis.scale.setExtent(Infinity, -Infinity);
  26131. });
  26132. ecModel.eachSeries(function (seriesModel) {
  26133. if (isCartesian2D(seriesModel)) {
  26134. var axesModels = findAxesModels(seriesModel, ecModel);
  26135. var xAxisModel = axesModels[0];
  26136. var yAxisModel = axesModels[1];
  26137. if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel)
  26138. || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel)
  26139. ) {
  26140. return;
  26141. }
  26142. var cartesian = this.getCartesian(
  26143. xAxisModel.componentIndex, yAxisModel.componentIndex
  26144. );
  26145. var data = seriesModel.getData();
  26146. var xAxis = cartesian.getAxis('x');
  26147. var yAxis = cartesian.getAxis('y');
  26148. if (data.type === 'list') {
  26149. unionExtent(data, xAxis, seriesModel);
  26150. unionExtent(data, yAxis, seriesModel);
  26151. }
  26152. }
  26153. }, this);
  26154. function unionExtent(data, axis, seriesModel) {
  26155. each(seriesModel.coordDimToDataDim(axis.dim), function (dim) {
  26156. axis.scale.unionExtentFromData(data, dim);
  26157. });
  26158. }
  26159. };
  26160. /**
  26161. * @param {string} [dim] 'x' or 'y' or 'auto' or null/undefined
  26162. * @return {Object} {baseAxes: [], otherAxes: []}
  26163. */
  26164. gridProto.getTooltipAxes = function (dim) {
  26165. var baseAxes = [];
  26166. var otherAxes = [];
  26167. each(this.getCartesians(), function (cartesian) {
  26168. var baseAxis = (dim != null && dim !== 'auto')
  26169. ? cartesian.getAxis(dim) : cartesian.getBaseAxis();
  26170. var otherAxis = cartesian.getOtherAxis(baseAxis);
  26171. zrUtil.indexOf(baseAxes, baseAxis) < 0 && baseAxes.push(baseAxis);
  26172. zrUtil.indexOf(otherAxes, otherAxis) < 0 && otherAxes.push(otherAxis);
  26173. });
  26174. return {baseAxes: baseAxes, otherAxes: otherAxes};
  26175. };
  26176. /**
  26177. * @inner
  26178. */
  26179. function updateAxisTransfrom(axis, coordBase) {
  26180. var axisExtent = axis.getExtent();
  26181. var axisExtentSum = axisExtent[0] + axisExtent[1];
  26182. // Fast transform
  26183. axis.toGlobalCoord = axis.dim === 'x'
  26184. ? function (coord) {
  26185. return coord + coordBase;
  26186. }
  26187. : function (coord) {
  26188. return axisExtentSum - coord + coordBase;
  26189. };
  26190. axis.toLocalCoord = axis.dim === 'x'
  26191. ? function (coord) {
  26192. return coord - coordBase;
  26193. }
  26194. : function (coord) {
  26195. return axisExtentSum - coord + coordBase;
  26196. };
  26197. }
  26198. var axesTypes = ['xAxis', 'yAxis'];
  26199. /**
  26200. * @inner
  26201. */
  26202. function findAxesModels(seriesModel, ecModel) {
  26203. return zrUtil.map(axesTypes, function (axisType) {
  26204. var axisModel = seriesModel.getReferringComponents(axisType)[0];
  26205. if (true) {
  26206. if (!axisModel) {
  26207. throw new Error(axisType + ' "' + zrUtil.retrieve(
  26208. seriesModel.get(axisType + 'Index'),
  26209. seriesModel.get(axisType + 'Id'),
  26210. 0
  26211. ) + '" not found');
  26212. }
  26213. }
  26214. return axisModel;
  26215. });
  26216. }
  26217. /**
  26218. * @inner
  26219. */
  26220. function isCartesian2D(seriesModel) {
  26221. return seriesModel.get('coordinateSystem') === 'cartesian2d';
  26222. }
  26223. Grid.create = function (ecModel, api) {
  26224. var grids = [];
  26225. ecModel.eachComponent('grid', function (gridModel, idx) {
  26226. var grid = new Grid(gridModel, ecModel, api);
  26227. grid.name = 'grid_' + idx;
  26228. // dataSampling requires axis extent, so resize
  26229. // should be performed in create stage.
  26230. grid.resize(gridModel, api, true);
  26231. gridModel.coordinateSystem = grid;
  26232. grids.push(grid);
  26233. });
  26234. // Inject the coordinateSystems into seriesModel
  26235. ecModel.eachSeries(function (seriesModel) {
  26236. if (!isCartesian2D(seriesModel)) {
  26237. return;
  26238. }
  26239. var axesModels = findAxesModels(seriesModel, ecModel);
  26240. var xAxisModel = axesModels[0];
  26241. var yAxisModel = axesModels[1];
  26242. var gridModel = xAxisModel.getCoordSysModel();
  26243. if (true) {
  26244. if (!gridModel) {
  26245. throw new Error(
  26246. 'Grid "' + zrUtil.retrieve(
  26247. xAxisModel.get('gridIndex'),
  26248. xAxisModel.get('gridId'),
  26249. 0
  26250. ) + '" not found'
  26251. );
  26252. }
  26253. if (xAxisModel.getCoordSysModel() !== yAxisModel.getCoordSysModel()) {
  26254. throw new Error('xAxis and yAxis must use the same grid');
  26255. }
  26256. }
  26257. var grid = gridModel.coordinateSystem;
  26258. seriesModel.coordinateSystem = grid.getCartesian(
  26259. xAxisModel.componentIndex, yAxisModel.componentIndex
  26260. );
  26261. });
  26262. return grids;
  26263. };
  26264. // For deciding which dimensions to use when creating list data
  26265. Grid.dimensions = Grid.prototype.dimensions = Cartesian2D.prototype.dimensions;
  26266. __webpack_require__(79).register('cartesian2d', Grid);
  26267. module.exports = Grid;
  26268. /***/ }),
  26269. /* 129 */
  26270. /***/ (function(module, exports, __webpack_require__) {
  26271. 'use strict';
  26272. var zrUtil = __webpack_require__(4);
  26273. var Cartesian = __webpack_require__(130);
  26274. function Cartesian2D(name) {
  26275. Cartesian.call(this, name);
  26276. }
  26277. Cartesian2D.prototype = {
  26278. constructor: Cartesian2D,
  26279. type: 'cartesian2d',
  26280. /**
  26281. * @type {Array.<string>}
  26282. * @readOnly
  26283. */
  26284. dimensions: ['x', 'y'],
  26285. /**
  26286. * Base axis will be used on stacking.
  26287. *
  26288. * @return {module:echarts/coord/cartesian/Axis2D}
  26289. */
  26290. getBaseAxis: function () {
  26291. return this.getAxesByScale('ordinal')[0]
  26292. || this.getAxesByScale('time')[0]
  26293. || this.getAxis('x');
  26294. },
  26295. /**
  26296. * If contain point
  26297. * @param {Array.<number>} point
  26298. * @return {boolean}
  26299. */
  26300. containPoint: function (point) {
  26301. var axisX = this.getAxis('x');
  26302. var axisY = this.getAxis('y');
  26303. return axisX.contain(axisX.toLocalCoord(point[0]))
  26304. && axisY.contain(axisY.toLocalCoord(point[1]));
  26305. },
  26306. /**
  26307. * If contain data
  26308. * @param {Array.<number>} data
  26309. * @return {boolean}
  26310. */
  26311. containData: function (data) {
  26312. return this.getAxis('x').containData(data[0])
  26313. && this.getAxis('y').containData(data[1]);
  26314. },
  26315. /**
  26316. * @param {Array.<number>} data
  26317. * @param {boolean} [clamp=false]
  26318. * @return {Array.<number>}
  26319. */
  26320. dataToPoint: function (data, clamp) {
  26321. var xAxis = this.getAxis('x');
  26322. var yAxis = this.getAxis('y');
  26323. return [
  26324. xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)),
  26325. yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp))
  26326. ];
  26327. },
  26328. /**
  26329. * @param {Array.<number>} point
  26330. * @param {boolean} [clamp=false]
  26331. * @return {Array.<number>}
  26332. */
  26333. pointToData: function (point, clamp) {
  26334. var xAxis = this.getAxis('x');
  26335. var yAxis = this.getAxis('y');
  26336. return [
  26337. xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp),
  26338. yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp)
  26339. ];
  26340. },
  26341. /**
  26342. * Get other axis
  26343. * @param {module:echarts/coord/cartesian/Axis2D} axis
  26344. */
  26345. getOtherAxis: function (axis) {
  26346. return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
  26347. }
  26348. };
  26349. zrUtil.inherits(Cartesian2D, Cartesian);
  26350. module.exports = Cartesian2D;
  26351. /***/ }),
  26352. /* 130 */
  26353. /***/ (function(module, exports, __webpack_require__) {
  26354. 'use strict';
  26355. /**
  26356. * Cartesian coordinate system
  26357. * @module echarts/coord/Cartesian
  26358. *
  26359. */
  26360. var zrUtil = __webpack_require__(4);
  26361. function dimAxisMapper(dim) {
  26362. return this._axes[dim];
  26363. }
  26364. /**
  26365. * @alias module:echarts/coord/Cartesian
  26366. * @constructor
  26367. */
  26368. var Cartesian = function (name) {
  26369. this._axes = {};
  26370. this._dimList = [];
  26371. /**
  26372. * @type {string}
  26373. */
  26374. this.name = name || '';
  26375. };
  26376. Cartesian.prototype = {
  26377. constructor: Cartesian,
  26378. type: 'cartesian',
  26379. /**
  26380. * Get axis
  26381. * @param {number|string} dim
  26382. * @return {module:echarts/coord/Cartesian~Axis}
  26383. */
  26384. getAxis: function (dim) {
  26385. return this._axes[dim];
  26386. },
  26387. /**
  26388. * Get axes list
  26389. * @return {Array.<module:echarts/coord/Cartesian~Axis>}
  26390. */
  26391. getAxes: function () {
  26392. return zrUtil.map(this._dimList, dimAxisMapper, this);
  26393. },
  26394. /**
  26395. * Get axes list by given scale type
  26396. */
  26397. getAxesByScale: function (scaleType) {
  26398. scaleType = scaleType.toLowerCase();
  26399. return zrUtil.filter(
  26400. this.getAxes(),
  26401. function (axis) {
  26402. return axis.scale.type === scaleType;
  26403. }
  26404. );
  26405. },
  26406. /**
  26407. * Add axis
  26408. * @param {module:echarts/coord/Cartesian.Axis}
  26409. */
  26410. addAxis: function (axis) {
  26411. var dim = axis.dim;
  26412. this._axes[dim] = axis;
  26413. this._dimList.push(dim);
  26414. },
  26415. /**
  26416. * Convert data to coord in nd space
  26417. * @param {Array.<number>|Object.<string, number>} val
  26418. * @return {Array.<number>|Object.<string, number>}
  26419. */
  26420. dataToCoord: function (val) {
  26421. return this._dataCoordConvert(val, 'dataToCoord');
  26422. },
  26423. /**
  26424. * Convert coord in nd space to data
  26425. * @param {Array.<number>|Object.<string, number>} val
  26426. * @return {Array.<number>|Object.<string, number>}
  26427. */
  26428. coordToData: function (val) {
  26429. return this._dataCoordConvert(val, 'coordToData');
  26430. },
  26431. _dataCoordConvert: function (input, method) {
  26432. var dimList = this._dimList;
  26433. var output = input instanceof Array ? [] : {};
  26434. for (var i = 0; i < dimList.length; i++) {
  26435. var dim = dimList[i];
  26436. var axis = this._axes[dim];
  26437. output[dim] = axis[method](input[dim]);
  26438. }
  26439. return output;
  26440. }
  26441. };
  26442. module.exports = Cartesian;
  26443. /***/ }),
  26444. /* 131 */
  26445. /***/ (function(module, exports, __webpack_require__) {
  26446. var zrUtil = __webpack_require__(4);
  26447. var Axis = __webpack_require__(103);
  26448. /**
  26449. * Extend axis 2d
  26450. * @constructor module:echarts/coord/cartesian/Axis2D
  26451. * @extends {module:echarts/coord/cartesian/Axis}
  26452. * @param {string} dim
  26453. * @param {*} scale
  26454. * @param {Array.<number>} coordExtent
  26455. * @param {string} axisType
  26456. * @param {string} position
  26457. */
  26458. var Axis2D = function (dim, scale, coordExtent, axisType, position) {
  26459. Axis.call(this, dim, scale, coordExtent);
  26460. /**
  26461. * Axis type
  26462. * - 'category'
  26463. * - 'value'
  26464. * - 'time'
  26465. * - 'log'
  26466. * @type {string}
  26467. */
  26468. this.type = axisType || 'value';
  26469. /**
  26470. * Axis position
  26471. * - 'top'
  26472. * - 'bottom'
  26473. * - 'left'
  26474. * - 'right'
  26475. */
  26476. this.position = position || 'bottom';
  26477. };
  26478. Axis2D.prototype = {
  26479. constructor: Axis2D,
  26480. /**
  26481. * Index of axis, can be used as key
  26482. */
  26483. index: 0,
  26484. /**
  26485. * If axis is on the zero position of the other axis
  26486. * @type {boolean}
  26487. */
  26488. onZero: false,
  26489. /**
  26490. * Axis model
  26491. * @param {module:echarts/coord/cartesian/AxisModel}
  26492. */
  26493. model: null,
  26494. isHorizontal: function () {
  26495. var position = this.position;
  26496. return position === 'top' || position === 'bottom';
  26497. },
  26498. /**
  26499. * Each item cooresponds to this.getExtent(), which
  26500. * means globalExtent[0] may greater than globalExtent[1],
  26501. * unless `asc` is input.
  26502. *
  26503. * @param {boolean} [asc]
  26504. * @return {Array.<number>}
  26505. */
  26506. getGlobalExtent: function (asc) {
  26507. var ret = this.getExtent();
  26508. ret[0] = this.toGlobalCoord(ret[0]);
  26509. ret[1] = this.toGlobalCoord(ret[1]);
  26510. asc && ret[0] > ret[1] && ret.reverse();
  26511. return ret;
  26512. },
  26513. getOtherAxis: function () {
  26514. this.grid.getOtherAxis();
  26515. },
  26516. /**
  26517. * If label is ignored.
  26518. * Automatically used when axis is category and label can not be all shown
  26519. * @param {number} idx
  26520. * @return {boolean}
  26521. */
  26522. isLabelIgnored: function (idx) {
  26523. if (this.type === 'category') {
  26524. var labelInterval = this.getLabelInterval();
  26525. return ((typeof labelInterval === 'function')
  26526. && !labelInterval(idx, this.scale.getLabel(idx)))
  26527. || idx % (labelInterval + 1);
  26528. }
  26529. },
  26530. /**
  26531. * @override
  26532. */
  26533. pointToData: function (point, clamp) {
  26534. return this.coordToData(this.toLocalCoord(point[this.dim === 'x' ? 0 : 1]), clamp);
  26535. },
  26536. /**
  26537. * Transform global coord to local coord,
  26538. * i.e. var localCoord = axis.toLocalCoord(80);
  26539. * designate by module:echarts/coord/cartesian/Grid.
  26540. * @type {Function}
  26541. */
  26542. toLocalCoord: null,
  26543. /**
  26544. * Transform global coord to local coord,
  26545. * i.e. var globalCoord = axis.toLocalCoord(40);
  26546. * designate by module:echarts/coord/cartesian/Grid.
  26547. * @type {Function}
  26548. */
  26549. toGlobalCoord: null
  26550. };
  26551. zrUtil.inherits(Axis2D, Axis);
  26552. module.exports = Axis2D;
  26553. /***/ }),
  26554. /* 132 */
  26555. /***/ (function(module, exports, __webpack_require__) {
  26556. 'use strict';
  26557. // Grid 是在有直角坐标系的时候必须要存在的
  26558. // 所以这里也要被 Cartesian2D 依赖
  26559. __webpack_require__(133);
  26560. var ComponentModel = __webpack_require__(72);
  26561. module.exports = ComponentModel.extend({
  26562. type: 'grid',
  26563. dependencies: ['xAxis', 'yAxis'],
  26564. layoutMode: 'box',
  26565. /**
  26566. * @type {module:echarts/coord/cartesian/Grid}
  26567. */
  26568. coordinateSystem: null,
  26569. defaultOption: {
  26570. show: false,
  26571. zlevel: 0,
  26572. z: 0,
  26573. left: '10%',
  26574. top: 60,
  26575. right: '10%',
  26576. bottom: 60,
  26577. // If grid size contain label
  26578. containLabel: false,
  26579. // width: {totalWidth} - left - right,
  26580. // height: {totalHeight} - top - bottom,
  26581. backgroundColor: 'rgba(0,0,0,0)',
  26582. borderWidth: 1,
  26583. borderColor: '#ccc'
  26584. }
  26585. });
  26586. /***/ }),
  26587. /* 133 */
  26588. /***/ (function(module, exports, __webpack_require__) {
  26589. 'use strict';
  26590. var ComponentModel = __webpack_require__(72);
  26591. var zrUtil = __webpack_require__(4);
  26592. var axisModelCreator = __webpack_require__(134);
  26593. var AxisModel = ComponentModel.extend({
  26594. type: 'cartesian2dAxis',
  26595. /**
  26596. * @type {module:echarts/coord/cartesian/Axis2D}
  26597. */
  26598. axis: null,
  26599. /**
  26600. * @override
  26601. */
  26602. init: function () {
  26603. AxisModel.superApply(this, 'init', arguments);
  26604. this.resetRange();
  26605. },
  26606. /**
  26607. * @override
  26608. */
  26609. mergeOption: function () {
  26610. AxisModel.superApply(this, 'mergeOption', arguments);
  26611. this.resetRange();
  26612. },
  26613. /**
  26614. * @override
  26615. */
  26616. restoreData: function () {
  26617. AxisModel.superApply(this, 'restoreData', arguments);
  26618. this.resetRange();
  26619. },
  26620. /**
  26621. * @override
  26622. * @return {module:echarts/model/Component}
  26623. */
  26624. getCoordSysModel: function () {
  26625. return this.ecModel.queryComponents({
  26626. mainType: 'grid',
  26627. index: this.option.gridIndex,
  26628. id: this.option.gridId
  26629. })[0];
  26630. }
  26631. });
  26632. function getAxisType(axisDim, option) {
  26633. // Default axis with data is category axis
  26634. return option.type || (option.data ? 'category' : 'value');
  26635. }
  26636. zrUtil.merge(AxisModel.prototype, __webpack_require__(115));
  26637. var extraOption = {
  26638. // gridIndex: 0,
  26639. // gridId: '',
  26640. // Offset is for multiple axis on the same position
  26641. offset: 0
  26642. };
  26643. axisModelCreator('x', AxisModel, getAxisType, extraOption);
  26644. axisModelCreator('y', AxisModel, getAxisType, extraOption);
  26645. module.exports = AxisModel;
  26646. /***/ }),
  26647. /* 134 */
  26648. /***/ (function(module, exports, __webpack_require__) {
  26649. var axisDefault = __webpack_require__(135);
  26650. var zrUtil = __webpack_require__(4);
  26651. var ComponentModel = __webpack_require__(72);
  26652. var layout = __webpack_require__(74);
  26653. // FIXME axisType is fixed ?
  26654. var AXIS_TYPES = ['value', 'category', 'time', 'log'];
  26655. /**
  26656. * Generate sub axis model class
  26657. * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel'
  26658. * @param {module:echarts/model/Component} BaseAxisModelClass
  26659. * @param {Function} axisTypeDefaulter
  26660. * @param {Object} [extraDefaultOption]
  26661. */
  26662. module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
  26663. zrUtil.each(AXIS_TYPES, function (axisType) {
  26664. BaseAxisModelClass.extend({
  26665. type: axisName + 'Axis.' + axisType,
  26666. mergeDefaultAndTheme: function (option, ecModel) {
  26667. var layoutMode = this.layoutMode;
  26668. var inputPositionParams = layoutMode
  26669. ? layout.getLayoutParams(option) : {};
  26670. var themeModel = ecModel.getTheme();
  26671. zrUtil.merge(option, themeModel.get(axisType + 'Axis'));
  26672. zrUtil.merge(option, this.getDefaultOption());
  26673. option.type = axisTypeDefaulter(axisName, option);
  26674. if (layoutMode) {
  26675. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  26676. }
  26677. },
  26678. defaultOption: zrUtil.mergeAll(
  26679. [
  26680. {},
  26681. axisDefault[axisType + 'Axis'],
  26682. extraDefaultOption
  26683. ],
  26684. true
  26685. )
  26686. });
  26687. });
  26688. ComponentModel.registerSubTypeDefaulter(
  26689. axisName + 'Axis',
  26690. zrUtil.curry(axisTypeDefaulter, axisName)
  26691. );
  26692. };
  26693. /***/ }),
  26694. /* 135 */
  26695. /***/ (function(module, exports, __webpack_require__) {
  26696. var zrUtil = __webpack_require__(4);
  26697. var defaultOption = {
  26698. show: true,
  26699. zlevel: 0, // 一级层叠
  26700. z: 0, // 二级层叠
  26701. // 反向坐标轴
  26702. inverse: false,
  26703. // 坐标轴名字,默认为空
  26704. name: '',
  26705. // 坐标轴名字位置,支持'start' | 'middle' | 'end'
  26706. nameLocation: 'end',
  26707. // 坐标轴名字旋转,degree。
  26708. nameRotate: null, // Adapt to axis rotate, when nameLocation is 'middle'.
  26709. nameTruncate: {
  26710. maxWidth: null,
  26711. ellipsis: '...',
  26712. placeholder: '.'
  26713. },
  26714. // 坐标轴文字样式,默认取全局样式
  26715. nameTextStyle: {},
  26716. // 文字与轴线距离
  26717. nameGap: 15,
  26718. silent: false, // Default false to support tooltip.
  26719. triggerEvent: false, // Default false to avoid legacy user event listener fail.
  26720. tooltip: {
  26721. show: false
  26722. },
  26723. axisPointer: {},
  26724. // 坐标轴线
  26725. axisLine: {
  26726. // 默认显示,属性show控制显示与否
  26727. show: true,
  26728. onZero: true,
  26729. onZeroAxisIndex: null,
  26730. // 属性lineStyle控制线条样式
  26731. lineStyle: {
  26732. color: '#333',
  26733. width: 1,
  26734. type: 'solid'
  26735. }
  26736. },
  26737. // 坐标轴小标记
  26738. axisTick: {
  26739. // 属性show控制显示与否,默认显示
  26740. show: true,
  26741. // 控制小标记是否在grid里
  26742. inside: false,
  26743. // 属性length控制线长
  26744. length: 5,
  26745. // 属性lineStyle控制线条样式
  26746. lineStyle: {
  26747. width: 1
  26748. }
  26749. },
  26750. // 坐标轴文本标签,详见axis.axisLabel
  26751. axisLabel: {
  26752. show: true,
  26753. // 控制文本标签是否在grid里
  26754. inside: false,
  26755. rotate: 0,
  26756. showMinLabel: null, // true | false | null (auto)
  26757. showMaxLabel: null, // true | false | null (auto)
  26758. margin: 8,
  26759. // formatter: null,
  26760. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  26761. fontSize: 12
  26762. },
  26763. // 分隔线
  26764. splitLine: {
  26765. // 默认显示,属性show控制显示与否
  26766. show: true,
  26767. // 属性lineStyle(详见lineStyle)控制线条样式
  26768. lineStyle: {
  26769. color: ['#ccc'],
  26770. width: 1,
  26771. type: 'solid'
  26772. }
  26773. },
  26774. // 分隔区域
  26775. splitArea: {
  26776. // 默认不显示,属性show控制显示与否
  26777. show: false,
  26778. // 属性areaStyle(详见areaStyle)控制区域样式
  26779. areaStyle: {
  26780. color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)']
  26781. }
  26782. }
  26783. };
  26784. var categoryAxis = zrUtil.merge({
  26785. // 类目起始和结束两端空白策略
  26786. boundaryGap: true,
  26787. // splitArea: {
  26788. // show: false
  26789. // },
  26790. splitLine: {
  26791. show: false
  26792. },
  26793. // 坐标轴小标记
  26794. axisTick: {
  26795. // If tick is align with label when boundaryGap is true
  26796. alignWithLabel: false,
  26797. interval: 'auto'
  26798. },
  26799. // 坐标轴文本标签,详见axis.axisLabel
  26800. axisLabel: {
  26801. interval: 'auto'
  26802. }
  26803. }, defaultOption);
  26804. var valueAxis = zrUtil.merge({
  26805. // 数值起始和结束两端空白策略
  26806. boundaryGap: [0, 0],
  26807. // 最小值, 设置成 'dataMin' 则从数据中计算最小值
  26808. // min: null,
  26809. // 最大值,设置成 'dataMax' 则从数据中计算最大值
  26810. // max: null,
  26811. // Readonly prop, specifies start value of the range when using data zoom.
  26812. // rangeStart: null
  26813. // Readonly prop, specifies end value of the range when using data zoom.
  26814. // rangeEnd: null
  26815. // 脱离0值比例,放大聚焦到最终_min,_max区间
  26816. // scale: false,
  26817. // 分割段数,默认为5
  26818. splitNumber: 5
  26819. // Minimum interval
  26820. // minInterval: null
  26821. // maxInterval: null
  26822. }, defaultOption);
  26823. // FIXME
  26824. var timeAxis = zrUtil.defaults({
  26825. scale: true,
  26826. min: 'dataMin',
  26827. max: 'dataMax'
  26828. }, valueAxis);
  26829. var logAxis = zrUtil.defaults({
  26830. scale: true,
  26831. logBase: 10
  26832. }, valueAxis);
  26833. module.exports = {
  26834. categoryAxis: categoryAxis,
  26835. valueAxis: valueAxis,
  26836. timeAxis: timeAxis,
  26837. logAxis: logAxis
  26838. };
  26839. /***/ }),
  26840. /* 136 */
  26841. /***/ (function(module, exports, __webpack_require__) {
  26842. 'use strict';
  26843. // TODO boundaryGap
  26844. __webpack_require__(133);
  26845. __webpack_require__(137);
  26846. /***/ }),
  26847. /* 137 */
  26848. /***/ (function(module, exports, __webpack_require__) {
  26849. var zrUtil = __webpack_require__(4);
  26850. var graphic = __webpack_require__(20);
  26851. var AxisBuilder = __webpack_require__(138);
  26852. var AxisView = __webpack_require__(139);
  26853. var cartesianAxisHelper = __webpack_require__(141);
  26854. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  26855. var getInterval = AxisBuilder.getInterval;
  26856. var axisBuilderAttrs = [
  26857. 'axisLine', 'axisTickLabel', 'axisName'
  26858. ];
  26859. var selfBuilderAttrs = [
  26860. 'splitArea', 'splitLine'
  26861. ];
  26862. // function getAlignWithLabel(model, axisModel) {
  26863. // var alignWithLabel = model.get('alignWithLabel');
  26864. // if (alignWithLabel === 'auto') {
  26865. // alignWithLabel = axisModel.get('axisTick.alignWithLabel');
  26866. // }
  26867. // return alignWithLabel;
  26868. // }
  26869. var CartesianAxisView = AxisView.extend({
  26870. type: 'cartesianAxis',
  26871. axisPointerClass: 'CartesianAxisPointer',
  26872. /**
  26873. * @override
  26874. */
  26875. render: function (axisModel, ecModel, api, payload) {
  26876. this.group.removeAll();
  26877. var oldAxisGroup = this._axisGroup;
  26878. this._axisGroup = new graphic.Group();
  26879. this.group.add(this._axisGroup);
  26880. if (!axisModel.get('show')) {
  26881. return;
  26882. }
  26883. var gridModel = axisModel.getCoordSysModel();
  26884. var layout = cartesianAxisHelper.layout(gridModel, axisModel);
  26885. var axisBuilder = new AxisBuilder(axisModel, layout);
  26886. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  26887. this._axisGroup.add(axisBuilder.getGroup());
  26888. zrUtil.each(selfBuilderAttrs, function (name) {
  26889. if (axisModel.get(name + '.show')) {
  26890. this['_' + name](axisModel, gridModel, layout.labelInterval);
  26891. }
  26892. }, this);
  26893. graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  26894. CartesianAxisView.superCall(this, 'render', axisModel, ecModel, api, payload);
  26895. },
  26896. /**
  26897. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  26898. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  26899. * @param {number|Function} labelInterval
  26900. * @private
  26901. */
  26902. _splitLine: function (axisModel, gridModel, labelInterval) {
  26903. var axis = axisModel.axis;
  26904. if (axis.scale.isBlank()) {
  26905. return;
  26906. }
  26907. var splitLineModel = axisModel.getModel('splitLine');
  26908. var lineStyleModel = splitLineModel.getModel('lineStyle');
  26909. var lineColors = lineStyleModel.get('color');
  26910. var lineInterval = getInterval(splitLineModel, labelInterval);
  26911. lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];
  26912. var gridRect = gridModel.coordinateSystem.getRect();
  26913. var isHorizontal = axis.isHorizontal();
  26914. var lineCount = 0;
  26915. var ticksCoords = axis.getTicksCoords(
  26916. // splitLineModel.get('alignWithLabel')
  26917. );
  26918. var ticks = axis.scale.getTicks();
  26919. var showMinLabel = axisModel.get('axisLabel.showMinLabel');
  26920. var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
  26921. var p1 = [];
  26922. var p2 = [];
  26923. // Simple optimization
  26924. // Batching the lines if color are the same
  26925. var lineStyle = lineStyleModel.getLineStyle();
  26926. for (var i = 0; i < ticksCoords.length; i++) {
  26927. if (ifIgnoreOnTick(
  26928. axis, i, lineInterval, ticksCoords.length,
  26929. showMinLabel, showMaxLabel
  26930. )) {
  26931. continue;
  26932. }
  26933. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  26934. if (isHorizontal) {
  26935. p1[0] = tickCoord;
  26936. p1[1] = gridRect.y;
  26937. p2[0] = tickCoord;
  26938. p2[1] = gridRect.y + gridRect.height;
  26939. }
  26940. else {
  26941. p1[0] = gridRect.x;
  26942. p1[1] = tickCoord;
  26943. p2[0] = gridRect.x + gridRect.width;
  26944. p2[1] = tickCoord;
  26945. }
  26946. var colorIndex = (lineCount++) % lineColors.length;
  26947. this._axisGroup.add(new graphic.Line(graphic.subPixelOptimizeLine({
  26948. anid: 'line_' + ticks[i],
  26949. shape: {
  26950. x1: p1[0],
  26951. y1: p1[1],
  26952. x2: p2[0],
  26953. y2: p2[1]
  26954. },
  26955. style: zrUtil.defaults({
  26956. stroke: lineColors[colorIndex]
  26957. }, lineStyle),
  26958. silent: true
  26959. })));
  26960. }
  26961. },
  26962. /**
  26963. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  26964. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  26965. * @param {number|Function} labelInterval
  26966. * @private
  26967. */
  26968. _splitArea: function (axisModel, gridModel, labelInterval) {
  26969. var axis = axisModel.axis;
  26970. if (axis.scale.isBlank()) {
  26971. return;
  26972. }
  26973. var splitAreaModel = axisModel.getModel('splitArea');
  26974. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  26975. var areaColors = areaStyleModel.get('color');
  26976. var gridRect = gridModel.coordinateSystem.getRect();
  26977. var ticksCoords = axis.getTicksCoords(
  26978. // splitAreaModel.get('alignWithLabel')
  26979. );
  26980. var ticks = axis.scale.getTicks();
  26981. var prevX = axis.toGlobalCoord(ticksCoords[0]);
  26982. var prevY = axis.toGlobalCoord(ticksCoords[0]);
  26983. var count = 0;
  26984. var areaInterval = getInterval(splitAreaModel, labelInterval);
  26985. var areaStyle = areaStyleModel.getAreaStyle();
  26986. areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
  26987. var showMinLabel = axisModel.get('axisLabel.showMinLabel');
  26988. var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
  26989. for (var i = 1; i < ticksCoords.length; i++) {
  26990. if (ifIgnoreOnTick(
  26991. axis, i, areaInterval, ticksCoords.length,
  26992. showMinLabel, showMaxLabel
  26993. )) {
  26994. continue;
  26995. }
  26996. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  26997. var x;
  26998. var y;
  26999. var width;
  27000. var height;
  27001. if (axis.isHorizontal()) {
  27002. x = prevX;
  27003. y = gridRect.y;
  27004. width = tickCoord - x;
  27005. height = gridRect.height;
  27006. }
  27007. else {
  27008. x = gridRect.x;
  27009. y = prevY;
  27010. width = gridRect.width;
  27011. height = tickCoord - y;
  27012. }
  27013. var colorIndex = (count++) % areaColors.length;
  27014. this._axisGroup.add(new graphic.Rect({
  27015. anid: 'area_' + ticks[i],
  27016. shape: {
  27017. x: x,
  27018. y: y,
  27019. width: width,
  27020. height: height
  27021. },
  27022. style: zrUtil.defaults({
  27023. fill: areaColors[colorIndex]
  27024. }, areaStyle),
  27025. silent: true
  27026. }));
  27027. prevX = x + width;
  27028. prevY = y + height;
  27029. }
  27030. }
  27031. });
  27032. CartesianAxisView.extend({
  27033. type: 'xAxis'
  27034. });
  27035. CartesianAxisView.extend({
  27036. type: 'yAxis'
  27037. });
  27038. /***/ }),
  27039. /* 138 */
  27040. /***/ (function(module, exports, __webpack_require__) {
  27041. var zrUtil = __webpack_require__(4);
  27042. var formatUtil = __webpack_require__(6);
  27043. var graphic = __webpack_require__(20);
  27044. var Model = __webpack_require__(14);
  27045. var numberUtil = __webpack_require__(7);
  27046. var remRadian = numberUtil.remRadian;
  27047. var isRadianAroundZero = numberUtil.isRadianAroundZero;
  27048. var vec2 = __webpack_require__(10);
  27049. var matrix = __webpack_require__(11);
  27050. var v2ApplyTransform = vec2.applyTransform;
  27051. var retrieve = zrUtil.retrieve;
  27052. var PI = Math.PI;
  27053. function makeAxisEventDataBase(axisModel) {
  27054. var eventData = {
  27055. componentType: axisModel.mainType
  27056. };
  27057. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex;
  27058. return eventData;
  27059. }
  27060. /**
  27061. * A final axis is translated and rotated from a "standard axis".
  27062. * So opt.position and opt.rotation is required.
  27063. *
  27064. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  27065. * for example: (0, 0) ------------> (0, 50)
  27066. *
  27067. * nameDirection or tickDirection or labelDirection is 1 means tick
  27068. * or label is below the standard axis, whereas is -1 means above
  27069. * the standard axis. labelOffset means offset between label and axis,
  27070. * which is useful when 'onZero', where axisLabel is in the grid and
  27071. * label in outside grid.
  27072. *
  27073. * Tips: like always,
  27074. * positive rotation represents anticlockwise, and negative rotation
  27075. * represents clockwise.
  27076. * The direction of position coordinate is the same as the direction
  27077. * of screen coordinate.
  27078. *
  27079. * Do not need to consider axis 'inverse', which is auto processed by
  27080. * axis extent.
  27081. *
  27082. * @param {module:zrender/container/Group} group
  27083. * @param {Object} axisModel
  27084. * @param {Object} opt Standard axis parameters.
  27085. * @param {Array.<number>} opt.position [x, y]
  27086. * @param {number} opt.rotation by radian
  27087. * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle' or 'center'.
  27088. * @param {number} [opt.tickDirection=1] 1 or -1
  27089. * @param {number} [opt.labelDirection=1] 1 or -1
  27090. * @param {number} [opt.labelOffset=0] Usefull when onZero.
  27091. * @param {string} [opt.axisLabelShow] default get from axisModel.
  27092. * @param {string} [opt.axisName] default get from axisModel.
  27093. * @param {number} [opt.axisNameAvailableWidth]
  27094. * @param {number} [opt.labelRotate] by degree, default get from axisModel.
  27095. * @param {number} [opt.labelInterval] Default label interval when label
  27096. * interval from model is null or 'auto'.
  27097. * @param {number} [opt.strokeContainThreshold] Default label interval when label
  27098. * @param {number} [opt.nameTruncateMaxWidth]
  27099. */
  27100. var AxisBuilder = function (axisModel, opt) {
  27101. /**
  27102. * @readOnly
  27103. */
  27104. this.opt = opt;
  27105. /**
  27106. * @readOnly
  27107. */
  27108. this.axisModel = axisModel;
  27109. // Default value
  27110. zrUtil.defaults(
  27111. opt,
  27112. {
  27113. labelOffset: 0,
  27114. nameDirection: 1,
  27115. tickDirection: 1,
  27116. labelDirection: 1,
  27117. silent: true
  27118. }
  27119. );
  27120. /**
  27121. * @readOnly
  27122. */
  27123. this.group = new graphic.Group();
  27124. // FIXME Not use a seperate text group?
  27125. var dumbGroup = new graphic.Group({
  27126. position: opt.position.slice(),
  27127. rotation: opt.rotation
  27128. });
  27129. // this.group.add(dumbGroup);
  27130. // this._dumbGroup = dumbGroup;
  27131. dumbGroup.updateTransform();
  27132. this._transform = dumbGroup.transform;
  27133. this._dumbGroup = dumbGroup;
  27134. };
  27135. AxisBuilder.prototype = {
  27136. constructor: AxisBuilder,
  27137. hasBuilder: function (name) {
  27138. return !!builders[name];
  27139. },
  27140. add: function (name) {
  27141. builders[name].call(this);
  27142. },
  27143. getGroup: function () {
  27144. return this.group;
  27145. }
  27146. };
  27147. var builders = {
  27148. /**
  27149. * @private
  27150. */
  27151. axisLine: function () {
  27152. var opt = this.opt;
  27153. var axisModel = this.axisModel;
  27154. if (!axisModel.get('axisLine.show')) {
  27155. return;
  27156. }
  27157. var extent = this.axisModel.axis.getExtent();
  27158. var matrix = this._transform;
  27159. var pt1 = [extent[0], 0];
  27160. var pt2 = [extent[1], 0];
  27161. if (matrix) {
  27162. v2ApplyTransform(pt1, pt1, matrix);
  27163. v2ApplyTransform(pt2, pt2, matrix);
  27164. }
  27165. this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
  27166. // Id for animation
  27167. anid: 'line',
  27168. shape: {
  27169. x1: pt1[0],
  27170. y1: pt1[1],
  27171. x2: pt2[0],
  27172. y2: pt2[1]
  27173. },
  27174. style: zrUtil.extend(
  27175. {lineCap: 'round'},
  27176. axisModel.getModel('axisLine.lineStyle').getLineStyle()
  27177. ),
  27178. strokeContainThreshold: opt.strokeContainThreshold || 5,
  27179. silent: true,
  27180. z2: 1
  27181. })));
  27182. },
  27183. /**
  27184. * @private
  27185. */
  27186. axisTickLabel: function () {
  27187. var axisModel = this.axisModel;
  27188. var opt = this.opt;
  27189. var tickEls = buildAxisTick(this, axisModel, opt);
  27190. var labelEls = buildAxisLabel(this, axisModel, opt);
  27191. fixMinMaxLabelShow(axisModel, labelEls, tickEls);
  27192. },
  27193. /**
  27194. * @private
  27195. */
  27196. axisName: function () {
  27197. var opt = this.opt;
  27198. var axisModel = this.axisModel;
  27199. var name = retrieve(opt.axisName, axisModel.get('name'));
  27200. if (!name) {
  27201. return;
  27202. }
  27203. var nameLocation = axisModel.get('nameLocation');
  27204. var nameDirection = opt.nameDirection;
  27205. var textStyleModel = axisModel.getModel('nameTextStyle');
  27206. var gap = axisModel.get('nameGap') || 0;
  27207. var extent = this.axisModel.axis.getExtent();
  27208. var gapSignal = extent[0] > extent[1] ? -1 : 1;
  27209. var pos = [
  27210. nameLocation === 'start'
  27211. ? extent[0] - gapSignal * gap
  27212. : nameLocation === 'end'
  27213. ? extent[1] + gapSignal * gap
  27214. : (extent[0] + extent[1]) / 2, // 'middle'
  27215. // Reuse labelOffset.
  27216. isNameLocationCenter(nameLocation) ? opt.labelOffset + nameDirection * gap : 0
  27217. ];
  27218. var labelLayout;
  27219. var nameRotation = axisModel.get('nameRotate');
  27220. if (nameRotation != null) {
  27221. nameRotation = nameRotation * PI / 180; // To radian.
  27222. }
  27223. var axisNameAvailableWidth;
  27224. if (isNameLocationCenter(nameLocation)) {
  27225. labelLayout = innerTextLayout(
  27226. opt.rotation,
  27227. nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
  27228. nameDirection
  27229. );
  27230. }
  27231. else {
  27232. labelLayout = endTextLayout(
  27233. opt, nameLocation, nameRotation || 0, extent
  27234. );
  27235. axisNameAvailableWidth = opt.axisNameAvailableWidth;
  27236. if (axisNameAvailableWidth != null) {
  27237. axisNameAvailableWidth = Math.abs(
  27238. axisNameAvailableWidth / Math.sin(labelLayout.rotation)
  27239. );
  27240. !isFinite(axisNameAvailableWidth) && (axisNameAvailableWidth = null);
  27241. }
  27242. }
  27243. var textFont = textStyleModel.getFont();
  27244. var truncateOpt = axisModel.get('nameTruncate', true) || {};
  27245. var ellipsis = truncateOpt.ellipsis;
  27246. var maxWidth = retrieve(
  27247. opt.nameTruncateMaxWidth, truncateOpt.maxWidth, axisNameAvailableWidth
  27248. );
  27249. // FIXME
  27250. // truncate rich text? (consider performance)
  27251. var truncatedText = (ellipsis != null && maxWidth != null)
  27252. ? formatUtil.truncateText(
  27253. name, maxWidth, textFont, ellipsis,
  27254. {minChar: 2, placeholder: truncateOpt.placeholder}
  27255. )
  27256. : name;
  27257. var tooltipOpt = axisModel.get('tooltip', true);
  27258. var mainType = axisModel.mainType;
  27259. var formatterParams = {
  27260. componentType: mainType,
  27261. name: name,
  27262. $vars: ['name']
  27263. };
  27264. formatterParams[mainType + 'Index'] = axisModel.componentIndex;
  27265. var textEl = new graphic.Text({
  27266. // Id for animation
  27267. anid: 'name',
  27268. __fullText: name,
  27269. __truncatedText: truncatedText,
  27270. position: pos,
  27271. rotation: labelLayout.rotation,
  27272. silent: isSilent(axisModel),
  27273. z2: 1,
  27274. tooltip: (tooltipOpt && tooltipOpt.show)
  27275. ? zrUtil.extend({
  27276. content: name,
  27277. formatter: function () {
  27278. return name;
  27279. },
  27280. formatterParams: formatterParams
  27281. }, tooltipOpt)
  27282. : null
  27283. });
  27284. graphic.setTextStyle(textEl.style, textStyleModel, {
  27285. text: truncatedText,
  27286. textFont: textFont,
  27287. textFill: textStyleModel.getTextColor()
  27288. || axisModel.get('axisLine.lineStyle.color'),
  27289. textAlign: labelLayout.textAlign,
  27290. textVerticalAlign: labelLayout.textVerticalAlign
  27291. });
  27292. if (axisModel.get('triggerEvent')) {
  27293. textEl.eventData = makeAxisEventDataBase(axisModel);
  27294. textEl.eventData.targetType = 'axisName';
  27295. textEl.eventData.name = name;
  27296. }
  27297. // FIXME
  27298. this._dumbGroup.add(textEl);
  27299. textEl.updateTransform();
  27300. this.group.add(textEl);
  27301. textEl.decomposeTransform();
  27302. }
  27303. };
  27304. /**
  27305. * @public
  27306. * @static
  27307. * @param {Object} opt
  27308. * @param {number} axisRotation in radian
  27309. * @param {number} textRotation in radian
  27310. * @param {number} direction
  27311. * @return {Object} {
  27312. * rotation, // according to axis
  27313. * textAlign,
  27314. * textVerticalAlign
  27315. * }
  27316. */
  27317. var innerTextLayout = AxisBuilder.innerTextLayout = function (axisRotation, textRotation, direction) {
  27318. var rotationDiff = remRadian(textRotation - axisRotation);
  27319. var textAlign;
  27320. var textVerticalAlign;
  27321. if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line.
  27322. textVerticalAlign = direction > 0 ? 'top' : 'bottom';
  27323. textAlign = 'center';
  27324. }
  27325. else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line.
  27326. textVerticalAlign = direction > 0 ? 'bottom' : 'top';
  27327. textAlign = 'center';
  27328. }
  27329. else {
  27330. textVerticalAlign = 'middle';
  27331. if (rotationDiff > 0 && rotationDiff < PI) {
  27332. textAlign = direction > 0 ? 'right' : 'left';
  27333. }
  27334. else {
  27335. textAlign = direction > 0 ? 'left' : 'right';
  27336. }
  27337. }
  27338. return {
  27339. rotation: rotationDiff,
  27340. textAlign: textAlign,
  27341. textVerticalAlign: textVerticalAlign
  27342. };
  27343. };
  27344. function endTextLayout(opt, textPosition, textRotate, extent) {
  27345. var rotationDiff = remRadian(textRotate - opt.rotation);
  27346. var textAlign;
  27347. var textVerticalAlign;
  27348. var inverse = extent[0] > extent[1];
  27349. var onLeft = (textPosition === 'start' && !inverse)
  27350. || (textPosition !== 'start' && inverse);
  27351. if (isRadianAroundZero(rotationDiff - PI / 2)) {
  27352. textVerticalAlign = onLeft ? 'bottom' : 'top';
  27353. textAlign = 'center';
  27354. }
  27355. else if (isRadianAroundZero(rotationDiff - PI * 1.5)) {
  27356. textVerticalAlign = onLeft ? 'top' : 'bottom';
  27357. textAlign = 'center';
  27358. }
  27359. else {
  27360. textVerticalAlign = 'middle';
  27361. if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) {
  27362. textAlign = onLeft ? 'left' : 'right';
  27363. }
  27364. else {
  27365. textAlign = onLeft ? 'right' : 'left';
  27366. }
  27367. }
  27368. return {
  27369. rotation: rotationDiff,
  27370. textAlign: textAlign,
  27371. textVerticalAlign: textVerticalAlign
  27372. };
  27373. }
  27374. function isSilent(axisModel) {
  27375. var tooltipOpt = axisModel.get('tooltip');
  27376. return axisModel.get('silent')
  27377. // Consider mouse cursor, add these restrictions.
  27378. || !(
  27379. axisModel.get('triggerEvent') || (tooltipOpt && tooltipOpt.show)
  27380. );
  27381. }
  27382. function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
  27383. // If min or max are user set, we need to check
  27384. // If the tick on min(max) are overlap on their neighbour tick
  27385. // If they are overlapped, we need to hide the min(max) tick label
  27386. var showMinLabel = axisModel.get('axisLabel.showMinLabel');
  27387. var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
  27388. // FIXME
  27389. // Have not consider onBand yet, where tick els is more than label els.
  27390. labelEls = labelEls || [];
  27391. tickEls = tickEls || [];
  27392. var firstLabel = labelEls[0];
  27393. var nextLabel = labelEls[1];
  27394. var lastLabel = labelEls[labelEls.length - 1];
  27395. var prevLabel = labelEls[labelEls.length - 2];
  27396. var firstTick = tickEls[0];
  27397. var nextTick = tickEls[1];
  27398. var lastTick = tickEls[tickEls.length - 1];
  27399. var prevTick = tickEls[tickEls.length - 2];
  27400. if (showMinLabel === false) {
  27401. ignoreEl(firstLabel);
  27402. ignoreEl(firstTick);
  27403. }
  27404. else if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
  27405. if (showMinLabel) {
  27406. ignoreEl(nextLabel);
  27407. ignoreEl(nextTick);
  27408. }
  27409. else {
  27410. ignoreEl(firstLabel);
  27411. ignoreEl(firstTick);
  27412. }
  27413. }
  27414. if (showMaxLabel === false) {
  27415. ignoreEl(lastLabel);
  27416. ignoreEl(lastTick);
  27417. }
  27418. else if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
  27419. if (showMaxLabel) {
  27420. ignoreEl(prevLabel);
  27421. ignoreEl(prevTick);
  27422. }
  27423. else {
  27424. ignoreEl(lastLabel);
  27425. ignoreEl(lastTick);
  27426. }
  27427. }
  27428. }
  27429. function ignoreEl(el) {
  27430. el && (el.ignore = true);
  27431. }
  27432. function isTwoLabelOverlapped(current, next, labelLayout) {
  27433. // current and next has the same rotation.
  27434. var firstRect = current && current.getBoundingRect().clone();
  27435. var nextRect = next && next.getBoundingRect().clone();
  27436. if (!firstRect || !nextRect) {
  27437. return;
  27438. }
  27439. // When checking intersect of two rotated labels, we use mRotationBack
  27440. // to avoid that boundingRect is enlarge when using `boundingRect.applyTransform`.
  27441. var mRotationBack = matrix.identity([]);
  27442. matrix.rotate(mRotationBack, mRotationBack, -current.rotation);
  27443. firstRect.applyTransform(matrix.mul([], mRotationBack, current.getLocalTransform()));
  27444. nextRect.applyTransform(matrix.mul([], mRotationBack, next.getLocalTransform()));
  27445. return firstRect.intersect(nextRect);
  27446. }
  27447. function isNameLocationCenter(nameLocation) {
  27448. return nameLocation === 'middle' || nameLocation === 'center';
  27449. }
  27450. /**
  27451. * @static
  27452. */
  27453. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (
  27454. axis,
  27455. i,
  27456. interval,
  27457. ticksCnt,
  27458. showMinLabel,
  27459. showMaxLabel
  27460. ) {
  27461. if (i === 0 && showMinLabel || i === ticksCnt - 1 && showMaxLabel) {
  27462. return false;
  27463. }
  27464. // FIXME
  27465. // Have not consider label overlap (if label is too long) yet.
  27466. var rawTick;
  27467. var scale = axis.scale;
  27468. return scale.type === 'ordinal'
  27469. && (
  27470. typeof interval === 'function'
  27471. ? (
  27472. rawTick = scale.getTicks()[i],
  27473. !interval(rawTick, scale.getLabel(rawTick))
  27474. )
  27475. : i % (interval + 1)
  27476. );
  27477. };
  27478. /**
  27479. * @static
  27480. */
  27481. var getInterval = AxisBuilder.getInterval = function (model, labelInterval) {
  27482. var interval = model.get('interval');
  27483. if (interval == null || interval == 'auto') {
  27484. interval = labelInterval;
  27485. }
  27486. return interval;
  27487. };
  27488. function buildAxisTick(axisBuilder, axisModel, opt) {
  27489. var axis = axisModel.axis;
  27490. if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
  27491. return;
  27492. }
  27493. var tickModel = axisModel.getModel('axisTick');
  27494. var lineStyleModel = tickModel.getModel('lineStyle');
  27495. var tickLen = tickModel.get('length');
  27496. var tickInterval = getInterval(tickModel, opt.labelInterval);
  27497. var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
  27498. // FIXME
  27499. // Corresponds to ticksCoords ?
  27500. var ticks = axis.scale.getTicks();
  27501. var showMinLabel = axisModel.get('axisLabel.showMinLabel');
  27502. var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
  27503. var pt1 = [];
  27504. var pt2 = [];
  27505. var matrix = axisBuilder._transform;
  27506. var tickEls = [];
  27507. var ticksCnt = ticksCoords.length;
  27508. for (var i = 0; i < ticksCnt; i++) {
  27509. // Only ordinal scale support tick interval
  27510. if (ifIgnoreOnTick(
  27511. axis, i, tickInterval, ticksCnt,
  27512. showMinLabel, showMaxLabel
  27513. )) {
  27514. continue;
  27515. }
  27516. var tickCoord = ticksCoords[i];
  27517. pt1[0] = tickCoord;
  27518. pt1[1] = 0;
  27519. pt2[0] = tickCoord;
  27520. pt2[1] = opt.tickDirection * tickLen;
  27521. if (matrix) {
  27522. v2ApplyTransform(pt1, pt1, matrix);
  27523. v2ApplyTransform(pt2, pt2, matrix);
  27524. }
  27525. // Tick line, Not use group transform to have better line draw
  27526. var tickEl = new graphic.Line(graphic.subPixelOptimizeLine({
  27527. // Id for animation
  27528. anid: 'tick_' + ticks[i],
  27529. shape: {
  27530. x1: pt1[0],
  27531. y1: pt1[1],
  27532. x2: pt2[0],
  27533. y2: pt2[1]
  27534. },
  27535. style: zrUtil.defaults(
  27536. lineStyleModel.getLineStyle(),
  27537. {
  27538. stroke: axisModel.get('axisLine.lineStyle.color')
  27539. }
  27540. ),
  27541. z2: 2,
  27542. silent: true
  27543. }));
  27544. axisBuilder.group.add(tickEl);
  27545. tickEls.push(tickEl);
  27546. }
  27547. return tickEls;
  27548. }
  27549. function buildAxisLabel(axisBuilder, axisModel, opt) {
  27550. var axis = axisModel.axis;
  27551. var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
  27552. if (!show || axis.scale.isBlank()) {
  27553. return;
  27554. }
  27555. var labelModel = axisModel.getModel('axisLabel');
  27556. var labelMargin = labelModel.get('margin');
  27557. var ticks = axis.scale.getTicks();
  27558. var labels = axisModel.getFormattedLabels();
  27559. // Special label rotate.
  27560. var labelRotation = (
  27561. retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
  27562. ) * PI / 180;
  27563. var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
  27564. var categoryData = axisModel.get('data');
  27565. var labelEls = [];
  27566. var silent = isSilent(axisModel);
  27567. var triggerEvent = axisModel.get('triggerEvent');
  27568. var showMinLabel = axisModel.get('axisLabel.showMinLabel');
  27569. var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
  27570. zrUtil.each(ticks, function (tickVal, index) {
  27571. if (ifIgnoreOnTick(
  27572. axis, index, opt.labelInterval, ticks.length,
  27573. showMinLabel, showMaxLabel
  27574. )) {
  27575. return;
  27576. }
  27577. var itemLabelModel = labelModel;
  27578. if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
  27579. itemLabelModel = new Model(
  27580. categoryData[tickVal].textStyle, labelModel, axisModel.ecModel
  27581. );
  27582. }
  27583. var textColor = itemLabelModel.getTextColor()
  27584. || axisModel.get('axisLine.lineStyle.color');
  27585. var tickCoord = axis.dataToCoord(tickVal);
  27586. var pos = [
  27587. tickCoord,
  27588. opt.labelOffset + opt.labelDirection * labelMargin
  27589. ];
  27590. var labelStr = axis.scale.getLabel(tickVal);
  27591. var textEl = new graphic.Text({
  27592. // Id for animation
  27593. anid: 'label_' + tickVal,
  27594. position: pos,
  27595. rotation: labelLayout.rotation,
  27596. silent: silent,
  27597. z2: 10
  27598. });
  27599. graphic.setTextStyle(textEl.style, itemLabelModel, {
  27600. text: labels[index],
  27601. textAlign: itemLabelModel.getShallow('align', true)
  27602. || labelLayout.textAlign,
  27603. textVerticalAlign: itemLabelModel.getShallow('verticalAlign', true)
  27604. || itemLabelModel.getShallow('baseline', true)
  27605. || labelLayout.textVerticalAlign,
  27606. textFill: typeof textColor === 'function'
  27607. ? textColor(
  27608. // (1) In category axis with data zoom, tick is not the original
  27609. // index of axis.data. So tick should not be exposed to user
  27610. // in category axis.
  27611. // (2) Compatible with previous version, which always returns labelStr.
  27612. // But in interval scale labelStr is like '223,445', which maked
  27613. // user repalce ','. So we modify it to return original val but remain
  27614. // it as 'string' to avoid error in replacing.
  27615. axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
  27616. index
  27617. )
  27618. : textColor
  27619. });
  27620. // Pack data for mouse event
  27621. if (triggerEvent) {
  27622. textEl.eventData = makeAxisEventDataBase(axisModel);
  27623. textEl.eventData.targetType = 'axisLabel';
  27624. textEl.eventData.value = labelStr;
  27625. }
  27626. // FIXME
  27627. axisBuilder._dumbGroup.add(textEl);
  27628. textEl.updateTransform();
  27629. labelEls.push(textEl);
  27630. axisBuilder.group.add(textEl);
  27631. textEl.decomposeTransform();
  27632. });
  27633. return labelEls;
  27634. }
  27635. module.exports = AxisBuilder;
  27636. /***/ }),
  27637. /* 139 */
  27638. /***/ (function(module, exports, __webpack_require__) {
  27639. var axisPointerModelHelper = __webpack_require__(140);
  27640. /**
  27641. * Base class of AxisView.
  27642. */
  27643. var AxisView = __webpack_require__(1).extendComponentView({
  27644. type: 'axis',
  27645. /**
  27646. * @private
  27647. */
  27648. _axisPointer: null,
  27649. /**
  27650. * @protected
  27651. * @type {string}
  27652. */
  27653. axisPointerClass: null,
  27654. /**
  27655. * @override
  27656. */
  27657. render: function (axisModel, ecModel, api, payload) {
  27658. // FIXME
  27659. // This process should proformed after coordinate systems updated
  27660. // (axis scale updated), and should be performed each time update.
  27661. // So put it here temporarily, although it is not appropriate to
  27662. // put a model-writing procedure in `view`.
  27663. this.axisPointerClass && axisPointerModelHelper.fixValue(axisModel);
  27664. AxisView.superApply(this, 'render', arguments);
  27665. updateAxisPointer(this, axisModel, ecModel, api, payload, true);
  27666. },
  27667. /**
  27668. * Action handler.
  27669. * @public
  27670. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  27671. * @param {module:echarts/model/Global} ecModel
  27672. * @param {module:echarts/ExtensionAPI} api
  27673. * @param {Object} payload
  27674. */
  27675. updateAxisPointer: function (axisModel, ecModel, api, payload, force) {
  27676. updateAxisPointer(this, axisModel, ecModel, api, payload, false);
  27677. },
  27678. /**
  27679. * @override
  27680. */
  27681. remove: function (ecModel, api) {
  27682. var axisPointer = this._axisPointer;
  27683. axisPointer && axisPointer.remove(api);
  27684. AxisView.superApply(this, 'remove', arguments);
  27685. },
  27686. /**
  27687. * @override
  27688. */
  27689. dispose: function (ecModel, api) {
  27690. disposeAxisPointer(this, api);
  27691. AxisView.superApply(this, 'dispose', arguments);
  27692. }
  27693. });
  27694. function updateAxisPointer(axisView, axisModel, ecModel, api, payload, forceRender) {
  27695. var Clazz = AxisView.getAxisPointerClass(axisView.axisPointerClass);
  27696. if (!Clazz) {
  27697. return;
  27698. }
  27699. var axisPointerModel = axisPointerModelHelper.getAxisPointerModel(axisModel);
  27700. axisPointerModel
  27701. ? (axisView._axisPointer || (axisView._axisPointer = new Clazz()))
  27702. .render(axisModel, axisPointerModel, api, forceRender)
  27703. : disposeAxisPointer(axisView, api);
  27704. }
  27705. function disposeAxisPointer(axisView, ecModel, api) {
  27706. var axisPointer = axisView._axisPointer;
  27707. axisPointer && axisPointer.dispose(ecModel, api);
  27708. axisView._axisPointer = null;
  27709. }
  27710. var axisPointerClazz = [];
  27711. AxisView.registerAxisPointerClass = function (type, clazz) {
  27712. if (true) {
  27713. if (axisPointerClazz[type]) {
  27714. throw new Error('axisPointer ' + type + ' exists');
  27715. }
  27716. }
  27717. axisPointerClazz[type] = clazz;
  27718. };
  27719. AxisView.getAxisPointerClass = function (type) {
  27720. return type && axisPointerClazz[type];
  27721. };
  27722. module.exports = AxisView;
  27723. /***/ }),
  27724. /* 140 */
  27725. /***/ (function(module, exports, __webpack_require__) {
  27726. var zrUtil = __webpack_require__(4);
  27727. var Model = __webpack_require__(14);
  27728. var each = zrUtil.each;
  27729. var curry = zrUtil.curry;
  27730. var helper = {};
  27731. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  27732. // allAxesInfo should be updated when setOption performed.
  27733. helper.collect = function (ecModel, api) {
  27734. var result = {
  27735. /**
  27736. * key: makeKey(axis.model)
  27737. * value: {
  27738. * axis,
  27739. * coordSys,
  27740. * axisPointerModel,
  27741. * triggerTooltip,
  27742. * involveSeries,
  27743. * snap,
  27744. * seriesModels,
  27745. * seriesDataCount
  27746. * }
  27747. */
  27748. axesInfo: {},
  27749. seriesInvolved: false,
  27750. /**
  27751. * key: makeKey(coordSys.model)
  27752. * value: Object: key makeKey(axis.model), value: axisInfo
  27753. */
  27754. coordSysAxesInfo: {},
  27755. coordSysMap: {}
  27756. };
  27757. collectAxesInfo(result, ecModel, api);
  27758. // Check seriesInvolved for performance, in case too many series in some chart.
  27759. result.seriesInvolved && collectSeriesInfo(result, ecModel);
  27760. return result;
  27761. };
  27762. function collectAxesInfo(result, ecModel, api) {
  27763. var globalTooltipModel = ecModel.getComponent('tooltip');
  27764. var globalAxisPointerModel = ecModel.getComponent('axisPointer');
  27765. // links can only be set on global.
  27766. var linksOption = globalAxisPointerModel.get('link', true) || [];
  27767. var linkGroups = [];
  27768. // Collect axes info.
  27769. each(api.getCoordinateSystems(), function (coordSys) {
  27770. // Some coordinate system do not support axes, like geo.
  27771. if (!coordSys.axisPointerEnabled) {
  27772. return;
  27773. }
  27774. var coordSysKey = makeKey(coordSys.model);
  27775. var axesInfoInCoordSys = result.coordSysAxesInfo[coordSysKey] = {};
  27776. result.coordSysMap[coordSysKey] = coordSys;
  27777. // Set tooltip (like 'cross') is a convienent way to show axisPointer
  27778. // for user. So we enable seting tooltip on coordSys model.
  27779. var coordSysModel = coordSys.model;
  27780. var baseTooltipModel = coordSysModel.getModel('tooltip', globalTooltipModel);
  27781. each(coordSys.getAxes(), curry(saveTooltipAxisInfo, false, null));
  27782. // If axis tooltip used, choose tooltip axis for each coordSys.
  27783. // Notice this case: coordSys is `grid` but not `cartesian2D` here.
  27784. if (coordSys.getTooltipAxes
  27785. && globalTooltipModel
  27786. // If tooltip.showContent is set as false, tooltip will not
  27787. // show but axisPointer will show as normal.
  27788. && baseTooltipModel.get('show')
  27789. ) {
  27790. // Compatible with previous logic. But series.tooltip.trigger: 'axis'
  27791. // or series.data[n].tooltip.trigger: 'axis' are not support any more.
  27792. var triggerAxis = baseTooltipModel.get('trigger') === 'axis';
  27793. var cross = baseTooltipModel.get('axisPointer.type') === 'cross';
  27794. var tooltipAxes = coordSys.getTooltipAxes(baseTooltipModel.get('axisPointer.axis'));
  27795. if (triggerAxis || cross) {
  27796. each(tooltipAxes.baseAxes, curry(
  27797. saveTooltipAxisInfo, cross ? 'cross' : true, triggerAxis
  27798. ));
  27799. }
  27800. if (cross) {
  27801. each(tooltipAxes.otherAxes, curry(saveTooltipAxisInfo, 'cross', false));
  27802. }
  27803. }
  27804. // fromTooltip: true | false | 'cross'
  27805. // triggerTooltip: true | false | null
  27806. function saveTooltipAxisInfo(fromTooltip, triggerTooltip, axis) {
  27807. var axisPointerModel = axis.model.getModel('axisPointer', globalAxisPointerModel);
  27808. var axisPointerShow = axisPointerModel.get('show');
  27809. if (!axisPointerShow || (
  27810. axisPointerShow === 'auto'
  27811. && !fromTooltip
  27812. && !isHandleTrigger(axisPointerModel)
  27813. )) {
  27814. return;
  27815. }
  27816. if (triggerTooltip == null) {
  27817. triggerTooltip = axisPointerModel.get('triggerTooltip');
  27818. }
  27819. axisPointerModel = fromTooltip
  27820. ? makeAxisPointerModel(
  27821. axis, baseTooltipModel, globalAxisPointerModel, ecModel,
  27822. fromTooltip, triggerTooltip
  27823. )
  27824. : axisPointerModel;
  27825. var snap = axisPointerModel.get('snap');
  27826. var key = makeKey(axis.model);
  27827. var involveSeries = triggerTooltip || snap || axis.type === 'category';
  27828. // If result.axesInfo[key] exist, override it (tooltip has higher priority).
  27829. var axisInfo = result.axesInfo[key] = {
  27830. key: key,
  27831. axis: axis,
  27832. coordSys: coordSys,
  27833. axisPointerModel: axisPointerModel,
  27834. triggerTooltip: triggerTooltip,
  27835. involveSeries: involveSeries,
  27836. snap: snap,
  27837. useHandle: isHandleTrigger(axisPointerModel),
  27838. seriesModels: []
  27839. };
  27840. axesInfoInCoordSys[key] = axisInfo;
  27841. result.seriesInvolved |= involveSeries;
  27842. var groupIndex = getLinkGroupIndex(linksOption, axis);
  27843. if (groupIndex != null) {
  27844. var linkGroup = linkGroups[groupIndex] || (linkGroups[groupIndex] = {axesInfo: {}});
  27845. linkGroup.axesInfo[key] = axisInfo;
  27846. linkGroup.mapper = linksOption[groupIndex].mapper;
  27847. axisInfo.linkGroup = linkGroup;
  27848. }
  27849. }
  27850. });
  27851. }
  27852. function makeAxisPointerModel(
  27853. axis, baseTooltipModel, globalAxisPointerModel, ecModel, fromTooltip, triggerTooltip
  27854. ) {
  27855. var tooltipAxisPointerModel = baseTooltipModel.getModel('axisPointer');
  27856. var volatileOption = {};
  27857. each(
  27858. [
  27859. 'type', 'snap', 'lineStyle', 'shadowStyle', 'label',
  27860. 'animation', 'animationDurationUpdate', 'animationEasingUpdate', 'z'
  27861. ],
  27862. function (field) {
  27863. volatileOption[field] = zrUtil.clone(tooltipAxisPointerModel.get(field));
  27864. }
  27865. );
  27866. // category axis do not auto snap, otherwise some tick that do not
  27867. // has value can not be hovered. value/time/log axis default snap if
  27868. // triggered from tooltip and trigger tooltip.
  27869. volatileOption.snap = axis.type !== 'category' && !!triggerTooltip;
  27870. // Compatibel with previous behavior, tooltip axis do not show label by default.
  27871. // Only these properties can be overrided from tooltip to axisPointer.
  27872. if (tooltipAxisPointerModel.get('type') === 'cross') {
  27873. volatileOption.type = 'line';
  27874. }
  27875. var labelOption = volatileOption.label || (volatileOption.label = {});
  27876. // Follow the convention, do not show label when triggered by tooltip by default.
  27877. labelOption.show == null && (labelOption.show = false);
  27878. if (fromTooltip === 'cross') {
  27879. // When 'cross', both axes show labels.
  27880. labelOption.show = true;
  27881. // If triggerTooltip, this is a base axis, which should better not use cross style
  27882. // (cross style is dashed by default)
  27883. if (!triggerTooltip) {
  27884. var crossStyle = volatileOption.lineStyle = tooltipAxisPointerModel.get('crossStyle');
  27885. crossStyle && zrUtil.defaults(labelOption, crossStyle.textStyle);
  27886. }
  27887. }
  27888. return axis.model.getModel(
  27889. 'axisPointer',
  27890. new Model(volatileOption, globalAxisPointerModel, ecModel)
  27891. );
  27892. }
  27893. function collectSeriesInfo(result, ecModel) {
  27894. // Prepare data for axis trigger
  27895. ecModel.eachSeries(function (seriesModel) {
  27896. // Notice this case: this coordSys is `cartesian2D` but not `grid`.
  27897. var coordSys = seriesModel.coordinateSystem;
  27898. var seriesTooltipTrigger = seriesModel.get('tooltip.trigger', true);
  27899. var seriesTooltipShow = seriesModel.get('tooltip.show', true);
  27900. if (!coordSys
  27901. || seriesTooltipTrigger === 'none'
  27902. || seriesTooltipTrigger === false
  27903. || seriesTooltipTrigger === 'item'
  27904. || seriesTooltipShow === false
  27905. || seriesModel.get('axisPointer.show', true) === false
  27906. ) {
  27907. return;
  27908. }
  27909. each(result.coordSysAxesInfo[makeKey(coordSys.model)], function (axisInfo) {
  27910. var axis = axisInfo.axis;
  27911. if (coordSys.getAxis(axis.dim) === axis) {
  27912. axisInfo.seriesModels.push(seriesModel);
  27913. axisInfo.seriesDataCount == null && (axisInfo.seriesDataCount = 0);
  27914. axisInfo.seriesDataCount += seriesModel.getData().count();
  27915. }
  27916. });
  27917. }, this);
  27918. }
  27919. /**
  27920. * For example:
  27921. * {
  27922. * axisPointer: {
  27923. * links: [{
  27924. * xAxisIndex: [2, 4],
  27925. * yAxisIndex: 'all'
  27926. * }, {
  27927. * xAxisId: ['a5', 'a7'],
  27928. * xAxisName: 'xxx'
  27929. * }]
  27930. * }
  27931. * }
  27932. */
  27933. function getLinkGroupIndex(linksOption, axis) {
  27934. var axisModel = axis.model;
  27935. var dim = axis.dim;
  27936. for (var i = 0; i < linksOption.length; i++) {
  27937. var linkOption = linksOption[i] || {};
  27938. if (checkPropInLink(linkOption[dim + 'AxisId'], axisModel.id)
  27939. || checkPropInLink(linkOption[dim + 'AxisIndex'], axisModel.componentIndex)
  27940. || checkPropInLink(linkOption[dim + 'AxisName'], axisModel.name)
  27941. ) {
  27942. return i;
  27943. }
  27944. }
  27945. }
  27946. function checkPropInLink(linkPropValue, axisPropValue) {
  27947. return linkPropValue === 'all'
  27948. || (zrUtil.isArray(linkPropValue) && zrUtil.indexOf(linkPropValue, axisPropValue) >= 0)
  27949. || linkPropValue === axisPropValue;
  27950. }
  27951. helper.fixValue = function (axisModel) {
  27952. var axisInfo = helper.getAxisInfo(axisModel);
  27953. if (!axisInfo) {
  27954. return;
  27955. }
  27956. var axisPointerModel = axisInfo.axisPointerModel;
  27957. var scale = axisInfo.axis.scale;
  27958. var option = axisPointerModel.option;
  27959. var status = axisPointerModel.get('status');
  27960. var value = axisPointerModel.get('value');
  27961. // Parse init value for category and time axis.
  27962. if (value != null) {
  27963. value = scale.parse(value);
  27964. }
  27965. var useHandle = isHandleTrigger(axisPointerModel);
  27966. // If `handle` used, `axisPointer` will always be displayed, so value
  27967. // and status should be initialized.
  27968. if (status == null) {
  27969. option.status = useHandle ? 'show' : 'hide';
  27970. }
  27971. var extent = scale.getExtent().slice();
  27972. extent[0] > extent[1] && extent.reverse();
  27973. if (// Pick a value on axis when initializing.
  27974. value == null
  27975. // If both `handle` and `dataZoom` are used, value may be out of axis extent,
  27976. // where we should re-pick a value to keep `handle` displaying normally.
  27977. || value > extent[1]
  27978. ) {
  27979. // Make handle displayed on the end of the axis when init, which looks better.
  27980. value = extent[1];
  27981. }
  27982. if (value < extent[0]) {
  27983. value = extent[0];
  27984. }
  27985. option.value = value;
  27986. if (useHandle) {
  27987. option.status = axisInfo.axis.scale.isBlank() ? 'hide' : 'show';
  27988. }
  27989. };
  27990. helper.getAxisInfo = function (axisModel) {
  27991. var coordSysAxesInfo = (axisModel.ecModel.getComponent('axisPointer') || {}).coordSysAxesInfo;
  27992. return coordSysAxesInfo && coordSysAxesInfo.axesInfo[makeKey(axisModel)];
  27993. };
  27994. helper.getAxisPointerModel = function (axisModel) {
  27995. var axisInfo = helper.getAxisInfo(axisModel);
  27996. return axisInfo && axisInfo.axisPointerModel;
  27997. };
  27998. function isHandleTrigger(axisPointerModel) {
  27999. return !!axisPointerModel.get('handle.show');
  28000. }
  28001. /**
  28002. * @param {module:echarts/model/Model} model
  28003. * @return {string} unique key
  28004. */
  28005. var makeKey = helper.makeKey = function (model) {
  28006. return model.type + '||' + model.id;
  28007. };
  28008. module.exports = helper;
  28009. /***/ }),
  28010. /* 141 */
  28011. /***/ (function(module, exports, __webpack_require__) {
  28012. var zrUtil = __webpack_require__(4);
  28013. var helper = {};
  28014. /**
  28015. * @param {Object} opt {labelInside}
  28016. * @return {Object} {
  28017. * position, rotation, labelDirection, labelOffset,
  28018. * tickDirection, labelRotate, labelInterval, z2
  28019. * }
  28020. */
  28021. helper.layout = function (gridModel, axisModel, opt) {
  28022. opt = opt || {};
  28023. var grid = gridModel.coordinateSystem;
  28024. var axis = axisModel.axis;
  28025. var layout = {};
  28026. var rawAxisPosition = axis.position;
  28027. var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition;
  28028. var axisDim = axis.dim;
  28029. var rect = grid.getRect();
  28030. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  28031. var idx = {left: 0, right: 1, top: 0, bottom: 1, onZero: 2};
  28032. var axisOffset = axisModel.get('offset') || 0;
  28033. var posBound = axisDim === 'x'
  28034. ? [rectBound[2] - axisOffset, rectBound[3] + axisOffset]
  28035. : [rectBound[0] - axisOffset, rectBound[1] + axisOffset];
  28036. if (axis.onZero) {
  28037. var otherAxis = grid.getAxis(axisDim === 'x' ? 'y' : 'x', axis.onZeroAxisIndex);
  28038. var onZeroCoord = otherAxis.toGlobalCoord(otherAxis.dataToCoord(0));
  28039. posBound[idx['onZero']] = Math.max(Math.min(onZeroCoord, posBound[1]), posBound[0]);
  28040. }
  28041. // Axis position
  28042. layout.position = [
  28043. axisDim === 'y' ? posBound[idx[axisPosition]] : rectBound[0],
  28044. axisDim === 'x' ? posBound[idx[axisPosition]] : rectBound[3]
  28045. ];
  28046. // Axis rotation
  28047. layout.rotation = Math.PI / 2 * (axisDim === 'x' ? 0 : 1);
  28048. // Tick and label direction, x y is axisDim
  28049. var dirMap = {top: -1, bottom: 1, left: -1, right: 1};
  28050. layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition];
  28051. layout.labelOffset = axis.onZero ? posBound[idx[rawAxisPosition]] - posBound[idx['onZero']] : 0;
  28052. if (axisModel.get('axisTick.inside')) {
  28053. layout.tickDirection = -layout.tickDirection;
  28054. }
  28055. if (zrUtil.retrieve(opt.labelInside, axisModel.get('axisLabel.inside'))) {
  28056. layout.labelDirection = -layout.labelDirection;
  28057. }
  28058. // Special label rotation
  28059. var labelRotate = axisModel.get('axisLabel.rotate');
  28060. layout.labelRotate = axisPosition === 'top' ? -labelRotate : labelRotate;
  28061. // label interval when auto mode.
  28062. layout.labelInterval = axis.getLabelInterval();
  28063. // Over splitLine and splitArea
  28064. layout.z2 = 1;
  28065. return layout;
  28066. };
  28067. module.exports = helper;
  28068. /***/ }),
  28069. /* 142 */
  28070. /***/ (function(module, exports, __webpack_require__) {
  28071. var zrUtil = __webpack_require__(4);
  28072. __webpack_require__(128);
  28073. __webpack_require__(143);
  28074. __webpack_require__(145);
  28075. var barLayoutGrid = __webpack_require__(148);
  28076. var echarts = __webpack_require__(1);
  28077. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
  28078. // Visual coding for legend
  28079. echarts.registerVisual(function (ecModel) {
  28080. ecModel.eachSeriesByType('bar', function (seriesModel) {
  28081. var data = seriesModel.getData();
  28082. data.setVisual('legendSymbol', 'roundRect');
  28083. });
  28084. });
  28085. // In case developer forget to include grid component
  28086. __webpack_require__(127);
  28087. /***/ }),
  28088. /* 143 */
  28089. /***/ (function(module, exports, __webpack_require__) {
  28090. module.exports = __webpack_require__(144).extend({
  28091. type: 'series.bar',
  28092. dependencies: ['grid', 'polar'],
  28093. brushSelector: 'rect'
  28094. });
  28095. /***/ }),
  28096. /* 144 */
  28097. /***/ (function(module, exports, __webpack_require__) {
  28098. 'use strict';
  28099. var SeriesModel = __webpack_require__(83);
  28100. var createListFromArray = __webpack_require__(112);
  28101. module.exports = SeriesModel.extend({
  28102. type: 'series.__base_bar__',
  28103. getInitialData: function (option, ecModel) {
  28104. return createListFromArray(option.data, this, ecModel);
  28105. },
  28106. getMarkerPosition: function (value) {
  28107. var coordSys = this.coordinateSystem;
  28108. if (coordSys) {
  28109. // PENDING if clamp ?
  28110. var pt = coordSys.dataToPoint(value, true);
  28111. var data = this.getData();
  28112. var offset = data.getLayout('offset');
  28113. var size = data.getLayout('size');
  28114. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
  28115. pt[offsetIndex] += offset + size / 2;
  28116. return pt;
  28117. }
  28118. return [NaN, NaN];
  28119. },
  28120. defaultOption: {
  28121. zlevel: 0, // 一级层叠
  28122. z: 2, // 二级层叠
  28123. coordinateSystem: 'cartesian2d',
  28124. legendHoverLink: true,
  28125. // stack: null
  28126. // Cartesian coordinate system
  28127. // xAxisIndex: 0,
  28128. // yAxisIndex: 0,
  28129. // 最小高度改为0
  28130. barMinHeight: 0,
  28131. // 最小角度为0,仅对极坐标系下的柱状图有效
  28132. barMinAngle: 0,
  28133. // cursor: null,
  28134. // barMaxWidth: null,
  28135. // 默认自适应
  28136. // barWidth: null,
  28137. // 柱间距离,默认为柱形宽度的30%,可设固定值
  28138. // barGap: '30%',
  28139. // 类目间柱形距离,默认为类目间距的20%,可设固定值
  28140. // barCategoryGap: '20%',
  28141. // label: {
  28142. // normal: {
  28143. // show: false
  28144. // }
  28145. // },
  28146. itemStyle: {
  28147. // normal: {
  28148. // color: '各异'
  28149. // },
  28150. // emphasis: {}
  28151. }
  28152. }
  28153. });
  28154. /***/ }),
  28155. /* 145 */
  28156. /***/ (function(module, exports, __webpack_require__) {
  28157. 'use strict';
  28158. var zrUtil = __webpack_require__(4);
  28159. var graphic = __webpack_require__(20);
  28160. var helper = __webpack_require__(146);
  28161. var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'normal', 'barBorderWidth'];
  28162. // FIXME
  28163. // Just for compatible with ec2.
  28164. zrUtil.extend(__webpack_require__(14).prototype, __webpack_require__(147));
  28165. var BarView = __webpack_require__(1).extendChartView({
  28166. type: 'bar',
  28167. render: function (seriesModel, ecModel, api) {
  28168. var coordinateSystemType = seriesModel.get('coordinateSystem');
  28169. if (coordinateSystemType === 'cartesian2d'
  28170. || coordinateSystemType === 'polar'
  28171. ) {
  28172. this._render(seriesModel, ecModel, api);
  28173. }
  28174. else if (true) {
  28175. console.warn('Only cartesian2d and polar supported for bar.');
  28176. }
  28177. return this.group;
  28178. },
  28179. dispose: zrUtil.noop,
  28180. _render: function (seriesModel, ecModel, api) {
  28181. var group = this.group;
  28182. var data = seriesModel.getData();
  28183. var oldData = this._data;
  28184. var coord = seriesModel.coordinateSystem;
  28185. var baseAxis = coord.getBaseAxis();
  28186. var isHorizontalOrRadial;
  28187. if (coord.type === 'cartesian2d') {
  28188. isHorizontalOrRadial = baseAxis.isHorizontal();
  28189. }
  28190. else if (coord.type === 'polar') {
  28191. isHorizontalOrRadial = baseAxis.dim === 'angle';
  28192. }
  28193. var animationModel = seriesModel.isAnimationEnabled() ? seriesModel : null;
  28194. data.diff(oldData)
  28195. .add(function (dataIndex) {
  28196. if (!data.hasValue(dataIndex)) {
  28197. return;
  28198. }
  28199. var itemModel = data.getItemModel(dataIndex);
  28200. var layout = getLayout[coord.type](data, dataIndex, itemModel);
  28201. var el = elementCreator[coord.type](
  28202. data, dataIndex, itemModel, layout, isHorizontalOrRadial, animationModel
  28203. );
  28204. data.setItemGraphicEl(dataIndex, el);
  28205. group.add(el);
  28206. updateStyle(
  28207. el, data, dataIndex, itemModel, layout,
  28208. seriesModel, isHorizontalOrRadial, coord.type === 'polar'
  28209. );
  28210. })
  28211. .update(function (newIndex, oldIndex) {
  28212. var el = oldData.getItemGraphicEl(oldIndex);
  28213. if (!data.hasValue(newIndex)) {
  28214. group.remove(el);
  28215. return;
  28216. }
  28217. var itemModel = data.getItemModel(newIndex);
  28218. var layout = getLayout[coord.type](data, newIndex, itemModel);
  28219. if (el) {
  28220. graphic.updateProps(el, {shape: layout}, animationModel, newIndex);
  28221. }
  28222. else {
  28223. el = elementCreator[coord.type](
  28224. data, newIndex, itemModel, layout, isHorizontalOrRadial, animationModel, true
  28225. );
  28226. }
  28227. data.setItemGraphicEl(newIndex, el);
  28228. // Add back
  28229. group.add(el);
  28230. updateStyle(
  28231. el, data, newIndex, itemModel, layout,
  28232. seriesModel, isHorizontalOrRadial, coord.type === 'polar'
  28233. );
  28234. })
  28235. .remove(function (dataIndex) {
  28236. var el = oldData.getItemGraphicEl(dataIndex);
  28237. if (coord.type === 'cartesian2d') {
  28238. el && removeRect(dataIndex, animationModel, el);
  28239. }
  28240. else {
  28241. el && removeSector(dataIndex, animationModel, el);
  28242. }
  28243. })
  28244. .execute();
  28245. this._data = data;
  28246. },
  28247. remove: function (ecModel, api) {
  28248. var group = this.group;
  28249. var data = this._data;
  28250. if (ecModel.get('animation')) {
  28251. if (data) {
  28252. data.eachItemGraphicEl(function (el) {
  28253. if (el.type === 'sector') {
  28254. removeSector(el.dataIndex, ecModel, el);
  28255. }
  28256. else {
  28257. removeRect(el.dataIndex, ecModel, el);
  28258. }
  28259. });
  28260. }
  28261. }
  28262. else {
  28263. group.removeAll();
  28264. }
  28265. }
  28266. });
  28267. var elementCreator = {
  28268. cartesian2d: function (
  28269. data, dataIndex, itemModel, layout, isHorizontal,
  28270. animationModel, isUpdate
  28271. ) {
  28272. var rect = new graphic.Rect({shape: zrUtil.extend({}, layout)});
  28273. // Animation
  28274. if (animationModel) {
  28275. var rectShape = rect.shape;
  28276. var animateProperty = isHorizontal ? 'height' : 'width';
  28277. var animateTarget = {};
  28278. rectShape[animateProperty] = 0;
  28279. animateTarget[animateProperty] = layout[animateProperty];
  28280. graphic[isUpdate ? 'updateProps' : 'initProps'](rect, {
  28281. shape: animateTarget
  28282. }, animationModel, dataIndex);
  28283. }
  28284. return rect;
  28285. },
  28286. polar: function (
  28287. data, dataIndex, itemModel, layout, isRadial,
  28288. animationModel, isUpdate
  28289. ) {
  28290. var sector = new graphic.Sector({shape: zrUtil.extend({}, layout)});
  28291. // Animation
  28292. if (animationModel) {
  28293. var sectorShape = sector.shape;
  28294. var animateProperty = isRadial ? 'r' : 'endAngle';
  28295. var animateTarget = {};
  28296. sectorShape[animateProperty] = isRadial ? 0 : layout.startAngle;
  28297. animateTarget[animateProperty] = layout[animateProperty];
  28298. graphic[isUpdate ? 'updateProps' : 'initProps'](sector, {
  28299. shape: animateTarget
  28300. }, animationModel, dataIndex);
  28301. }
  28302. return sector;
  28303. }
  28304. };
  28305. function removeRect(dataIndex, animationModel, el) {
  28306. // Not show text when animating
  28307. el.style.text = null;
  28308. graphic.updateProps(el, {
  28309. shape: {
  28310. width: 0
  28311. }
  28312. }, animationModel, dataIndex, function () {
  28313. el.parent && el.parent.remove(el);
  28314. });
  28315. }
  28316. function removeSector(dataIndex, animationModel, el) {
  28317. // Not show text when animating
  28318. el.style.text = null;
  28319. graphic.updateProps(el, {
  28320. shape: {
  28321. r: el.shape.r0
  28322. }
  28323. }, animationModel, dataIndex, function () {
  28324. el.parent && el.parent.remove(el);
  28325. });
  28326. }
  28327. var getLayout = {
  28328. cartesian2d: function (data, dataIndex, itemModel) {
  28329. var layout = data.getItemLayout(dataIndex);
  28330. var fixedLineWidth = getLineWidth(itemModel, layout);
  28331. // fix layout with lineWidth
  28332. var signX = layout.width > 0 ? 1 : -1;
  28333. var signY = layout.height > 0 ? 1 : -1;
  28334. return {
  28335. x: layout.x + signX * fixedLineWidth / 2,
  28336. y: layout.y + signY * fixedLineWidth / 2,
  28337. width: layout.width - signX * fixedLineWidth,
  28338. height: layout.height - signY * fixedLineWidth
  28339. };
  28340. },
  28341. polar: function (data, dataIndex, itemModel) {
  28342. var layout = data.getItemLayout(dataIndex);
  28343. return {
  28344. cx: layout.cx,
  28345. cy: layout.cy,
  28346. r0: layout.r0,
  28347. r: layout.r,
  28348. startAngle: layout.startAngle,
  28349. endAngle: layout.endAngle
  28350. };
  28351. }
  28352. };
  28353. function updateStyle(
  28354. el, data, dataIndex, itemModel, layout, seriesModel, isHorizontal, isPolar
  28355. ) {
  28356. var color = data.getItemVisual(dataIndex, 'color');
  28357. var opacity = data.getItemVisual(dataIndex, 'opacity');
  28358. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  28359. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
  28360. if (!isPolar) {
  28361. el.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
  28362. }
  28363. el.useStyle(zrUtil.defaults(
  28364. {
  28365. fill: color,
  28366. opacity: opacity
  28367. },
  28368. itemStyleModel.getBarItemStyle()
  28369. ));
  28370. var cursorStyle = itemModel.getShallow('cursor');
  28371. cursorStyle && el.attr('cursor', cursorStyle);
  28372. var labelPositionOutside = isHorizontal
  28373. ? (layout.height > 0 ? 'bottom' : 'top')
  28374. : (layout.width > 0 ? 'left' : 'right');
  28375. if (!isPolar) {
  28376. helper.setLabel(
  28377. el.style, hoverStyle, itemModel, color,
  28378. seriesModel, dataIndex, labelPositionOutside
  28379. );
  28380. }
  28381. graphic.setHoverStyle(el, hoverStyle);
  28382. }
  28383. // In case width or height are too small.
  28384. function getLineWidth(itemModel, rawLayout) {
  28385. var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
  28386. return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
  28387. }
  28388. module.exports = BarView;
  28389. /***/ }),
  28390. /* 146 */
  28391. /***/ (function(module, exports, __webpack_require__) {
  28392. var graphic = __webpack_require__(20);
  28393. var helper = {};
  28394. helper.setLabel = function (
  28395. normalStyle, hoverStyle, itemModel, color, seriesModel, dataIndex, labelPositionOutside
  28396. ) {
  28397. var labelModel = itemModel.getModel('label.normal');
  28398. var hoverLabelModel = itemModel.getModel('label.emphasis');
  28399. graphic.setLabelStyle(
  28400. normalStyle, hoverStyle, labelModel, hoverLabelModel,
  28401. {
  28402. labelFetcher: seriesModel,
  28403. labelDataIndex: dataIndex,
  28404. defaultText: seriesModel.getRawValue(dataIndex),
  28405. isRectText: true,
  28406. autoColor: color
  28407. }
  28408. );
  28409. fixPosition(normalStyle);
  28410. fixPosition(hoverStyle);
  28411. };
  28412. function fixPosition(style, labelPositionOutside) {
  28413. if (style.textPosition === 'outside') {
  28414. style.textPosition = labelPositionOutside;
  28415. }
  28416. }
  28417. module.exports = helper;
  28418. /***/ }),
  28419. /* 147 */
  28420. /***/ (function(module, exports, __webpack_require__) {
  28421. var getBarItemStyle = __webpack_require__(17)(
  28422. [
  28423. ['fill', 'color'],
  28424. ['stroke', 'borderColor'],
  28425. ['lineWidth', 'borderWidth'],
  28426. // Compatitable with 2
  28427. ['stroke', 'barBorderColor'],
  28428. ['lineWidth', 'barBorderWidth'],
  28429. ['opacity'],
  28430. ['shadowBlur'],
  28431. ['shadowOffsetX'],
  28432. ['shadowOffsetY'],
  28433. ['shadowColor']
  28434. ]
  28435. );
  28436. module.exports = {
  28437. getBarItemStyle: function (excludes) {
  28438. var style = getBarItemStyle.call(this, excludes);
  28439. if (this.getBorderLineDash) {
  28440. var lineDash = this.getBorderLineDash();
  28441. lineDash && (style.lineDash = lineDash);
  28442. }
  28443. return style;
  28444. }
  28445. };
  28446. /***/ }),
  28447. /* 148 */
  28448. /***/ (function(module, exports, __webpack_require__) {
  28449. 'use strict';
  28450. var zrUtil = __webpack_require__(4);
  28451. var numberUtil = __webpack_require__(7);
  28452. var parsePercent = numberUtil.parsePercent;
  28453. var STACK_PREFIX = '__ec_stack_';
  28454. function getSeriesStackId(seriesModel) {
  28455. return seriesModel.get('stack') || STACK_PREFIX + seriesModel.seriesIndex;
  28456. }
  28457. function getAxisKey(axis) {
  28458. return axis.dim + axis.index;
  28459. }
  28460. /**
  28461. * @param {Object} opt
  28462. * @param {module:echarts/coord/Axis} opt.axis Only support category axis currently.
  28463. * @param {number} opt.count Positive interger.
  28464. * @param {number} [opt.barWidth]
  28465. * @param {number} [opt.barMaxWidth]
  28466. * @param {number} [opt.barGap]
  28467. * @param {number} [opt.barCategoryGap]
  28468. * @return {Object} {width, offset, offsetCenter} If axis.type is not 'category', return undefined.
  28469. */
  28470. function getLayoutOnAxis(opt, api) {
  28471. var params = [];
  28472. var baseAxis = opt.axis;
  28473. var axisKey = 'axis0';
  28474. if (baseAxis.type !== 'category') {
  28475. return;
  28476. }
  28477. var bandWidth = baseAxis.getBandWidth();
  28478. for (var i = 0; i < opt.count || 0; i++) {
  28479. params.push(zrUtil.defaults({
  28480. bandWidth: bandWidth,
  28481. axisKey: axisKey,
  28482. stackId: STACK_PREFIX + i
  28483. }, opt));
  28484. }
  28485. var widthAndOffsets = doCalBarWidthAndOffset(params, api);
  28486. var result = [];
  28487. for (var i = 0; i < opt.count; i++) {
  28488. var item = widthAndOffsets[axisKey][STACK_PREFIX + i];
  28489. item.offsetCenter = item.offset + item.width / 2;
  28490. result.push(item);
  28491. }
  28492. return result;
  28493. }
  28494. function calBarWidthAndOffset(barSeries, api) {
  28495. var seriesInfoList = zrUtil.map(barSeries, function (seriesModel) {
  28496. var data = seriesModel.getData();
  28497. var cartesian = seriesModel.coordinateSystem;
  28498. var baseAxis = cartesian.getBaseAxis();
  28499. var axisExtent = baseAxis.getExtent();
  28500. var bandWidth = baseAxis.type === 'category'
  28501. ? baseAxis.getBandWidth()
  28502. : (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
  28503. var barWidth = parsePercent(
  28504. seriesModel.get('barWidth'), bandWidth
  28505. );
  28506. var barMaxWidth = parsePercent(
  28507. seriesModel.get('barMaxWidth'), bandWidth
  28508. );
  28509. var barGap = seriesModel.get('barGap');
  28510. var barCategoryGap = seriesModel.get('barCategoryGap');
  28511. return {
  28512. bandWidth: bandWidth,
  28513. barWidth: barWidth,
  28514. barMaxWidth: barMaxWidth,
  28515. barGap: barGap,
  28516. barCategoryGap: barCategoryGap,
  28517. axisKey: getAxisKey(baseAxis),
  28518. stackId: getSeriesStackId(seriesModel)
  28519. };
  28520. });
  28521. return doCalBarWidthAndOffset(seriesInfoList, api);
  28522. }
  28523. function doCalBarWidthAndOffset(seriesInfoList, api) {
  28524. // Columns info on each category axis. Key is cartesian name
  28525. var columnsMap = {};
  28526. zrUtil.each(seriesInfoList, function (seriesInfo, idx) {
  28527. var axisKey = seriesInfo.axisKey;
  28528. var bandWidth = seriesInfo.bandWidth;
  28529. var columnsOnAxis = columnsMap[axisKey] || {
  28530. bandWidth: bandWidth,
  28531. remainedWidth: bandWidth,
  28532. autoWidthCount: 0,
  28533. categoryGap: '20%',
  28534. gap: '30%',
  28535. stacks: {}
  28536. };
  28537. var stacks = columnsOnAxis.stacks;
  28538. columnsMap[axisKey] = columnsOnAxis;
  28539. var stackId = seriesInfo.stackId;
  28540. if (!stacks[stackId]) {
  28541. columnsOnAxis.autoWidthCount++;
  28542. }
  28543. stacks[stackId] = stacks[stackId] || {
  28544. width: 0,
  28545. maxWidth: 0
  28546. };
  28547. // Caution: In a single coordinate system, these barGrid attributes
  28548. // will be shared by series. Consider that they have default values,
  28549. // only the attributes set on the last series will work.
  28550. // Do not change this fact unless there will be a break change.
  28551. // TODO
  28552. var barWidth = seriesInfo.barWidth;
  28553. if (barWidth && !stacks[stackId].width) {
  28554. // See #6312, do not restrict width.
  28555. stacks[stackId].width = barWidth;
  28556. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  28557. columnsOnAxis.remainedWidth -= barWidth;
  28558. }
  28559. var barMaxWidth = seriesInfo.barMaxWidth;
  28560. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  28561. var barGap = seriesInfo.barGap;
  28562. (barGap != null) && (columnsOnAxis.gap = barGap);
  28563. var barCategoryGap = seriesInfo.barCategoryGap;
  28564. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  28565. });
  28566. var result = {};
  28567. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  28568. result[coordSysName] = {};
  28569. var stacks = columnsOnAxis.stacks;
  28570. var bandWidth = columnsOnAxis.bandWidth;
  28571. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  28572. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  28573. var remainedWidth = columnsOnAxis.remainedWidth;
  28574. var autoWidthCount = columnsOnAxis.autoWidthCount;
  28575. var autoWidth = (remainedWidth - categoryGap)
  28576. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  28577. autoWidth = Math.max(autoWidth, 0);
  28578. // Find if any auto calculated bar exceeded maxBarWidth
  28579. zrUtil.each(stacks, function (column, stack) {
  28580. var maxWidth = column.maxWidth;
  28581. if (maxWidth && maxWidth < autoWidth) {
  28582. maxWidth = Math.min(maxWidth, remainedWidth);
  28583. if (column.width) {
  28584. maxWidth = Math.min(maxWidth, column.width);
  28585. }
  28586. remainedWidth -= maxWidth;
  28587. column.width = maxWidth;
  28588. autoWidthCount--;
  28589. }
  28590. });
  28591. // Recalculate width again
  28592. autoWidth = (remainedWidth - categoryGap)
  28593. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  28594. autoWidth = Math.max(autoWidth, 0);
  28595. var widthSum = 0;
  28596. var lastColumn;
  28597. zrUtil.each(stacks, function (column, idx) {
  28598. if (!column.width) {
  28599. column.width = autoWidth;
  28600. }
  28601. lastColumn = column;
  28602. widthSum += column.width * (1 + barGapPercent);
  28603. });
  28604. if (lastColumn) {
  28605. widthSum -= lastColumn.width * barGapPercent;
  28606. }
  28607. var offset = -widthSum / 2;
  28608. zrUtil.each(stacks, function (column, stackId) {
  28609. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  28610. offset: offset,
  28611. width: column.width
  28612. };
  28613. offset += column.width * (1 + barGapPercent);
  28614. });
  28615. });
  28616. return result;
  28617. }
  28618. /**
  28619. * @param {string} seriesType
  28620. * @param {module:echarts/model/Global} ecModel
  28621. * @param {module:echarts/ExtensionAPI} api
  28622. */
  28623. function barLayoutGrid(seriesType, ecModel, api) {
  28624. var barWidthAndOffset = calBarWidthAndOffset(
  28625. zrUtil.filter(
  28626. ecModel.getSeriesByType(seriesType),
  28627. function (seriesModel) {
  28628. return !ecModel.isSeriesFiltered(seriesModel)
  28629. && seriesModel.coordinateSystem
  28630. && seriesModel.coordinateSystem.type === 'cartesian2d';
  28631. }
  28632. )
  28633. );
  28634. var lastStackCoords = {};
  28635. var lastStackCoordsOrigin = {};
  28636. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  28637. // Check series coordinate, do layout for cartesian2d only
  28638. if (seriesModel.coordinateSystem.type !== 'cartesian2d') {
  28639. return;
  28640. }
  28641. var data = seriesModel.getData();
  28642. var cartesian = seriesModel.coordinateSystem;
  28643. var baseAxis = cartesian.getBaseAxis();
  28644. var stackId = getSeriesStackId(seriesModel);
  28645. var columnLayoutInfo = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
  28646. var columnOffset = columnLayoutInfo.offset;
  28647. var columnWidth = columnLayoutInfo.width;
  28648. var valueAxis = cartesian.getOtherAxis(baseAxis);
  28649. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  28650. var valueAxisStart = baseAxis.onZero
  28651. ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0))
  28652. : valueAxis.getGlobalExtent()[0];
  28653. var coordDims = [
  28654. seriesModel.coordDimToDataDim('x')[0],
  28655. seriesModel.coordDimToDataDim('y')[0]
  28656. ];
  28657. var coords = data.mapArray(coordDims, function (x, y) {
  28658. return cartesian.dataToPoint([x, y]);
  28659. }, true);
  28660. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  28661. lastStackCoordsOrigin[stackId] = lastStackCoordsOrigin[stackId] || []; // Fix #4243
  28662. data.setLayout({
  28663. offset: columnOffset,
  28664. size: columnWidth
  28665. });
  28666. data.each(seriesModel.coordDimToDataDim(valueAxis.dim)[0], function (value, idx) {
  28667. if (isNaN(value)) {
  28668. return;
  28669. }
  28670. if (!lastStackCoords[stackId][idx]) {
  28671. lastStackCoords[stackId][idx] = {
  28672. p: valueAxisStart, // Positive stack
  28673. n: valueAxisStart // Negative stack
  28674. };
  28675. lastStackCoordsOrigin[stackId][idx] = {
  28676. p: valueAxisStart, // Positive stack
  28677. n: valueAxisStart // Negative stack
  28678. };
  28679. }
  28680. var sign = value >= 0 ? 'p' : 'n';
  28681. var coord = coords[idx];
  28682. var lastCoord = lastStackCoords[stackId][idx][sign];
  28683. var lastCoordOrigin = lastStackCoordsOrigin[stackId][idx][sign];
  28684. var x;
  28685. var y;
  28686. var width;
  28687. var height;
  28688. if (valueAxis.isHorizontal()) {
  28689. x = lastCoord;
  28690. y = coord[1] + columnOffset;
  28691. width = coord[0] - lastCoordOrigin;
  28692. height = columnWidth;
  28693. lastStackCoordsOrigin[stackId][idx][sign] += width;
  28694. if (Math.abs(width) < barMinHeight) {
  28695. width = (width < 0 ? -1 : 1) * barMinHeight;
  28696. }
  28697. lastStackCoords[stackId][idx][sign] += width;
  28698. }
  28699. else {
  28700. x = coord[0] + columnOffset;
  28701. y = lastCoord;
  28702. width = columnWidth;
  28703. height = coord[1] - lastCoordOrigin;
  28704. lastStackCoordsOrigin[stackId][idx][sign] += height;
  28705. if (Math.abs(height) < barMinHeight) {
  28706. // Include zero to has a positive bar
  28707. height = (height <= 0 ? -1 : 1) * barMinHeight;
  28708. }
  28709. lastStackCoords[stackId][idx][sign] += height;
  28710. }
  28711. data.setItemLayout(idx, {
  28712. x: x,
  28713. y: y,
  28714. width: width,
  28715. height: height
  28716. });
  28717. }, true);
  28718. }, this);
  28719. }
  28720. barLayoutGrid.getLayoutOnAxis = getLayoutOnAxis;
  28721. module.exports = barLayoutGrid;
  28722. /***/ }),
  28723. /* 149 */
  28724. /***/ (function(module, exports, __webpack_require__) {
  28725. var zrUtil = __webpack_require__(4);
  28726. var echarts = __webpack_require__(1);
  28727. __webpack_require__(150);
  28728. __webpack_require__(152);
  28729. __webpack_require__(153)('pie', [{
  28730. type: 'pieToggleSelect',
  28731. event: 'pieselectchanged',
  28732. method: 'toggleSelected'
  28733. }, {
  28734. type: 'pieSelect',
  28735. event: 'pieselected',
  28736. method: 'select'
  28737. }, {
  28738. type: 'pieUnSelect',
  28739. event: 'pieunselected',
  28740. method: 'unSelect'
  28741. }]);
  28742. echarts.registerVisual(zrUtil.curry(__webpack_require__(154), 'pie'));
  28743. echarts.registerLayout(zrUtil.curry(
  28744. __webpack_require__(155), 'pie'
  28745. ));
  28746. echarts.registerProcessor(zrUtil.curry(__webpack_require__(157), 'pie'));
  28747. /***/ }),
  28748. /* 150 */
  28749. /***/ (function(module, exports, __webpack_require__) {
  28750. 'use strict';
  28751. var List = __webpack_require__(101);
  28752. var zrUtil = __webpack_require__(4);
  28753. var modelUtil = __webpack_require__(5);
  28754. var numberUtil = __webpack_require__(7);
  28755. var completeDimensions = __webpack_require__(113);
  28756. var dataSelectableMixin = __webpack_require__(151);
  28757. var PieSeries = __webpack_require__(1).extendSeriesModel({
  28758. type: 'series.pie',
  28759. // Overwrite
  28760. init: function (option) {
  28761. PieSeries.superApply(this, 'init', arguments);
  28762. // Enable legend selection for each data item
  28763. // Use a function instead of direct access because data reference may changed
  28764. this.legendDataProvider = function () {
  28765. return this.getRawData();
  28766. };
  28767. this.updateSelectedMap(option.data);
  28768. this._defaultLabelLine(option);
  28769. },
  28770. // Overwrite
  28771. mergeOption: function (newOption) {
  28772. PieSeries.superCall(this, 'mergeOption', newOption);
  28773. this.updateSelectedMap(this.option.data);
  28774. },
  28775. getInitialData: function (option, ecModel) {
  28776. var dimensions = completeDimensions(['value'], option.data);
  28777. var list = new List(dimensions, this);
  28778. list.initData(option.data);
  28779. return list;
  28780. },
  28781. // Overwrite
  28782. getDataParams: function (dataIndex) {
  28783. var data = this.getData();
  28784. var params = PieSeries.superCall(this, 'getDataParams', dataIndex);
  28785. // FIXME toFixed?
  28786. var valueList = [];
  28787. data.each('value', function (value) {
  28788. valueList.push(value);
  28789. });
  28790. params.percent = numberUtil.getPercentWithPrecision(
  28791. valueList,
  28792. dataIndex,
  28793. data.hostModel.get('percentPrecision')
  28794. );
  28795. params.$vars.push('percent');
  28796. return params;
  28797. },
  28798. _defaultLabelLine: function (option) {
  28799. // Extend labelLine emphasis
  28800. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  28801. var labelLineNormalOpt = option.labelLine.normal;
  28802. var labelLineEmphasisOpt = option.labelLine.emphasis;
  28803. // Not show label line if `label.normal.show = false`
  28804. labelLineNormalOpt.show = labelLineNormalOpt.show
  28805. && option.label.normal.show;
  28806. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  28807. && option.label.emphasis.show;
  28808. },
  28809. defaultOption: {
  28810. zlevel: 0,
  28811. z: 2,
  28812. legendHoverLink: true,
  28813. hoverAnimation: true,
  28814. // 默认全局居中
  28815. center: ['50%', '50%'],
  28816. radius: [0, '75%'],
  28817. // 默认顺时针
  28818. clockwise: true,
  28819. startAngle: 90,
  28820. // 最小角度改为0
  28821. minAngle: 0,
  28822. // 选中时扇区偏移量
  28823. selectedOffset: 10,
  28824. // 高亮扇区偏移量
  28825. hoverOffset: 10,
  28826. // If use strategy to avoid label overlapping
  28827. avoidLabelOverlap: true,
  28828. // 选择模式,默认关闭,可选single,multiple
  28829. // selectedMode: false,
  28830. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  28831. // roseType: null,
  28832. percentPrecision: 2,
  28833. // If still show when all data zero.
  28834. stillShowZeroSum: true,
  28835. // cursor: null,
  28836. label: {
  28837. normal: {
  28838. // If rotate around circle
  28839. rotate: false,
  28840. show: true,
  28841. // 'outer', 'inside', 'center'
  28842. position: 'outer'
  28843. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  28844. // 默认使用全局文本样式,详见TEXTSTYLE
  28845. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  28846. },
  28847. emphasis: {}
  28848. },
  28849. // Enabled when label.normal.position is 'outer'
  28850. labelLine: {
  28851. normal: {
  28852. show: true,
  28853. // 引导线两段中的第一段长度
  28854. length: 15,
  28855. // 引导线两段中的第二段长度
  28856. length2: 15,
  28857. smooth: false,
  28858. lineStyle: {
  28859. // color: 各异,
  28860. width: 1,
  28861. type: 'solid'
  28862. }
  28863. }
  28864. },
  28865. itemStyle: {
  28866. normal: {
  28867. borderWidth: 1
  28868. },
  28869. emphasis: {}
  28870. },
  28871. // Animation type canbe expansion, scale
  28872. animationType: 'expansion',
  28873. animationEasing: 'cubicOut',
  28874. data: []
  28875. }
  28876. });
  28877. zrUtil.mixin(PieSeries, dataSelectableMixin);
  28878. module.exports = PieSeries;
  28879. /***/ }),
  28880. /* 151 */
  28881. /***/ (function(module, exports, __webpack_require__) {
  28882. /**
  28883. * Data selectable mixin for chart series.
  28884. * To eanble data select, option of series must have `selectedMode`.
  28885. * And each data item will use `selected` to toggle itself selected status
  28886. *
  28887. * @module echarts/chart/helper/DataSelectable
  28888. */
  28889. var zrUtil = __webpack_require__(4);
  28890. module.exports = {
  28891. updateSelectedMap: function (targetList) {
  28892. this._targetList = targetList.slice();
  28893. this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
  28894. targetMap.set(target.name, target);
  28895. return targetMap;
  28896. }, zrUtil.createHashMap());
  28897. },
  28898. /**
  28899. * Either name or id should be passed as input here.
  28900. * If both of them are defined, id is used.
  28901. *
  28902. * @param {string|undefined} name name of data
  28903. * @param {number|undefined} id dataIndex of data
  28904. */
  28905. // PENGING If selectedMode is null ?
  28906. select: function (name, id) {
  28907. var target = id != null
  28908. ? this._targetList[id]
  28909. : this._selectTargetMap.get(name);
  28910. var selectedMode = this.get('selectedMode');
  28911. if (selectedMode === 'single') {
  28912. this._selectTargetMap.each(function (target) {
  28913. target.selected = false;
  28914. });
  28915. }
  28916. target && (target.selected = true);
  28917. },
  28918. /**
  28919. * Either name or id should be passed as input here.
  28920. * If both of them are defined, id is used.
  28921. *
  28922. * @param {string|undefined} name name of data
  28923. * @param {number|undefined} id dataIndex of data
  28924. */
  28925. unSelect: function (name, id) {
  28926. var target = id != null
  28927. ? this._targetList[id]
  28928. : this._selectTargetMap.get(name);
  28929. // var selectedMode = this.get('selectedMode');
  28930. // selectedMode !== 'single' && target && (target.selected = false);
  28931. target && (target.selected = false);
  28932. },
  28933. /**
  28934. * Either name or id should be passed as input here.
  28935. * If both of them are defined, id is used.
  28936. *
  28937. * @param {string|undefined} name name of data
  28938. * @param {number|undefined} id dataIndex of data
  28939. */
  28940. toggleSelected: function (name, id) {
  28941. var target = id != null
  28942. ? this._targetList[id]
  28943. : this._selectTargetMap.get(name);
  28944. if (target != null) {
  28945. this[target.selected ? 'unSelect' : 'select'](name, id);
  28946. return target.selected;
  28947. }
  28948. },
  28949. /**
  28950. * Either name or id should be passed as input here.
  28951. * If both of them are defined, id is used.
  28952. *
  28953. * @param {string|undefined} name name of data
  28954. * @param {number|undefined} id dataIndex of data
  28955. */
  28956. isSelected: function (name, id) {
  28957. var target = id != null
  28958. ? this._targetList[id]
  28959. : this._selectTargetMap.get(name);
  28960. return target && target.selected;
  28961. }
  28962. };
  28963. /***/ }),
  28964. /* 152 */
  28965. /***/ (function(module, exports, __webpack_require__) {
  28966. var graphic = __webpack_require__(20);
  28967. var zrUtil = __webpack_require__(4);
  28968. /**
  28969. * @param {module:echarts/model/Series} seriesModel
  28970. * @param {boolean} hasAnimation
  28971. * @inner
  28972. */
  28973. function updateDataSelected(uid, seriesModel, hasAnimation, api) {
  28974. var data = seriesModel.getData();
  28975. var dataIndex = this.dataIndex;
  28976. var name = data.getName(dataIndex);
  28977. var selectedOffset = seriesModel.get('selectedOffset');
  28978. api.dispatchAction({
  28979. type: 'pieToggleSelect',
  28980. from: uid,
  28981. name: name,
  28982. seriesId: seriesModel.id
  28983. });
  28984. data.each(function (idx) {
  28985. toggleItemSelected(
  28986. data.getItemGraphicEl(idx),
  28987. data.getItemLayout(idx),
  28988. seriesModel.isSelected(data.getName(idx)),
  28989. selectedOffset,
  28990. hasAnimation
  28991. );
  28992. });
  28993. }
  28994. /**
  28995. * @param {module:zrender/graphic/Sector} el
  28996. * @param {Object} layout
  28997. * @param {boolean} isSelected
  28998. * @param {number} selectedOffset
  28999. * @param {boolean} hasAnimation
  29000. * @inner
  29001. */
  29002. function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) {
  29003. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  29004. var dx = Math.cos(midAngle);
  29005. var dy = Math.sin(midAngle);
  29006. var offset = isSelected ? selectedOffset : 0;
  29007. var position = [dx * offset, dy * offset];
  29008. hasAnimation
  29009. // animateTo will stop revious animation like update transition
  29010. ? el.animate()
  29011. .when(200, {
  29012. position: position
  29013. })
  29014. .start('bounceOut')
  29015. : el.attr('position', position);
  29016. }
  29017. /**
  29018. * Piece of pie including Sector, Label, LabelLine
  29019. * @constructor
  29020. * @extends {module:zrender/graphic/Group}
  29021. */
  29022. function PiePiece(data, idx) {
  29023. graphic.Group.call(this);
  29024. var sector = new graphic.Sector({
  29025. z2: 2
  29026. });
  29027. var polyline = new graphic.Polyline();
  29028. var text = new graphic.Text();
  29029. this.add(sector);
  29030. this.add(polyline);
  29031. this.add(text);
  29032. this.updateData(data, idx, true);
  29033. // Hover to change label and labelLine
  29034. function onEmphasis() {
  29035. polyline.ignore = polyline.hoverIgnore;
  29036. text.ignore = text.hoverIgnore;
  29037. }
  29038. function onNormal() {
  29039. polyline.ignore = polyline.normalIgnore;
  29040. text.ignore = text.normalIgnore;
  29041. }
  29042. this.on('emphasis', onEmphasis)
  29043. .on('normal', onNormal)
  29044. .on('mouseover', onEmphasis)
  29045. .on('mouseout', onNormal);
  29046. }
  29047. var piePieceProto = PiePiece.prototype;
  29048. piePieceProto.updateData = function (data, idx, firstCreate) {
  29049. var sector = this.childAt(0);
  29050. var seriesModel = data.hostModel;
  29051. var itemModel = data.getItemModel(idx);
  29052. var layout = data.getItemLayout(idx);
  29053. var sectorShape = zrUtil.extend({}, layout);
  29054. sectorShape.label = null;
  29055. if (firstCreate) {
  29056. sector.setShape(sectorShape);
  29057. var animationType = seriesModel.getShallow('animationType');
  29058. if (animationType === 'scale') {
  29059. sector.shape.r = layout.r0;
  29060. graphic.initProps(sector, {
  29061. shape: {
  29062. r: layout.r
  29063. }
  29064. }, seriesModel, idx);
  29065. }
  29066. // Expansion
  29067. else {
  29068. sector.shape.endAngle = layout.startAngle;
  29069. graphic.updateProps(sector, {
  29070. shape: {
  29071. endAngle: layout.endAngle
  29072. }
  29073. }, seriesModel, idx);
  29074. }
  29075. }
  29076. else {
  29077. graphic.updateProps(sector, {
  29078. shape: sectorShape
  29079. }, seriesModel, idx);
  29080. }
  29081. // Update common style
  29082. var itemStyleModel = itemModel.getModel('itemStyle');
  29083. var visualColor = data.getItemVisual(idx, 'color');
  29084. sector.useStyle(
  29085. zrUtil.defaults(
  29086. {
  29087. lineJoin: 'bevel',
  29088. fill: visualColor
  29089. },
  29090. itemStyleModel.getModel('normal').getItemStyle()
  29091. )
  29092. );
  29093. sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  29094. var cursorStyle = itemModel.getShallow('cursor');
  29095. cursorStyle && sector.attr('cursor', cursorStyle);
  29096. // Toggle selected
  29097. toggleItemSelected(
  29098. this,
  29099. data.getItemLayout(idx),
  29100. itemModel.get('selected'),
  29101. seriesModel.get('selectedOffset'),
  29102. seriesModel.get('animation')
  29103. );
  29104. function onEmphasis() {
  29105. // Sector may has animation of updating data. Force to move to the last frame
  29106. // Or it may stopped on the wrong shape
  29107. sector.stopAnimation(true);
  29108. sector.animateTo({
  29109. shape: {
  29110. r: layout.r + seriesModel.get('hoverOffset')
  29111. }
  29112. }, 300, 'elasticOut');
  29113. }
  29114. function onNormal() {
  29115. sector.stopAnimation(true);
  29116. sector.animateTo({
  29117. shape: {
  29118. r: layout.r
  29119. }
  29120. }, 300, 'elasticOut');
  29121. }
  29122. sector.off('mouseover').off('mouseout').off('emphasis').off('normal');
  29123. if (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled()) {
  29124. sector
  29125. .on('mouseover', onEmphasis)
  29126. .on('mouseout', onNormal)
  29127. .on('emphasis', onEmphasis)
  29128. .on('normal', onNormal);
  29129. }
  29130. this._updateLabel(data, idx);
  29131. graphic.setHoverStyle(this);
  29132. };
  29133. piePieceProto._updateLabel = function (data, idx) {
  29134. var labelLine = this.childAt(1);
  29135. var labelText = this.childAt(2);
  29136. var seriesModel = data.hostModel;
  29137. var itemModel = data.getItemModel(idx);
  29138. var layout = data.getItemLayout(idx);
  29139. var labelLayout = layout.label;
  29140. var visualColor = data.getItemVisual(idx, 'color');
  29141. graphic.updateProps(labelLine, {
  29142. shape: {
  29143. points: labelLayout.linePoints || [
  29144. [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y]
  29145. ]
  29146. }
  29147. }, seriesModel, idx);
  29148. graphic.updateProps(labelText, {
  29149. style: {
  29150. x: labelLayout.x,
  29151. y: labelLayout.y
  29152. }
  29153. }, seriesModel, idx);
  29154. labelText.attr({
  29155. rotation: labelLayout.rotation,
  29156. origin: [labelLayout.x, labelLayout.y],
  29157. z2: 10
  29158. });
  29159. var labelModel = itemModel.getModel('label.normal');
  29160. var labelHoverModel = itemModel.getModel('label.emphasis');
  29161. var labelLineModel = itemModel.getModel('labelLine.normal');
  29162. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  29163. var visualColor = data.getItemVisual(idx, 'color');
  29164. graphic.setLabelStyle(
  29165. labelText.style, labelText.hoverStyle = {}, labelModel, labelHoverModel,
  29166. {
  29167. labelFetcher: data.hostModel,
  29168. labelDataIndex: idx,
  29169. defaultText: data.getName(idx),
  29170. autoColor: visualColor,
  29171. useInsideStyle: !!labelLayout.inside
  29172. },
  29173. {
  29174. textAlign: labelLayout.textAlign,
  29175. textVerticalAlign: labelLayout.verticalAlign,
  29176. opacity: data.getItemVisual(idx, 'opacity')
  29177. }
  29178. );
  29179. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  29180. labelText.hoverIgnore = !labelHoverModel.get('show');
  29181. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  29182. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  29183. // Default use item visual color
  29184. labelLine.setStyle({
  29185. stroke: visualColor,
  29186. opacity: data.getItemVisual(idx, 'opacity')
  29187. });
  29188. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  29189. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  29190. var smooth = labelLineModel.get('smooth');
  29191. if (smooth && smooth === true) {
  29192. smooth = 0.4;
  29193. }
  29194. labelLine.setShape({
  29195. smooth: smooth
  29196. });
  29197. };
  29198. zrUtil.inherits(PiePiece, graphic.Group);
  29199. // Pie view
  29200. var Pie = __webpack_require__(85).extend({
  29201. type: 'pie',
  29202. init: function () {
  29203. var sectorGroup = new graphic.Group();
  29204. this._sectorGroup = sectorGroup;
  29205. },
  29206. render: function (seriesModel, ecModel, api, payload) {
  29207. if (payload && (payload.from === this.uid)) {
  29208. return;
  29209. }
  29210. var data = seriesModel.getData();
  29211. var oldData = this._data;
  29212. var group = this.group;
  29213. var hasAnimation = ecModel.get('animation');
  29214. var isFirstRender = !oldData;
  29215. var animationType = seriesModel.get('animationType');
  29216. var onSectorClick = zrUtil.curry(
  29217. updateDataSelected, this.uid, seriesModel, hasAnimation, api
  29218. );
  29219. var selectedMode = seriesModel.get('selectedMode');
  29220. data.diff(oldData)
  29221. .add(function (idx) {
  29222. var piePiece = new PiePiece(data, idx);
  29223. // Default expansion animation
  29224. if (isFirstRender && animationType !== 'scale') {
  29225. piePiece.eachChild(function (child) {
  29226. child.stopAnimation(true);
  29227. });
  29228. }
  29229. selectedMode && piePiece.on('click', onSectorClick);
  29230. data.setItemGraphicEl(idx, piePiece);
  29231. group.add(piePiece);
  29232. })
  29233. .update(function (newIdx, oldIdx) {
  29234. var piePiece = oldData.getItemGraphicEl(oldIdx);
  29235. piePiece.updateData(data, newIdx);
  29236. piePiece.off('click');
  29237. selectedMode && piePiece.on('click', onSectorClick);
  29238. group.add(piePiece);
  29239. data.setItemGraphicEl(newIdx, piePiece);
  29240. })
  29241. .remove(function (idx) {
  29242. var piePiece = oldData.getItemGraphicEl(idx);
  29243. group.remove(piePiece);
  29244. })
  29245. .execute();
  29246. if (
  29247. hasAnimation && isFirstRender && data.count() > 0
  29248. // Default expansion animation
  29249. && animationType !== 'scale'
  29250. ) {
  29251. var shape = data.getItemLayout(0);
  29252. var r = Math.max(api.getWidth(), api.getHeight()) / 2;
  29253. var removeClipPath = zrUtil.bind(group.removeClipPath, group);
  29254. group.setClipPath(this._createClipPath(
  29255. shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel
  29256. ));
  29257. }
  29258. this._data = data;
  29259. },
  29260. dispose: function () {},
  29261. _createClipPath: function (
  29262. cx, cy, r, startAngle, clockwise, cb, seriesModel
  29263. ) {
  29264. var clipPath = new graphic.Sector({
  29265. shape: {
  29266. cx: cx,
  29267. cy: cy,
  29268. r0: 0,
  29269. r: r,
  29270. startAngle: startAngle,
  29271. endAngle: startAngle,
  29272. clockwise: clockwise
  29273. }
  29274. });
  29275. graphic.initProps(clipPath, {
  29276. shape: {
  29277. endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2
  29278. }
  29279. }, seriesModel, cb);
  29280. return clipPath;
  29281. },
  29282. /**
  29283. * @implement
  29284. */
  29285. containPoint: function (point, seriesModel) {
  29286. var data = seriesModel.getData();
  29287. var itemLayout = data.getItemLayout(0);
  29288. if (itemLayout) {
  29289. var dx = point[0] - itemLayout.cx;
  29290. var dy = point[1] - itemLayout.cy;
  29291. var radius = Math.sqrt(dx * dx + dy * dy);
  29292. return radius <= itemLayout.r && radius >= itemLayout.r0;
  29293. }
  29294. }
  29295. });
  29296. module.exports = Pie;
  29297. /***/ }),
  29298. /* 153 */
  29299. /***/ (function(module, exports, __webpack_require__) {
  29300. var echarts = __webpack_require__(1);
  29301. var zrUtil = __webpack_require__(4);
  29302. module.exports = function (seriesType, actionInfos) {
  29303. zrUtil.each(actionInfos, function (actionInfo) {
  29304. actionInfo.update = 'updateView';
  29305. /**
  29306. * @payload
  29307. * @property {string} seriesName
  29308. * @property {string} name
  29309. */
  29310. echarts.registerAction(actionInfo, function (payload, ecModel) {
  29311. var selected = {};
  29312. ecModel.eachComponent(
  29313. {mainType: 'series', subType: seriesType, query: payload},
  29314. function (seriesModel) {
  29315. if (seriesModel[actionInfo.method]) {
  29316. seriesModel[actionInfo.method](
  29317. payload.name,
  29318. payload.dataIndex
  29319. );
  29320. }
  29321. var data = seriesModel.getData();
  29322. // Create selected map
  29323. data.each(function (idx) {
  29324. var name = data.getName(idx);
  29325. selected[name] = seriesModel.isSelected(name)
  29326. || false;
  29327. });
  29328. }
  29329. );
  29330. return {
  29331. name: payload.name,
  29332. selected: selected
  29333. };
  29334. });
  29335. });
  29336. };
  29337. /***/ }),
  29338. /* 154 */
  29339. /***/ (function(module, exports) {
  29340. // Pick color from palette for each data item.
  29341. // Applicable for charts that require applying color palette
  29342. // in data level (like pie, funnel, chord).
  29343. module.exports = function (seriesType, ecModel) {
  29344. // Pie and funnel may use diferrent scope
  29345. var paletteScope = {};
  29346. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  29347. var dataAll = seriesModel.getRawData();
  29348. var idxMap = {};
  29349. if (!ecModel.isSeriesFiltered(seriesModel)) {
  29350. var data = seriesModel.getData();
  29351. data.each(function (idx) {
  29352. var rawIdx = data.getRawIndex(idx);
  29353. idxMap[rawIdx] = idx;
  29354. });
  29355. dataAll.each(function (rawIdx) {
  29356. var filteredIdx = idxMap[rawIdx];
  29357. // If series.itemStyle.normal.color is a function. itemVisual may be encoded
  29358. var singleDataColor = filteredIdx != null
  29359. && data.getItemVisual(filteredIdx, 'color', true);
  29360. if (!singleDataColor) {
  29361. // FIXME Performance
  29362. var itemModel = dataAll.getItemModel(rawIdx);
  29363. var color = itemModel.get('itemStyle.normal.color')
  29364. || seriesModel.getColorFromPalette(dataAll.getName(rawIdx), paletteScope);
  29365. // Legend may use the visual info in data before processed
  29366. dataAll.setItemVisual(rawIdx, 'color', color);
  29367. // Data is not filtered
  29368. if (filteredIdx != null) {
  29369. data.setItemVisual(filteredIdx, 'color', color);
  29370. }
  29371. }
  29372. else {
  29373. // Set data all color for legend
  29374. dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
  29375. }
  29376. });
  29377. }
  29378. });
  29379. };
  29380. /***/ }),
  29381. /* 155 */
  29382. /***/ (function(module, exports, __webpack_require__) {
  29383. var numberUtil = __webpack_require__(7);
  29384. var parsePercent = numberUtil.parsePercent;
  29385. var labelLayout = __webpack_require__(156);
  29386. var zrUtil = __webpack_require__(4);
  29387. var PI2 = Math.PI * 2;
  29388. var RADIAN = Math.PI / 180;
  29389. module.exports = function (seriesType, ecModel, api, payload) {
  29390. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  29391. var center = seriesModel.get('center');
  29392. var radius = seriesModel.get('radius');
  29393. if (!zrUtil.isArray(radius)) {
  29394. radius = [0, radius];
  29395. }
  29396. if (!zrUtil.isArray(center)) {
  29397. center = [center, center];
  29398. }
  29399. var width = api.getWidth();
  29400. var height = api.getHeight();
  29401. var size = Math.min(width, height);
  29402. var cx = parsePercent(center[0], width);
  29403. var cy = parsePercent(center[1], height);
  29404. var r0 = parsePercent(radius[0], size / 2);
  29405. var r = parsePercent(radius[1], size / 2);
  29406. var data = seriesModel.getData();
  29407. var startAngle = -seriesModel.get('startAngle') * RADIAN;
  29408. var minAngle = seriesModel.get('minAngle') * RADIAN;
  29409. var validDataCount = 0;
  29410. data.each('value', function (value) {
  29411. !isNaN(value) && validDataCount++;
  29412. });
  29413. var sum = data.getSum('value');
  29414. // Sum may be 0
  29415. var unitRadian = Math.PI / (sum || validDataCount) * 2;
  29416. var clockwise = seriesModel.get('clockwise');
  29417. var roseType = seriesModel.get('roseType');
  29418. var stillShowZeroSum = seriesModel.get('stillShowZeroSum');
  29419. // [0...max]
  29420. var extent = data.getDataExtent('value');
  29421. extent[0] = 0;
  29422. // In the case some sector angle is smaller than minAngle
  29423. var restAngle = PI2;
  29424. var valueSumLargerThanMinAngle = 0;
  29425. var currentAngle = startAngle;
  29426. var dir = clockwise ? 1 : -1;
  29427. data.each('value', function (value, idx) {
  29428. var angle;
  29429. if (isNaN(value)) {
  29430. data.setItemLayout(idx, {
  29431. angle: NaN,
  29432. startAngle: NaN,
  29433. endAngle: NaN,
  29434. clockwise: clockwise,
  29435. cx: cx,
  29436. cy: cy,
  29437. r0: r0,
  29438. r: roseType
  29439. ? NaN
  29440. : r
  29441. });
  29442. return;
  29443. }
  29444. // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  29445. if (roseType !== 'area') {
  29446. angle = (sum === 0 && stillShowZeroSum)
  29447. ? unitRadian : (value * unitRadian);
  29448. }
  29449. else {
  29450. angle = PI2 / validDataCount;
  29451. }
  29452. if (angle < minAngle) {
  29453. angle = minAngle;
  29454. restAngle -= minAngle;
  29455. }
  29456. else {
  29457. valueSumLargerThanMinAngle += value;
  29458. }
  29459. var endAngle = currentAngle + dir * angle;
  29460. data.setItemLayout(idx, {
  29461. angle: angle,
  29462. startAngle: currentAngle,
  29463. endAngle: endAngle,
  29464. clockwise: clockwise,
  29465. cx: cx,
  29466. cy: cy,
  29467. r0: r0,
  29468. r: roseType
  29469. ? numberUtil.linearMap(value, extent, [r0, r])
  29470. : r
  29471. });
  29472. currentAngle = endAngle;
  29473. }, true);
  29474. // Some sector is constrained by minAngle
  29475. // Rest sectors needs recalculate angle
  29476. if (restAngle < PI2 && validDataCount) {
  29477. // Average the angle if rest angle is not enough after all angles is
  29478. // Constrained by minAngle
  29479. if (restAngle <= 1e-3) {
  29480. var angle = PI2 / validDataCount;
  29481. data.each('value', function (value, idx) {
  29482. if (!isNaN(value)) {
  29483. var layout = data.getItemLayout(idx);
  29484. layout.angle = angle;
  29485. layout.startAngle = startAngle + dir * idx * angle;
  29486. layout.endAngle = startAngle + dir * (idx + 1) * angle;
  29487. }
  29488. });
  29489. }
  29490. else {
  29491. unitRadian = restAngle / valueSumLargerThanMinAngle;
  29492. currentAngle = startAngle;
  29493. data.each('value', function (value, idx) {
  29494. if (!isNaN(value)) {
  29495. var layout = data.getItemLayout(idx);
  29496. var angle = layout.angle === minAngle
  29497. ? minAngle : value * unitRadian;
  29498. layout.startAngle = currentAngle;
  29499. layout.endAngle = currentAngle + dir * angle;
  29500. currentAngle += dir * angle;
  29501. }
  29502. });
  29503. }
  29504. }
  29505. labelLayout(seriesModel, r, width, height);
  29506. });
  29507. };
  29508. /***/ }),
  29509. /* 156 */
  29510. /***/ (function(module, exports, __webpack_require__) {
  29511. 'use strict';
  29512. // FIXME emphasis label position is not same with normal label position
  29513. var textContain = __webpack_require__(8);
  29514. function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
  29515. list.sort(function (a, b) {
  29516. return a.y - b.y;
  29517. });
  29518. // 压
  29519. function shiftDown(start, end, delta, dir) {
  29520. for (var j = start; j < end; j++) {
  29521. list[j].y += delta;
  29522. if (j > start
  29523. && j + 1 < end
  29524. && list[j + 1].y > list[j].y + list[j].height
  29525. ) {
  29526. shiftUp(j, delta / 2);
  29527. return;
  29528. }
  29529. }
  29530. shiftUp(end - 1, delta / 2);
  29531. }
  29532. // 弹
  29533. function shiftUp(end, delta) {
  29534. for (var j = end; j >= 0; j--) {
  29535. list[j].y -= delta;
  29536. if (j > 0
  29537. && list[j].y > list[j - 1].y + list[j - 1].height
  29538. ) {
  29539. break;
  29540. }
  29541. }
  29542. }
  29543. function changeX(list, isDownList, cx, cy, r, dir) {
  29544. var lastDeltaX = dir > 0
  29545. ? isDownList // 右侧
  29546. ? Number.MAX_VALUE // 下
  29547. : 0 // 上
  29548. : isDownList // 左侧
  29549. ? Number.MAX_VALUE // 下
  29550. : 0; // 上
  29551. for (var i = 0, l = list.length; i < l; i++) {
  29552. // Not change x for center label
  29553. if (list[i].position === 'center') {
  29554. continue;
  29555. }
  29556. var deltaY = Math.abs(list[i].y - cy);
  29557. var length = list[i].len;
  29558. var length2 = list[i].len2;
  29559. var deltaX = (deltaY < r + length)
  29560. ? Math.sqrt(
  29561. (r + length + length2) * (r + length + length2)
  29562. - deltaY * deltaY
  29563. )
  29564. : Math.abs(list[i].x - cx);
  29565. if (isDownList && deltaX >= lastDeltaX) {
  29566. // 右下,左下
  29567. deltaX = lastDeltaX - 10;
  29568. }
  29569. if (!isDownList && deltaX <= lastDeltaX) {
  29570. // 右上,左上
  29571. deltaX = lastDeltaX + 10;
  29572. }
  29573. list[i].x = cx + deltaX * dir;
  29574. lastDeltaX = deltaX;
  29575. }
  29576. }
  29577. var lastY = 0;
  29578. var delta;
  29579. var len = list.length;
  29580. var upList = [];
  29581. var downList = [];
  29582. for (var i = 0; i < len; i++) {
  29583. delta = list[i].y - lastY;
  29584. if (delta < 0) {
  29585. shiftDown(i, len, -delta, dir);
  29586. }
  29587. lastY = list[i].y + list[i].height;
  29588. }
  29589. if (viewHeight - lastY < 0) {
  29590. shiftUp(len - 1, lastY - viewHeight);
  29591. }
  29592. for (var i = 0; i < len; i++) {
  29593. if (list[i].y >= cy) {
  29594. downList.push(list[i]);
  29595. }
  29596. else {
  29597. upList.push(list[i]);
  29598. }
  29599. }
  29600. changeX(upList, false, cx, cy, r, dir);
  29601. changeX(downList, true, cx, cy, r, dir);
  29602. }
  29603. function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
  29604. var leftList = [];
  29605. var rightList = [];
  29606. for (var i = 0; i < labelLayoutList.length; i++) {
  29607. if (labelLayoutList[i].x < cx) {
  29608. leftList.push(labelLayoutList[i]);
  29609. }
  29610. else {
  29611. rightList.push(labelLayoutList[i]);
  29612. }
  29613. }
  29614. adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
  29615. adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
  29616. for (var i = 0; i < labelLayoutList.length; i++) {
  29617. var linePoints = labelLayoutList[i].linePoints;
  29618. if (linePoints) {
  29619. var dist = linePoints[1][0] - linePoints[2][0];
  29620. if (labelLayoutList[i].x < cx) {
  29621. linePoints[2][0] = labelLayoutList[i].x + 3;
  29622. }
  29623. else {
  29624. linePoints[2][0] = labelLayoutList[i].x - 3;
  29625. }
  29626. linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
  29627. linePoints[1][0] = linePoints[2][0] + dist;
  29628. }
  29629. }
  29630. }
  29631. module.exports = function (seriesModel, r, viewWidth, viewHeight) {
  29632. var data = seriesModel.getData();
  29633. var labelLayoutList = [];
  29634. var cx;
  29635. var cy;
  29636. var hasLabelRotate = false;
  29637. data.each(function (idx) {
  29638. var layout = data.getItemLayout(idx);
  29639. var itemModel = data.getItemModel(idx);
  29640. var labelModel = itemModel.getModel('label.normal');
  29641. // Use position in normal or emphasis
  29642. var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position');
  29643. var labelLineModel = itemModel.getModel('labelLine.normal');
  29644. var labelLineLen = labelLineModel.get('length');
  29645. var labelLineLen2 = labelLineModel.get('length2');
  29646. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  29647. var dx = Math.cos(midAngle);
  29648. var dy = Math.sin(midAngle);
  29649. var textX;
  29650. var textY;
  29651. var linePoints;
  29652. var textAlign;
  29653. cx = layout.cx;
  29654. cy = layout.cy;
  29655. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  29656. if (labelPosition === 'center') {
  29657. textX = layout.cx;
  29658. textY = layout.cy;
  29659. textAlign = 'center';
  29660. }
  29661. else {
  29662. var x1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dx : layout.r * dx) + cx;
  29663. var y1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dy : layout.r * dy) + cy;
  29664. textX = x1 + dx * 3;
  29665. textY = y1 + dy * 3;
  29666. if (!isLabelInside) {
  29667. // For roseType
  29668. var x2 = x1 + dx * (labelLineLen + r - layout.r);
  29669. var y2 = y1 + dy * (labelLineLen + r - layout.r);
  29670. var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
  29671. var y3 = y2;
  29672. textX = x3 + (dx < 0 ? -5 : 5);
  29673. textY = y3;
  29674. linePoints = [[x1, y1], [x2, y2], [x3, y3]];
  29675. }
  29676. textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
  29677. }
  29678. var font = labelModel.getFont();
  29679. var labelRotate = labelModel.get('rotate')
  29680. ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0;
  29681. var text = seriesModel.getFormattedLabel(idx, 'normal')
  29682. || data.getName(idx);
  29683. var textRect = textContain.getBoundingRect(
  29684. text, font, textAlign, 'top'
  29685. );
  29686. hasLabelRotate = !!labelRotate;
  29687. layout.label = {
  29688. x: textX,
  29689. y: textY,
  29690. position: labelPosition,
  29691. height: textRect.height,
  29692. len: labelLineLen,
  29693. len2: labelLineLen2,
  29694. linePoints: linePoints,
  29695. textAlign: textAlign,
  29696. verticalAlign: 'middle',
  29697. rotation: labelRotate,
  29698. inside: isLabelInside
  29699. };
  29700. // Not layout the inside label
  29701. if (!isLabelInside) {
  29702. labelLayoutList.push(layout.label);
  29703. }
  29704. });
  29705. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  29706. avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
  29707. }
  29708. };
  29709. /***/ }),
  29710. /* 157 */
  29711. /***/ (function(module, exports) {
  29712. module.exports = function (seriesType, ecModel) {
  29713. var legendModels = ecModel.findComponents({
  29714. mainType: 'legend'
  29715. });
  29716. if (!legendModels || !legendModels.length) {
  29717. return;
  29718. }
  29719. ecModel.eachSeriesByType(seriesType, function (series) {
  29720. var data = series.getData();
  29721. data.filterSelf(function (idx) {
  29722. var name = data.getName(idx);
  29723. // If in any legend component the status is not selected.
  29724. for (var i = 0; i < legendModels.length; i++) {
  29725. if (!legendModels[i].isSelected(name)) {
  29726. return false;
  29727. }
  29728. }
  29729. return true;
  29730. }, this);
  29731. }, this);
  29732. };
  29733. /***/ }),
  29734. /* 158 */
  29735. /***/ (function(module, exports, __webpack_require__) {
  29736. var zrUtil = __webpack_require__(4);
  29737. var echarts = __webpack_require__(1);
  29738. __webpack_require__(159);
  29739. __webpack_require__(160);
  29740. echarts.registerVisual(zrUtil.curry(
  29741. __webpack_require__(124), 'scatter', 'circle', null
  29742. ));
  29743. echarts.registerLayout(zrUtil.curry(
  29744. __webpack_require__(125), 'scatter'
  29745. ));
  29746. // In case developer forget to include grid component
  29747. __webpack_require__(127);
  29748. /***/ }),
  29749. /* 159 */
  29750. /***/ (function(module, exports, __webpack_require__) {
  29751. 'use strict';
  29752. var createListFromArray = __webpack_require__(112);
  29753. var SeriesModel = __webpack_require__(83);
  29754. module.exports = SeriesModel.extend({
  29755. type: 'series.scatter',
  29756. dependencies: ['grid', 'polar', 'geo', 'singleAxis', 'calendar'],
  29757. getInitialData: function (option, ecModel) {
  29758. return createListFromArray(option.data, this, ecModel);
  29759. },
  29760. brushSelector: 'point',
  29761. defaultOption: {
  29762. coordinateSystem: 'cartesian2d',
  29763. zlevel: 0,
  29764. z: 2,
  29765. legendHoverLink: true,
  29766. hoverAnimation: true,
  29767. // Cartesian coordinate system
  29768. // xAxisIndex: 0,
  29769. // yAxisIndex: 0,
  29770. // Polar coordinate system
  29771. // polarIndex: 0,
  29772. // Geo coordinate system
  29773. // geoIndex: 0,
  29774. // symbol: null, // 图形类型
  29775. symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  29776. // symbolRotate: null, // 图形旋转控制
  29777. large: false,
  29778. // Available when large is true
  29779. largeThreshold: 2000,
  29780. // cursor: null,
  29781. // label: {
  29782. // normal: {
  29783. // show: false
  29784. // distance: 5,
  29785. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  29786. // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
  29787. // 'inside'|'left'|'right'|'top'|'bottom'
  29788. // 默认使用全局文本样式,详见TEXTSTYLE
  29789. // }
  29790. // },
  29791. itemStyle: {
  29792. normal: {
  29793. opacity: 0.8
  29794. // color: 各异
  29795. }
  29796. }
  29797. }
  29798. });
  29799. /***/ }),
  29800. /* 160 */
  29801. /***/ (function(module, exports, __webpack_require__) {
  29802. var SymbolDraw = __webpack_require__(119);
  29803. var LargeSymbolDraw = __webpack_require__(161);
  29804. __webpack_require__(1).extendChartView({
  29805. type: 'scatter',
  29806. init: function () {
  29807. this._normalSymbolDraw = new SymbolDraw();
  29808. this._largeSymbolDraw = new LargeSymbolDraw();
  29809. },
  29810. render: function (seriesModel, ecModel, api) {
  29811. var data = seriesModel.getData();
  29812. var largeSymbolDraw = this._largeSymbolDraw;
  29813. var normalSymbolDraw = this._normalSymbolDraw;
  29814. var group = this.group;
  29815. var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold')
  29816. ? largeSymbolDraw : normalSymbolDraw;
  29817. this._symbolDraw = symbolDraw;
  29818. symbolDraw.updateData(data);
  29819. group.add(symbolDraw.group);
  29820. group.remove(
  29821. symbolDraw === largeSymbolDraw
  29822. ? normalSymbolDraw.group : largeSymbolDraw.group
  29823. );
  29824. },
  29825. updateLayout: function (seriesModel) {
  29826. this._symbolDraw.updateLayout(seriesModel);
  29827. },
  29828. remove: function (ecModel, api) {
  29829. this._symbolDraw && this._symbolDraw.remove(api, true);
  29830. },
  29831. dispose: function () {}
  29832. });
  29833. /***/ }),
  29834. /* 161 */
  29835. /***/ (function(module, exports, __webpack_require__) {
  29836. // TODO Batch by color
  29837. var graphic = __webpack_require__(20);
  29838. var symbolUtil = __webpack_require__(114);
  29839. var LargeSymbolPath = graphic.extendShape({
  29840. shape: {
  29841. points: null,
  29842. sizes: null
  29843. },
  29844. symbolProxy: null,
  29845. buildPath: function (path, shape) {
  29846. var points = shape.points;
  29847. var sizes = shape.sizes;
  29848. var symbolProxy = this.symbolProxy;
  29849. var symbolProxyShape = symbolProxy.shape;
  29850. for (var i = 0; i < points.length; i++) {
  29851. var pt = points[i];
  29852. if (isNaN(pt[0]) || isNaN(pt[1])) {
  29853. continue;
  29854. }
  29855. var size = sizes[i];
  29856. if (size[0] < 4) {
  29857. // Optimize for small symbol
  29858. path.rect(
  29859. pt[0] - size[0] / 2, pt[1] - size[1] / 2,
  29860. size[0], size[1]
  29861. );
  29862. }
  29863. else {
  29864. symbolProxyShape.x = pt[0] - size[0] / 2;
  29865. symbolProxyShape.y = pt[1] - size[1] / 2;
  29866. symbolProxyShape.width = size[0];
  29867. symbolProxyShape.height = size[1];
  29868. symbolProxy.buildPath(path, symbolProxyShape, true);
  29869. }
  29870. }
  29871. },
  29872. findDataIndex: function (x, y) {
  29873. var shape = this.shape;
  29874. var points = shape.points;
  29875. var sizes = shape.sizes;
  29876. // Not consider transform
  29877. // Treat each element as a rect
  29878. // top down traverse
  29879. for (var i = points.length - 1; i >= 0; i--) {
  29880. var pt = points[i];
  29881. var size = sizes[i];
  29882. var x0 = pt[0] - size[0] / 2;
  29883. var y0 = pt[1] - size[1] / 2;
  29884. if (x >= x0 && y >= y0 && x <= x0 + size[0] && y <= y0 + size[1]) {
  29885. // i is dataIndex
  29886. return i;
  29887. }
  29888. }
  29889. return -1;
  29890. }
  29891. });
  29892. function LargeSymbolDraw() {
  29893. this.group = new graphic.Group();
  29894. this._symbolEl = new LargeSymbolPath({
  29895. // rectHover: true,
  29896. // cursor: 'default'
  29897. });
  29898. }
  29899. var largeSymbolProto = LargeSymbolDraw.prototype;
  29900. /**
  29901. * Update symbols draw by new data
  29902. * @param {module:echarts/data/List} data
  29903. */
  29904. largeSymbolProto.updateData = function (data) {
  29905. this.group.removeAll();
  29906. var symbolEl = this._symbolEl;
  29907. var seriesModel = data.hostModel;
  29908. symbolEl.setShape({
  29909. points: data.mapArray(data.getItemLayout),
  29910. sizes: data.mapArray(
  29911. function (idx) {
  29912. var size = data.getItemVisual(idx, 'symbolSize');
  29913. if (!(size instanceof Array)) {
  29914. size = [size, size];
  29915. }
  29916. return size;
  29917. }
  29918. )
  29919. });
  29920. // Create symbolProxy to build path for each data
  29921. symbolEl.symbolProxy = symbolUtil.createSymbol(
  29922. data.getVisual('symbol'), 0, 0, 0, 0
  29923. );
  29924. // Use symbolProxy setColor method
  29925. symbolEl.setColor = symbolEl.symbolProxy.setColor;
  29926. symbolEl.useStyle(
  29927. seriesModel.getModel('itemStyle.normal').getItemStyle(['color'])
  29928. );
  29929. var visualColor = data.getVisual('color');
  29930. if (visualColor) {
  29931. symbolEl.setColor(visualColor);
  29932. }
  29933. // Enable tooltip
  29934. // PENDING May have performance issue when path is extremely large
  29935. symbolEl.seriesIndex = seriesModel.seriesIndex;
  29936. symbolEl.on('mousemove', function (e) {
  29937. symbolEl.dataIndex = null;
  29938. var dataIndex = symbolEl.findDataIndex(e.offsetX, e.offsetY);
  29939. if (dataIndex >= 0) {
  29940. // Provide dataIndex for tooltip
  29941. symbolEl.dataIndex = dataIndex;
  29942. }
  29943. });
  29944. // Add back
  29945. this.group.add(symbolEl);
  29946. };
  29947. largeSymbolProto.updateLayout = function (seriesModel) {
  29948. var data = seriesModel.getData();
  29949. this._symbolEl.setShape({
  29950. points: data.mapArray(data.getItemLayout)
  29951. });
  29952. };
  29953. largeSymbolProto.remove = function () {
  29954. this.group.removeAll();
  29955. };
  29956. module.exports = LargeSymbolDraw;
  29957. /***/ }),
  29958. /* 162 */
  29959. /***/ (function(module, exports, __webpack_require__) {
  29960. var zrUtil = __webpack_require__(4);
  29961. var echarts = __webpack_require__(1);
  29962. // Must use radar component
  29963. __webpack_require__(163);
  29964. __webpack_require__(168);
  29965. __webpack_require__(169);
  29966. echarts.registerVisual(zrUtil.curry(__webpack_require__(154), 'radar'));
  29967. echarts.registerVisual(zrUtil.curry(
  29968. __webpack_require__(124), 'radar', 'circle', null
  29969. ));
  29970. echarts.registerLayout(__webpack_require__(170));
  29971. echarts.registerProcessor(
  29972. zrUtil.curry(__webpack_require__(157), 'radar')
  29973. );
  29974. echarts.registerPreprocessor(__webpack_require__(171));
  29975. /***/ }),
  29976. /* 163 */
  29977. /***/ (function(module, exports, __webpack_require__) {
  29978. __webpack_require__(164);
  29979. __webpack_require__(166);
  29980. __webpack_require__(167);
  29981. /***/ }),
  29982. /* 164 */
  29983. /***/ (function(module, exports, __webpack_require__) {
  29984. // TODO clockwise
  29985. var zrUtil = __webpack_require__(4);
  29986. var IndicatorAxis = __webpack_require__(165);
  29987. var IntervalScale = __webpack_require__(107);
  29988. var numberUtil = __webpack_require__(7);
  29989. var axisHelper = __webpack_require__(104);
  29990. function Radar(radarModel, ecModel, api) {
  29991. this._model = radarModel;
  29992. /**
  29993. * Radar dimensions
  29994. * @type {Array.<string>}
  29995. */
  29996. this.dimensions = [];
  29997. this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
  29998. var dim = 'indicator_' + idx;
  29999. var indicatorAxis = new IndicatorAxis(dim, new IntervalScale());
  30000. indicatorAxis.name = indicatorModel.get('name');
  30001. // Inject model and axis
  30002. indicatorAxis.model = indicatorModel;
  30003. indicatorModel.axis = indicatorAxis;
  30004. this.dimensions.push(dim);
  30005. return indicatorAxis;
  30006. }, this);
  30007. this.resize(radarModel, api);
  30008. /**
  30009. * @type {number}
  30010. * @readOnly
  30011. */
  30012. this.cx;
  30013. /**
  30014. * @type {number}
  30015. * @readOnly
  30016. */
  30017. this.cy;
  30018. /**
  30019. * @type {number}
  30020. * @readOnly
  30021. */
  30022. this.r;
  30023. /**
  30024. * @type {number}
  30025. * @readOnly
  30026. */
  30027. this.startAngle;
  30028. }
  30029. Radar.prototype.getIndicatorAxes = function () {
  30030. return this._indicatorAxes;
  30031. };
  30032. Radar.prototype.dataToPoint = function (value, indicatorIndex) {
  30033. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  30034. return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
  30035. };
  30036. Radar.prototype.coordToPoint = function (coord, indicatorIndex) {
  30037. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  30038. var angle = indicatorAxis.angle;
  30039. var x = this.cx + coord * Math.cos(angle);
  30040. var y = this.cy - coord * Math.sin(angle);
  30041. return [x, y];
  30042. };
  30043. Radar.prototype.pointToData = function (pt) {
  30044. var dx = pt[0] - this.cx;
  30045. var dy = pt[1] - this.cy;
  30046. var radius = Math.sqrt(dx * dx + dy * dy);
  30047. dx /= radius;
  30048. dy /= radius;
  30049. var radian = Math.atan2(-dy, dx);
  30050. // Find the closest angle
  30051. // FIXME index can calculated directly
  30052. var minRadianDiff = Infinity;
  30053. var closestAxis;
  30054. var closestAxisIdx = -1;
  30055. for (var i = 0; i < this._indicatorAxes.length; i++) {
  30056. var indicatorAxis = this._indicatorAxes[i];
  30057. var diff = Math.abs(radian - indicatorAxis.angle);
  30058. if (diff < minRadianDiff) {
  30059. closestAxis = indicatorAxis;
  30060. closestAxisIdx = i;
  30061. minRadianDiff = diff;
  30062. }
  30063. }
  30064. return [closestAxisIdx, +(closestAxis && closestAxis.coodToData(radius))];
  30065. };
  30066. Radar.prototype.resize = function (radarModel, api) {
  30067. var center = radarModel.get('center');
  30068. var viewWidth = api.getWidth();
  30069. var viewHeight = api.getHeight();
  30070. var viewSize = Math.min(viewWidth, viewHeight) / 2;
  30071. this.cx = numberUtil.parsePercent(center[0], viewWidth);
  30072. this.cy = numberUtil.parsePercent(center[1], viewHeight);
  30073. this.startAngle = radarModel.get('startAngle') * Math.PI / 180;
  30074. this.r = numberUtil.parsePercent(radarModel.get('radius'), viewSize);
  30075. zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) {
  30076. indicatorAxis.setExtent(0, this.r);
  30077. var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
  30078. // Normalize to [-PI, PI]
  30079. angle = Math.atan2(Math.sin(angle), Math.cos(angle));
  30080. indicatorAxis.angle = angle;
  30081. }, this);
  30082. };
  30083. Radar.prototype.update = function (ecModel, api) {
  30084. var indicatorAxes = this._indicatorAxes;
  30085. var radarModel = this._model;
  30086. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  30087. indicatorAxis.scale.setExtent(Infinity, -Infinity);
  30088. });
  30089. ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
  30090. if (radarSeries.get('coordinateSystem') !== 'radar'
  30091. || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel
  30092. ) {
  30093. return;
  30094. }
  30095. var data = radarSeries.getData();
  30096. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  30097. indicatorAxis.scale.unionExtentFromData(data, indicatorAxis.dim);
  30098. });
  30099. }, this);
  30100. var splitNumber = radarModel.get('splitNumber');
  30101. function increaseInterval(interval) {
  30102. var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10));
  30103. // Increase interval
  30104. var f = interval / exp10;
  30105. if (f === 2) {
  30106. f = 5;
  30107. }
  30108. else { // f is 2 or 5
  30109. f *= 2;
  30110. }
  30111. return f * exp10;
  30112. }
  30113. // Force all the axis fixing the maxSplitNumber.
  30114. zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
  30115. var rawExtent = axisHelper.getScaleExtent(indicatorAxis.scale, indicatorAxis.model);
  30116. axisHelper.niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);
  30117. var axisModel = indicatorAxis.model;
  30118. var scale = indicatorAxis.scale;
  30119. var fixedMin = axisModel.getMin();
  30120. var fixedMax = axisModel.getMax();
  30121. var interval = scale.getInterval();
  30122. if (fixedMin != null && fixedMax != null) {
  30123. // User set min, max, divide to get new interval
  30124. scale.setExtent(+fixedMin, +fixedMax);
  30125. scale.setInterval(
  30126. (fixedMax - fixedMin) / splitNumber
  30127. );
  30128. }
  30129. else if (fixedMin != null) {
  30130. var max;
  30131. // User set min, expand extent on the other side
  30132. do {
  30133. max = fixedMin + interval * splitNumber;
  30134. scale.setExtent(+fixedMin, max);
  30135. // Interval must been set after extent
  30136. // FIXME
  30137. scale.setInterval(interval);
  30138. interval = increaseInterval(interval);
  30139. } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
  30140. }
  30141. else if (fixedMax != null) {
  30142. var min;
  30143. // User set min, expand extent on the other side
  30144. do {
  30145. min = fixedMax - interval * splitNumber;
  30146. scale.setExtent(min, +fixedMax);
  30147. scale.setInterval(interval);
  30148. interval = increaseInterval(interval);
  30149. } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
  30150. }
  30151. else {
  30152. var nicedSplitNumber = scale.getTicks().length - 1;
  30153. if (nicedSplitNumber > splitNumber) {
  30154. interval = increaseInterval(interval);
  30155. }
  30156. // PENDING
  30157. var center = Math.round((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
  30158. var halfSplitNumber = Math.round(splitNumber / 2);
  30159. scale.setExtent(
  30160. numberUtil.round(center - halfSplitNumber * interval),
  30161. numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
  30162. );
  30163. scale.setInterval(interval);
  30164. }
  30165. });
  30166. };
  30167. /**
  30168. * Radar dimensions is based on the data
  30169. * @type {Array}
  30170. */
  30171. Radar.dimensions = [];
  30172. Radar.create = function (ecModel, api) {
  30173. var radarList = [];
  30174. ecModel.eachComponent('radar', function (radarModel) {
  30175. var radar = new Radar(radarModel, ecModel, api);
  30176. radarList.push(radar);
  30177. radarModel.coordinateSystem = radar;
  30178. });
  30179. ecModel.eachSeriesByType('radar', function (radarSeries) {
  30180. if (radarSeries.get('coordinateSystem') === 'radar') {
  30181. // Inject coordinate system
  30182. radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
  30183. }
  30184. });
  30185. return radarList;
  30186. };
  30187. __webpack_require__(79).register('radar', Radar);
  30188. module.exports = Radar;
  30189. /***/ }),
  30190. /* 165 */
  30191. /***/ (function(module, exports, __webpack_require__) {
  30192. var zrUtil = __webpack_require__(4);
  30193. var Axis = __webpack_require__(103);
  30194. function IndicatorAxis(dim, scale, radiusExtent) {
  30195. Axis.call(this, dim, scale, radiusExtent);
  30196. /**
  30197. * Axis type
  30198. * - 'category'
  30199. * - 'value'
  30200. * - 'time'
  30201. * - 'log'
  30202. * @type {string}
  30203. */
  30204. this.type = 'value';
  30205. this.angle = 0;
  30206. /**
  30207. * Indicator name
  30208. * @type {string}
  30209. */
  30210. this.name = '';
  30211. /**
  30212. * @type {module:echarts/model/Model}
  30213. */
  30214. this.model;
  30215. }
  30216. zrUtil.inherits(IndicatorAxis, Axis);
  30217. module.exports = IndicatorAxis;
  30218. /***/ }),
  30219. /* 166 */
  30220. /***/ (function(module, exports, __webpack_require__) {
  30221. var axisDefault = __webpack_require__(135);
  30222. var valueAxisDefault = axisDefault.valueAxis;
  30223. var Model = __webpack_require__(14);
  30224. var zrUtil = __webpack_require__(4);
  30225. var axisModelCommonMixin = __webpack_require__(115);
  30226. function defaultsShow(opt, show) {
  30227. return zrUtil.defaults({
  30228. show: show
  30229. }, opt);
  30230. }
  30231. var RadarModel = __webpack_require__(1).extendComponentModel({
  30232. type: 'radar',
  30233. optionUpdated: function () {
  30234. var boundaryGap = this.get('boundaryGap');
  30235. var splitNumber = this.get('splitNumber');
  30236. var scale = this.get('scale');
  30237. var axisLine = this.get('axisLine');
  30238. var axisTick = this.get('axisTick');
  30239. var axisLabel = this.get('axisLabel');
  30240. var nameTextStyle = this.get('name');
  30241. var showName = this.get('name.show');
  30242. var nameFormatter = this.get('name.formatter');
  30243. var nameGap = this.get('nameGap');
  30244. var triggerEvent = this.get('triggerEvent');
  30245. var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
  30246. // PENDING
  30247. if (indicatorOpt.max != null && indicatorOpt.max > 0 && !indicatorOpt.min) {
  30248. indicatorOpt.min = 0;
  30249. }
  30250. else if (indicatorOpt.min != null && indicatorOpt.min < 0 && !indicatorOpt.max) {
  30251. indicatorOpt.max = 0;
  30252. }
  30253. var iNameTextStyle = nameTextStyle;
  30254. if(indicatorOpt.color != null) {
  30255. iNameTextStyle = zrUtil.defaults({color: indicatorOpt.color}, nameTextStyle);
  30256. }
  30257. // Use same configuration
  30258. indicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
  30259. boundaryGap: boundaryGap,
  30260. splitNumber: splitNumber,
  30261. scale: scale,
  30262. axisLine: axisLine,
  30263. axisTick: axisTick,
  30264. axisLabel: axisLabel,
  30265. // Competitable with 2 and use text
  30266. name: indicatorOpt.text,
  30267. nameLocation: 'end',
  30268. nameGap: nameGap,
  30269. // min: 0,
  30270. nameTextStyle: iNameTextStyle,
  30271. triggerEvent: triggerEvent
  30272. }, false);
  30273. if (!showName) {
  30274. indicatorOpt.name = '';
  30275. }
  30276. if (typeof nameFormatter === 'string') {
  30277. var indName = indicatorOpt.name;
  30278. indicatorOpt.name = nameFormatter.replace('{value}', indName != null ? indName : '');
  30279. }
  30280. else if (typeof nameFormatter === 'function') {
  30281. indicatorOpt.name = nameFormatter(
  30282. indicatorOpt.name, indicatorOpt
  30283. );
  30284. }
  30285. var model = zrUtil.extend(
  30286. new Model(indicatorOpt, null, this.ecModel),
  30287. axisModelCommonMixin
  30288. );
  30289. // For triggerEvent.
  30290. model.mainType = 'radar';
  30291. model.componentIndex = this.componentIndex;
  30292. return model;
  30293. }, this);
  30294. this.getIndicatorModels = function () {
  30295. return indicatorModels;
  30296. };
  30297. },
  30298. defaultOption: {
  30299. zlevel: 0,
  30300. z: 0,
  30301. center: ['50%', '50%'],
  30302. radius: '75%',
  30303. startAngle: 90,
  30304. name: {
  30305. show: true
  30306. // formatter: null
  30307. // textStyle: {}
  30308. },
  30309. boundaryGap: [0, 0],
  30310. splitNumber: 5,
  30311. nameGap: 15,
  30312. scale: false,
  30313. // Polygon or circle
  30314. shape: 'polygon',
  30315. axisLine: zrUtil.merge(
  30316. {
  30317. lineStyle: {
  30318. color: '#bbb'
  30319. }
  30320. },
  30321. valueAxisDefault.axisLine
  30322. ),
  30323. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  30324. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  30325. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  30326. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  30327. // {text, min, max}
  30328. indicator: []
  30329. }
  30330. });
  30331. module.exports = RadarModel;
  30332. /***/ }),
  30333. /* 167 */
  30334. /***/ (function(module, exports, __webpack_require__) {
  30335. var AxisBuilder = __webpack_require__(138);
  30336. var zrUtil = __webpack_require__(4);
  30337. var graphic = __webpack_require__(20);
  30338. var axisBuilderAttrs = [
  30339. 'axisLine', 'axisTickLabel', 'axisName'
  30340. ];
  30341. module.exports = __webpack_require__(1).extendComponentView({
  30342. type: 'radar',
  30343. render: function (radarModel, ecModel, api) {
  30344. var group = this.group;
  30345. group.removeAll();
  30346. this._buildAxes(radarModel);
  30347. this._buildSplitLineAndArea(radarModel);
  30348. },
  30349. _buildAxes: function (radarModel) {
  30350. var radar = radarModel.coordinateSystem;
  30351. var indicatorAxes = radar.getIndicatorAxes();
  30352. var axisBuilders = zrUtil.map(indicatorAxes, function (indicatorAxis) {
  30353. var axisBuilder = new AxisBuilder(indicatorAxis.model, {
  30354. position: [radar.cx, radar.cy],
  30355. rotation: indicatorAxis.angle,
  30356. labelDirection: -1,
  30357. tickDirection: -1,
  30358. nameDirection: 1
  30359. });
  30360. return axisBuilder;
  30361. });
  30362. zrUtil.each(axisBuilders, function (axisBuilder) {
  30363. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  30364. this.group.add(axisBuilder.getGroup());
  30365. }, this);
  30366. },
  30367. _buildSplitLineAndArea: function (radarModel) {
  30368. var radar = radarModel.coordinateSystem;
  30369. var indicatorAxes = radar.getIndicatorAxes();
  30370. if (!indicatorAxes.length) {
  30371. return;
  30372. }
  30373. var shape = radarModel.get('shape');
  30374. var splitLineModel = radarModel.getModel('splitLine');
  30375. var splitAreaModel = radarModel.getModel('splitArea');
  30376. var lineStyleModel = splitLineModel.getModel('lineStyle');
  30377. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  30378. var showSplitLine = splitLineModel.get('show');
  30379. var showSplitArea = splitAreaModel.get('show');
  30380. var splitLineColors = lineStyleModel.get('color');
  30381. var splitAreaColors = areaStyleModel.get('color');
  30382. splitLineColors = zrUtil.isArray(splitLineColors) ? splitLineColors : [splitLineColors];
  30383. splitAreaColors = zrUtil.isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors];
  30384. var splitLines = [];
  30385. var splitAreas = [];
  30386. function getColorIndex(areaOrLine, areaOrLineColorList, idx) {
  30387. var colorIndex = idx % areaOrLineColorList.length;
  30388. areaOrLine[colorIndex] = areaOrLine[colorIndex] || [];
  30389. return colorIndex;
  30390. }
  30391. if (shape === 'circle') {
  30392. var ticksRadius = indicatorAxes[0].getTicksCoords();
  30393. var cx = radar.cx;
  30394. var cy = radar.cy;
  30395. for (var i = 0; i < ticksRadius.length; i++) {
  30396. if (showSplitLine) {
  30397. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  30398. splitLines[colorIndex].push(new graphic.Circle({
  30399. shape: {
  30400. cx: cx,
  30401. cy: cy,
  30402. r: ticksRadius[i]
  30403. }
  30404. }));
  30405. }
  30406. if (showSplitArea && i < ticksRadius.length - 1) {
  30407. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i);
  30408. splitAreas[colorIndex].push(new graphic.Ring({
  30409. shape: {
  30410. cx: cx,
  30411. cy: cy,
  30412. r0: ticksRadius[i],
  30413. r: ticksRadius[i + 1]
  30414. }
  30415. }));
  30416. }
  30417. }
  30418. }
  30419. // Polyyon
  30420. else {
  30421. var realSplitNumber;
  30422. var axesTicksPoints = zrUtil.map(indicatorAxes, function (indicatorAxis, idx) {
  30423. var ticksCoords = indicatorAxis.getTicksCoords();
  30424. realSplitNumber = realSplitNumber == null
  30425. ? ticksCoords.length - 1
  30426. : Math.min(ticksCoords.length - 1, realSplitNumber);
  30427. return zrUtil.map(ticksCoords, function (tickCoord) {
  30428. return radar.coordToPoint(tickCoord, idx);
  30429. });
  30430. });
  30431. var prevPoints = [];
  30432. for (var i = 0; i <= realSplitNumber; i++) {
  30433. var points = [];
  30434. for (var j = 0; j < indicatorAxes.length; j++) {
  30435. points.push(axesTicksPoints[j][i]);
  30436. }
  30437. // Close
  30438. if (points[0]) {
  30439. points.push(points[0].slice());
  30440. }
  30441. else {
  30442. if (true) {
  30443. console.error('Can\'t draw value axis ' + i);
  30444. }
  30445. }
  30446. if (showSplitLine) {
  30447. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  30448. splitLines[colorIndex].push(new graphic.Polyline({
  30449. shape: {
  30450. points: points
  30451. }
  30452. }));
  30453. }
  30454. if (showSplitArea && prevPoints) {
  30455. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i - 1);
  30456. splitAreas[colorIndex].push(new graphic.Polygon({
  30457. shape: {
  30458. points: points.concat(prevPoints)
  30459. }
  30460. }));
  30461. }
  30462. prevPoints = points.slice().reverse();
  30463. }
  30464. }
  30465. var lineStyle = lineStyleModel.getLineStyle();
  30466. var areaStyle = areaStyleModel.getAreaStyle();
  30467. // Add splitArea before splitLine
  30468. zrUtil.each(splitAreas, function (splitAreas, idx) {
  30469. this.group.add(graphic.mergePath(
  30470. splitAreas, {
  30471. style: zrUtil.defaults({
  30472. stroke: 'none',
  30473. fill: splitAreaColors[idx % splitAreaColors.length]
  30474. }, areaStyle),
  30475. silent: true
  30476. }
  30477. ));
  30478. }, this);
  30479. zrUtil.each(splitLines, function (splitLines, idx) {
  30480. this.group.add(graphic.mergePath(
  30481. splitLines, {
  30482. style: zrUtil.defaults({
  30483. fill: 'none',
  30484. stroke: splitLineColors[idx % splitLineColors.length]
  30485. }, lineStyle),
  30486. silent: true
  30487. }
  30488. ));
  30489. }, this);
  30490. }
  30491. });
  30492. /***/ }),
  30493. /* 168 */
  30494. /***/ (function(module, exports, __webpack_require__) {
  30495. 'use strict';
  30496. var SeriesModel = __webpack_require__(83);
  30497. var List = __webpack_require__(101);
  30498. var completeDimensions = __webpack_require__(113);
  30499. var zrUtil = __webpack_require__(4);
  30500. var encodeHTML = __webpack_require__(6).encodeHTML;
  30501. var RadarSeries = SeriesModel.extend({
  30502. type: 'series.radar',
  30503. dependencies: ['radar'],
  30504. // Overwrite
  30505. init: function (option) {
  30506. RadarSeries.superApply(this, 'init', arguments);
  30507. // Enable legend selection for each data item
  30508. // Use a function instead of direct access because data reference may changed
  30509. this.legendDataProvider = function () {
  30510. return this.getRawData();
  30511. };
  30512. },
  30513. getInitialData: function (option, ecModel) {
  30514. var data = option.data || [];
  30515. var dimensions = completeDimensions(
  30516. [], data, {extraPrefix: 'indicator_', extraFromZero: true}
  30517. );
  30518. var list = new List(dimensions, this);
  30519. list.initData(data);
  30520. return list;
  30521. },
  30522. formatTooltip: function (dataIndex) {
  30523. var value = this.getRawValue(dataIndex);
  30524. var coordSys = this.coordinateSystem;
  30525. var indicatorAxes = coordSys.getIndicatorAxes();
  30526. var name = this.getData().getName(dataIndex);
  30527. return encodeHTML(name === '' ? this.name : name) + '<br/>'
  30528. + zrUtil.map(indicatorAxes, function (axis, idx) {
  30529. return encodeHTML(axis.name + ' : ' + value[idx]);
  30530. }).join('<br />');
  30531. },
  30532. defaultOption: {
  30533. zlevel: 0,
  30534. z: 2,
  30535. coordinateSystem: 'radar',
  30536. legendHoverLink: true,
  30537. radarIndex: 0,
  30538. lineStyle: {
  30539. normal: {
  30540. width: 2,
  30541. type: 'solid'
  30542. }
  30543. },
  30544. label: {
  30545. normal: {
  30546. position: 'top'
  30547. }
  30548. },
  30549. // areaStyle: {
  30550. // },
  30551. // itemStyle: {}
  30552. symbol: 'emptyCircle',
  30553. symbolSize: 4
  30554. // symbolRotate: null
  30555. }
  30556. });
  30557. module.exports = RadarSeries;
  30558. /***/ }),
  30559. /* 169 */
  30560. /***/ (function(module, exports, __webpack_require__) {
  30561. var graphic = __webpack_require__(20);
  30562. var zrUtil = __webpack_require__(4);
  30563. var symbolUtil = __webpack_require__(114);
  30564. function normalizeSymbolSize(symbolSize) {
  30565. if (!zrUtil.isArray(symbolSize)) {
  30566. symbolSize = [+symbolSize, +symbolSize];
  30567. }
  30568. return symbolSize;
  30569. }
  30570. module.exports = __webpack_require__(1).extendChartView({
  30571. type: 'radar',
  30572. render: function (seriesModel, ecModel, api) {
  30573. var polar = seriesModel.coordinateSystem;
  30574. var group = this.group;
  30575. var data = seriesModel.getData();
  30576. var oldData = this._data;
  30577. function createSymbol(data, idx) {
  30578. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  30579. var color = data.getItemVisual(idx, 'color');
  30580. if (symbolType === 'none') {
  30581. return;
  30582. }
  30583. var symbolSize = normalizeSymbolSize(
  30584. data.getItemVisual(idx, 'symbolSize')
  30585. );
  30586. var symbolPath = symbolUtil.createSymbol(
  30587. symbolType, -1, -1, 2, 2, color
  30588. );
  30589. symbolPath.attr({
  30590. style: {
  30591. strokeNoScale: true
  30592. },
  30593. z2: 100,
  30594. scale: [symbolSize[0] / 2, symbolSize[1] / 2]
  30595. });
  30596. return symbolPath;
  30597. }
  30598. function updateSymbols(oldPoints, newPoints, symbolGroup, data, idx, isInit) {
  30599. // Simply rerender all
  30600. symbolGroup.removeAll();
  30601. for (var i = 0; i < newPoints.length - 1; i++) {
  30602. var symbolPath = createSymbol(data, idx);
  30603. if (symbolPath) {
  30604. symbolPath.__dimIdx = i;
  30605. if (oldPoints[i]) {
  30606. symbolPath.attr('position', oldPoints[i]);
  30607. graphic[isInit ? 'initProps' : 'updateProps'](
  30608. symbolPath, {
  30609. position: newPoints[i]
  30610. }, seriesModel, idx
  30611. );
  30612. }
  30613. else {
  30614. symbolPath.attr('position', newPoints[i]);
  30615. }
  30616. symbolGroup.add(symbolPath);
  30617. }
  30618. }
  30619. }
  30620. function getInitialPoints(points) {
  30621. return zrUtil.map(points, function (pt) {
  30622. return [polar.cx, polar.cy];
  30623. });
  30624. }
  30625. data.diff(oldData)
  30626. .add(function (idx) {
  30627. var points = data.getItemLayout(idx);
  30628. if (!points) {
  30629. return;
  30630. }
  30631. var polygon = new graphic.Polygon();
  30632. var polyline = new graphic.Polyline();
  30633. var target = {
  30634. shape: {
  30635. points: points
  30636. }
  30637. };
  30638. polygon.shape.points = getInitialPoints(points);
  30639. polyline.shape.points = getInitialPoints(points);
  30640. graphic.initProps(polygon, target, seriesModel, idx);
  30641. graphic.initProps(polyline, target, seriesModel, idx);
  30642. var itemGroup = new graphic.Group();
  30643. var symbolGroup = new graphic.Group();
  30644. itemGroup.add(polyline);
  30645. itemGroup.add(polygon);
  30646. itemGroup.add(symbolGroup);
  30647. updateSymbols(
  30648. polyline.shape.points, points, symbolGroup, data, idx, true
  30649. );
  30650. data.setItemGraphicEl(idx, itemGroup);
  30651. })
  30652. .update(function (newIdx, oldIdx) {
  30653. var itemGroup = oldData.getItemGraphicEl(oldIdx);
  30654. var polyline = itemGroup.childAt(0);
  30655. var polygon = itemGroup.childAt(1);
  30656. var symbolGroup = itemGroup.childAt(2);
  30657. var target = {
  30658. shape: {
  30659. points: data.getItemLayout(newIdx)
  30660. }
  30661. };
  30662. if (!target.shape.points) {
  30663. return;
  30664. }
  30665. updateSymbols(
  30666. polyline.shape.points, target.shape.points, symbolGroup, data, newIdx, false
  30667. );
  30668. graphic.updateProps(polyline, target, seriesModel);
  30669. graphic.updateProps(polygon, target, seriesModel);
  30670. data.setItemGraphicEl(newIdx, itemGroup);
  30671. })
  30672. .remove(function (idx) {
  30673. group.remove(oldData.getItemGraphicEl(idx));
  30674. })
  30675. .execute();
  30676. data.eachItemGraphicEl(function (itemGroup, idx) {
  30677. var itemModel = data.getItemModel(idx);
  30678. var polyline = itemGroup.childAt(0);
  30679. var polygon = itemGroup.childAt(1);
  30680. var symbolGroup = itemGroup.childAt(2);
  30681. var color = data.getItemVisual(idx, 'color');
  30682. group.add(itemGroup);
  30683. polyline.useStyle(
  30684. zrUtil.defaults(
  30685. itemModel.getModel('lineStyle.normal').getLineStyle(),
  30686. {
  30687. fill: 'none',
  30688. stroke: color
  30689. }
  30690. )
  30691. );
  30692. polyline.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  30693. var areaStyleModel = itemModel.getModel('areaStyle.normal');
  30694. var hoverAreaStyleModel = itemModel.getModel('areaStyle.emphasis');
  30695. var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty();
  30696. var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty();
  30697. hoverPolygonIgnore = hoverPolygonIgnore && polygonIgnore;
  30698. polygon.ignore = polygonIgnore;
  30699. polygon.useStyle(
  30700. zrUtil.defaults(
  30701. areaStyleModel.getAreaStyle(),
  30702. {
  30703. fill: color,
  30704. opacity: 0.7
  30705. }
  30706. )
  30707. );
  30708. polygon.hoverStyle = hoverAreaStyleModel.getAreaStyle();
  30709. var itemStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  30710. var itemHoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  30711. var labelModel = itemModel.getModel('label.normal');
  30712. var labelHoverModel = itemModel.getModel('label.emphasis');
  30713. symbolGroup.eachChild(function (symbolPath) {
  30714. symbolPath.setStyle(itemStyle);
  30715. symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
  30716. graphic.setLabelStyle(
  30717. symbolPath.style, symbolPath.hoverStyle, labelModel, labelHoverModel,
  30718. {
  30719. labelFetcher: data.hostModel,
  30720. labelDataIndex: idx,
  30721. labelDimIndex: symbolPath.__dimIdx,
  30722. defaultText: data.get(data.dimensions[symbolPath.__dimIdx], idx),
  30723. autoColor: color,
  30724. isRectText: true
  30725. }
  30726. );
  30727. });
  30728. function onEmphasis() {
  30729. polygon.attr('ignore', hoverPolygonIgnore);
  30730. }
  30731. function onNormal() {
  30732. polygon.attr('ignore', polygonIgnore);
  30733. }
  30734. itemGroup.off('mouseover').off('mouseout').off('normal').off('emphasis');
  30735. itemGroup.on('emphasis', onEmphasis)
  30736. .on('mouseover', onEmphasis)
  30737. .on('normal', onNormal)
  30738. .on('mouseout', onNormal);
  30739. graphic.setHoverStyle(itemGroup);
  30740. });
  30741. this._data = data;
  30742. },
  30743. remove: function () {
  30744. this.group.removeAll();
  30745. this._data = null;
  30746. },
  30747. dispose: function () {}
  30748. });
  30749. /***/ }),
  30750. /* 170 */
  30751. /***/ (function(module, exports) {
  30752. module.exports = function (ecModel) {
  30753. ecModel.eachSeriesByType('radar', function (seriesModel) {
  30754. var data = seriesModel.getData();
  30755. var points = [];
  30756. var coordSys = seriesModel.coordinateSystem;
  30757. if (!coordSys) {
  30758. return;
  30759. }
  30760. function pointsConverter(val, idx) {
  30761. points[idx] = points[idx] || [];
  30762. points[idx][i] = coordSys.dataToPoint(val, i);
  30763. }
  30764. for (var i = 0; i < coordSys.getIndicatorAxes().length; i++) {
  30765. var dim = data.dimensions[i];
  30766. data.each(dim, pointsConverter);
  30767. }
  30768. data.each(function (idx) {
  30769. // Close polygon
  30770. points[idx][0] && points[idx].push(points[idx][0].slice());
  30771. data.setItemLayout(idx, points[idx]);
  30772. });
  30773. });
  30774. };
  30775. /***/ }),
  30776. /* 171 */
  30777. /***/ (function(module, exports, __webpack_require__) {
  30778. // Backward compat for radar chart in 2
  30779. var zrUtil = __webpack_require__(4);
  30780. module.exports = function (option) {
  30781. var polarOptArr = option.polar;
  30782. if (polarOptArr) {
  30783. if (!zrUtil.isArray(polarOptArr)) {
  30784. polarOptArr = [polarOptArr];
  30785. }
  30786. var polarNotRadar = [];
  30787. zrUtil.each(polarOptArr, function (polarOpt, idx) {
  30788. if (polarOpt.indicator) {
  30789. if (polarOpt.type && !polarOpt.shape) {
  30790. polarOpt.shape = polarOpt.type;
  30791. }
  30792. option.radar = option.radar || [];
  30793. if (!zrUtil.isArray(option.radar)) {
  30794. option.radar = [option.radar];
  30795. }
  30796. option.radar.push(polarOpt);
  30797. }
  30798. else {
  30799. polarNotRadar.push(polarOpt);
  30800. }
  30801. });
  30802. option.polar = polarNotRadar;
  30803. }
  30804. zrUtil.each(option.series, function (seriesOpt) {
  30805. if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
  30806. seriesOpt.radarIndex = seriesOpt.polarIndex;
  30807. }
  30808. });
  30809. };
  30810. /***/ }),
  30811. /* 172 */
  30812. /***/ (function(module, exports, __webpack_require__) {
  30813. var echarts = __webpack_require__(1);
  30814. var PRIORITY = echarts.PRIORITY;
  30815. __webpack_require__(173);
  30816. __webpack_require__(184);
  30817. __webpack_require__(190);
  30818. __webpack_require__(174);
  30819. echarts.registerLayout(__webpack_require__(192));
  30820. echarts.registerVisual(__webpack_require__(193));
  30821. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, __webpack_require__(194));
  30822. echarts.registerPreprocessor(__webpack_require__(195));
  30823. __webpack_require__(153)('map', [{
  30824. type: 'mapToggleSelect',
  30825. event: 'mapselectchanged',
  30826. method: 'toggleSelected'
  30827. }, {
  30828. type: 'mapSelect',
  30829. event: 'mapselected',
  30830. method: 'select'
  30831. }, {
  30832. type: 'mapUnSelect',
  30833. event: 'mapunselected',
  30834. method: 'unSelect'
  30835. }]);
  30836. /***/ }),
  30837. /* 173 */
  30838. /***/ (function(module, exports, __webpack_require__) {
  30839. var List = __webpack_require__(101);
  30840. var SeriesModel = __webpack_require__(83);
  30841. var zrUtil = __webpack_require__(4);
  30842. var completeDimensions = __webpack_require__(113);
  30843. var formatUtil = __webpack_require__(6);
  30844. var encodeHTML = formatUtil.encodeHTML;
  30845. var addCommas = formatUtil.addCommas;
  30846. var dataSelectableMixin = __webpack_require__(151);
  30847. var geoCreator = __webpack_require__(174);
  30848. var MapSeries = SeriesModel.extend({
  30849. type: 'series.map',
  30850. dependencies: ['geo'],
  30851. layoutMode: 'box',
  30852. /**
  30853. * Only first map series of same mapType will drawMap
  30854. * @type {boolean}
  30855. */
  30856. needsDrawMap: false,
  30857. /**
  30858. * Group of all map series with same mapType
  30859. * @type {boolean}
  30860. */
  30861. seriesGroup: [],
  30862. init: function (option) {
  30863. option = this._fillOption(option, this.getMapType());
  30864. this.option = option;
  30865. MapSeries.superApply(this, 'init', arguments);
  30866. this.updateSelectedMap(option.data);
  30867. },
  30868. getInitialData: function (option) {
  30869. var dimensions = completeDimensions(['value'], option.data || []);
  30870. var list = new List(dimensions, this);
  30871. list.initData(option.data);
  30872. return list;
  30873. },
  30874. mergeOption: function (newOption) {
  30875. if (newOption.data) {
  30876. newOption = this._fillOption(newOption, this.getMapType());
  30877. }
  30878. MapSeries.superCall(this, 'mergeOption', newOption);
  30879. this.updateSelectedMap(this.option.data);
  30880. },
  30881. /**
  30882. * If no host geo model, return null, which means using a
  30883. * inner exclusive geo model.
  30884. */
  30885. getHostGeoModel: function () {
  30886. var geoIndex = this.option.geoIndex;
  30887. return geoIndex != null
  30888. ? this.dependentModels.geo[geoIndex]
  30889. : null;
  30890. },
  30891. getMapType: function () {
  30892. return (this.getHostGeoModel() || this).option.map;
  30893. },
  30894. _fillOption: function (option, mapName) {
  30895. // Shallow clone
  30896. option = zrUtil.extend({}, option);
  30897. option.data = geoCreator.getFilledRegions(option.data, mapName, option.nameMap);
  30898. return option;
  30899. },
  30900. getRawValue: function (dataIndex) {
  30901. // Use value stored in data instead because it is calculated from multiple series
  30902. // FIXME Provide all value of multiple series ?
  30903. return this.getData().get('value', dataIndex);
  30904. },
  30905. /**
  30906. * Get model of region
  30907. * @param {string} name
  30908. * @return {module:echarts/model/Model}
  30909. */
  30910. getRegionModel: function (regionName) {
  30911. var data = this.getData();
  30912. return data.getItemModel(data.indexOfName(regionName));
  30913. },
  30914. /**
  30915. * Map tooltip formatter
  30916. *
  30917. * @param {number} dataIndex
  30918. */
  30919. formatTooltip: function (dataIndex) {
  30920. // FIXME orignalData and data is a bit confusing
  30921. var data = this.getData();
  30922. var formattedValue = addCommas(this.getRawValue(dataIndex));
  30923. var name = data.getName(dataIndex);
  30924. var seriesGroup = this.seriesGroup;
  30925. var seriesNames = [];
  30926. for (var i = 0; i < seriesGroup.length; i++) {
  30927. var otherIndex = seriesGroup[i].originalData.indexOfName(name);
  30928. if (!isNaN(seriesGroup[i].originalData.get('value', otherIndex))) {
  30929. seriesNames.push(
  30930. encodeHTML(seriesGroup[i].name)
  30931. );
  30932. }
  30933. }
  30934. return seriesNames.join(', ') + '<br />'
  30935. + encodeHTML(name + ' : ' + formattedValue);
  30936. },
  30937. /**
  30938. * @implement
  30939. */
  30940. getTooltipPosition: function (dataIndex) {
  30941. if (dataIndex != null) {
  30942. var name = this.getData().getName(dataIndex);
  30943. var geo = this.coordinateSystem;
  30944. var region = geo.getRegion(name);
  30945. return region && geo.dataToPoint(region.center);
  30946. }
  30947. },
  30948. setZoom: function (zoom) {
  30949. this.option.zoom = zoom;
  30950. },
  30951. setCenter: function (center) {
  30952. this.option.center = center;
  30953. },
  30954. defaultOption: {
  30955. // 一级层叠
  30956. zlevel: 0,
  30957. // 二级层叠
  30958. z: 2,
  30959. coordinateSystem: 'geo',
  30960. // map should be explicitly specified since ec3.
  30961. map: '',
  30962. // If `geoIndex` is not specified, a exclusive geo will be
  30963. // created. Otherwise use the specified geo component, and
  30964. // `map` and `mapType` are ignored.
  30965. // geoIndex: 0,
  30966. // 'center' | 'left' | 'right' | 'x%' | {number}
  30967. left: 'center',
  30968. // 'center' | 'top' | 'bottom' | 'x%' | {number}
  30969. top: 'center',
  30970. // right
  30971. // bottom
  30972. // width:
  30973. // height
  30974. // Aspect is width / height. Inited to be geoJson bbox aspect
  30975. // This parameter is used for scale this aspect
  30976. aspectScale: 0.75,
  30977. ///// Layout with center and size
  30978. // If you wan't to put map in a fixed size box with right aspect ratio
  30979. // This two properties may more conveninet
  30980. // layoutCenter: [50%, 50%]
  30981. // layoutSize: 100
  30982. // 数值合并方式,默认加和,可选为:
  30983. // 'sum' | 'average' | 'max' | 'min'
  30984. // mapValueCalculation: 'sum',
  30985. // 地图数值计算结果小数精度
  30986. // mapValuePrecision: 0,
  30987. // 显示图例颜色标识(系列标识的小圆点),图例开启时有效
  30988. showLegendSymbol: true,
  30989. // 选择模式,默认关闭,可选single,multiple
  30990. // selectedMode: false,
  30991. dataRangeHoverLink: true,
  30992. // 是否开启缩放及漫游模式
  30993. // roam: false,
  30994. // Define left-top, right-bottom coords to control view
  30995. // For example, [ [180, 90], [-180, -90] ],
  30996. // higher priority than center and zoom
  30997. boundingCoords: null,
  30998. // Default on center of map
  30999. center: null,
  31000. zoom: 1,
  31001. scaleLimit: null,
  31002. label: {
  31003. normal: {
  31004. show: false,
  31005. color: '#000'
  31006. },
  31007. emphasis: {
  31008. show: true,
  31009. color: 'rgb(100,0,0)'
  31010. }
  31011. },
  31012. // scaleLimit: null,
  31013. itemStyle: {
  31014. normal: {
  31015. // color: 各异,
  31016. borderWidth: 0.5,
  31017. borderColor: '#444',
  31018. areaColor: '#eee'
  31019. },
  31020. // 也是选中样式
  31021. emphasis: {
  31022. areaColor: 'rgba(255,215,0,0.8)'
  31023. }
  31024. }
  31025. }
  31026. });
  31027. zrUtil.mixin(MapSeries, dataSelectableMixin);
  31028. module.exports = MapSeries;
  31029. /***/ }),
  31030. /* 174 */
  31031. /***/ (function(module, exports, __webpack_require__) {
  31032. var Geo = __webpack_require__(175);
  31033. var layout = __webpack_require__(74);
  31034. var zrUtil = __webpack_require__(4);
  31035. var numberUtil = __webpack_require__(7);
  31036. var mapDataStores = {};
  31037. /**
  31038. * Resize method bound to the geo
  31039. * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
  31040. * @param {module:echarts/ExtensionAPI} api
  31041. */
  31042. function resizeGeo (geoModel, api) {
  31043. var boundingCoords = geoModel.get('boundingCoords');
  31044. if (boundingCoords != null) {
  31045. var leftTop = boundingCoords[0];
  31046. var rightBottom = boundingCoords[1];
  31047. if (isNaN(leftTop[0]) || isNaN(leftTop[1]) || isNaN(rightBottom[0]) || isNaN(rightBottom[1])) {
  31048. if (true) {
  31049. console.error('Invalid boundingCoords');
  31050. }
  31051. }
  31052. else {
  31053. this.setBoundingRect(leftTop[0], leftTop[1], rightBottom[0] - leftTop[0], rightBottom[1] - leftTop[1]);
  31054. }
  31055. }
  31056. var rect = this.getBoundingRect();
  31057. var boxLayoutOption;
  31058. var center = geoModel.get('layoutCenter');
  31059. var size = geoModel.get('layoutSize');
  31060. var viewWidth = api.getWidth();
  31061. var viewHeight = api.getHeight();
  31062. var aspectScale = geoModel.get('aspectScale') || 0.75;
  31063. var aspect = rect.width / rect.height * aspectScale;
  31064. var useCenterAndSize = false;
  31065. if (center && size) {
  31066. center = [
  31067. numberUtil.parsePercent(center[0], viewWidth),
  31068. numberUtil.parsePercent(center[1], viewHeight)
  31069. ];
  31070. size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
  31071. if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
  31072. useCenterAndSize = true;
  31073. }
  31074. else {
  31075. if (true) {
  31076. console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
  31077. }
  31078. }
  31079. }
  31080. var viewRect;
  31081. if (useCenterAndSize) {
  31082. var viewRect = {};
  31083. if (aspect > 1) {
  31084. // Width is same with size
  31085. viewRect.width = size;
  31086. viewRect.height = size / aspect;
  31087. }
  31088. else {
  31089. viewRect.height = size;
  31090. viewRect.width = size * aspect;
  31091. }
  31092. viewRect.y = center[1] - viewRect.height / 2;
  31093. viewRect.x = center[0] - viewRect.width / 2;
  31094. }
  31095. else {
  31096. // Use left/top/width/height
  31097. boxLayoutOption = geoModel.getBoxLayoutParams();
  31098. // 0.75 rate
  31099. boxLayoutOption.aspect = aspect;
  31100. viewRect = layout.getLayoutRect(boxLayoutOption, {
  31101. width: viewWidth,
  31102. height: viewHeight
  31103. });
  31104. }
  31105. this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
  31106. this.setCenter(geoModel.get('center'));
  31107. this.setZoom(geoModel.get('zoom'));
  31108. }
  31109. /**
  31110. * @param {module:echarts/coord/Geo} geo
  31111. * @param {module:echarts/model/Model} model
  31112. * @inner
  31113. */
  31114. function setGeoCoords(geo, model) {
  31115. zrUtil.each(model.get('geoCoord'), function (geoCoord, name) {
  31116. geo.addGeoCoord(name, geoCoord);
  31117. });
  31118. }
  31119. if (true) {
  31120. var mapNotExistsError = function (name) {
  31121. console.error('Map ' + name + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html');
  31122. };
  31123. }
  31124. var geoCreator = {
  31125. // For deciding which dimensions to use when creating list data
  31126. dimensions: Geo.prototype.dimensions,
  31127. create: function (ecModel, api) {
  31128. var geoList = [];
  31129. // FIXME Create each time may be slow
  31130. ecModel.eachComponent('geo', function (geoModel, idx) {
  31131. var name = geoModel.get('map');
  31132. var mapData = mapDataStores[name];
  31133. if (true) {
  31134. if (!mapData) {
  31135. mapNotExistsError(name);
  31136. }
  31137. }
  31138. var geo = new Geo(
  31139. name + idx, name,
  31140. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  31141. geoModel.get('nameMap')
  31142. );
  31143. geo.zoomLimit = geoModel.get('scaleLimit');
  31144. geoList.push(geo);
  31145. setGeoCoords(geo, geoModel);
  31146. geoModel.coordinateSystem = geo;
  31147. geo.model = geoModel;
  31148. // Inject resize method
  31149. geo.resize = resizeGeo;
  31150. geo.resize(geoModel, api);
  31151. });
  31152. ecModel.eachSeries(function (seriesModel) {
  31153. var coordSys = seriesModel.get('coordinateSystem');
  31154. if (coordSys === 'geo') {
  31155. var geoIndex = seriesModel.get('geoIndex') || 0;
  31156. seriesModel.coordinateSystem = geoList[geoIndex];
  31157. }
  31158. });
  31159. // If has map series
  31160. var mapModelGroupBySeries = {};
  31161. ecModel.eachSeriesByType('map', function (seriesModel) {
  31162. if (!seriesModel.getHostGeoModel()) {
  31163. var mapType = seriesModel.getMapType();
  31164. mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || [];
  31165. mapModelGroupBySeries[mapType].push(seriesModel);
  31166. }
  31167. });
  31168. zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) {
  31169. var mapData = mapDataStores[mapType];
  31170. if (true) {
  31171. if (!mapData) {
  31172. mapNotExistsError(mapSeries[0].get('map'));
  31173. }
  31174. }
  31175. var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) {
  31176. return singleMapSeries.get('nameMap');
  31177. });
  31178. var geo = new Geo(
  31179. mapType, mapType,
  31180. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  31181. zrUtil.mergeAll(nameMapList)
  31182. );
  31183. geo.zoomLimit = zrUtil.retrieve.apply(null, zrUtil.map(mapSeries, function (singleMapSeries) {
  31184. return singleMapSeries.get('scaleLimit');
  31185. }));
  31186. geoList.push(geo);
  31187. // Inject resize method
  31188. geo.resize = resizeGeo;
  31189. geo.resize(mapSeries[0], api);
  31190. zrUtil.each(mapSeries, function (singleMapSeries) {
  31191. singleMapSeries.coordinateSystem = geo;
  31192. setGeoCoords(geo, singleMapSeries);
  31193. });
  31194. });
  31195. return geoList;
  31196. },
  31197. /**
  31198. * @param {string} mapName
  31199. * @param {Object|string} geoJson
  31200. * @param {Object} [specialAreas]
  31201. *
  31202. * @example
  31203. * $.get('USA.json', function (geoJson) {
  31204. * echarts.registerMap('USA', geoJson);
  31205. * // Or
  31206. * echarts.registerMap('USA', {
  31207. * geoJson: geoJson,
  31208. * specialAreas: {}
  31209. * })
  31210. * });
  31211. */
  31212. registerMap: function (mapName, geoJson, specialAreas) {
  31213. if (geoJson.geoJson && !geoJson.features) {
  31214. specialAreas = geoJson.specialAreas;
  31215. geoJson = geoJson.geoJson;
  31216. }
  31217. if (typeof geoJson === 'string') {
  31218. geoJson = (typeof JSON !== 'undefined' && JSON.parse)
  31219. ? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))();
  31220. }
  31221. mapDataStores[mapName] = {
  31222. geoJson: geoJson,
  31223. specialAreas: specialAreas
  31224. };
  31225. },
  31226. /**
  31227. * @param {string} mapName
  31228. * @return {Object}
  31229. */
  31230. getMap: function (mapName) {
  31231. return mapDataStores[mapName];
  31232. },
  31233. /**
  31234. * Fill given regions array
  31235. * @param {Array.<Object>} originRegionArr
  31236. * @param {string} mapName
  31237. * @param {Object} [nameMap]
  31238. * @return {Array}
  31239. */
  31240. getFilledRegions: function (originRegionArr, mapName, nameMap) {
  31241. // Not use the original
  31242. var regionsArr = (originRegionArr || []).slice();
  31243. nameMap = nameMap || {};
  31244. var map = geoCreator.getMap(mapName);
  31245. var geoJson = map && map.geoJson;
  31246. if (!geoJson) {
  31247. if (true) {
  31248. mapNotExistsError(mapName);
  31249. }
  31250. return originRegionArr;
  31251. }
  31252. var dataNameMap = zrUtil.createHashMap();
  31253. var features = geoJson.features;
  31254. for (var i = 0; i < regionsArr.length; i++) {
  31255. dataNameMap.set(regionsArr[i].name, regionsArr[i]);
  31256. }
  31257. for (var i = 0; i < features.length; i++) {
  31258. var name = features[i].properties.name;
  31259. if (!dataNameMap.get(name)) {
  31260. if (nameMap.hasOwnProperty(name)) {
  31261. name = nameMap[name];
  31262. }
  31263. regionsArr.push({
  31264. name: name
  31265. });
  31266. }
  31267. }
  31268. return regionsArr;
  31269. }
  31270. };
  31271. // Inject methods into echarts
  31272. var echarts = __webpack_require__(1);
  31273. echarts.registerMap = geoCreator.registerMap;
  31274. echarts.getMap = geoCreator.getMap;
  31275. echarts.parseGeoJSON = __webpack_require__(176);
  31276. // TODO
  31277. echarts.loadMap = function () {};
  31278. echarts.registerCoordinateSystem('geo', geoCreator);
  31279. module.exports = geoCreator;
  31280. /***/ }),
  31281. /* 175 */
  31282. /***/ (function(module, exports, __webpack_require__) {
  31283. var parseGeoJson = __webpack_require__(176);
  31284. var zrUtil = __webpack_require__(4);
  31285. var BoundingRect = __webpack_require__(9);
  31286. var View = __webpack_require__(179);
  31287. // Geo fix functions
  31288. var geoFixFuncs = [
  31289. __webpack_require__(180),
  31290. __webpack_require__(181),
  31291. __webpack_require__(182),
  31292. __webpack_require__(183)
  31293. ];
  31294. /**
  31295. * [Geo description]
  31296. * @param {string} name Geo name
  31297. * @param {string} map Map type
  31298. * @param {Object} geoJson
  31299. * @param {Object} [specialAreas]
  31300. * Specify the positioned areas by left, top, width, height
  31301. * @param {Object.<string, string>} [nameMap]
  31302. * Specify name alias
  31303. */
  31304. function Geo(name, map, geoJson, specialAreas, nameMap) {
  31305. View.call(this, name);
  31306. /**
  31307. * Map type
  31308. * @type {string}
  31309. */
  31310. this.map = map;
  31311. this._nameCoordMap = zrUtil.createHashMap();
  31312. this.loadGeoJson(geoJson, specialAreas, nameMap);
  31313. }
  31314. Geo.prototype = {
  31315. constructor: Geo,
  31316. type: 'geo',
  31317. /**
  31318. * @param {Array.<string>}
  31319. * @readOnly
  31320. */
  31321. dimensions: ['lng', 'lat'],
  31322. /**
  31323. * If contain given lng,lat coord
  31324. * @param {Array.<number>}
  31325. * @readOnly
  31326. */
  31327. containCoord: function (coord) {
  31328. var regions = this.regions;
  31329. for (var i = 0; i < regions.length; i++) {
  31330. if (regions[i].contain(coord)) {
  31331. return true;
  31332. }
  31333. }
  31334. return false;
  31335. },
  31336. /**
  31337. * @param {Object} geoJson
  31338. * @param {Object} [specialAreas]
  31339. * Specify the positioned areas by left, top, width, height
  31340. * @param {Object.<string, string>} [nameMap]
  31341. * Specify name alias
  31342. */
  31343. loadGeoJson: function (geoJson, specialAreas, nameMap) {
  31344. // https://jsperf.com/try-catch-performance-overhead
  31345. try {
  31346. this.regions = geoJson ? parseGeoJson(geoJson) : [];
  31347. }
  31348. catch (e) {
  31349. throw 'Invalid geoJson format\n' + e.message;
  31350. }
  31351. specialAreas = specialAreas || {};
  31352. nameMap = nameMap || {};
  31353. var regions = this.regions;
  31354. var regionsMap = zrUtil.createHashMap();
  31355. for (var i = 0; i < regions.length; i++) {
  31356. var regionName = regions[i].name;
  31357. // Try use the alias in nameMap
  31358. regionName = nameMap.hasOwnProperty(regionName) ? nameMap[regionName] : regionName;
  31359. regions[i].name = regionName;
  31360. regionsMap.set(regionName, regions[i]);
  31361. // Add geoJson
  31362. this.addGeoCoord(regionName, regions[i].center);
  31363. // Some area like Alaska in USA map needs to be tansformed
  31364. // to look better
  31365. var specialArea = specialAreas[regionName];
  31366. if (specialArea) {
  31367. regions[i].transformTo(
  31368. specialArea.left, specialArea.top, specialArea.width, specialArea.height
  31369. );
  31370. }
  31371. }
  31372. this._regionsMap = regionsMap;
  31373. this._rect = null;
  31374. zrUtil.each(geoFixFuncs, function (fixFunc) {
  31375. fixFunc(this);
  31376. }, this);
  31377. },
  31378. // Overwrite
  31379. transformTo: function (x, y, width, height) {
  31380. var rect = this.getBoundingRect();
  31381. rect = rect.clone();
  31382. // Longitute is inverted
  31383. rect.y = -rect.y - rect.height;
  31384. var viewTransform = this._viewTransform;
  31385. viewTransform.transform = rect.calculateTransform(
  31386. new BoundingRect(x, y, width, height)
  31387. );
  31388. viewTransform.decomposeTransform();
  31389. var scale = viewTransform.scale;
  31390. scale[1] = -scale[1];
  31391. viewTransform.updateTransform();
  31392. this._updateTransform();
  31393. },
  31394. /**
  31395. * @param {string} name
  31396. * @return {module:echarts/coord/geo/Region}
  31397. */
  31398. getRegion: function (name) {
  31399. return this._regionsMap.get(name);
  31400. },
  31401. getRegionByCoord: function (coord) {
  31402. var regions = this.regions;
  31403. for (var i = 0; i < regions.length; i++) {
  31404. if (regions[i].contain(coord)) {
  31405. return regions[i];
  31406. }
  31407. }
  31408. },
  31409. /**
  31410. * Add geoCoord for indexing by name
  31411. * @param {string} name
  31412. * @param {Array.<number>} geoCoord
  31413. */
  31414. addGeoCoord: function (name, geoCoord) {
  31415. this._nameCoordMap.set(name, geoCoord);
  31416. },
  31417. /**
  31418. * Get geoCoord by name
  31419. * @param {string} name
  31420. * @return {Array.<number>}
  31421. */
  31422. getGeoCoord: function (name) {
  31423. return this._nameCoordMap.get(name);
  31424. },
  31425. // Overwrite
  31426. getBoundingRect: function () {
  31427. if (this._rect) {
  31428. return this._rect;
  31429. }
  31430. var rect;
  31431. var regions = this.regions;
  31432. for (var i = 0; i < regions.length; i++) {
  31433. var regionRect = regions[i].getBoundingRect();
  31434. rect = rect || regionRect.clone();
  31435. rect.union(regionRect);
  31436. }
  31437. // FIXME Always return new ?
  31438. return (this._rect = rect || new BoundingRect(0, 0, 0, 0));
  31439. },
  31440. /**
  31441. * @param {string|Array.<number>} data
  31442. * @return {Array.<number>}
  31443. */
  31444. dataToPoint: function (data) {
  31445. if (typeof data === 'string') {
  31446. // Map area name to geoCoord
  31447. data = this.getGeoCoord(data);
  31448. }
  31449. if (data) {
  31450. return View.prototype.dataToPoint.call(this, data);
  31451. }
  31452. },
  31453. /**
  31454. * @inheritDoc
  31455. */
  31456. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  31457. /**
  31458. * @inheritDoc
  31459. */
  31460. convertFromPixel: zrUtil.curry(doConvert, 'pointToData')
  31461. };
  31462. zrUtil.mixin(Geo, View);
  31463. function doConvert(methodName, ecModel, finder, value) {
  31464. var geoModel = finder.geoModel;
  31465. var seriesModel = finder.seriesModel;
  31466. var coordSys = geoModel
  31467. ? geoModel.coordinateSystem
  31468. : seriesModel
  31469. ? (
  31470. seriesModel.coordinateSystem // For map.
  31471. || (seriesModel.getReferringComponents('geo')[0] || {}).coordinateSystem
  31472. )
  31473. : null;
  31474. return coordSys === this ? coordSys[methodName](value) : null;
  31475. }
  31476. module.exports = Geo;
  31477. /***/ }),
  31478. /* 176 */
  31479. /***/ (function(module, exports, __webpack_require__) {
  31480. /**
  31481. * Parse and decode geo json
  31482. * @module echarts/coord/geo/parseGeoJson
  31483. */
  31484. var zrUtil = __webpack_require__(4);
  31485. var Region = __webpack_require__(177);
  31486. function decode(json) {
  31487. if (!json.UTF8Encoding) {
  31488. return json;
  31489. }
  31490. var encodeScale = json.UTF8Scale;
  31491. if (encodeScale == null) {
  31492. encodeScale = 1024;
  31493. }
  31494. var features = json.features;
  31495. for (var f = 0; f < features.length; f++) {
  31496. var feature = features[f];
  31497. var geometry = feature.geometry;
  31498. var coordinates = geometry.coordinates;
  31499. var encodeOffsets = geometry.encodeOffsets;
  31500. for (var c = 0; c < coordinates.length; c++) {
  31501. var coordinate = coordinates[c];
  31502. if (geometry.type === 'Polygon') {
  31503. coordinates[c] = decodePolygon(
  31504. coordinate,
  31505. encodeOffsets[c],
  31506. encodeScale
  31507. );
  31508. }
  31509. else if (geometry.type === 'MultiPolygon') {
  31510. for (var c2 = 0; c2 < coordinate.length; c2++) {
  31511. var polygon = coordinate[c2];
  31512. coordinate[c2] = decodePolygon(
  31513. polygon,
  31514. encodeOffsets[c][c2],
  31515. encodeScale
  31516. );
  31517. }
  31518. }
  31519. }
  31520. }
  31521. // Has been decoded
  31522. json.UTF8Encoding = false;
  31523. return json;
  31524. }
  31525. function decodePolygon(coordinate, encodeOffsets, encodeScale) {
  31526. var result = [];
  31527. var prevX = encodeOffsets[0];
  31528. var prevY = encodeOffsets[1];
  31529. for (var i = 0; i < coordinate.length; i += 2) {
  31530. var x = coordinate.charCodeAt(i) - 64;
  31531. var y = coordinate.charCodeAt(i + 1) - 64;
  31532. // ZigZag decoding
  31533. x = (x >> 1) ^ (-(x & 1));
  31534. y = (y >> 1) ^ (-(y & 1));
  31535. // Delta deocding
  31536. x += prevX;
  31537. y += prevY;
  31538. prevX = x;
  31539. prevY = y;
  31540. // Dequantize
  31541. result.push([x / encodeScale, y / encodeScale]);
  31542. }
  31543. return result;
  31544. }
  31545. /**
  31546. * @alias module:echarts/coord/geo/parseGeoJson
  31547. * @param {Object} geoJson
  31548. * @return {module:zrender/container/Group}
  31549. */
  31550. module.exports = function (geoJson) {
  31551. decode(geoJson);
  31552. return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {
  31553. // Output of mapshaper may have geometry null
  31554. return featureObj.geometry
  31555. && featureObj.properties
  31556. && featureObj.geometry.coordinates.length > 0;
  31557. }), function (featureObj) {
  31558. var properties = featureObj.properties;
  31559. var geo = featureObj.geometry;
  31560. var coordinates = geo.coordinates;
  31561. var geometries = [];
  31562. if (geo.type === 'Polygon') {
  31563. geometries.push({
  31564. type: 'polygon',
  31565. // According to the GeoJSON specification.
  31566. // First must be exterior, and the rest are all interior(holes).
  31567. exterior: coordinates[0],
  31568. interiors: coordinates.slice(1)
  31569. });
  31570. }
  31571. if (geo.type === 'MultiPolygon') {
  31572. zrUtil.each(coordinates, function (item) {
  31573. if (item[0]) {
  31574. geometries.push({
  31575. type: 'polygon',
  31576. exterior: item[0],
  31577. interiors: item.slice(1)
  31578. });
  31579. }
  31580. });
  31581. }
  31582. var region = new Region(
  31583. properties.name,
  31584. geometries,
  31585. properties.cp
  31586. );
  31587. region.properties = properties;
  31588. return region;
  31589. });
  31590. };
  31591. /***/ }),
  31592. /* 177 */
  31593. /***/ (function(module, exports, __webpack_require__) {
  31594. /**
  31595. * @module echarts/coord/geo/Region
  31596. */
  31597. var polygonContain = __webpack_require__(178);
  31598. var BoundingRect = __webpack_require__(9);
  31599. var bbox = __webpack_require__(41);
  31600. var vec2 = __webpack_require__(10);
  31601. /**
  31602. * @param {string} name
  31603. * @param {Array} geometries
  31604. * @param {Array.<number>} cp
  31605. */
  31606. function Region(name, geometries, cp) {
  31607. /**
  31608. * @type {string}
  31609. * @readOnly
  31610. */
  31611. this.name = name;
  31612. /**
  31613. * @type {Array.<Array>}
  31614. * @readOnly
  31615. */
  31616. this.geometries = geometries;
  31617. if (!cp) {
  31618. var rect = this.getBoundingRect();
  31619. cp = [
  31620. rect.x + rect.width / 2,
  31621. rect.y + rect.height / 2
  31622. ];
  31623. }
  31624. else {
  31625. cp = [cp[0], cp[1]];
  31626. }
  31627. /**
  31628. * @type {Array.<number>}
  31629. */
  31630. this.center = cp;
  31631. }
  31632. Region.prototype = {
  31633. constructor: Region,
  31634. properties: null,
  31635. /**
  31636. * @return {module:zrender/core/BoundingRect}
  31637. */
  31638. getBoundingRect: function () {
  31639. var rect = this._rect;
  31640. if (rect) {
  31641. return rect;
  31642. }
  31643. var MAX_NUMBER = Number.MAX_VALUE;
  31644. var min = [MAX_NUMBER, MAX_NUMBER];
  31645. var max = [-MAX_NUMBER, -MAX_NUMBER];
  31646. var min2 = [];
  31647. var max2 = [];
  31648. var geometries = this.geometries;
  31649. for (var i = 0; i < geometries.length; i++) {
  31650. // Only support polygon
  31651. if (geometries[i].type !== 'polygon') {
  31652. continue;
  31653. }
  31654. // Doesn't consider hole
  31655. var exterior = geometries[i].exterior;
  31656. bbox.fromPoints(exterior, min2, max2);
  31657. vec2.min(min, min, min2);
  31658. vec2.max(max, max, max2);
  31659. }
  31660. // No data
  31661. if (i === 0) {
  31662. min[0] = min[1] = max[0] = max[1] = 0;
  31663. }
  31664. return (this._rect = new BoundingRect(
  31665. min[0], min[1], max[0] - min[0], max[1] - min[1]
  31666. ));
  31667. },
  31668. /**
  31669. * @param {<Array.<number>} coord
  31670. * @return {boolean}
  31671. */
  31672. contain: function (coord) {
  31673. var rect = this.getBoundingRect();
  31674. var geometries = this.geometries;
  31675. if (!rect.contain(coord[0], coord[1])) {
  31676. return false;
  31677. }
  31678. loopGeo: for (var i = 0, len = geometries.length; i < len; i++) {
  31679. // Only support polygon.
  31680. if (geometries[i].type !== 'polygon') {
  31681. continue;
  31682. }
  31683. var exterior = geometries[i].exterior;
  31684. var interiors = geometries[i].interiors;
  31685. if (polygonContain.contain(exterior, coord[0], coord[1])) {
  31686. // Not in the region if point is in the hole.
  31687. for (var k = 0; k < (interiors ? interiors.length : 0); k++) {
  31688. if (polygonContain.contain(interiors[k])) {
  31689. continue loopGeo;
  31690. }
  31691. }
  31692. return true;
  31693. }
  31694. }
  31695. return false;
  31696. },
  31697. transformTo: function (x, y, width, height) {
  31698. var rect = this.getBoundingRect();
  31699. var aspect = rect.width / rect.height;
  31700. if (!width) {
  31701. width = aspect * height;
  31702. }
  31703. else if (!height) {
  31704. height = width / aspect ;
  31705. }
  31706. var target = new BoundingRect(x, y, width, height);
  31707. var transform = rect.calculateTransform(target);
  31708. var geometries = this.geometries;
  31709. for (var i = 0; i < geometries.length; i++) {
  31710. // Only support polygon.
  31711. if (geometries[i].type !== 'polygon') {
  31712. continue;
  31713. }
  31714. var exterior = geometries[i].exterior;
  31715. var interiors = geometries[i].interiors;
  31716. for (var p = 0; p < exterior.length; p++) {
  31717. vec2.applyTransform(exterior[p], exterior[p], transform);
  31718. }
  31719. for (var h = 0; h < (interiors ? interiors.length : 0); h++) {
  31720. for (var p = 0; p < interiors[h].length; p++) {
  31721. vec2.applyTransform(interiors[h][p], interiors[h][p], transform);
  31722. }
  31723. }
  31724. }
  31725. rect = this._rect;
  31726. rect.copy(target);
  31727. // Update center
  31728. this.center = [
  31729. rect.x + rect.width / 2,
  31730. rect.y + rect.height / 2
  31731. ];
  31732. }
  31733. };
  31734. module.exports = Region;
  31735. /***/ }),
  31736. /* 178 */
  31737. /***/ (function(module, exports, __webpack_require__) {
  31738. var windingLine = __webpack_require__(48);
  31739. var EPSILON = 1e-8;
  31740. function isAroundEqual(a, b) {
  31741. return Math.abs(a - b) < EPSILON;
  31742. }
  31743. function contain(points, x, y) {
  31744. var w = 0;
  31745. var p = points[0];
  31746. if (!p) {
  31747. return false;
  31748. }
  31749. for (var i = 1; i < points.length; i++) {
  31750. var p2 = points[i];
  31751. w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
  31752. p = p2;
  31753. }
  31754. // Close polygon
  31755. var p0 = points[0];
  31756. if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) {
  31757. w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
  31758. }
  31759. return w !== 0;
  31760. }
  31761. module.exports = {
  31762. contain: contain
  31763. };
  31764. /***/ }),
  31765. /* 179 */
  31766. /***/ (function(module, exports, __webpack_require__) {
  31767. /**
  31768. * Simple view coordinate system
  31769. * Mapping given x, y to transformd view x, y
  31770. */
  31771. var vector = __webpack_require__(10);
  31772. var matrix = __webpack_require__(11);
  31773. var Transformable = __webpack_require__(28);
  31774. var zrUtil = __webpack_require__(4);
  31775. var BoundingRect = __webpack_require__(9);
  31776. var v2ApplyTransform = vector.applyTransform;
  31777. // Dummy transform node
  31778. function TransformDummy() {
  31779. Transformable.call(this);
  31780. }
  31781. zrUtil.mixin(TransformDummy, Transformable);
  31782. function View(name) {
  31783. /**
  31784. * @type {string}
  31785. */
  31786. this.name = name;
  31787. /**
  31788. * @type {Object}
  31789. */
  31790. this.zoomLimit;
  31791. Transformable.call(this);
  31792. this._roamTransform = new TransformDummy();
  31793. this._viewTransform = new TransformDummy();
  31794. this._center;
  31795. this._zoom;
  31796. }
  31797. View.prototype = {
  31798. constructor: View,
  31799. type: 'view',
  31800. /**
  31801. * @param {Array.<string>}
  31802. * @readOnly
  31803. */
  31804. dimensions: ['x', 'y'],
  31805. /**
  31806. * Set bounding rect
  31807. * @param {number} x
  31808. * @param {number} y
  31809. * @param {number} width
  31810. * @param {number} height
  31811. */
  31812. // PENDING to getRect
  31813. setBoundingRect: function (x, y, width, height) {
  31814. this._rect = new BoundingRect(x, y, width, height);
  31815. return this._rect;
  31816. },
  31817. /**
  31818. * @return {module:zrender/core/BoundingRect}
  31819. */
  31820. // PENDING to getRect
  31821. getBoundingRect: function () {
  31822. return this._rect;
  31823. },
  31824. /**
  31825. * @param {number} x
  31826. * @param {number} y
  31827. * @param {number} width
  31828. * @param {number} height
  31829. */
  31830. setViewRect: function (x, y, width, height) {
  31831. this.transformTo(x, y, width, height);
  31832. this._viewRect = new BoundingRect(x, y, width, height);
  31833. },
  31834. /**
  31835. * Transformed to particular position and size
  31836. * @param {number} x
  31837. * @param {number} y
  31838. * @param {number} width
  31839. * @param {number} height
  31840. */
  31841. transformTo: function (x, y, width, height) {
  31842. var rect = this.getBoundingRect();
  31843. var viewTransform = this._viewTransform;
  31844. viewTransform.transform = rect.calculateTransform(
  31845. new BoundingRect(x, y, width, height)
  31846. );
  31847. viewTransform.decomposeTransform();
  31848. this._updateTransform();
  31849. },
  31850. /**
  31851. * Set center of view
  31852. * @param {Array.<number>} [centerCoord]
  31853. */
  31854. setCenter: function (centerCoord) {
  31855. if (!centerCoord) {
  31856. return;
  31857. }
  31858. this._center = centerCoord;
  31859. this._updateCenterAndZoom();
  31860. },
  31861. /**
  31862. * @param {number} zoom
  31863. */
  31864. setZoom: function (zoom) {
  31865. zoom = zoom || 1;
  31866. var zoomLimit = this.zoomLimit;
  31867. if (zoomLimit) {
  31868. if (zoomLimit.max != null) {
  31869. zoom = Math.min(zoomLimit.max, zoom);
  31870. }
  31871. if (zoomLimit.min != null) {
  31872. zoom = Math.max(zoomLimit.min, zoom);
  31873. }
  31874. }
  31875. this._zoom = zoom;
  31876. this._updateCenterAndZoom();
  31877. },
  31878. /**
  31879. * Get default center without roam
  31880. */
  31881. getDefaultCenter: function () {
  31882. // Rect before any transform
  31883. var rawRect = this.getBoundingRect();
  31884. var cx = rawRect.x + rawRect.width / 2;
  31885. var cy = rawRect.y + rawRect.height / 2;
  31886. return [cx, cy];
  31887. },
  31888. getCenter: function () {
  31889. return this._center || this.getDefaultCenter();
  31890. },
  31891. getZoom: function () {
  31892. return this._zoom || 1;
  31893. },
  31894. /**
  31895. * @return {Array.<number}
  31896. */
  31897. getRoamTransform: function () {
  31898. return this._roamTransform;
  31899. },
  31900. _updateCenterAndZoom: function () {
  31901. // Must update after view transform updated
  31902. var viewTransformMatrix = this._viewTransform.getLocalTransform();
  31903. var roamTransform = this._roamTransform;
  31904. var defaultCenter = this.getDefaultCenter();
  31905. var center = this.getCenter();
  31906. var zoom = this.getZoom();
  31907. center = vector.applyTransform([], center, viewTransformMatrix);
  31908. defaultCenter = vector.applyTransform([], defaultCenter, viewTransformMatrix);
  31909. roamTransform.origin = center;
  31910. roamTransform.position = [
  31911. defaultCenter[0] - center[0],
  31912. defaultCenter[1] - center[1]
  31913. ];
  31914. roamTransform.scale = [zoom, zoom];
  31915. this._updateTransform();
  31916. },
  31917. /**
  31918. * Update transform from roam and mapLocation
  31919. * @private
  31920. */
  31921. _updateTransform: function () {
  31922. var roamTransform = this._roamTransform;
  31923. var viewTransform = this._viewTransform;
  31924. viewTransform.parent = roamTransform;
  31925. roamTransform.updateTransform();
  31926. viewTransform.updateTransform();
  31927. viewTransform.transform
  31928. && matrix.copy(this.transform || (this.transform = []), viewTransform.transform);
  31929. if (this.transform) {
  31930. this.invTransform = this.invTransform || [];
  31931. matrix.invert(this.invTransform, this.transform);
  31932. }
  31933. else {
  31934. this.invTransform = null;
  31935. }
  31936. this.decomposeTransform();
  31937. },
  31938. /**
  31939. * @return {module:zrender/core/BoundingRect}
  31940. */
  31941. getViewRect: function () {
  31942. return this._viewRect;
  31943. },
  31944. /**
  31945. * Get view rect after roam transform
  31946. * @return {module:zrender/core/BoundingRect}
  31947. */
  31948. getViewRectAfterRoam: function () {
  31949. var rect = this.getBoundingRect().clone();
  31950. rect.applyTransform(this.transform);
  31951. return rect;
  31952. },
  31953. /**
  31954. * Convert a single (lon, lat) data item to (x, y) point.
  31955. * @param {Array.<number>} data
  31956. * @return {Array.<number>}
  31957. */
  31958. dataToPoint: function (data) {
  31959. var transform = this.transform;
  31960. return transform
  31961. ? v2ApplyTransform([], data, transform)
  31962. : [data[0], data[1]];
  31963. },
  31964. /**
  31965. * Convert a (x, y) point to (lon, lat) data
  31966. * @param {Array.<number>} point
  31967. * @return {Array.<number>}
  31968. */
  31969. pointToData: function (point) {
  31970. var invTransform = this.invTransform;
  31971. return invTransform
  31972. ? v2ApplyTransform([], point, invTransform)
  31973. : [point[0], point[1]];
  31974. },
  31975. /**
  31976. * @implements
  31977. * see {module:echarts/CoodinateSystem}
  31978. */
  31979. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  31980. /**
  31981. * @implements
  31982. * see {module:echarts/CoodinateSystem}
  31983. */
  31984. convertFromPixel: zrUtil.curry(doConvert, 'pointToData'),
  31985. /**
  31986. * @implements
  31987. * see {module:echarts/CoodinateSystem}
  31988. */
  31989. containPoint: function (point) {
  31990. return this.getViewRectAfterRoam().contain(point[0], point[1]);
  31991. }
  31992. /**
  31993. * @return {number}
  31994. */
  31995. // getScalarScale: function () {
  31996. // // Use determinant square root of transform to mutiply scalar
  31997. // var m = this.transform;
  31998. // var det = Math.sqrt(Math.abs(m[0] * m[3] - m[2] * m[1]));
  31999. // return det;
  32000. // }
  32001. };
  32002. zrUtil.mixin(View, Transformable);
  32003. function doConvert(methodName, ecModel, finder, value) {
  32004. var seriesModel = finder.seriesModel;
  32005. var coordSys = seriesModel ? seriesModel.coordinateSystem : null; // e.g., graph.
  32006. return coordSys === this ? coordSys[methodName](value) : null;
  32007. }
  32008. module.exports = View;
  32009. /***/ }),
  32010. /* 180 */
  32011. /***/ (function(module, exports, __webpack_require__) {
  32012. // Fix for 南海诸岛
  32013. var Region = __webpack_require__(177);
  32014. var zrUtil = __webpack_require__(4);
  32015. var geoCoord = [126, 25];
  32016. var points = [
  32017. [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7],
  32018. [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]],
  32019. [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]],
  32020. [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]],
  32021. [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]],
  32022. [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]],
  32023. [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]],
  32024. [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]],
  32025. [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]],
  32026. [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]],
  32027. [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]],
  32028. [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]],
  32029. [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4],
  32030. [1,92.4],[1,3.5],[0,3.5]]
  32031. ];
  32032. for (var i = 0; i < points.length; i++) {
  32033. for (var k = 0; k < points[i].length; k++) {
  32034. points[i][k][0] /= 10.5;
  32035. points[i][k][1] /= -10.5 / 0.75;
  32036. points[i][k][0] += geoCoord[0];
  32037. points[i][k][1] += geoCoord[1];
  32038. }
  32039. }
  32040. module.exports = function (geo) {
  32041. if (geo.map === 'china') {
  32042. geo.regions.push(new Region(
  32043. '南海诸岛',
  32044. zrUtil.map(points, function (exterior) {
  32045. return {
  32046. type: 'polygon',
  32047. exterior: exterior
  32048. };
  32049. }), geoCoord
  32050. ));
  32051. }
  32052. };
  32053. /***/ }),
  32054. /* 181 */
  32055. /***/ (function(module, exports, __webpack_require__) {
  32056. var zrUtil = __webpack_require__(4);
  32057. var coordsOffsetMap = {
  32058. '南海诸岛' : [32, 80],
  32059. // 全国
  32060. '广东': [0, -10],
  32061. '香港': [10, 5],
  32062. '澳门': [-10, 10],
  32063. //'北京': [-10, 0],
  32064. '天津': [5, 5]
  32065. };
  32066. module.exports = function (geo) {
  32067. zrUtil.each(geo.regions, function (region) {
  32068. var coordFix = coordsOffsetMap[region.name];
  32069. if (coordFix) {
  32070. var cp = region.center;
  32071. cp[0] += coordFix[0] / 10.5;
  32072. cp[1] += -coordFix[1] / (10.5 / 0.75);
  32073. }
  32074. });
  32075. };
  32076. /***/ }),
  32077. /* 182 */
  32078. /***/ (function(module, exports, __webpack_require__) {
  32079. var zrUtil = __webpack_require__(4);
  32080. var geoCoordMap = {
  32081. 'Russia': [100, 60],
  32082. 'United States': [-99, 38],
  32083. 'United States of America': [-99, 38]
  32084. };
  32085. module.exports = function (geo) {
  32086. zrUtil.each(geo.regions, function (region) {
  32087. var geoCoord = geoCoordMap[region.name];
  32088. if (geoCoord) {
  32089. var cp = region.center;
  32090. cp[0] = geoCoord[0];
  32091. cp[1] = geoCoord[1];
  32092. }
  32093. });
  32094. };
  32095. /***/ }),
  32096. /* 183 */
  32097. /***/ (function(module, exports) {
  32098. // Fix for 钓鱼岛
  32099. // var Region = require('../Region');
  32100. // var zrUtil = require('zrender/lib/core/util');
  32101. // var geoCoord = [126, 25];
  32102. var points = [
  32103. [
  32104. [123.45165252685547, 25.73527164402261],
  32105. [123.49731445312499, 25.73527164402261],
  32106. [123.49731445312499, 25.750734064600884],
  32107. [123.45165252685547, 25.750734064600884],
  32108. [123.45165252685547, 25.73527164402261]
  32109. ]
  32110. ];
  32111. module.exports = function (geo) {
  32112. if (geo.map === 'china') {
  32113. for (var i = 0, len = geo.regions.length; i < len; ++i) {
  32114. if (geo.regions[i].name === '台湾') {
  32115. geo.regions[i].geometries.push({
  32116. type: 'polygon',
  32117. exterior: points[0]
  32118. });
  32119. }
  32120. }
  32121. }
  32122. };
  32123. /***/ }),
  32124. /* 184 */
  32125. /***/ (function(module, exports, __webpack_require__) {
  32126. // var zrUtil = require('zrender/lib/core/util');
  32127. var graphic = __webpack_require__(20);
  32128. var zrUtil = __webpack_require__(4);
  32129. var MapDraw = __webpack_require__(185);
  32130. __webpack_require__(1).extendChartView({
  32131. type: 'map',
  32132. render: function (mapModel, ecModel, api, payload) {
  32133. // Not render if it is an toggleSelect action from self
  32134. if (payload && payload.type === 'mapToggleSelect'
  32135. && payload.from === this.uid
  32136. ) {
  32137. return;
  32138. }
  32139. var group = this.group;
  32140. group.removeAll();
  32141. if (mapModel.getHostGeoModel()) {
  32142. return;
  32143. }
  32144. // Not update map if it is an roam action from self
  32145. if (!(payload && payload.type === 'geoRoam'
  32146. && payload.componentType === 'series'
  32147. && payload.seriesId === mapModel.id
  32148. )
  32149. ) {
  32150. if (mapModel.needsDrawMap) {
  32151. var mapDraw = this._mapDraw || new MapDraw(api, true);
  32152. group.add(mapDraw.group);
  32153. mapDraw.draw(mapModel, ecModel, api, this, payload);
  32154. this._mapDraw = mapDraw;
  32155. }
  32156. else {
  32157. // Remove drawed map
  32158. this._mapDraw && this._mapDraw.remove();
  32159. this._mapDraw = null;
  32160. }
  32161. }
  32162. else {
  32163. var mapDraw = this._mapDraw;
  32164. mapDraw && group.add(mapDraw.group);
  32165. }
  32166. mapModel.get('showLegendSymbol') && ecModel.getComponent('legend')
  32167. && this._renderSymbols(mapModel, ecModel, api);
  32168. },
  32169. remove: function () {
  32170. this._mapDraw && this._mapDraw.remove();
  32171. this._mapDraw = null;
  32172. this.group.removeAll();
  32173. },
  32174. dispose: function () {
  32175. this._mapDraw && this._mapDraw.remove();
  32176. this._mapDraw = null;
  32177. },
  32178. _renderSymbols: function (mapModel, ecModel, api) {
  32179. var originalData = mapModel.originalData;
  32180. var group = this.group;
  32181. originalData.each('value', function (value, idx) {
  32182. if (isNaN(value)) {
  32183. return;
  32184. }
  32185. var layout = originalData.getItemLayout(idx);
  32186. if (!layout || !layout.point) {
  32187. // Not exists in map
  32188. return;
  32189. }
  32190. var point = layout.point;
  32191. var offset = layout.offset;
  32192. var circle = new graphic.Circle({
  32193. style: {
  32194. // Because the special of map draw.
  32195. // Which needs statistic of multiple series and draw on one map.
  32196. // And each series also need a symbol with legend color
  32197. //
  32198. // Layout and visual are put one the different data
  32199. fill: mapModel.getData().getVisual('color')
  32200. },
  32201. shape: {
  32202. cx: point[0] + offset * 9,
  32203. cy: point[1],
  32204. r: 3
  32205. },
  32206. silent: true,
  32207. // Do not overlap the first series, on which labels are displayed.
  32208. z2: !offset ? 10 : 8
  32209. });
  32210. // First data on the same region
  32211. if (!offset) {
  32212. var fullData = mapModel.mainSeries.getData();
  32213. var name = originalData.getName(idx);
  32214. var fullIndex = fullData.indexOfName(name);
  32215. var itemModel = originalData.getItemModel(idx);
  32216. var labelModel = itemModel.getModel('label.normal');
  32217. var hoverLabelModel = itemModel.getModel('label.emphasis');
  32218. var polygonGroups = fullData.getItemGraphicEl(fullIndex);
  32219. var normalText = zrUtil.retrieve2(
  32220. mapModel.getFormattedLabel(idx, 'normal'),
  32221. name
  32222. );
  32223. var emphasisText = zrUtil.retrieve2(
  32224. mapModel.getFormattedLabel(idx, 'emphasis'),
  32225. normalText
  32226. );
  32227. var onEmphasis = function () {
  32228. var hoverStyle = graphic.setTextStyle({}, hoverLabelModel, {
  32229. text: hoverLabelModel.get('show') ? emphasisText : null
  32230. }, {isRectText: true, useInsideStyle: false}, true);
  32231. circle.style.extendFrom(hoverStyle);
  32232. // Make label upper than others if overlaps.
  32233. circle.__mapOriginalZ2 = circle.z2;
  32234. circle.z2 += 1;
  32235. };
  32236. var onNormal = function () {
  32237. graphic.setTextStyle(circle.style, labelModel, {
  32238. text: labelModel.get('show') ? normalText : null,
  32239. textPosition: labelModel.getShallow('position') || 'bottom'
  32240. }, {isRectText: true, useInsideStyle: false});
  32241. if (circle.__mapOriginalZ2 != null) {
  32242. circle.z2 = circle.__mapOriginalZ2;
  32243. circle.__mapOriginalZ2 = null;
  32244. }
  32245. };
  32246. polygonGroups.on('mouseover', onEmphasis)
  32247. .on('mouseout', onNormal)
  32248. .on('emphasis', onEmphasis)
  32249. .on('normal', onNormal);
  32250. onNormal();
  32251. }
  32252. group.add(circle);
  32253. });
  32254. }
  32255. });
  32256. /***/ }),
  32257. /* 185 */
  32258. /***/ (function(module, exports, __webpack_require__) {
  32259. /**
  32260. * @module echarts/component/helper/MapDraw
  32261. */
  32262. var RoamController = __webpack_require__(186);
  32263. var roamHelper = __webpack_require__(188);
  32264. var cursorHelper = __webpack_require__(189);
  32265. var graphic = __webpack_require__(20);
  32266. var zrUtil = __webpack_require__(4);
  32267. function getFixedItemStyle(model, scale) {
  32268. var itemStyle = model.getItemStyle();
  32269. var areaColor = model.get('areaColor');
  32270. // If user want the color not to be changed when hover,
  32271. // they should both set areaColor and color to be null.
  32272. if (areaColor != null) {
  32273. itemStyle.fill = areaColor;
  32274. }
  32275. return itemStyle;
  32276. }
  32277. function updateMapSelectHandler(mapDraw, mapOrGeoModel, group, api, fromView) {
  32278. group.off('click');
  32279. group.off('mousedown');
  32280. if (mapOrGeoModel.get('selectedMode')) {
  32281. group.on('mousedown', function () {
  32282. mapDraw._mouseDownFlag = true;
  32283. });
  32284. group.on('click', function (e) {
  32285. if (!mapDraw._mouseDownFlag) {
  32286. return;
  32287. }
  32288. mapDraw._mouseDownFlag = false;
  32289. var el = e.target;
  32290. while (!el.__regions) {
  32291. el = el.parent;
  32292. }
  32293. if (!el) {
  32294. return;
  32295. }
  32296. var action = {
  32297. type: (mapOrGeoModel.mainType === 'geo' ? 'geo' : 'map') + 'ToggleSelect',
  32298. batch: zrUtil.map(el.__regions, function (region) {
  32299. return {
  32300. name: region.name,
  32301. from: fromView.uid
  32302. };
  32303. })
  32304. };
  32305. action[mapOrGeoModel.mainType + 'Id'] = mapOrGeoModel.id;
  32306. api.dispatchAction(action);
  32307. updateMapSelected(mapOrGeoModel, group);
  32308. });
  32309. }
  32310. }
  32311. function updateMapSelected(mapOrGeoModel, group) {
  32312. // FIXME
  32313. group.eachChild(function (otherRegionEl) {
  32314. zrUtil.each(otherRegionEl.__regions, function (region) {
  32315. otherRegionEl.trigger(mapOrGeoModel.isSelected(region.name) ? 'emphasis' : 'normal');
  32316. });
  32317. });
  32318. }
  32319. /**
  32320. * @alias module:echarts/component/helper/MapDraw
  32321. * @param {module:echarts/ExtensionAPI} api
  32322. * @param {boolean} updateGroup
  32323. */
  32324. function MapDraw(api, updateGroup) {
  32325. var group = new graphic.Group();
  32326. /**
  32327. * @type {module:echarts/component/helper/RoamController}
  32328. * @private
  32329. */
  32330. this._controller = new RoamController(api.getZr());
  32331. /**
  32332. * @type {Object} {target, zoom, zoomLimit}
  32333. * @private
  32334. */
  32335. this._controllerHost = {target: updateGroup ? group : null};
  32336. /**
  32337. * @type {module:zrender/container/Group}
  32338. * @readOnly
  32339. */
  32340. this.group = group;
  32341. /**
  32342. * @type {boolean}
  32343. * @private
  32344. */
  32345. this._updateGroup = updateGroup;
  32346. /**
  32347. * This flag is used to make sure that only one among
  32348. * `pan`, `zoom`, `click` can occurs, otherwise 'selected'
  32349. * action may be triggered when `pan`, which is unexpected.
  32350. * @type {booelan}
  32351. */
  32352. this._mouseDownFlag;
  32353. }
  32354. MapDraw.prototype = {
  32355. constructor: MapDraw,
  32356. draw: function (mapOrGeoModel, ecModel, api, fromView, payload) {
  32357. var isGeo = mapOrGeoModel.mainType === 'geo';
  32358. // Map series has data. GEO model that controlled by map series
  32359. // will be assigned with map data. Other GEO model has no data.
  32360. var data = mapOrGeoModel.getData && mapOrGeoModel.getData();
  32361. isGeo && ecModel.eachComponent({mainType: 'series', subType: 'map'}, function (mapSeries) {
  32362. if (!data && mapSeries.getHostGeoModel() === mapOrGeoModel) {
  32363. data = mapSeries.getData();
  32364. }
  32365. });
  32366. var geo = mapOrGeoModel.coordinateSystem;
  32367. var group = this.group;
  32368. var scale = geo.scale;
  32369. var groupNewProp = {
  32370. position: geo.position,
  32371. scale: scale
  32372. };
  32373. // No animation when first draw or in action
  32374. if (!group.childAt(0) || payload) {
  32375. group.attr(groupNewProp);
  32376. }
  32377. else {
  32378. graphic.updateProps(group, groupNewProp, mapOrGeoModel);
  32379. }
  32380. group.removeAll();
  32381. var itemStyleAccessPath = ['itemStyle', 'normal'];
  32382. var hoverItemStyleAccessPath = ['itemStyle', 'emphasis'];
  32383. var labelAccessPath = ['label', 'normal'];
  32384. var hoverLabelAccessPath = ['label', 'emphasis'];
  32385. var nameMap = zrUtil.createHashMap();
  32386. zrUtil.each(geo.regions, function (region) {
  32387. // Consider in GeoJson properties.name may be duplicated, for example,
  32388. // there is multiple region named "United Kindom" or "France" (so many
  32389. // colonies). And it is not appropriate to merge them in geo, which
  32390. // will make them share the same label and bring trouble in label
  32391. // location calculation.
  32392. var regionGroup = nameMap.get(region.name)
  32393. || nameMap.set(region.name, new graphic.Group());
  32394. var compoundPath = new graphic.CompoundPath({
  32395. shape: {
  32396. paths: []
  32397. }
  32398. });
  32399. regionGroup.add(compoundPath);
  32400. var regionModel = mapOrGeoModel.getRegionModel(region.name) || mapOrGeoModel;
  32401. var itemStyleModel = regionModel.getModel(itemStyleAccessPath);
  32402. var hoverItemStyleModel = regionModel.getModel(hoverItemStyleAccessPath);
  32403. var itemStyle = getFixedItemStyle(itemStyleModel, scale);
  32404. var hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale);
  32405. var labelModel = regionModel.getModel(labelAccessPath);
  32406. var hoverLabelModel = regionModel.getModel(hoverLabelAccessPath);
  32407. var dataIdx;
  32408. // Use the itemStyle in data if has data
  32409. if (data) {
  32410. dataIdx = data.indexOfName(region.name);
  32411. // Only visual color of each item will be used. It can be encoded by dataRange
  32412. // But visual color of series is used in symbol drawing
  32413. //
  32414. // Visual color for each series is for the symbol draw
  32415. var visualColor = data.getItemVisual(dataIdx, 'color', true);
  32416. if (visualColor) {
  32417. itemStyle.fill = visualColor;
  32418. }
  32419. }
  32420. zrUtil.each(region.geometries, function (geometry) {
  32421. if (geometry.type !== 'polygon') {
  32422. return;
  32423. }
  32424. compoundPath.shape.paths.push(new graphic.Polygon({
  32425. shape: {
  32426. points: geometry.exterior
  32427. }
  32428. }));
  32429. for (var i = 0; i < (geometry.interiors ? geometry.interiors.length : 0); i++) {
  32430. compoundPath.shape.paths.push(new graphic.Polygon({
  32431. shape: {
  32432. points: geometry.interiors[i]
  32433. }
  32434. }));
  32435. }
  32436. });
  32437. compoundPath.setStyle(itemStyle);
  32438. compoundPath.style.strokeNoScale = true;
  32439. compoundPath.culling = true;
  32440. // Label
  32441. var showLabel = labelModel.get('show');
  32442. var hoverShowLabel = hoverLabelModel.get('show');
  32443. var isDataNaN = data && isNaN(data.get('value', dataIdx));
  32444. var itemLayout = data && data.getItemLayout(dataIdx);
  32445. // In the following cases label will be drawn
  32446. // 1. In map series and data value is NaN
  32447. // 2. In geo component
  32448. // 4. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout
  32449. if (
  32450. (isGeo || isDataNaN && (showLabel || hoverShowLabel))
  32451. || (itemLayout && itemLayout.showLabel)
  32452. ) {
  32453. var query = !isGeo ? dataIdx : region.name;
  32454. var labelFetcher;
  32455. // Consider dataIdx not found.
  32456. if (!data || dataIdx >= 0) {
  32457. labelFetcher = mapOrGeoModel;
  32458. }
  32459. var textEl = new graphic.Text({
  32460. position: region.center.slice(),
  32461. scale: [1 / scale[0], 1 / scale[1]],
  32462. z2: 10,
  32463. silent: true
  32464. });
  32465. graphic.setLabelStyle(
  32466. textEl.style, textEl.hoverStyle = {}, labelModel, hoverLabelModel,
  32467. {
  32468. labelFetcher: labelFetcher,
  32469. labelDataIndex: query,
  32470. defaultText: region.name,
  32471. useInsideStyle: false
  32472. },
  32473. {
  32474. textAlign: 'center',
  32475. textVerticalAlign: 'middle'
  32476. }
  32477. );
  32478. regionGroup.add(textEl);
  32479. }
  32480. // setItemGraphicEl, setHoverStyle after all polygons and labels
  32481. // are added to the rigionGroup
  32482. if (data) {
  32483. data.setItemGraphicEl(dataIdx, regionGroup);
  32484. }
  32485. else {
  32486. var regionModel = mapOrGeoModel.getRegionModel(region.name);
  32487. // Package custom mouse event for geo component
  32488. compoundPath.eventData = {
  32489. componentType: 'geo',
  32490. geoIndex: mapOrGeoModel.componentIndex,
  32491. name: region.name,
  32492. region: (regionModel && regionModel.option) || {}
  32493. };
  32494. }
  32495. var groupRegions = regionGroup.__regions || (regionGroup.__regions = []);
  32496. groupRegions.push(region);
  32497. graphic.setHoverStyle(
  32498. regionGroup,
  32499. hoverItemStyle,
  32500. {hoverSilentOnTouch: !!mapOrGeoModel.get('selectedMode')}
  32501. );
  32502. group.add(regionGroup);
  32503. });
  32504. this._updateController(mapOrGeoModel, ecModel, api);
  32505. updateMapSelectHandler(this, mapOrGeoModel, group, api, fromView);
  32506. updateMapSelected(mapOrGeoModel, group);
  32507. },
  32508. remove: function () {
  32509. this.group.removeAll();
  32510. this._controller.dispose();
  32511. this._controllerHost = {};
  32512. },
  32513. _updateController: function (mapOrGeoModel, ecModel, api) {
  32514. var geo = mapOrGeoModel.coordinateSystem;
  32515. var controller = this._controller;
  32516. var controllerHost = this._controllerHost;
  32517. controllerHost.zoomLimit = mapOrGeoModel.get('scaleLimit');
  32518. controllerHost.zoom = geo.getZoom();
  32519. // roamType is will be set default true if it is null
  32520. controller.enable(mapOrGeoModel.get('roam') || false);
  32521. var mainType = mapOrGeoModel.mainType;
  32522. function makeActionBase() {
  32523. var action = {
  32524. type: 'geoRoam',
  32525. componentType: mainType
  32526. };
  32527. action[mainType + 'Id'] = mapOrGeoModel.id;
  32528. return action;
  32529. }
  32530. controller.off('pan').on('pan', function (dx, dy) {
  32531. this._mouseDownFlag = false;
  32532. roamHelper.updateViewOnPan(controllerHost, dx, dy);
  32533. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  32534. dx: dx,
  32535. dy: dy
  32536. }));
  32537. }, this);
  32538. controller.off('zoom').on('zoom', function (zoom, mouseX, mouseY) {
  32539. this._mouseDownFlag = false;
  32540. roamHelper.updateViewOnZoom(controllerHost, zoom, mouseX, mouseY);
  32541. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  32542. zoom: zoom,
  32543. originX: mouseX,
  32544. originY: mouseY
  32545. }));
  32546. if (this._updateGroup) {
  32547. var group = this.group;
  32548. var scale = group.scale;
  32549. group.traverse(function (el) {
  32550. if (el.type === 'text') {
  32551. el.attr('scale', [1 / scale[0], 1 / scale[1]]);
  32552. }
  32553. });
  32554. }
  32555. }, this);
  32556. controller.setPointerChecker(function (e, x, y) {
  32557. return geo.getViewRectAfterRoam().contain(x, y)
  32558. && !cursorHelper.onIrrelevantElement(e, api, mapOrGeoModel);
  32559. });
  32560. }
  32561. };
  32562. module.exports = MapDraw;
  32563. /***/ }),
  32564. /* 186 */
  32565. /***/ (function(module, exports, __webpack_require__) {
  32566. /**
  32567. * @module echarts/component/helper/RoamController
  32568. */
  32569. var Eventful = __webpack_require__(27);
  32570. var zrUtil = __webpack_require__(4);
  32571. var eventTool = __webpack_require__(93);
  32572. var interactionMutex = __webpack_require__(187);
  32573. /**
  32574. * @alias module:echarts/component/helper/RoamController
  32575. * @constructor
  32576. * @mixin {module:zrender/mixin/Eventful}
  32577. *
  32578. * @param {module:zrender/zrender~ZRender} zr
  32579. */
  32580. function RoamController(zr) {
  32581. /**
  32582. * @type {Function}
  32583. */
  32584. this.pointerChecker;
  32585. /**
  32586. * @type {module:zrender}
  32587. */
  32588. this._zr = zr;
  32589. /**
  32590. * @type {Object}
  32591. */
  32592. this._opt = {};
  32593. // Avoid two roamController bind the same handler
  32594. var bind = zrUtil.bind;
  32595. var mousedownHandler = bind(mousedown, this);
  32596. var mousemoveHandler = bind(mousemove, this);
  32597. var mouseupHandler = bind(mouseup, this);
  32598. var mousewheelHandler = bind(mousewheel, this);
  32599. var pinchHandler = bind(pinch, this);
  32600. Eventful.call(this);
  32601. /**
  32602. * @param {Function} pointerChecker
  32603. * input: x, y
  32604. * output: boolean
  32605. */
  32606. this.setPointerChecker = function (pointerChecker) {
  32607. this.pointerChecker = pointerChecker;
  32608. };
  32609. /**
  32610. * Notice: only enable needed types. For example, if 'zoom'
  32611. * is not needed, 'zoom' should not be enabled, otherwise
  32612. * default mousewheel behaviour (scroll page) will be disabled.
  32613. *
  32614. * @param {boolean|string} [controlType=true] Specify the control type,
  32615. * which can be null/undefined or true/false
  32616. * or 'pan/move' or 'zoom'/'scale'
  32617. * @param {Object} [opt]
  32618. * @param {Object} [opt.zoomOnMouseWheel=true]
  32619. * @param {Object} [opt.moveOnMouseMove=true]
  32620. * @param {Object} [opt.preventDefaultMouseMove=true] When pan.
  32621. */
  32622. this.enable = function (controlType, opt) {
  32623. // Disable previous first
  32624. this.disable();
  32625. this._opt = zrUtil.defaults(zrUtil.clone(opt) || {}, {
  32626. zoomOnMouseWheel: true,
  32627. moveOnMouseMove: true,
  32628. preventDefaultMouseMove: true
  32629. });
  32630. if (controlType == null) {
  32631. controlType = true;
  32632. }
  32633. if (controlType === true || (controlType === 'move' || controlType === 'pan')) {
  32634. zr.on('mousedown', mousedownHandler);
  32635. zr.on('mousemove', mousemoveHandler);
  32636. zr.on('mouseup', mouseupHandler);
  32637. }
  32638. if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) {
  32639. zr.on('mousewheel', mousewheelHandler);
  32640. zr.on('pinch', pinchHandler);
  32641. }
  32642. };
  32643. this.disable = function () {
  32644. zr.off('mousedown', mousedownHandler);
  32645. zr.off('mousemove', mousemoveHandler);
  32646. zr.off('mouseup', mouseupHandler);
  32647. zr.off('mousewheel', mousewheelHandler);
  32648. zr.off('pinch', pinchHandler);
  32649. };
  32650. this.dispose = this.disable;
  32651. this.isDragging = function () {
  32652. return this._dragging;
  32653. };
  32654. this.isPinching = function () {
  32655. return this._pinching;
  32656. };
  32657. }
  32658. zrUtil.mixin(RoamController, Eventful);
  32659. function mousedown(e) {
  32660. if (eventTool.notLeftMouse(e)
  32661. || (e.target && e.target.draggable)
  32662. ) {
  32663. return;
  32664. }
  32665. var x = e.offsetX;
  32666. var y = e.offsetY;
  32667. // Only check on mosedown, but not mousemove.
  32668. // Mouse can be out of target when mouse moving.
  32669. if (this.pointerChecker && this.pointerChecker(e, x, y)) {
  32670. this._x = x;
  32671. this._y = y;
  32672. this._dragging = true;
  32673. }
  32674. }
  32675. function mousemove(e) {
  32676. if (eventTool.notLeftMouse(e)
  32677. || !checkKeyBinding(this, 'moveOnMouseMove', e)
  32678. || !this._dragging
  32679. || e.gestureEvent === 'pinch'
  32680. || interactionMutex.isTaken(this._zr, 'globalPan')
  32681. ) {
  32682. return;
  32683. }
  32684. var x = e.offsetX;
  32685. var y = e.offsetY;
  32686. var oldX = this._x;
  32687. var oldY = this._y;
  32688. var dx = x - oldX;
  32689. var dy = y - oldY;
  32690. this._x = x;
  32691. this._y = y;
  32692. this._opt.preventDefaultMouseMove && eventTool.stop(e.event);
  32693. this.trigger('pan', dx, dy, oldX, oldY, x, y);
  32694. }
  32695. function mouseup(e) {
  32696. if (!eventTool.notLeftMouse(e)) {
  32697. this._dragging = false;
  32698. }
  32699. }
  32700. function mousewheel(e) {
  32701. // wheelDelta maybe -0 in chrome mac.
  32702. if (!checkKeyBinding(this, 'zoomOnMouseWheel', e) || e.wheelDelta === 0) {
  32703. return;
  32704. }
  32705. // Convenience:
  32706. // Mac and VM Windows on Mac: scroll up: zoom out.
  32707. // Windows: scroll up: zoom in.
  32708. var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1;
  32709. zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY);
  32710. }
  32711. function pinch(e) {
  32712. if (interactionMutex.isTaken(this._zr, 'globalPan')) {
  32713. return;
  32714. }
  32715. var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
  32716. zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY);
  32717. }
  32718. function zoom(e, zoomDelta, zoomX, zoomY) {
  32719. if (this.pointerChecker && this.pointerChecker(e, zoomX, zoomY)) {
  32720. // When mouse is out of roamController rect,
  32721. // default befavoius should not be be disabled, otherwise
  32722. // page sliding is disabled, contrary to expectation.
  32723. eventTool.stop(e.event);
  32724. this.trigger('zoom', zoomDelta, zoomX, zoomY);
  32725. }
  32726. }
  32727. function checkKeyBinding(roamController, prop, e) {
  32728. var setting = roamController._opt[prop];
  32729. return setting
  32730. && (!zrUtil.isString(setting) || e.event[setting + 'Key']);
  32731. }
  32732. module.exports = RoamController;
  32733. /***/ }),
  32734. /* 187 */
  32735. /***/ (function(module, exports, __webpack_require__) {
  32736. var ATTR = '\0_ec_interaction_mutex';
  32737. var interactionMutex = {
  32738. take: function (zr, resourceKey, userKey) {
  32739. var store = getStore(zr);
  32740. store[resourceKey] = userKey;
  32741. },
  32742. release: function (zr, resourceKey, userKey) {
  32743. var store = getStore(zr);
  32744. var uKey = store[resourceKey];
  32745. if (uKey === userKey) {
  32746. store[resourceKey] = null;
  32747. }
  32748. },
  32749. isTaken: function (zr, resourceKey) {
  32750. return !!getStore(zr)[resourceKey];
  32751. }
  32752. };
  32753. function getStore(zr) {
  32754. return zr[ATTR] || (zr[ATTR] = {});
  32755. }
  32756. /**
  32757. * payload: {
  32758. * type: 'takeGlobalCursor',
  32759. * key: 'dataZoomSelect', or 'brush', or ...,
  32760. * If no userKey, release global cursor.
  32761. * }
  32762. */
  32763. __webpack_require__(1).registerAction(
  32764. {type: 'takeGlobalCursor', event: 'globalCursorTaken', update: 'update'},
  32765. function () {}
  32766. );
  32767. module.exports = interactionMutex;
  32768. /***/ }),
  32769. /* 188 */
  32770. /***/ (function(module, exports) {
  32771. var helper = {};
  32772. /**
  32773. * For geo and graph.
  32774. *
  32775. * @param {Object} controllerHost
  32776. * @param {module:zrender/Element} controllerHost.target
  32777. */
  32778. helper.updateViewOnPan = function (controllerHost, dx, dy) {
  32779. var target = controllerHost.target;
  32780. var pos = target.position;
  32781. pos[0] += dx;
  32782. pos[1] += dy;
  32783. target.dirty();
  32784. };
  32785. /**
  32786. * For geo and graph.
  32787. *
  32788. * @param {Object} controllerHost
  32789. * @param {module:zrender/Element} controllerHost.target
  32790. * @param {number} controllerHost.zoom
  32791. * @param {number} controllerHost.zoomLimit like: {min: 1, max: 2}
  32792. */
  32793. helper.updateViewOnZoom = function (controllerHost, zoomDelta, zoomX, zoomY) {
  32794. var target = controllerHost.target;
  32795. var zoomLimit = controllerHost.zoomLimit;
  32796. var pos = target.position;
  32797. var scale = target.scale;
  32798. var newZoom = controllerHost.zoom = controllerHost.zoom || 1;
  32799. newZoom *= zoomDelta;
  32800. if (zoomLimit) {
  32801. var zoomMin = zoomLimit.min || 0;
  32802. var zoomMax = zoomLimit.max || Infinity;
  32803. newZoom = Math.max(
  32804. Math.min(zoomMax, newZoom),
  32805. zoomMin
  32806. );
  32807. }
  32808. var zoomScale = newZoom / controllerHost.zoom;
  32809. controllerHost.zoom = newZoom;
  32810. // Keep the mouse center when scaling
  32811. pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
  32812. pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
  32813. scale[0] *= zoomScale;
  32814. scale[1] *= zoomScale;
  32815. target.dirty();
  32816. };
  32817. module.exports = helper;
  32818. /***/ }),
  32819. /* 189 */
  32820. /***/ (function(module, exports) {
  32821. var helper = {};
  32822. var IRRELEVANT_EXCLUDES = {'axisPointer': 1, 'tooltip': 1, 'brush': 1};
  32823. /**
  32824. * Avoid that: mouse click on a elements that is over geo or graph,
  32825. * but roam is triggered.
  32826. */
  32827. helper.onIrrelevantElement = function (e, api, targetCoordSysModel) {
  32828. var model = api.getComponentByElement(e.topTarget);
  32829. // If model is axisModel, it works only if it is injected with coordinateSystem.
  32830. var coordSys = model && model.coordinateSystem;
  32831. return model
  32832. && model !== targetCoordSysModel
  32833. && !IRRELEVANT_EXCLUDES[model.mainType]
  32834. && (coordSys && coordSys.model !== targetCoordSysModel);
  32835. };
  32836. module.exports = helper;
  32837. /***/ }),
  32838. /* 190 */
  32839. /***/ (function(module, exports, __webpack_require__) {
  32840. var zrUtil = __webpack_require__(4);
  32841. var roamHelper = __webpack_require__(191);
  32842. var echarts = __webpack_require__(1);
  32843. /**
  32844. * @payload
  32845. * @property {string} [componentType=series]
  32846. * @property {number} [dx]
  32847. * @property {number} [dy]
  32848. * @property {number} [zoom]
  32849. * @property {number} [originX]
  32850. * @property {number} [originY]
  32851. */
  32852. echarts.registerAction({
  32853. type: 'geoRoam',
  32854. event: 'geoRoam',
  32855. update: 'updateLayout'
  32856. }, function (payload, ecModel) {
  32857. var componentType = payload.componentType || 'series';
  32858. ecModel.eachComponent(
  32859. { mainType: componentType, query: payload },
  32860. function (componentModel) {
  32861. var geo = componentModel.coordinateSystem;
  32862. if (geo.type !== 'geo') {
  32863. return;
  32864. }
  32865. var res = roamHelper.updateCenterAndZoom(
  32866. geo, payload, componentModel.get('scaleLimit')
  32867. );
  32868. componentModel.setCenter
  32869. && componentModel.setCenter(res.center);
  32870. componentModel.setZoom
  32871. && componentModel.setZoom(res.zoom);
  32872. // All map series with same `map` use the same geo coordinate system
  32873. // So the center and zoom must be in sync. Include the series not selected by legend
  32874. if (componentType === 'series') {
  32875. zrUtil.each(componentModel.seriesGroup, function (seriesModel) {
  32876. seriesModel.setCenter(res.center);
  32877. seriesModel.setZoom(res.zoom);
  32878. });
  32879. }
  32880. }
  32881. );
  32882. });
  32883. /***/ }),
  32884. /* 191 */
  32885. /***/ (function(module, exports) {
  32886. var roamHelper = {};
  32887. /**
  32888. * @param {module:echarts/coord/View} view
  32889. * @param {Object} payload
  32890. * @param {Object} [zoomLimit]
  32891. */
  32892. roamHelper.updateCenterAndZoom = function (
  32893. view, payload, zoomLimit
  32894. ) {
  32895. var previousZoom = view.getZoom();
  32896. var center = view.getCenter();
  32897. var zoom = payload.zoom;
  32898. var point = view.dataToPoint(center);
  32899. if (payload.dx != null && payload.dy != null) {
  32900. point[0] -= payload.dx;
  32901. point[1] -= payload.dy;
  32902. var center = view.pointToData(point);
  32903. view.setCenter(center);
  32904. }
  32905. if (zoom != null) {
  32906. if (zoomLimit) {
  32907. var zoomMin = zoomLimit.min || 0;
  32908. var zoomMax = zoomLimit.max || Infinity;
  32909. zoom = Math.max(
  32910. Math.min(previousZoom * zoom, zoomMax),
  32911. zoomMin
  32912. ) / previousZoom;
  32913. }
  32914. // Zoom on given point(originX, originY)
  32915. view.scale[0] *= zoom;
  32916. view.scale[1] *= zoom;
  32917. var position = view.position;
  32918. var fixX = (payload.originX - position[0]) * (zoom - 1);
  32919. var fixY = (payload.originY - position[1]) * (zoom - 1);
  32920. position[0] -= fixX;
  32921. position[1] -= fixY;
  32922. view.updateTransform();
  32923. // Get the new center
  32924. var center = view.pointToData(point);
  32925. view.setCenter(center);
  32926. view.setZoom(zoom * previousZoom);
  32927. }
  32928. return {
  32929. center: view.getCenter(),
  32930. zoom: view.getZoom()
  32931. };
  32932. };
  32933. module.exports = roamHelper;
  32934. /***/ }),
  32935. /* 192 */
  32936. /***/ (function(module, exports, __webpack_require__) {
  32937. var zrUtil = __webpack_require__(4);
  32938. module.exports = function (ecModel) {
  32939. var processedMapType = {};
  32940. ecModel.eachSeriesByType('map', function (mapSeries) {
  32941. var mapType = mapSeries.getMapType();
  32942. if (mapSeries.getHostGeoModel() || processedMapType[mapType]) {
  32943. return;
  32944. }
  32945. var mapSymbolOffsets = {};
  32946. zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) {
  32947. var geo = subMapSeries.coordinateSystem;
  32948. var data = subMapSeries.originalData;
  32949. if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) {
  32950. data.each('value', function (value, idx) {
  32951. var name = data.getName(idx);
  32952. var region = geo.getRegion(name);
  32953. // If input series.data is [11, 22, '-'/null/undefined, 44],
  32954. // it will be filled with NaN: [11, 22, NaN, 44] and NaN will
  32955. // not be drawn. So here must validate if value is NaN.
  32956. if (!region || isNaN(value)) {
  32957. return;
  32958. }
  32959. var offset = mapSymbolOffsets[name] || 0;
  32960. var point = geo.dataToPoint(region.center);
  32961. mapSymbolOffsets[name] = offset + 1;
  32962. data.setItemLayout(idx, {
  32963. point: point,
  32964. offset: offset
  32965. });
  32966. });
  32967. }
  32968. });
  32969. // Show label of those region not has legendSymbol(which is offset 0)
  32970. var data = mapSeries.getData();
  32971. data.each(function (idx) {
  32972. var name = data.getName(idx);
  32973. var layout = data.getItemLayout(idx) || {};
  32974. layout.showLabel = !mapSymbolOffsets[name];
  32975. data.setItemLayout(idx, layout);
  32976. });
  32977. processedMapType[mapType] = true;
  32978. });
  32979. };
  32980. /***/ }),
  32981. /* 193 */
  32982. /***/ (function(module, exports) {
  32983. module.exports = function (ecModel) {
  32984. ecModel.eachSeriesByType('map', function (seriesModel) {
  32985. var colorList = seriesModel.get('color');
  32986. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  32987. var areaColor = itemStyleModel.get('areaColor');
  32988. var color = itemStyleModel.get('color')
  32989. || colorList[seriesModel.seriesIndex % colorList.length];
  32990. seriesModel.getData().setVisual({
  32991. 'areaColor': areaColor,
  32992. 'color': color
  32993. });
  32994. });
  32995. };
  32996. /***/ }),
  32997. /* 194 */
  32998. /***/ (function(module, exports, __webpack_require__) {
  32999. var zrUtil = __webpack_require__(4);
  33000. // FIXME 公用?
  33001. /**
  33002. * @param {Array.<module:echarts/data/List>} datas
  33003. * @param {string} statisticType 'average' 'sum'
  33004. * @inner
  33005. */
  33006. function dataStatistics(datas, statisticType) {
  33007. var dataNameMap = {};
  33008. var dims = ['value'];
  33009. zrUtil.each(datas, function (data) {
  33010. data.each(dims, function (value, idx) {
  33011. // Add prefix to avoid conflict with Object.prototype.
  33012. var mapKey = 'ec-' + data.getName(idx);
  33013. dataNameMap[mapKey] = dataNameMap[mapKey] || [];
  33014. if (!isNaN(value)) {
  33015. dataNameMap[mapKey].push(value);
  33016. }
  33017. });
  33018. });
  33019. return datas[0].map(dims, function (value, idx) {
  33020. var mapKey = 'ec-' + datas[0].getName(idx);
  33021. var sum = 0;
  33022. var min = Infinity;
  33023. var max = -Infinity;
  33024. var len = dataNameMap[mapKey].length;
  33025. for (var i = 0; i < len; i++) {
  33026. min = Math.min(min, dataNameMap[mapKey][i]);
  33027. max = Math.max(max, dataNameMap[mapKey][i]);
  33028. sum += dataNameMap[mapKey][i];
  33029. }
  33030. var result;
  33031. if (statisticType === 'min') {
  33032. result = min;
  33033. }
  33034. else if (statisticType === 'max') {
  33035. result = max;
  33036. }
  33037. else if (statisticType === 'average') {
  33038. result = sum / len;
  33039. }
  33040. else {
  33041. result = sum;
  33042. }
  33043. return len === 0 ? NaN : result;
  33044. });
  33045. }
  33046. module.exports = function (ecModel) {
  33047. var seriesGroups = {};
  33048. ecModel.eachSeriesByType('map', function (seriesModel) {
  33049. var hostGeoModel = seriesModel.getHostGeoModel();
  33050. var key = hostGeoModel ? 'o' + hostGeoModel.id : 'i' + seriesModel.getMapType();
  33051. (seriesGroups[key] = seriesGroups[key] || []).push(seriesModel);
  33052. });
  33053. zrUtil.each(seriesGroups, function (seriesList, key) {
  33054. var data = dataStatistics(
  33055. zrUtil.map(seriesList, function (seriesModel) {
  33056. return seriesModel.getData();
  33057. }),
  33058. seriesList[0].get('mapValueCalculation')
  33059. );
  33060. for (var i = 0; i < seriesList.length; i++) {
  33061. seriesList[i].originalData = seriesList[i].getData();
  33062. }
  33063. // FIXME Put where?
  33064. for (var i = 0; i < seriesList.length; i++) {
  33065. seriesList[i].seriesGroup = seriesList;
  33066. seriesList[i].needsDrawMap = i === 0 && !seriesList[i].getHostGeoModel();
  33067. seriesList[i].setData(data.cloneShallow());
  33068. seriesList[i].mainSeries = seriesList[0];
  33069. }
  33070. });
  33071. };
  33072. /***/ }),
  33073. /* 195 */
  33074. /***/ (function(module, exports, __webpack_require__) {
  33075. var zrUtil = __webpack_require__(4);
  33076. module.exports = function (option) {
  33077. // Save geoCoord
  33078. var mapSeries = [];
  33079. zrUtil.each(option.series, function (seriesOpt) {
  33080. if (seriesOpt.type === 'map') {
  33081. mapSeries.push(seriesOpt);
  33082. }
  33083. });
  33084. zrUtil.each(mapSeries, function (seriesOpt) {
  33085. seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
  33086. // Put x, y, width, height, x2, y2 in the top level
  33087. zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
  33088. });
  33089. };
  33090. /***/ }),
  33091. /* 196 */
  33092. /***/ (function(module, exports, __webpack_require__) {
  33093. var echarts = __webpack_require__(1);
  33094. __webpack_require__(197);
  33095. __webpack_require__(201);
  33096. __webpack_require__(204);
  33097. echarts.registerVisual(__webpack_require__(205));
  33098. echarts.registerLayout(__webpack_require__(207));
  33099. /***/ }),
  33100. /* 197 */
  33101. /***/ (function(module, exports, __webpack_require__) {
  33102. var SeriesModel = __webpack_require__(83);
  33103. var Tree = __webpack_require__(198);
  33104. var zrUtil = __webpack_require__(4);
  33105. var Model = __webpack_require__(14);
  33106. var formatUtil = __webpack_require__(6);
  33107. var helper = __webpack_require__(200);
  33108. var encodeHTML = formatUtil.encodeHTML;
  33109. var addCommas = formatUtil.addCommas;
  33110. module.exports = SeriesModel.extend({
  33111. type: 'series.treemap',
  33112. layoutMode: 'box',
  33113. dependencies: ['grid', 'polar'],
  33114. /**
  33115. * @type {module:echarts/data/Tree~Node}
  33116. */
  33117. _viewRoot: null,
  33118. defaultOption: {
  33119. // Disable progressive rendering
  33120. progressive: 0,
  33121. hoverLayerThreshold: Infinity,
  33122. // center: ['50%', '50%'], // not supported in ec3.
  33123. // size: ['80%', '80%'], // deprecated, compatible with ec2.
  33124. left: 'center',
  33125. top: 'middle',
  33126. right: null,
  33127. bottom: null,
  33128. width: '80%',
  33129. height: '80%',
  33130. sort: true, // Can be null or false or true
  33131. // (order by desc default, asc not supported yet (strange effect))
  33132. clipWindow: 'origin', // Size of clipped window when zooming. 'origin' or 'fullscreen'
  33133. squareRatio: 0.5 * (1 + Math.sqrt(5)), // golden ratio
  33134. leafDepth: null, // Nodes on depth from root are regarded as leaves.
  33135. // Count from zero (zero represents only view root).
  33136. drillDownIcon: '▶', // Use html character temporarily because it is complicated
  33137. // to align specialized icon. ▷▶❒❐▼✚
  33138. zoomToNodeRatio: 0.32 * 0.32, // Be effective when using zoomToNode. Specify the proportion of the
  33139. // target node area in the view area.
  33140. roam: true, // true, false, 'scale' or 'zoom', 'move'.
  33141. nodeClick: 'zoomToNode', // Leaf node click behaviour: 'zoomToNode', 'link', false.
  33142. // If leafDepth is set and clicking a node which has children but
  33143. // be on left depth, the behaviour would be changing root. Otherwise
  33144. // use behavious defined above.
  33145. animation: true,
  33146. animationDurationUpdate: 900,
  33147. animationEasing: 'quinticInOut',
  33148. breadcrumb: {
  33149. show: true,
  33150. height: 22,
  33151. left: 'center',
  33152. top: 'bottom',
  33153. // right
  33154. // bottom
  33155. emptyItemWidth: 25, // Width of empty node.
  33156. itemStyle: {
  33157. normal: {
  33158. color: 'rgba(0,0,0,0.7)', //'#5793f3',
  33159. borderColor: 'rgba(255,255,255,0.7)',
  33160. borderWidth: 1,
  33161. shadowColor: 'rgba(150,150,150,1)',
  33162. shadowBlur: 3,
  33163. shadowOffsetX: 0,
  33164. shadowOffsetY: 0,
  33165. textStyle: {
  33166. color: '#fff'
  33167. }
  33168. },
  33169. emphasis: {
  33170. textStyle: {}
  33171. }
  33172. }
  33173. },
  33174. label: {
  33175. normal: {
  33176. show: true,
  33177. // Do not use textDistance, for ellipsis rect just the same as treemap node rect.
  33178. distance: 0,
  33179. padding: 5,
  33180. position: 'inside', // Can be [5, '5%'] or position stirng like 'insideTopLeft', ...
  33181. // formatter: null,
  33182. color: '#fff',
  33183. ellipsis: true
  33184. // align
  33185. // verticalAlign
  33186. }
  33187. },
  33188. upperLabel: { // Label when node is parent.
  33189. normal: {
  33190. show: false,
  33191. position: [0, '50%'],
  33192. height: 20,
  33193. // formatter: null,
  33194. color: '#fff',
  33195. ellipsis: true,
  33196. // align: null,
  33197. verticalAlign: 'middle'
  33198. },
  33199. emphasis: {
  33200. show: true,
  33201. position: [0, '50%'],
  33202. color: '#fff',
  33203. ellipsis: true,
  33204. verticalAlign: 'middle'
  33205. }
  33206. },
  33207. itemStyle: {
  33208. normal: {
  33209. color: null, // Can be 'none' if not necessary.
  33210. colorAlpha: null, // Can be 'none' if not necessary.
  33211. colorSaturation: null, // Can be 'none' if not necessary.
  33212. borderWidth: 0,
  33213. gapWidth: 0,
  33214. borderColor: '#fff',
  33215. borderColorSaturation: null // If specified, borderColor will be ineffective, and the
  33216. // border color is evaluated by color of current node and
  33217. // borderColorSaturation.
  33218. },
  33219. emphasis: {
  33220. }
  33221. },
  33222. visualDimension: 0, // Can be 0, 1, 2, 3.
  33223. visualMin: null,
  33224. visualMax: null,
  33225. color: [], // + treemapSeries.color should not be modified. Please only modified
  33226. // level[n].color (if necessary).
  33227. // + Specify color list of each level. level[0].color would be global
  33228. // color list if not specified. (see method `setDefault`).
  33229. // + But set as a empty array to forbid fetch color from global palette
  33230. // when using nodeModel.get('color'), otherwise nodes on deep level
  33231. // will always has color palette set and are not able to inherit color
  33232. // from parent node.
  33233. // + TreemapSeries.color can not be set as 'none', otherwise effect
  33234. // legend color fetching (see seriesColor.js).
  33235. colorAlpha: null, // Array. Specify color alpha range of each level, like [0.2, 0.8]
  33236. colorSaturation: null, // Array. Specify color saturation of each level, like [0.2, 0.5]
  33237. colorMappingBy: 'index', // 'value' or 'index' or 'id'.
  33238. visibleMin: 10, // If area less than this threshold (unit: pixel^2), node will not
  33239. // be rendered. Only works when sort is 'asc' or 'desc'.
  33240. childrenVisibleMin: null, // If area of a node less than this threshold (unit: pixel^2),
  33241. // grandchildren will not show.
  33242. // Why grandchildren? If not grandchildren but children,
  33243. // some siblings show children and some not,
  33244. // the appearance may be mess and not consistent,
  33245. levels: [] // Each item: {
  33246. // visibleMin, itemStyle, visualDimension, label
  33247. // }
  33248. // data: {
  33249. // value: [],
  33250. // children: [],
  33251. // link: 'http://xxx.xxx.xxx',
  33252. // target: 'blank' or 'self'
  33253. // }
  33254. },
  33255. /**
  33256. * @override
  33257. */
  33258. getInitialData: function (option, ecModel) {
  33259. // Create a virtual root.
  33260. var root = {name: option.name, children: option.data};
  33261. completeTreeValue(root);
  33262. var levels = option.levels || [];
  33263. levels = option.levels = setDefault(levels, ecModel);
  33264. // Make sure always a new tree is created when setOption,
  33265. // in TreemapView, we check whether oldTree === newTree
  33266. // to choose mappings approach among old shapes and new shapes.
  33267. return Tree.createTree(root, this, levels).data;
  33268. },
  33269. optionUpdated: function () {
  33270. this.resetViewRoot();
  33271. },
  33272. /**
  33273. * @override
  33274. * @param {number} dataIndex
  33275. * @param {boolean} [mutipleSeries=false]
  33276. */
  33277. formatTooltip: function (dataIndex) {
  33278. var data = this.getData();
  33279. var value = this.getRawValue(dataIndex);
  33280. var formattedValue = zrUtil.isArray(value)
  33281. ? addCommas(value[0]) : addCommas(value);
  33282. var name = data.getName(dataIndex);
  33283. return encodeHTML(name + ': ' + formattedValue);
  33284. },
  33285. /**
  33286. * Add tree path to tooltip param
  33287. *
  33288. * @override
  33289. * @param {number} dataIndex
  33290. * @return {Object}
  33291. */
  33292. getDataParams: function (dataIndex) {
  33293. var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
  33294. var node = this.getData().tree.getNodeByDataIndex(dataIndex);
  33295. params.treePathInfo = helper.wrapTreePathInfo(node, this);
  33296. return params;
  33297. },
  33298. /**
  33299. * @public
  33300. * @param {Object} layoutInfo {
  33301. * x: containerGroup x
  33302. * y: containerGroup y
  33303. * width: containerGroup width
  33304. * height: containerGroup height
  33305. * }
  33306. */
  33307. setLayoutInfo: function (layoutInfo) {
  33308. /**
  33309. * @readOnly
  33310. * @type {Object}
  33311. */
  33312. this.layoutInfo = this.layoutInfo || {};
  33313. zrUtil.extend(this.layoutInfo, layoutInfo);
  33314. },
  33315. /**
  33316. * @param {string} id
  33317. * @return {number} index
  33318. */
  33319. mapIdToIndex: function (id) {
  33320. // A feature is implemented:
  33321. // index is monotone increasing with the sequence of
  33322. // input id at the first time.
  33323. // This feature can make sure that each data item and its
  33324. // mapped color have the same index between data list and
  33325. // color list at the beginning, which is useful for user
  33326. // to adjust data-color mapping.
  33327. /**
  33328. * @private
  33329. * @type {Object}
  33330. */
  33331. var idIndexMap = this._idIndexMap;
  33332. if (!idIndexMap) {
  33333. idIndexMap = this._idIndexMap = zrUtil.createHashMap();
  33334. /**
  33335. * @private
  33336. * @type {number}
  33337. */
  33338. this._idIndexMapCount = 0;
  33339. }
  33340. var index = idIndexMap.get(id);
  33341. if (index == null) {
  33342. idIndexMap.set(id, index = this._idIndexMapCount++);
  33343. }
  33344. return index;
  33345. },
  33346. getViewRoot: function () {
  33347. return this._viewRoot;
  33348. },
  33349. /**
  33350. * @param {module:echarts/data/Tree~Node} [viewRoot]
  33351. */
  33352. resetViewRoot: function (viewRoot) {
  33353. viewRoot
  33354. ? (this._viewRoot = viewRoot)
  33355. : (viewRoot = this._viewRoot);
  33356. var root = this.getData().tree.root;
  33357. if (!viewRoot
  33358. || (viewRoot !== root && !root.contains(viewRoot))
  33359. ) {
  33360. this._viewRoot = root;
  33361. }
  33362. }
  33363. });
  33364. /**
  33365. * @param {Object} dataNode
  33366. */
  33367. function completeTreeValue(dataNode) {
  33368. // Postorder travel tree.
  33369. // If value of none-leaf node is not set,
  33370. // calculate it by suming up the value of all children.
  33371. var sum = 0;
  33372. zrUtil.each(dataNode.children, function (child) {
  33373. completeTreeValue(child);
  33374. var childValue = child.value;
  33375. zrUtil.isArray(childValue) && (childValue = childValue[0]);
  33376. sum += childValue;
  33377. });
  33378. var thisValue = dataNode.value;
  33379. if (zrUtil.isArray(thisValue)) {
  33380. thisValue = thisValue[0];
  33381. }
  33382. if (thisValue == null || isNaN(thisValue)) {
  33383. thisValue = sum;
  33384. }
  33385. // Value should not less than 0.
  33386. if (thisValue < 0) {
  33387. thisValue = 0;
  33388. }
  33389. zrUtil.isArray(dataNode.value)
  33390. ? (dataNode.value[0] = thisValue)
  33391. : (dataNode.value = thisValue);
  33392. }
  33393. /**
  33394. * set default to level configuration
  33395. */
  33396. function setDefault(levels, ecModel) {
  33397. var globalColorList = ecModel.get('color');
  33398. if (!globalColorList) {
  33399. return;
  33400. }
  33401. levels = levels || [];
  33402. var hasColorDefine;
  33403. zrUtil.each(levels, function (levelDefine) {
  33404. var model = new Model(levelDefine);
  33405. var modelColor = model.get('color');
  33406. if (model.get('itemStyle.normal.color')
  33407. || (modelColor && modelColor !== 'none')
  33408. ) {
  33409. hasColorDefine = true;
  33410. }
  33411. });
  33412. if (!hasColorDefine) {
  33413. var level0 = levels[0] || (levels[0] = {});
  33414. level0.color = globalColorList.slice();
  33415. }
  33416. return levels;
  33417. }
  33418. /***/ }),
  33419. /* 198 */
  33420. /***/ (function(module, exports, __webpack_require__) {
  33421. /**
  33422. * Tree data structure
  33423. *
  33424. * @module echarts/data/Tree
  33425. */
  33426. var zrUtil = __webpack_require__(4);
  33427. var Model = __webpack_require__(14);
  33428. var List = __webpack_require__(101);
  33429. var linkList = __webpack_require__(199);
  33430. var completeDimensions = __webpack_require__(113);
  33431. /**
  33432. * @constructor module:echarts/data/Tree~TreeNode
  33433. * @param {string} name
  33434. * @param {module:echarts/data/Tree} hostTree
  33435. */
  33436. var TreeNode = function (name, hostTree) {
  33437. /**
  33438. * @type {string}
  33439. */
  33440. this.name = name || '';
  33441. /**
  33442. * Depth of node
  33443. *
  33444. * @type {number}
  33445. * @readOnly
  33446. */
  33447. this.depth = 0;
  33448. /**
  33449. * Height of the subtree rooted at this node.
  33450. * @type {number}
  33451. * @readOnly
  33452. */
  33453. this.height = 0;
  33454. /**
  33455. * @type {module:echarts/data/Tree~TreeNode}
  33456. * @readOnly
  33457. */
  33458. this.parentNode = null;
  33459. /**
  33460. * Reference to list item.
  33461. * Do not persistent dataIndex outside,
  33462. * besause it may be changed by list.
  33463. * If dataIndex -1,
  33464. * this node is logical deleted (filtered) in list.
  33465. *
  33466. * @type {Object}
  33467. * @readOnly
  33468. */
  33469. this.dataIndex = -1;
  33470. /**
  33471. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  33472. * @readOnly
  33473. */
  33474. this.children = [];
  33475. /**
  33476. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  33477. * @pubilc
  33478. */
  33479. this.viewChildren = [];
  33480. /**
  33481. * @type {moduel:echarts/data/Tree}
  33482. * @readOnly
  33483. */
  33484. this.hostTree = hostTree;
  33485. };
  33486. TreeNode.prototype = {
  33487. constructor: TreeNode,
  33488. /**
  33489. * The node is removed.
  33490. * @return {boolean} is removed.
  33491. */
  33492. isRemoved: function () {
  33493. return this.dataIndex < 0;
  33494. },
  33495. /**
  33496. * Travel this subtree (include this node).
  33497. * Usage:
  33498. * node.eachNode(function () { ... }); // preorder
  33499. * node.eachNode('preorder', function () { ... }); // preorder
  33500. * node.eachNode('postorder', function () { ... }); // postorder
  33501. * node.eachNode(
  33502. * {order: 'postorder', attr: 'viewChildren'},
  33503. * function () { ... }
  33504. * ); // postorder
  33505. *
  33506. * @param {(Object|string)} options If string, means order.
  33507. * @param {string=} options.order 'preorder' or 'postorder'
  33508. * @param {string=} options.attr 'children' or 'viewChildren'
  33509. * @param {Function} cb If in preorder and return false,
  33510. * its subtree will not be visited.
  33511. * @param {Object} [context]
  33512. */
  33513. eachNode: function (options, cb, context) {
  33514. if (typeof options === 'function') {
  33515. context = cb;
  33516. cb = options;
  33517. options = null;
  33518. }
  33519. options = options || {};
  33520. if (zrUtil.isString(options)) {
  33521. options = {order: options};
  33522. }
  33523. var order = options.order || 'preorder';
  33524. var children = this[options.attr || 'children'];
  33525. var suppressVisitSub;
  33526. order === 'preorder' && (suppressVisitSub = cb.call(context, this));
  33527. for (var i = 0; !suppressVisitSub && i < children.length; i++) {
  33528. children[i].eachNode(options, cb, context);
  33529. }
  33530. order === 'postorder' && cb.call(context, this);
  33531. },
  33532. /**
  33533. * Update depth and height of this subtree.
  33534. *
  33535. * @param {number} depth
  33536. */
  33537. updateDepthAndHeight: function (depth) {
  33538. var height = 0;
  33539. this.depth = depth;
  33540. for (var i = 0; i < this.children.length; i++) {
  33541. var child = this.children[i];
  33542. child.updateDepthAndHeight(depth + 1);
  33543. if (child.height > height) {
  33544. height = child.height;
  33545. }
  33546. }
  33547. this.height = height + 1;
  33548. },
  33549. /**
  33550. * @param {string} id
  33551. * @return {module:echarts/data/Tree~TreeNode}
  33552. */
  33553. getNodeById: function (id) {
  33554. if (this.getId() === id) {
  33555. return this;
  33556. }
  33557. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  33558. var res = children[i].getNodeById(id);
  33559. if (res) {
  33560. return res;
  33561. }
  33562. }
  33563. },
  33564. /**
  33565. * @param {module:echarts/data/Tree~TreeNode} node
  33566. * @return {boolean}
  33567. */
  33568. contains: function (node) {
  33569. if (node === this) {
  33570. return true;
  33571. }
  33572. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  33573. var res = children[i].contains(node);
  33574. if (res) {
  33575. return res;
  33576. }
  33577. }
  33578. },
  33579. /**
  33580. * @param {boolean} includeSelf Default false.
  33581. * @return {Array.<module:echarts/data/Tree~TreeNode>} order: [root, child, grandchild, ...]
  33582. */
  33583. getAncestors: function (includeSelf) {
  33584. var ancestors = [];
  33585. var node = includeSelf ? this : this.parentNode;
  33586. while (node) {
  33587. ancestors.push(node);
  33588. node = node.parentNode;
  33589. }
  33590. ancestors.reverse();
  33591. return ancestors;
  33592. },
  33593. /**
  33594. * @param {string|Array=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3
  33595. * @return {number} Value.
  33596. */
  33597. getValue: function (dimension) {
  33598. var data = this.hostTree.data;
  33599. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  33600. },
  33601. /**
  33602. * @param {Object} layout
  33603. * @param {boolean=} [merge=false]
  33604. */
  33605. setLayout: function (layout, merge) {
  33606. this.dataIndex >= 0
  33607. && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge);
  33608. },
  33609. /**
  33610. * @return {Object} layout
  33611. */
  33612. getLayout: function () {
  33613. return this.hostTree.data.getItemLayout(this.dataIndex);
  33614. },
  33615. /**
  33616. * @param {string} [path]
  33617. * @return {module:echarts/model/Model}
  33618. */
  33619. getModel: function (path) {
  33620. if (this.dataIndex < 0) {
  33621. return;
  33622. }
  33623. var hostTree = this.hostTree;
  33624. var itemModel = hostTree.data.getItemModel(this.dataIndex);
  33625. var levelModel = this.getLevelModel();
  33626. return itemModel.getModel(path, (levelModel || hostTree.hostModel).getModel(path));
  33627. },
  33628. /**
  33629. * @return {module:echarts/model/Model}
  33630. */
  33631. getLevelModel: function () {
  33632. return (this.hostTree.levelModels || [])[this.depth];
  33633. },
  33634. /**
  33635. * @example
  33636. * setItemVisual('color', color);
  33637. * setItemVisual({
  33638. * 'color': color
  33639. * });
  33640. */
  33641. setVisual: function (key, value) {
  33642. this.dataIndex >= 0
  33643. && this.hostTree.data.setItemVisual(this.dataIndex, key, value);
  33644. },
  33645. /**
  33646. * Get item visual
  33647. */
  33648. getVisual: function (key, ignoreParent) {
  33649. return this.hostTree.data.getItemVisual(this.dataIndex, key, ignoreParent);
  33650. },
  33651. /**
  33652. * @public
  33653. * @return {number}
  33654. */
  33655. getRawIndex: function () {
  33656. return this.hostTree.data.getRawIndex(this.dataIndex);
  33657. },
  33658. /**
  33659. * @public
  33660. * @return {string}
  33661. */
  33662. getId: function () {
  33663. return this.hostTree.data.getId(this.dataIndex);
  33664. }
  33665. };
  33666. /**
  33667. * @constructor
  33668. * @alias module:echarts/data/Tree
  33669. * @param {module:echarts/model/Model} hostModel
  33670. * @param {Array.<Object>} levelOptions
  33671. */
  33672. function Tree(hostModel, levelOptions) {
  33673. /**
  33674. * @type {module:echarts/data/Tree~TreeNode}
  33675. * @readOnly
  33676. */
  33677. this.root;
  33678. /**
  33679. * @type {module:echarts/data/List}
  33680. * @readOnly
  33681. */
  33682. this.data;
  33683. /**
  33684. * Index of each item is the same as the raw index of coresponding list item.
  33685. * @private
  33686. * @type {Array.<module:echarts/data/Tree~TreeNode}
  33687. */
  33688. this._nodes = [];
  33689. /**
  33690. * @private
  33691. * @readOnly
  33692. * @type {module:echarts/model/Model}
  33693. */
  33694. this.hostModel = hostModel;
  33695. /**
  33696. * @private
  33697. * @readOnly
  33698. * @type {Array.<module:echarts/model/Model}
  33699. */
  33700. this.levelModels = zrUtil.map(levelOptions || [], function (levelDefine) {
  33701. return new Model(levelDefine, hostModel, hostModel.ecModel);
  33702. });
  33703. }
  33704. Tree.prototype = {
  33705. constructor: Tree,
  33706. type: 'tree',
  33707. /**
  33708. * Travel this subtree (include this node).
  33709. * Usage:
  33710. * node.eachNode(function () { ... }); // preorder
  33711. * node.eachNode('preorder', function () { ... }); // preorder
  33712. * node.eachNode('postorder', function () { ... }); // postorder
  33713. * node.eachNode(
  33714. * {order: 'postorder', attr: 'viewChildren'},
  33715. * function () { ... }
  33716. * ); // postorder
  33717. *
  33718. * @param {(Object|string)} options If string, means order.
  33719. * @param {string=} options.order 'preorder' or 'postorder'
  33720. * @param {string=} options.attr 'children' or 'viewChildren'
  33721. * @param {Function} cb
  33722. * @param {Object} [context]
  33723. */
  33724. eachNode: function(options, cb, context) {
  33725. this.root.eachNode(options, cb, context);
  33726. },
  33727. /**
  33728. * @param {number} dataIndex
  33729. * @return {module:echarts/data/Tree~TreeNode}
  33730. */
  33731. getNodeByDataIndex: function (dataIndex) {
  33732. var rawIndex = this.data.getRawIndex(dataIndex);
  33733. return this._nodes[rawIndex];
  33734. },
  33735. /**
  33736. * @param {string} name
  33737. * @return {module:echarts/data/Tree~TreeNode}
  33738. */
  33739. getNodeByName: function (name) {
  33740. return this.root.getNodeByName(name);
  33741. },
  33742. /**
  33743. * Update item available by list,
  33744. * when list has been performed options like 'filterSelf' or 'map'.
  33745. */
  33746. update: function () {
  33747. var data = this.data;
  33748. var nodes = this._nodes;
  33749. for (var i = 0, len = nodes.length; i < len; i++) {
  33750. nodes[i].dataIndex = -1;
  33751. }
  33752. for (var i = 0, len = data.count(); i < len; i++) {
  33753. nodes[data.getRawIndex(i)].dataIndex = i;
  33754. }
  33755. },
  33756. /**
  33757. * Clear all layouts
  33758. */
  33759. clearLayouts: function () {
  33760. this.data.clearItemLayouts();
  33761. }
  33762. };
  33763. /**
  33764. * data node format:
  33765. * {
  33766. * name: ...
  33767. * value: ...
  33768. * children: [
  33769. * {
  33770. * name: ...
  33771. * value: ...
  33772. * children: ...
  33773. * },
  33774. * ...
  33775. * ]
  33776. * }
  33777. *
  33778. * @static
  33779. * @param {Object} dataRoot Root node.
  33780. * @param {module:echarts/model/Model} hostModel
  33781. * @param {Array.<Object>} levelOptions
  33782. * @return module:echarts/data/Tree
  33783. */
  33784. Tree.createTree = function (dataRoot, hostModel, levelOptions) {
  33785. var tree = new Tree(hostModel, levelOptions);
  33786. var listData = [];
  33787. var dimMax = 1;
  33788. buildHierarchy(dataRoot);
  33789. function buildHierarchy(dataNode, parentNode) {
  33790. var value = dataNode.value;
  33791. dimMax = Math.max(dimMax, zrUtil.isArray(value) ? value.length : 1);
  33792. listData.push(dataNode);
  33793. var node = new TreeNode(dataNode.name, tree);
  33794. parentNode
  33795. ? addChild(node, parentNode)
  33796. : (tree.root = node);
  33797. tree._nodes.push(node);
  33798. var children = dataNode.children;
  33799. if (children) {
  33800. for (var i = 0; i < children.length; i++) {
  33801. buildHierarchy(children[i], node);
  33802. }
  33803. }
  33804. }
  33805. tree.root.updateDepthAndHeight(0);
  33806. var dimensions = completeDimensions([{name: 'value'}], listData, {dimCount: dimMax});
  33807. var list = new List(dimensions, hostModel);
  33808. list.initData(listData);
  33809. linkList({
  33810. mainData: list,
  33811. struct: tree,
  33812. structAttr: 'tree'
  33813. });
  33814. tree.update();
  33815. return tree;
  33816. };
  33817. /**
  33818. * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote,
  33819. * so this function is not ready and not necessary to be public.
  33820. *
  33821. * @param {(module:echarts/data/Tree~TreeNode|Object)} child
  33822. */
  33823. function addChild(child, node) {
  33824. var children = node.children;
  33825. if (child.parentNode === node) {
  33826. return;
  33827. }
  33828. children.push(child);
  33829. child.parentNode = node;
  33830. }
  33831. module.exports = Tree;
  33832. /***/ }),
  33833. /* 199 */
  33834. /***/ (function(module, exports, __webpack_require__) {
  33835. /**
  33836. * Link lists and struct (graph or tree)
  33837. */
  33838. var zrUtil = __webpack_require__(4);
  33839. var each = zrUtil.each;
  33840. var DATAS = '\0__link_datas';
  33841. var MAIN_DATA = '\0__link_mainData';
  33842. // Caution:
  33843. // In most case, either list or its shallow clones (see list.cloneShallow)
  33844. // is active in echarts process. So considering heap memory consumption,
  33845. // we do not clone tree or graph, but share them among list and its shallow clones.
  33846. // But in some rare case, we have to keep old list (like do animation in chart). So
  33847. // please take care that both the old list and the new list share the same tree/graph.
  33848. /**
  33849. * @param {Object} opt
  33850. * @param {module:echarts/data/List} opt.mainData
  33851. * @param {Object} [opt.struct] For example, instance of Graph or Tree.
  33852. * @param {string} [opt.structAttr] designation: list[structAttr] = struct;
  33853. * @param {Object} [opt.datas] {dataType: data},
  33854. * like: {node: nodeList, edge: edgeList}.
  33855. * Should contain mainData.
  33856. * @param {Object} [opt.datasAttr] {dataType: attr},
  33857. * designation: struct[datasAttr[dataType]] = list;
  33858. */
  33859. function linkList(opt) {
  33860. var mainData = opt.mainData;
  33861. var datas = opt.datas;
  33862. if (!datas) {
  33863. datas = {main: mainData};
  33864. opt.datasAttr = {main: 'data'};
  33865. }
  33866. opt.datas = opt.mainData = null;
  33867. linkAll(mainData, datas, opt);
  33868. // Porxy data original methods.
  33869. each(datas, function (data) {
  33870. each(mainData.TRANSFERABLE_METHODS, function (methodName) {
  33871. data.wrapMethod(methodName, zrUtil.curry(transferInjection, opt));
  33872. });
  33873. });
  33874. // Beyond transfer, additional features should be added to `cloneShallow`.
  33875. mainData.wrapMethod('cloneShallow', zrUtil.curry(cloneShallowInjection, opt));
  33876. // Only mainData trigger change, because struct.update may trigger
  33877. // another changable methods, which may bring about dead lock.
  33878. each(mainData.CHANGABLE_METHODS, function (methodName) {
  33879. mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
  33880. });
  33881. // Make sure datas contains mainData.
  33882. zrUtil.assert(datas[mainData.dataType] === mainData);
  33883. }
  33884. function transferInjection(opt, res) {
  33885. if (isMainData(this)) {
  33886. // Transfer datas to new main data.
  33887. var datas = zrUtil.extend({}, this[DATAS]);
  33888. datas[this.dataType] = res;
  33889. linkAll(res, datas, opt);
  33890. }
  33891. else {
  33892. // Modify the reference in main data to point newData.
  33893. linkSingle(res, this.dataType, this[MAIN_DATA], opt);
  33894. }
  33895. return res;
  33896. }
  33897. function changeInjection(opt, res) {
  33898. opt.struct && opt.struct.update(this);
  33899. return res;
  33900. }
  33901. function cloneShallowInjection(opt, res) {
  33902. // cloneShallow, which brings about some fragilities, may be inappropriate
  33903. // to be exposed as an API. So for implementation simplicity we can make
  33904. // the restriction that cloneShallow of not-mainData should not be invoked
  33905. // outside, but only be invoked here.
  33906. each(res[DATAS], function (data, dataType) {
  33907. data !== res && linkSingle(data.cloneShallow(), dataType, res, opt);
  33908. });
  33909. return res;
  33910. }
  33911. /**
  33912. * Supplement method to List.
  33913. *
  33914. * @public
  33915. * @param {string} [dataType] If not specified, return mainData.
  33916. * @return {module:echarts/data/List}
  33917. */
  33918. function getLinkedData(dataType) {
  33919. var mainData = this[MAIN_DATA];
  33920. return (dataType == null || mainData == null)
  33921. ? mainData
  33922. : mainData[DATAS][dataType];
  33923. }
  33924. function isMainData(data) {
  33925. return data[MAIN_DATA] === data;
  33926. }
  33927. function linkAll(mainData, datas, opt) {
  33928. mainData[DATAS] = {};
  33929. each(datas, function (data, dataType) {
  33930. linkSingle(data, dataType, mainData, opt);
  33931. });
  33932. }
  33933. function linkSingle(data, dataType, mainData, opt) {
  33934. mainData[DATAS][dataType] = data;
  33935. data[MAIN_DATA] = mainData;
  33936. data.dataType = dataType;
  33937. if (opt.struct) {
  33938. data[opt.structAttr] = opt.struct;
  33939. opt.struct[opt.datasAttr[dataType]] = data;
  33940. }
  33941. // Supplement method.
  33942. data.getLinkedData = getLinkedData;
  33943. }
  33944. module.exports = linkList;
  33945. /***/ }),
  33946. /* 200 */
  33947. /***/ (function(module, exports, __webpack_require__) {
  33948. var zrUtil = __webpack_require__(4);
  33949. var helper = {
  33950. retrieveTargetInfo: function (payload, seriesModel) {
  33951. if (payload
  33952. && (
  33953. payload.type === 'treemapZoomToNode'
  33954. || payload.type === 'treemapRootToNode'
  33955. )
  33956. ) {
  33957. var root = seriesModel.getData().tree.root;
  33958. var targetNode = payload.targetNode;
  33959. if (targetNode && root.contains(targetNode)) {
  33960. return {node: targetNode};
  33961. }
  33962. var targetNodeId = payload.targetNodeId;
  33963. if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
  33964. return {node: targetNode};
  33965. }
  33966. }
  33967. },
  33968. // Not includes the given node at the last item.
  33969. getPathToRoot: function (node) {
  33970. var path = [];
  33971. while (node) {
  33972. node = node.parentNode;
  33973. node && path.push(node);
  33974. }
  33975. return path.reverse();
  33976. },
  33977. aboveViewRoot: function (viewRoot, node) {
  33978. var viewPath = helper.getPathToRoot(viewRoot);
  33979. return zrUtil.indexOf(viewPath, node) >= 0;
  33980. },
  33981. // From root to the input node (the input node will be included).
  33982. wrapTreePathInfo: function (node, seriesModel) {
  33983. var treePathInfo = [];
  33984. while (node) {
  33985. var nodeDataIndex = node.dataIndex;
  33986. treePathInfo.push({
  33987. name: node.name,
  33988. dataIndex: nodeDataIndex,
  33989. value: seriesModel.getRawValue(nodeDataIndex)
  33990. });
  33991. node = node.parentNode;
  33992. }
  33993. treePathInfo.reverse();
  33994. return treePathInfo;
  33995. }
  33996. };
  33997. module.exports = helper;
  33998. /***/ }),
  33999. /* 201 */
  34000. /***/ (function(module, exports, __webpack_require__) {
  34001. var zrUtil = __webpack_require__(4);
  34002. var graphic = __webpack_require__(20);
  34003. var DataDiffer = __webpack_require__(102);
  34004. var helper = __webpack_require__(200);
  34005. var Breadcrumb = __webpack_require__(202);
  34006. var RoamController = __webpack_require__(186);
  34007. var BoundingRect = __webpack_require__(9);
  34008. var matrix = __webpack_require__(11);
  34009. var animationUtil = __webpack_require__(203);
  34010. var bind = zrUtil.bind;
  34011. var Group = graphic.Group;
  34012. var Rect = graphic.Rect;
  34013. var each = zrUtil.each;
  34014. var DRAG_THRESHOLD = 3;
  34015. var PATH_LABEL_NOAMAL = ['label', 'normal'];
  34016. var PATH_LABEL_EMPHASIS = ['label', 'emphasis'];
  34017. var PATH_UPPERLABEL_NORMAL = ['upperLabel', 'normal'];
  34018. var PATH_UPPERLABEL_EMPHASIS = ['upperLabel', 'emphasis'];
  34019. var Z_BASE = 10; // Should bigger than every z.
  34020. var Z_BG = 1;
  34021. var Z_CONTENT = 2;
  34022. module.exports = __webpack_require__(1).extendChartView({
  34023. type: 'treemap',
  34024. /**
  34025. * @override
  34026. */
  34027. init: function (o, api) {
  34028. /**
  34029. * @private
  34030. * @type {module:zrender/container/Group}
  34031. */
  34032. this._containerGroup;
  34033. /**
  34034. * @private
  34035. * @type {Object.<string, Array.<module:zrender/container/Group>>}
  34036. */
  34037. this._storage = createStorage();
  34038. /**
  34039. * @private
  34040. * @type {module:echarts/data/Tree}
  34041. */
  34042. this._oldTree;
  34043. /**
  34044. * @private
  34045. * @type {module:echarts/chart/treemap/Breadcrumb}
  34046. */
  34047. this._breadcrumb;
  34048. /**
  34049. * @private
  34050. * @type {module:echarts/component/helper/RoamController}
  34051. */
  34052. this._controller;
  34053. /**
  34054. * 'ready', 'animating'
  34055. * @private
  34056. */
  34057. this._state = 'ready';
  34058. },
  34059. /**
  34060. * @override
  34061. */
  34062. render: function (seriesModel, ecModel, api, payload) {
  34063. var models = ecModel.findComponents({
  34064. mainType: 'series', subType: 'treemap', query: payload
  34065. });
  34066. if (zrUtil.indexOf(models, seriesModel) < 0) {
  34067. return;
  34068. }
  34069. this.seriesModel = seriesModel;
  34070. this.api = api;
  34071. this.ecModel = ecModel;
  34072. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  34073. var payloadType = payload && payload.type;
  34074. var layoutInfo = seriesModel.layoutInfo;
  34075. var isInit = !this._oldTree;
  34076. var thisStorage = this._storage;
  34077. // Mark new root when action is treemapRootToNode.
  34078. var reRoot = (payloadType === 'treemapRootToNode' && targetInfo && thisStorage)
  34079. ? {
  34080. rootNodeGroup: thisStorage.nodeGroup[targetInfo.node.getRawIndex()],
  34081. direction: payload.direction
  34082. }
  34083. : null;
  34084. var containerGroup = this._giveContainerGroup(layoutInfo);
  34085. var renderResult = this._doRender(containerGroup, seriesModel, reRoot);
  34086. (
  34087. !isInit && (
  34088. !payloadType
  34089. || payloadType === 'treemapZoomToNode'
  34090. || payloadType === 'treemapRootToNode'
  34091. )
  34092. )
  34093. ? this._doAnimation(containerGroup, renderResult, seriesModel, reRoot)
  34094. : renderResult.renderFinally();
  34095. this._resetController(api);
  34096. this._renderBreadcrumb(seriesModel, api, targetInfo);
  34097. },
  34098. /**
  34099. * @private
  34100. */
  34101. _giveContainerGroup: function (layoutInfo) {
  34102. var containerGroup = this._containerGroup;
  34103. if (!containerGroup) {
  34104. // FIXME
  34105. // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。
  34106. containerGroup = this._containerGroup = new Group();
  34107. this._initEvents(containerGroup);
  34108. this.group.add(containerGroup);
  34109. }
  34110. containerGroup.attr('position', [layoutInfo.x, layoutInfo.y]);
  34111. return containerGroup;
  34112. },
  34113. /**
  34114. * @private
  34115. */
  34116. _doRender: function (containerGroup, seriesModel, reRoot) {
  34117. var thisTree = seriesModel.getData().tree;
  34118. var oldTree = this._oldTree;
  34119. // Clear last shape records.
  34120. var lastsForAnimation = createStorage();
  34121. var thisStorage = createStorage();
  34122. var oldStorage = this._storage;
  34123. var willInvisibleEls = [];
  34124. var doRenderNode = zrUtil.curry(
  34125. renderNode, seriesModel,
  34126. thisStorage, oldStorage, reRoot,
  34127. lastsForAnimation, willInvisibleEls
  34128. );
  34129. // Notice: when thisTree and oldTree are the same tree (see list.cloneShallow),
  34130. // the oldTree is actually losted, so we can not find all of the old graphic
  34131. // elements from tree. So we use this stragegy: make element storage, move
  34132. // from old storage to new storage, clear old storage.
  34133. dualTravel(
  34134. thisTree.root ? [thisTree.root] : [],
  34135. (oldTree && oldTree.root) ? [oldTree.root] : [],
  34136. containerGroup,
  34137. thisTree === oldTree || !oldTree,
  34138. 0
  34139. );
  34140. // Process all removing.
  34141. var willDeleteEls = clearStorage(oldStorage);
  34142. this._oldTree = thisTree;
  34143. this._storage = thisStorage;
  34144. return {
  34145. lastsForAnimation: lastsForAnimation,
  34146. willDeleteEls: willDeleteEls,
  34147. renderFinally: renderFinally
  34148. };
  34149. function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, depth) {
  34150. // When 'render' is triggered by action,
  34151. // 'this' and 'old' may be the same tree,
  34152. // we use rawIndex in that case.
  34153. if (sameTree) {
  34154. oldViewChildren = thisViewChildren;
  34155. each(thisViewChildren, function (child, index) {
  34156. !child.isRemoved() && processNode(index, index);
  34157. });
  34158. }
  34159. // Diff hierarchically (diff only in each subtree, but not whole).
  34160. // because, consistency of view is important.
  34161. else {
  34162. (new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey))
  34163. .add(processNode)
  34164. .update(processNode)
  34165. .remove(zrUtil.curry(processNode, null))
  34166. .execute();
  34167. }
  34168. function getKey(node) {
  34169. // Identify by name or raw index.
  34170. return node.getId();
  34171. }
  34172. function processNode(newIndex, oldIndex) {
  34173. var thisNode = newIndex != null ? thisViewChildren[newIndex] : null;
  34174. var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null;
  34175. var group = doRenderNode(thisNode, oldNode, parentGroup, depth);
  34176. group && dualTravel(
  34177. thisNode && thisNode.viewChildren || [],
  34178. oldNode && oldNode.viewChildren || [],
  34179. group,
  34180. sameTree,
  34181. depth + 1
  34182. );
  34183. }
  34184. }
  34185. function clearStorage(storage) {
  34186. var willDeleteEls = createStorage();
  34187. storage && each(storage, function (store, storageName) {
  34188. var delEls = willDeleteEls[storageName];
  34189. each(store, function (el) {
  34190. el && (delEls.push(el), el.__tmWillDelete = 1);
  34191. });
  34192. });
  34193. return willDeleteEls;
  34194. }
  34195. function renderFinally() {
  34196. each(willDeleteEls, function (els) {
  34197. each(els, function (el) {
  34198. el.parent && el.parent.remove(el);
  34199. });
  34200. });
  34201. each(willInvisibleEls, function (el) {
  34202. el.invisible = true;
  34203. // Setting invisible is for optimizing, so no need to set dirty,
  34204. // just mark as invisible.
  34205. el.dirty();
  34206. });
  34207. }
  34208. },
  34209. /**
  34210. * @private
  34211. */
  34212. _doAnimation: function (containerGroup, renderResult, seriesModel, reRoot) {
  34213. if (!seriesModel.get('animation')) {
  34214. return;
  34215. }
  34216. var duration = seriesModel.get('animationDurationUpdate');
  34217. var easing = seriesModel.get('animationEasing');
  34218. var animationWrap = animationUtil.createWrap();
  34219. // Make delete animations.
  34220. each(renderResult.willDeleteEls, function (store, storageName) {
  34221. each(store, function (el, rawIndex) {
  34222. if (el.invisible) {
  34223. return;
  34224. }
  34225. var parent = el.parent; // Always has parent, and parent is nodeGroup.
  34226. var target;
  34227. if (reRoot && reRoot.direction === 'drillDown') {
  34228. target = parent === reRoot.rootNodeGroup
  34229. // This is the content element of view root.
  34230. // Only `content` will enter this branch, because
  34231. // `background` and `nodeGroup` will not be deleted.
  34232. ? {
  34233. shape: {
  34234. x: 0,
  34235. y: 0,
  34236. width: parent.__tmNodeWidth,
  34237. height: parent.__tmNodeHeight
  34238. },
  34239. style: {
  34240. opacity: 0
  34241. }
  34242. }
  34243. // Others.
  34244. : {style: {opacity: 0}};
  34245. }
  34246. else {
  34247. var targetX = 0;
  34248. var targetY = 0;
  34249. if (!parent.__tmWillDelete) {
  34250. // Let node animate to right-bottom corner, cooperating with fadeout,
  34251. // which is appropriate for user understanding.
  34252. // Divided by 2 for reRoot rolling up effect.
  34253. targetX = parent.__tmNodeWidth / 2;
  34254. targetY = parent.__tmNodeHeight / 2;
  34255. }
  34256. target = storageName === 'nodeGroup'
  34257. ? {position: [targetX, targetY], style: {opacity: 0}}
  34258. : {
  34259. shape: {x: targetX, y: targetY, width: 0, height: 0},
  34260. style: {opacity: 0}
  34261. };
  34262. }
  34263. target && animationWrap.add(el, target, duration, easing);
  34264. });
  34265. });
  34266. // Make other animations
  34267. each(this._storage, function (store, storageName) {
  34268. each(store, function (el, rawIndex) {
  34269. var last = renderResult.lastsForAnimation[storageName][rawIndex];
  34270. var target = {};
  34271. if (!last) {
  34272. return;
  34273. }
  34274. if (storageName === 'nodeGroup') {
  34275. if (last.old) {
  34276. target.position = el.position.slice();
  34277. el.attr('position', last.old);
  34278. }
  34279. }
  34280. else {
  34281. if (last.old) {
  34282. target.shape = zrUtil.extend({}, el.shape);
  34283. el.setShape(last.old);
  34284. }
  34285. if (last.fadein) {
  34286. el.setStyle('opacity', 0);
  34287. target.style = {opacity: 1};
  34288. }
  34289. // When animation is stopped for succedent animation starting,
  34290. // el.style.opacity might not be 1
  34291. else if (el.style.opacity !== 1) {
  34292. target.style = {opacity: 1};
  34293. }
  34294. }
  34295. animationWrap.add(el, target, duration, easing);
  34296. });
  34297. }, this);
  34298. this._state = 'animating';
  34299. animationWrap
  34300. .done(bind(function () {
  34301. this._state = 'ready';
  34302. renderResult.renderFinally();
  34303. }, this))
  34304. .start();
  34305. },
  34306. /**
  34307. * @private
  34308. */
  34309. _resetController: function (api) {
  34310. var controller = this._controller;
  34311. // Init controller.
  34312. if (!controller) {
  34313. controller = this._controller = new RoamController(api.getZr());
  34314. controller.enable(this.seriesModel.get('roam'));
  34315. controller.on('pan', bind(this._onPan, this));
  34316. controller.on('zoom', bind(this._onZoom, this));
  34317. }
  34318. var rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight());
  34319. controller.setPointerChecker(function (e, x, y) {
  34320. return rect.contain(x, y);
  34321. });
  34322. },
  34323. /**
  34324. * @private
  34325. */
  34326. _clearController: function () {
  34327. var controller = this._controller;
  34328. if (controller) {
  34329. controller.dispose();
  34330. controller = null;
  34331. }
  34332. },
  34333. /**
  34334. * @private
  34335. */
  34336. _onPan: function (dx, dy) {
  34337. if (this._state !== 'animating'
  34338. && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)
  34339. ) {
  34340. // These param must not be cached.
  34341. var root = this.seriesModel.getData().tree.root;
  34342. if (!root) {
  34343. return;
  34344. }
  34345. var rootLayout = root.getLayout();
  34346. if (!rootLayout) {
  34347. return;
  34348. }
  34349. this.api.dispatchAction({
  34350. type: 'treemapMove',
  34351. from: this.uid,
  34352. seriesId: this.seriesModel.id,
  34353. rootRect: {
  34354. x: rootLayout.x + dx, y: rootLayout.y + dy,
  34355. width: rootLayout.width, height: rootLayout.height
  34356. }
  34357. });
  34358. }
  34359. },
  34360. /**
  34361. * @private
  34362. */
  34363. _onZoom: function (scale, mouseX, mouseY) {
  34364. if (this._state !== 'animating') {
  34365. // These param must not be cached.
  34366. var root = this.seriesModel.getData().tree.root;
  34367. if (!root) {
  34368. return;
  34369. }
  34370. var rootLayout = root.getLayout();
  34371. if (!rootLayout) {
  34372. return;
  34373. }
  34374. var rect = new BoundingRect(
  34375. rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height
  34376. );
  34377. var layoutInfo = this.seriesModel.layoutInfo;
  34378. // Transform mouse coord from global to containerGroup.
  34379. mouseX -= layoutInfo.x;
  34380. mouseY -= layoutInfo.y;
  34381. // Scale root bounding rect.
  34382. var m = matrix.create();
  34383. matrix.translate(m, m, [-mouseX, -mouseY]);
  34384. matrix.scale(m, m, [scale, scale]);
  34385. matrix.translate(m, m, [mouseX, mouseY]);
  34386. rect.applyTransform(m);
  34387. this.api.dispatchAction({
  34388. type: 'treemapRender',
  34389. from: this.uid,
  34390. seriesId: this.seriesModel.id,
  34391. rootRect: {
  34392. x: rect.x, y: rect.y,
  34393. width: rect.width, height: rect.height
  34394. }
  34395. });
  34396. }
  34397. },
  34398. /**
  34399. * @private
  34400. */
  34401. _initEvents: function (containerGroup) {
  34402. containerGroup.on('click', function (e) {
  34403. if (this._state !== 'ready') {
  34404. return;
  34405. }
  34406. var nodeClick = this.seriesModel.get('nodeClick', true);
  34407. if (!nodeClick) {
  34408. return;
  34409. }
  34410. var targetInfo = this.findTarget(e.offsetX, e.offsetY);
  34411. if (!targetInfo) {
  34412. return;
  34413. }
  34414. var node = targetInfo.node;
  34415. if (node.getLayout().isLeafRoot) {
  34416. this._rootToNode(targetInfo);
  34417. }
  34418. else {
  34419. if (nodeClick === 'zoomToNode') {
  34420. this._zoomToNode(targetInfo);
  34421. }
  34422. else if (nodeClick === 'link') {
  34423. var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
  34424. var link = itemModel.get('link', true);
  34425. var linkTarget = itemModel.get('target', true) || 'blank';
  34426. link && window.open(link, linkTarget);
  34427. }
  34428. }
  34429. }, this);
  34430. },
  34431. /**
  34432. * @private
  34433. */
  34434. _renderBreadcrumb: function (seriesModel, api, targetInfo) {
  34435. if (!targetInfo) {
  34436. targetInfo = seriesModel.get('leafDepth', true) != null
  34437. ? {node: seriesModel.getViewRoot()}
  34438. // FIXME
  34439. // better way?
  34440. // Find breadcrumb tail on center of containerGroup.
  34441. : this.findTarget(api.getWidth() / 2, api.getHeight() / 2);
  34442. if (!targetInfo) {
  34443. targetInfo = {node: seriesModel.getData().tree.root};
  34444. }
  34445. }
  34446. (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group)))
  34447. .render(seriesModel, api, targetInfo.node, bind(onSelect, this));
  34448. function onSelect(node) {
  34449. if (this._state !== 'animating') {
  34450. helper.aboveViewRoot(seriesModel.getViewRoot(), node)
  34451. ? this._rootToNode({node: node})
  34452. : this._zoomToNode({node: node});
  34453. }
  34454. }
  34455. },
  34456. /**
  34457. * @override
  34458. */
  34459. remove: function () {
  34460. this._clearController();
  34461. this._containerGroup && this._containerGroup.removeAll();
  34462. this._storage = createStorage();
  34463. this._state = 'ready';
  34464. this._breadcrumb && this._breadcrumb.remove();
  34465. },
  34466. dispose: function () {
  34467. this._clearController();
  34468. },
  34469. /**
  34470. * @private
  34471. */
  34472. _zoomToNode: function (targetInfo) {
  34473. this.api.dispatchAction({
  34474. type: 'treemapZoomToNode',
  34475. from: this.uid,
  34476. seriesId: this.seriesModel.id,
  34477. targetNode: targetInfo.node
  34478. });
  34479. },
  34480. /**
  34481. * @private
  34482. */
  34483. _rootToNode: function (targetInfo) {
  34484. this.api.dispatchAction({
  34485. type: 'treemapRootToNode',
  34486. from: this.uid,
  34487. seriesId: this.seriesModel.id,
  34488. targetNode: targetInfo.node
  34489. });
  34490. },
  34491. /**
  34492. * @public
  34493. * @param {number} x Global coord x.
  34494. * @param {number} y Global coord y.
  34495. * @return {Object} info If not found, return undefined;
  34496. * @return {number} info.node Target node.
  34497. * @return {number} info.offsetX x refer to target node.
  34498. * @return {number} info.offsetY y refer to target node.
  34499. */
  34500. findTarget: function (x, y) {
  34501. var targetInfo;
  34502. var viewRoot = this.seriesModel.getViewRoot();
  34503. viewRoot.eachNode({attr: 'viewChildren', order: 'preorder'}, function (node) {
  34504. var bgEl = this._storage.background[node.getRawIndex()];
  34505. // If invisible, there might be no element.
  34506. if (bgEl) {
  34507. var point = bgEl.transformCoordToLocal(x, y);
  34508. var shape = bgEl.shape;
  34509. // For performance consideration, dont use 'getBoundingRect'.
  34510. if (shape.x <= point[0]
  34511. && point[0] <= shape.x + shape.width
  34512. && shape.y <= point[1]
  34513. && point[1] <= shape.y + shape.height
  34514. ) {
  34515. targetInfo = {node: node, offsetX: point[0], offsetY: point[1]};
  34516. }
  34517. else {
  34518. return false; // Suppress visit subtree.
  34519. }
  34520. }
  34521. }, this);
  34522. return targetInfo;
  34523. }
  34524. });
  34525. /**
  34526. * @inner
  34527. */
  34528. function createStorage() {
  34529. return {nodeGroup: [], background: [], content: []};
  34530. }
  34531. /**
  34532. * @inner
  34533. * @return Return undefined means do not travel further.
  34534. */
  34535. function renderNode(
  34536. seriesModel, thisStorage, oldStorage, reRoot,
  34537. lastsForAnimation, willInvisibleEls,
  34538. thisNode, oldNode, parentGroup, depth
  34539. ) {
  34540. // Whether under viewRoot.
  34541. if (!thisNode) {
  34542. // Deleting nodes will be performed finally. This method just find
  34543. // element from old storage, or create new element, set them to new
  34544. // storage, and set styles.
  34545. return;
  34546. }
  34547. // -------------------------------------------------------------------
  34548. // Start of closure variables available in "Procedures in renderNode".
  34549. var thisLayout = thisNode.getLayout();
  34550. if (!thisLayout || !thisLayout.isInView) {
  34551. return;
  34552. }
  34553. var thisWidth = thisLayout.width;
  34554. var thisHeight = thisLayout.height;
  34555. var borderWidth = thisLayout.borderWidth;
  34556. var thisInvisible = thisLayout.invisible;
  34557. var thisRawIndex = thisNode.getRawIndex();
  34558. var oldRawIndex = oldNode && oldNode.getRawIndex();
  34559. var thisViewChildren = thisNode.viewChildren;
  34560. var upperHeight = thisLayout.upperHeight;
  34561. var isParent = thisViewChildren && thisViewChildren.length;
  34562. var itemStyleEmphasisModel = thisNode.getModel('itemStyle.emphasis');
  34563. // End of closure ariables available in "Procedures in renderNode".
  34564. // -----------------------------------------------------------------
  34565. // Node group
  34566. var group = giveGraphic('nodeGroup', Group);
  34567. if (!group) {
  34568. return;
  34569. }
  34570. parentGroup.add(group);
  34571. // x,y are not set when el is above view root.
  34572. group.attr('position', [thisLayout.x || 0, thisLayout.y || 0]);
  34573. group.__tmNodeWidth = thisWidth;
  34574. group.__tmNodeHeight = thisHeight;
  34575. if (thisLayout.isAboveViewRoot) {
  34576. return group;
  34577. }
  34578. // Background
  34579. var bg = giveGraphic('background', Rect, depth, Z_BG);
  34580. bg && renderBackground(group, bg, isParent && thisLayout.upperHeight);
  34581. // No children, render content.
  34582. if (!isParent) {
  34583. var content = giveGraphic('content', Rect, depth, Z_CONTENT);
  34584. content && renderContent(group, content);
  34585. }
  34586. return group;
  34587. // ----------------------------
  34588. // | Procedures in renderNode |
  34589. // ----------------------------
  34590. function renderBackground(group, bg, useUpperLabel) {
  34591. // For tooltip.
  34592. bg.dataIndex = thisNode.dataIndex;
  34593. bg.seriesIndex = seriesModel.seriesIndex;
  34594. bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
  34595. var visualBorderColor = thisNode.getVisual('borderColor', true);
  34596. var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
  34597. updateStyle(bg, function () {
  34598. var normalStyle = {fill: visualBorderColor};
  34599. var emphasisStyle = {fill: emphasisBorderColor};
  34600. if (useUpperLabel) {
  34601. var upperLabelWidth = thisWidth - 2 * borderWidth;
  34602. prepareText(
  34603. normalStyle, emphasisStyle, visualBorderColor, upperLabelWidth, upperHeight,
  34604. {x: borderWidth, y: 0, width: upperLabelWidth, height: upperHeight}
  34605. );
  34606. }
  34607. // For old bg.
  34608. else {
  34609. normalStyle.text = emphasisStyle.text = null;
  34610. }
  34611. bg.setStyle(normalStyle);
  34612. graphic.setHoverStyle(bg, emphasisStyle);
  34613. });
  34614. group.add(bg);
  34615. }
  34616. function renderContent(group, content) {
  34617. // For tooltip.
  34618. content.dataIndex = thisNode.dataIndex;
  34619. content.seriesIndex = seriesModel.seriesIndex;
  34620. var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0);
  34621. var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0);
  34622. content.culling = true;
  34623. content.setShape({
  34624. x: borderWidth,
  34625. y: borderWidth,
  34626. width: contentWidth,
  34627. height: contentHeight
  34628. });
  34629. var visualColor = thisNode.getVisual('color', true);
  34630. updateStyle(content, function () {
  34631. var normalStyle = {fill: visualColor};
  34632. var emphasisStyle = itemStyleEmphasisModel.getItemStyle();
  34633. prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
  34634. content.setStyle(normalStyle);
  34635. graphic.setHoverStyle(content, emphasisStyle);
  34636. });
  34637. group.add(content);
  34638. }
  34639. function updateStyle(element, cb) {
  34640. if (!thisInvisible) {
  34641. // If invisible, do not set visual, otherwise the element will
  34642. // change immediately before animation. We think it is OK to
  34643. // remain its origin color when moving out of the view window.
  34644. cb();
  34645. if (!element.__tmWillVisible) {
  34646. element.invisible = false;
  34647. }
  34648. }
  34649. else {
  34650. // Delay invisible setting utill animation finished,
  34651. // avoid element vanish suddenly before animation.
  34652. !element.invisible && willInvisibleEls.push(element);
  34653. }
  34654. }
  34655. function prepareText(normalStyle, emphasisStyle, visualColor, width, height, upperLabelRect) {
  34656. var nodeModel = thisNode.getModel();
  34657. var text = zrUtil.retrieve(
  34658. seriesModel.getFormattedLabel(
  34659. thisNode.dataIndex, 'normal', null, null, upperLabelRect ? 'upperLabel' : 'label'
  34660. ),
  34661. nodeModel.get('name')
  34662. );
  34663. if (!upperLabelRect && thisLayout.isLeafRoot) {
  34664. var iconChar = seriesModel.get('drillDownIcon', true);
  34665. text = iconChar ? iconChar + ' ' + text : text;
  34666. }
  34667. var normalLabelModel = nodeModel.getModel(
  34668. upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL
  34669. );
  34670. var emphasisLabelModel = nodeModel.getModel(
  34671. upperLabelRect ? PATH_UPPERLABEL_EMPHASIS : PATH_LABEL_EMPHASIS
  34672. );
  34673. var isShow = normalLabelModel.getShallow('show');
  34674. graphic.setLabelStyle(
  34675. normalStyle, emphasisStyle, normalLabelModel, emphasisLabelModel,
  34676. {
  34677. defaultText: isShow ? text : null,
  34678. autoColor: visualColor,
  34679. isRectText: true
  34680. }
  34681. );
  34682. upperLabelRect && (normalStyle.textRect = zrUtil.clone(upperLabelRect));
  34683. normalStyle.truncate = (isShow && normalLabelModel.get('ellipsis'))
  34684. ? {
  34685. outerWidth: width,
  34686. outerHeight: height,
  34687. minChar: 2
  34688. }
  34689. : null;
  34690. }
  34691. function giveGraphic(storageName, Ctor, depth, z) {
  34692. var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
  34693. var lasts = lastsForAnimation[storageName];
  34694. if (element) {
  34695. // Remove from oldStorage
  34696. oldStorage[storageName][oldRawIndex] = null;
  34697. prepareAnimationWhenHasOld(lasts, element, storageName);
  34698. }
  34699. // If invisible and no old element, do not create new element (for optimizing).
  34700. else if (!thisInvisible) {
  34701. element = new Ctor({z: calculateZ(depth, z)});
  34702. element.__tmDepth = depth;
  34703. element.__tmStorageName = storageName;
  34704. prepareAnimationWhenNoOld(lasts, element, storageName);
  34705. }
  34706. // Set to thisStorage
  34707. return (thisStorage[storageName][thisRawIndex] = element);
  34708. }
  34709. function prepareAnimationWhenHasOld(lasts, element, storageName) {
  34710. var lastCfg = lasts[thisRawIndex] = {};
  34711. lastCfg.old = storageName === 'nodeGroup'
  34712. ? element.position.slice()
  34713. : zrUtil.extend({}, element.shape);
  34714. }
  34715. // If a element is new, we need to find the animation start point carefully,
  34716. // otherwise it will looks strange when 'zoomToNode'.
  34717. function prepareAnimationWhenNoOld(lasts, element, storageName) {
  34718. var lastCfg = lasts[thisRawIndex] = {};
  34719. var parentNode = thisNode.parentNode;
  34720. if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
  34721. var parentOldX = 0;
  34722. var parentOldY = 0;
  34723. // New nodes appear from right-bottom corner in 'zoomToNode' animation.
  34724. // For convenience, get old bounding rect from background.
  34725. var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
  34726. if (!reRoot && parentOldBg && parentOldBg.old) {
  34727. parentOldX = parentOldBg.old.width;
  34728. parentOldY = parentOldBg.old.height;
  34729. }
  34730. // When no parent old shape found, its parent is new too,
  34731. // so we can just use {x:0, y:0}.
  34732. lastCfg.old = storageName === 'nodeGroup'
  34733. ? [0, parentOldY]
  34734. : {x: parentOldX, y: parentOldY, width: 0, height: 0};
  34735. }
  34736. // Fade in, user can be aware that these nodes are new.
  34737. lastCfg.fadein = storageName !== 'nodeGroup';
  34738. }
  34739. }
  34740. // We can not set all backgroud with the same z, Because the behaviour of
  34741. // drill down and roll up differ background creation sequence from tree
  34742. // hierarchy sequence, which cause that lowser background element overlap
  34743. // upper ones. So we calculate z based on depth.
  34744. // Moreover, we try to shrink down z interval to [0, 1] to avoid that
  34745. // treemap with large z overlaps other components.
  34746. function calculateZ(depth, zInLevel) {
  34747. var zb = depth * Z_BASE + zInLevel;
  34748. return (zb - 1) / zb;
  34749. }
  34750. /***/ }),
  34751. /* 202 */
  34752. /***/ (function(module, exports, __webpack_require__) {
  34753. var graphic = __webpack_require__(20);
  34754. var layout = __webpack_require__(74);
  34755. var zrUtil = __webpack_require__(4);
  34756. var helper = __webpack_require__(200);
  34757. var TEXT_PADDING = 8;
  34758. var ITEM_GAP = 8;
  34759. var ARRAY_LENGTH = 5;
  34760. function Breadcrumb(containerGroup) {
  34761. /**
  34762. * @private
  34763. * @type {module:zrender/container/Group}
  34764. */
  34765. this.group = new graphic.Group();
  34766. containerGroup.add(this.group);
  34767. }
  34768. Breadcrumb.prototype = {
  34769. constructor: Breadcrumb,
  34770. render: function (seriesModel, api, targetNode, onSelect) {
  34771. var model = seriesModel.getModel('breadcrumb');
  34772. var thisGroup = this.group;
  34773. thisGroup.removeAll();
  34774. if (!model.get('show') || !targetNode) {
  34775. return;
  34776. }
  34777. var normalStyleModel = model.getModel('itemStyle.normal');
  34778. // var emphasisStyleModel = model.getModel('itemStyle.emphasis');
  34779. var textStyleModel = normalStyleModel.getModel('textStyle');
  34780. var layoutParam = {
  34781. pos: {
  34782. left: model.get('left'),
  34783. right: model.get('right'),
  34784. top: model.get('top'),
  34785. bottom: model.get('bottom')
  34786. },
  34787. box: {
  34788. width: api.getWidth(),
  34789. height: api.getHeight()
  34790. },
  34791. emptyItemWidth: model.get('emptyItemWidth'),
  34792. totalWidth: 0,
  34793. renderList: []
  34794. };
  34795. this._prepare(targetNode, layoutParam, textStyleModel);
  34796. this._renderContent(seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect);
  34797. layout.positionElement(thisGroup, layoutParam.pos, layoutParam.box);
  34798. },
  34799. /**
  34800. * Prepare render list and total width
  34801. * @private
  34802. */
  34803. _prepare: function (targetNode, layoutParam, textStyleModel) {
  34804. for (var node = targetNode; node; node = node.parentNode) {
  34805. var text = node.getModel().get('name');
  34806. var textRect = textStyleModel.getTextRect(text);
  34807. var itemWidth = Math.max(
  34808. textRect.width + TEXT_PADDING * 2,
  34809. layoutParam.emptyItemWidth
  34810. );
  34811. layoutParam.totalWidth += itemWidth + ITEM_GAP;
  34812. layoutParam.renderList.push({node: node, text: text, width: itemWidth});
  34813. }
  34814. },
  34815. /**
  34816. * @private
  34817. */
  34818. _renderContent: function (
  34819. seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect
  34820. ) {
  34821. // Start rendering.
  34822. var lastX = 0;
  34823. var emptyItemWidth = layoutParam.emptyItemWidth;
  34824. var height = seriesModel.get('breadcrumb.height');
  34825. var availableSize = layout.getAvailableSize(layoutParam.pos, layoutParam.box);
  34826. var totalWidth = layoutParam.totalWidth;
  34827. var renderList = layoutParam.renderList;
  34828. for (var i = renderList.length - 1; i >= 0; i--) {
  34829. var item = renderList[i];
  34830. var itemNode = item.node;
  34831. var itemWidth = item.width;
  34832. var text = item.text;
  34833. // Hdie text and shorten width if necessary.
  34834. if (totalWidth > availableSize.width) {
  34835. totalWidth -= itemWidth - emptyItemWidth;
  34836. itemWidth = emptyItemWidth;
  34837. text = null;
  34838. }
  34839. var el = new graphic.Polygon({
  34840. shape: {
  34841. points: makeItemPoints(
  34842. lastX, 0, itemWidth, height,
  34843. i === renderList.length - 1, i === 0
  34844. )
  34845. },
  34846. style: zrUtil.defaults(
  34847. normalStyleModel.getItemStyle(),
  34848. {
  34849. lineJoin: 'bevel',
  34850. text: text,
  34851. textFill: textStyleModel.getTextColor(),
  34852. textFont: textStyleModel.getFont()
  34853. }
  34854. ),
  34855. z: 10,
  34856. onclick: zrUtil.curry(onSelect, itemNode)
  34857. });
  34858. this.group.add(el);
  34859. packEventData(el, seriesModel, itemNode);
  34860. lastX += itemWidth + ITEM_GAP;
  34861. }
  34862. },
  34863. /**
  34864. * @override
  34865. */
  34866. remove: function () {
  34867. this.group.removeAll();
  34868. }
  34869. };
  34870. function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) {
  34871. var points = [
  34872. [head ? x : x - ARRAY_LENGTH, y],
  34873. [x + itemWidth, y],
  34874. [x + itemWidth, y + itemHeight],
  34875. [head ? x : x - ARRAY_LENGTH, y + itemHeight]
  34876. ];
  34877. !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]);
  34878. !head && points.push([x, y + itemHeight / 2]);
  34879. return points;
  34880. }
  34881. // Package custom mouse event.
  34882. function packEventData(el, seriesModel, itemNode) {
  34883. el.eventData = {
  34884. componentType: 'series',
  34885. componentSubType: 'treemap',
  34886. seriesIndex: seriesModel.componentIndex,
  34887. seriesName: seriesModel.name,
  34888. seriesType: 'treemap',
  34889. selfType: 'breadcrumb', // Distinguish with click event on treemap node.
  34890. nodeData: {
  34891. dataIndex: itemNode && itemNode.dataIndex,
  34892. name: itemNode && itemNode.name
  34893. },
  34894. treePathInfo: itemNode && helper.wrapTreePathInfo(itemNode, seriesModel)
  34895. };
  34896. }
  34897. module.exports = Breadcrumb;
  34898. /***/ }),
  34899. /* 203 */
  34900. /***/ (function(module, exports, __webpack_require__) {
  34901. var zrUtil = __webpack_require__(4);
  34902. /**
  34903. * @param {number} [time=500] Time in ms
  34904. * @param {string} [easing='linear']
  34905. * @param {number} [delay=0]
  34906. * @param {Function} [callback]
  34907. *
  34908. * @example
  34909. * // Animate position
  34910. * animation
  34911. * .createWrap()
  34912. * .add(el1, {position: [10, 10]})
  34913. * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400)
  34914. * .done(function () { // done })
  34915. * .start('cubicOut');
  34916. */
  34917. function createWrap() {
  34918. var storage = [];
  34919. var elExistsMap = {};
  34920. var doneCallback;
  34921. return {
  34922. /**
  34923. * Caution: a el can only be added once, otherwise 'done'
  34924. * might not be called. This method checks this (by el.id),
  34925. * suppresses adding and returns false when existing el found.
  34926. *
  34927. * @param {modele:zrender/Element} el
  34928. * @param {Object} target
  34929. * @param {number} [time=500]
  34930. * @param {number} [delay=0]
  34931. * @param {string} [easing='linear']
  34932. * @return {boolean} Whether adding succeeded.
  34933. *
  34934. * @example
  34935. * add(el, target, time, delay, easing);
  34936. * add(el, target, time, easing);
  34937. * add(el, target, time);
  34938. * add(el, target);
  34939. */
  34940. add: function (el, target, time, delay, easing) {
  34941. if (zrUtil.isString(delay)) {
  34942. easing = delay;
  34943. delay = 0;
  34944. }
  34945. if (elExistsMap[el.id]) {
  34946. return false;
  34947. }
  34948. elExistsMap[el.id] = 1;
  34949. storage.push(
  34950. {el: el, target: target, time: time, delay: delay, easing: easing}
  34951. );
  34952. return true;
  34953. },
  34954. /**
  34955. * Only execute when animation finished. Will not execute when any
  34956. * of 'stop' or 'stopAnimation' called.
  34957. *
  34958. * @param {Function} callback
  34959. */
  34960. done: function (callback) {
  34961. doneCallback = callback;
  34962. return this;
  34963. },
  34964. /**
  34965. * Will stop exist animation firstly.
  34966. */
  34967. start: function () {
  34968. var count = storage.length;
  34969. for (var i = 0, len = storage.length; i < len; i++) {
  34970. var item = storage[i];
  34971. item.el.animateTo(item.target, item.time, item.delay, item.easing, done);
  34972. }
  34973. return this;
  34974. function done() {
  34975. count--;
  34976. if (!count) {
  34977. storage.length = 0;
  34978. elExistsMap = {};
  34979. doneCallback && doneCallback();
  34980. }
  34981. }
  34982. }
  34983. };
  34984. }
  34985. module.exports = {createWrap: createWrap};
  34986. /***/ }),
  34987. /* 204 */
  34988. /***/ (function(module, exports, __webpack_require__) {
  34989. /**
  34990. * @file Treemap action
  34991. */
  34992. var echarts = __webpack_require__(1);
  34993. var helper = __webpack_require__(200);
  34994. var noop = function () {};
  34995. var actionTypes = [
  34996. 'treemapZoomToNode',
  34997. 'treemapRender',
  34998. 'treemapMove'
  34999. ];
  35000. for (var i = 0; i < actionTypes.length; i++) {
  35001. echarts.registerAction({type: actionTypes[i], update: 'updateView'}, noop);
  35002. }
  35003. echarts.registerAction(
  35004. {type: 'treemapRootToNode', update: 'updateView'},
  35005. function (payload, ecModel) {
  35006. ecModel.eachComponent(
  35007. {mainType: 'series', subType: 'treemap', query: payload},
  35008. handleRootToNode
  35009. );
  35010. function handleRootToNode(model, index) {
  35011. var targetInfo = helper.retrieveTargetInfo(payload, model);
  35012. if (targetInfo) {
  35013. var originViewRoot = model.getViewRoot();
  35014. if (originViewRoot) {
  35015. payload.direction = helper.aboveViewRoot(originViewRoot, targetInfo.node)
  35016. ? 'rollUp' : 'drillDown';
  35017. }
  35018. model.resetViewRoot(targetInfo.node);
  35019. }
  35020. }
  35021. }
  35022. );
  35023. /***/ }),
  35024. /* 205 */
  35025. /***/ (function(module, exports, __webpack_require__) {
  35026. var VisualMapping = __webpack_require__(206);
  35027. var zrColor = __webpack_require__(33);
  35028. var zrUtil = __webpack_require__(4);
  35029. var isArray = zrUtil.isArray;
  35030. var ITEM_STYLE_NORMAL = 'itemStyle.normal';
  35031. module.exports = function (ecModel, api, payload) {
  35032. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  35033. ecModel.eachComponent(condition, function (seriesModel) {
  35034. var tree = seriesModel.getData().tree;
  35035. var root = tree.root;
  35036. var seriesItemStyleModel = seriesModel.getModel(ITEM_STYLE_NORMAL);
  35037. if (root.isRemoved()) {
  35038. return;
  35039. }
  35040. var levelItemStyles = zrUtil.map(tree.levelModels, function (levelModel) {
  35041. return levelModel ? levelModel.get(ITEM_STYLE_NORMAL) : null;
  35042. });
  35043. travelTree(
  35044. root, // Visual should calculate from tree root but not view root.
  35045. {},
  35046. levelItemStyles,
  35047. seriesItemStyleModel,
  35048. seriesModel.getViewRoot().getAncestors(),
  35049. seriesModel
  35050. );
  35051. });
  35052. };
  35053. function travelTree(
  35054. node, designatedVisual, levelItemStyles, seriesItemStyleModel,
  35055. viewRootAncestors, seriesModel
  35056. ) {
  35057. var nodeModel = node.getModel();
  35058. var nodeLayout = node.getLayout();
  35059. // Optimize
  35060. if (!nodeLayout || nodeLayout.invisible || !nodeLayout.isInView) {
  35061. return;
  35062. }
  35063. var nodeItemStyleModel = node.getModel(ITEM_STYLE_NORMAL);
  35064. var levelItemStyle = levelItemStyles[node.depth];
  35065. var visuals = buildVisuals(
  35066. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  35067. );
  35068. // calculate border color
  35069. var borderColor = nodeItemStyleModel.get('borderColor');
  35070. var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation');
  35071. var thisNodeColor;
  35072. if (borderColorSaturation != null) {
  35073. // For performance, do not always execute 'calculateColor'.
  35074. thisNodeColor = calculateColor(visuals, node);
  35075. borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor);
  35076. }
  35077. node.setVisual('borderColor', borderColor);
  35078. var viewChildren = node.viewChildren;
  35079. if (!viewChildren || !viewChildren.length) {
  35080. thisNodeColor = calculateColor(visuals, node);
  35081. // Apply visual to this node.
  35082. node.setVisual('color', thisNodeColor);
  35083. }
  35084. else {
  35085. var mapping = buildVisualMapping(
  35086. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  35087. );
  35088. // Designate visual to children.
  35089. zrUtil.each(viewChildren, function (child, index) {
  35090. // If higher than viewRoot, only ancestors of viewRoot is needed to visit.
  35091. if (child.depth >= viewRootAncestors.length
  35092. || child === viewRootAncestors[child.depth]
  35093. ) {
  35094. var childVisual = mapVisual(
  35095. nodeModel, visuals, child, index, mapping, seriesModel
  35096. );
  35097. travelTree(
  35098. child, childVisual, levelItemStyles, seriesItemStyleModel,
  35099. viewRootAncestors, seriesModel
  35100. );
  35101. }
  35102. });
  35103. }
  35104. }
  35105. function buildVisuals(
  35106. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  35107. ) {
  35108. var visuals = zrUtil.extend({}, designatedVisual);
  35109. zrUtil.each(['color', 'colorAlpha', 'colorSaturation'], function (visualName) {
  35110. // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel
  35111. var val = nodeItemStyleModel.get(visualName, true); // Ignore parent
  35112. val == null && levelItemStyle && (val = levelItemStyle[visualName]);
  35113. val == null && (val = designatedVisual[visualName]);
  35114. val == null && (val = seriesItemStyleModel.get(visualName));
  35115. val != null && (visuals[visualName] = val);
  35116. });
  35117. return visuals;
  35118. }
  35119. function calculateColor(visuals) {
  35120. var color = getValueVisualDefine(visuals, 'color');
  35121. if (color) {
  35122. var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha');
  35123. var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation');
  35124. if (colorSaturation) {
  35125. color = zrColor.modifyHSL(color, null, null, colorSaturation);
  35126. }
  35127. if (colorAlpha) {
  35128. color = zrColor.modifyAlpha(color, colorAlpha);
  35129. }
  35130. return color;
  35131. }
  35132. }
  35133. function calculateBorderColor(borderColorSaturation, thisNodeColor) {
  35134. return thisNodeColor != null
  35135. ? zrColor.modifyHSL(thisNodeColor, null, null, borderColorSaturation)
  35136. : null;
  35137. }
  35138. function getValueVisualDefine(visuals, name) {
  35139. var value = visuals[name];
  35140. if (value != null && value !== 'none') {
  35141. return value;
  35142. }
  35143. }
  35144. function buildVisualMapping(
  35145. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  35146. ) {
  35147. if (!viewChildren || !viewChildren.length) {
  35148. return;
  35149. }
  35150. var rangeVisual = getRangeVisual(nodeModel, 'color')
  35151. || (
  35152. visuals.color != null
  35153. && visuals.color !== 'none'
  35154. && (
  35155. getRangeVisual(nodeModel, 'colorAlpha')
  35156. || getRangeVisual(nodeModel, 'colorSaturation')
  35157. )
  35158. );
  35159. if (!rangeVisual) {
  35160. return;
  35161. }
  35162. var visualMin = nodeModel.get('visualMin');
  35163. var visualMax = nodeModel.get('visualMax');
  35164. var dataExtent = nodeLayout.dataExtent.slice();
  35165. visualMin != null && visualMin < dataExtent[0] && (dataExtent[0] = visualMin);
  35166. visualMax != null && visualMax > dataExtent[1] && (dataExtent[1] = visualMax);
  35167. var colorMappingBy = nodeModel.get('colorMappingBy');
  35168. var opt = {
  35169. type: rangeVisual.name,
  35170. dataExtent: dataExtent,
  35171. visual: rangeVisual.range
  35172. };
  35173. if (opt.type === 'color'
  35174. && (colorMappingBy === 'index' || colorMappingBy === 'id')
  35175. ) {
  35176. opt.mappingMethod = 'category';
  35177. opt.loop = true;
  35178. // categories is ordinal, so do not set opt.categories.
  35179. }
  35180. else {
  35181. opt.mappingMethod = 'linear';
  35182. }
  35183. var mapping = new VisualMapping(opt);
  35184. mapping.__drColorMappingBy = colorMappingBy;
  35185. return mapping;
  35186. }
  35187. // Notice: If we dont have the attribute 'colorRange', but only use
  35188. // attribute 'color' to represent both concepts of 'colorRange' and 'color',
  35189. // (It means 'colorRange' when 'color' is Array, means 'color' when not array),
  35190. // this problem will be encountered:
  35191. // If a level-1 node dont have children, and its siblings has children,
  35192. // and colorRange is set on level-1, then the node can not be colored.
  35193. // So we separate 'colorRange' and 'color' to different attributes.
  35194. function getRangeVisual(nodeModel, name) {
  35195. // 'colorRange', 'colorARange', 'colorSRange'.
  35196. // If not exsits on this node, fetch from levels and series.
  35197. var range = nodeModel.get(name);
  35198. return (isArray(range) && range.length) ? {name: name, range: range} : null;
  35199. }
  35200. function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) {
  35201. var childVisuals = zrUtil.extend({}, visuals);
  35202. if (mapping) {
  35203. var mappingType = mapping.type;
  35204. var colorMappingBy = mappingType === 'color' && mapping.__drColorMappingBy;
  35205. var value =
  35206. colorMappingBy === 'index'
  35207. ? index
  35208. : colorMappingBy === 'id'
  35209. ? seriesModel.mapIdToIndex(child.getId())
  35210. : child.getValue(nodeModel.get('visualDimension'));
  35211. childVisuals[mappingType] = mapping.mapValueToVisual(value);
  35212. }
  35213. return childVisuals;
  35214. }
  35215. /***/ }),
  35216. /* 206 */
  35217. /***/ (function(module, exports, __webpack_require__) {
  35218. /**
  35219. * @file Visual mapping.
  35220. */
  35221. var zrUtil = __webpack_require__(4);
  35222. var zrColor = __webpack_require__(33);
  35223. var linearMap = __webpack_require__(7).linearMap;
  35224. var each = zrUtil.each;
  35225. var isObject = zrUtil.isObject;
  35226. var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
  35227. /**
  35228. * @param {Object} option
  35229. * @param {string} [option.type] See visualHandlers.
  35230. * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' or 'fixed'
  35231. * @param {Array.<number>=} [option.dataExtent] [minExtent, maxExtent],
  35232. * required when mappingMethod is 'linear'
  35233. * @param {Array.<Object>=} [option.pieceList] [
  35234. * {value: someValue},
  35235. * {interval: [min1, max1], visual: {...}},
  35236. * {interval: [min2, max2]}
  35237. * ],
  35238. * required when mappingMethod is 'piecewise'.
  35239. * Visual for only each piece can be specified.
  35240. * @param {Array.<string|Object>=} [option.categories] ['cate1', 'cate2']
  35241. * required when mappingMethod is 'category'.
  35242. * If no option.categories, categories is set
  35243. * as [0, 1, 2, ...].
  35244. * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'.
  35245. * @param {(Array|Object|*)} [option.visual] Visual data.
  35246. * when mappingMethod is 'category',
  35247. * visual data can be array or object
  35248. * (like: {cate1: '#222', none: '#fff'})
  35249. * or primary types (which represents
  35250. * defualt category visual), otherwise visual
  35251. * can be array or primary (which will be
  35252. * normalized to array).
  35253. *
  35254. */
  35255. var VisualMapping = function (option) {
  35256. var mappingMethod = option.mappingMethod;
  35257. var visualType = option.type;
  35258. /**
  35259. * @readOnly
  35260. * @type {Object}
  35261. */
  35262. var thisOption = this.option = zrUtil.clone(option);
  35263. /**
  35264. * @readOnly
  35265. * @type {string}
  35266. */
  35267. this.type = visualType;
  35268. /**
  35269. * @readOnly
  35270. * @type {string}
  35271. */
  35272. this.mappingMethod = mappingMethod;
  35273. /**
  35274. * @private
  35275. * @type {Function}
  35276. */
  35277. this._normalizeData = normalizers[mappingMethod];
  35278. var visualHandler = visualHandlers[visualType];
  35279. /**
  35280. * @public
  35281. * @type {Function}
  35282. */
  35283. this.applyVisual = visualHandler.applyVisual;
  35284. /**
  35285. * @public
  35286. * @type {Function}
  35287. */
  35288. this.getColorMapper = visualHandler.getColorMapper;
  35289. /**
  35290. * @private
  35291. * @type {Function}
  35292. */
  35293. this._doMap = visualHandler._doMap[mappingMethod];
  35294. if (mappingMethod === 'piecewise') {
  35295. normalizeVisualRange(thisOption);
  35296. preprocessForPiecewise(thisOption);
  35297. }
  35298. else if (mappingMethod === 'category') {
  35299. thisOption.categories
  35300. ? preprocessForSpecifiedCategory(thisOption)
  35301. // categories is ordinal when thisOption.categories not specified,
  35302. // which need no more preprocess except normalize visual.
  35303. : normalizeVisualRange(thisOption, true);
  35304. }
  35305. else { // mappingMethod === 'linear' or 'fixed'
  35306. zrUtil.assert(mappingMethod !== 'linear' || thisOption.dataExtent);
  35307. normalizeVisualRange(thisOption);
  35308. }
  35309. };
  35310. VisualMapping.prototype = {
  35311. constructor: VisualMapping,
  35312. mapValueToVisual: function (value) {
  35313. var normalized = this._normalizeData(value);
  35314. return this._doMap(normalized, value);
  35315. },
  35316. getNormalizer: function () {
  35317. return zrUtil.bind(this._normalizeData, this);
  35318. }
  35319. };
  35320. var visualHandlers = VisualMapping.visualHandlers = {
  35321. color: {
  35322. applyVisual: makeApplyVisual('color'),
  35323. /**
  35324. * Create a mapper function
  35325. * @return {Function}
  35326. */
  35327. getColorMapper: function () {
  35328. var thisOption = this.option;
  35329. return zrUtil.bind(
  35330. thisOption.mappingMethod === 'category'
  35331. ? function (value, isNormalized) {
  35332. !isNormalized && (value = this._normalizeData(value));
  35333. return doMapCategory.call(this, value);
  35334. }
  35335. : function (value, isNormalized, out) {
  35336. // If output rgb array
  35337. // which will be much faster and useful in pixel manipulation
  35338. var returnRGBArray = !!out;
  35339. !isNormalized && (value = this._normalizeData(value));
  35340. out = zrColor.fastLerp(value, thisOption.parsedVisual, out);
  35341. return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
  35342. },
  35343. this
  35344. );
  35345. },
  35346. _doMap: {
  35347. linear: function (normalized) {
  35348. return zrColor.stringify(
  35349. zrColor.fastLerp(normalized, this.option.parsedVisual),
  35350. 'rgba'
  35351. );
  35352. },
  35353. category: doMapCategory,
  35354. piecewise: function (normalized, value) {
  35355. var result = getSpecifiedVisual.call(this, value);
  35356. if (result == null) {
  35357. result = zrColor.stringify(
  35358. zrColor.fastLerp(normalized, this.option.parsedVisual),
  35359. 'rgba'
  35360. );
  35361. }
  35362. return result;
  35363. },
  35364. fixed: doMapFixed
  35365. }
  35366. },
  35367. colorHue: makePartialColorVisualHandler(function (color, value) {
  35368. return zrColor.modifyHSL(color, value);
  35369. }),
  35370. colorSaturation: makePartialColorVisualHandler(function (color, value) {
  35371. return zrColor.modifyHSL(color, null, value);
  35372. }),
  35373. colorLightness: makePartialColorVisualHandler(function (color, value) {
  35374. return zrColor.modifyHSL(color, null, null, value);
  35375. }),
  35376. colorAlpha: makePartialColorVisualHandler(function (color, value) {
  35377. return zrColor.modifyAlpha(color, value);
  35378. }),
  35379. opacity: {
  35380. applyVisual: makeApplyVisual('opacity'),
  35381. _doMap: makeDoMap([0, 1])
  35382. },
  35383. symbol: {
  35384. applyVisual: function (value, getter, setter) {
  35385. var symbolCfg = this.mapValueToVisual(value);
  35386. if (zrUtil.isString(symbolCfg)) {
  35387. setter('symbol', symbolCfg);
  35388. }
  35389. else if (isObject(symbolCfg)) {
  35390. for (var name in symbolCfg) {
  35391. if (symbolCfg.hasOwnProperty(name)) {
  35392. setter(name, symbolCfg[name]);
  35393. }
  35394. }
  35395. }
  35396. },
  35397. _doMap: {
  35398. linear: doMapToArray,
  35399. category: doMapCategory,
  35400. piecewise: function (normalized, value) {
  35401. var result = getSpecifiedVisual.call(this, value);
  35402. if (result == null) {
  35403. result = doMapToArray.call(this, normalized);
  35404. }
  35405. return result;
  35406. },
  35407. fixed: doMapFixed
  35408. }
  35409. },
  35410. symbolSize: {
  35411. applyVisual: makeApplyVisual('symbolSize'),
  35412. _doMap: makeDoMap([0, 1])
  35413. }
  35414. };
  35415. function preprocessForPiecewise(thisOption) {
  35416. var pieceList = thisOption.pieceList;
  35417. thisOption.hasSpecialVisual = false;
  35418. zrUtil.each(pieceList, function (piece, index) {
  35419. piece.originIndex = index;
  35420. // piece.visual is "result visual value" but not
  35421. // a visual range, so it does not need to be normalized.
  35422. if (piece.visual != null) {
  35423. thisOption.hasSpecialVisual = true;
  35424. }
  35425. });
  35426. }
  35427. function preprocessForSpecifiedCategory(thisOption) {
  35428. // Hash categories.
  35429. var categories = thisOption.categories;
  35430. var visual = thisOption.visual;
  35431. var categoryMap = thisOption.categoryMap = {};
  35432. each(categories, function (cate, index) {
  35433. categoryMap[cate] = index;
  35434. });
  35435. // Process visual map input.
  35436. if (!zrUtil.isArray(visual)) {
  35437. var visualArr = [];
  35438. if (zrUtil.isObject(visual)) {
  35439. each(visual, function (v, cate) {
  35440. var index = categoryMap[cate];
  35441. visualArr[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v;
  35442. });
  35443. }
  35444. else { // Is primary type, represents default visual.
  35445. visualArr[CATEGORY_DEFAULT_VISUAL_INDEX] = visual;
  35446. }
  35447. visual = setVisualToOption(thisOption, visualArr);
  35448. }
  35449. // Remove categories that has no visual,
  35450. // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX.
  35451. for (var i = categories.length - 1; i >= 0; i--) {
  35452. if (visual[i] == null) {
  35453. delete categoryMap[categories[i]];
  35454. categories.pop();
  35455. }
  35456. }
  35457. }
  35458. function normalizeVisualRange(thisOption, isCategory) {
  35459. var visual = thisOption.visual;
  35460. var visualArr = [];
  35461. if (zrUtil.isObject(visual)) {
  35462. each(visual, function (v) {
  35463. visualArr.push(v);
  35464. });
  35465. }
  35466. else if (visual != null) {
  35467. visualArr.push(visual);
  35468. }
  35469. var doNotNeedPair = {color: 1, symbol: 1};
  35470. if (!isCategory
  35471. && visualArr.length === 1
  35472. && !doNotNeedPair.hasOwnProperty(thisOption.type)
  35473. ) {
  35474. // Do not care visualArr.length === 0, which is illegal.
  35475. visualArr[1] = visualArr[0];
  35476. }
  35477. setVisualToOption(thisOption, visualArr);
  35478. }
  35479. function makePartialColorVisualHandler(applyValue) {
  35480. return {
  35481. applyVisual: function (value, getter, setter) {
  35482. value = this.mapValueToVisual(value);
  35483. // Must not be array value
  35484. setter('color', applyValue(getter('color'), value));
  35485. },
  35486. _doMap: makeDoMap([0, 1])
  35487. };
  35488. }
  35489. function doMapToArray(normalized) {
  35490. var visual = this.option.visual;
  35491. return visual[
  35492. Math.round(linearMap(normalized, [0, 1], [0, visual.length - 1], true))
  35493. ] || {};
  35494. }
  35495. function makeApplyVisual(visualType) {
  35496. return function (value, getter, setter) {
  35497. setter(visualType, this.mapValueToVisual(value));
  35498. };
  35499. }
  35500. function doMapCategory(normalized) {
  35501. var visual = this.option.visual;
  35502. return visual[
  35503. (this.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX)
  35504. ? normalized % visual.length
  35505. : normalized
  35506. ];
  35507. }
  35508. function doMapFixed() {
  35509. return this.option.visual[0];
  35510. }
  35511. function makeDoMap(sourceExtent) {
  35512. return {
  35513. linear: function (normalized) {
  35514. return linearMap(normalized, sourceExtent, this.option.visual, true);
  35515. },
  35516. category: doMapCategory,
  35517. piecewise: function (normalized, value) {
  35518. var result = getSpecifiedVisual.call(this, value);
  35519. if (result == null) {
  35520. result = linearMap(normalized, sourceExtent, this.option.visual, true);
  35521. }
  35522. return result;
  35523. },
  35524. fixed: doMapFixed
  35525. };
  35526. }
  35527. function getSpecifiedVisual(value) {
  35528. var thisOption = this.option;
  35529. var pieceList = thisOption.pieceList;
  35530. if (thisOption.hasSpecialVisual) {
  35531. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList);
  35532. var piece = pieceList[pieceIndex];
  35533. if (piece && piece.visual) {
  35534. return piece.visual[this.type];
  35535. }
  35536. }
  35537. }
  35538. function setVisualToOption(thisOption, visualArr) {
  35539. thisOption.visual = visualArr;
  35540. if (thisOption.type === 'color') {
  35541. thisOption.parsedVisual = zrUtil.map(visualArr, function (item) {
  35542. return zrColor.parse(item);
  35543. });
  35544. }
  35545. return visualArr;
  35546. }
  35547. /**
  35548. * Normalizers by mapping methods.
  35549. */
  35550. var normalizers = {
  35551. linear: function (value) {
  35552. return linearMap(value, this.option.dataExtent, [0, 1], true);
  35553. },
  35554. piecewise: function (value) {
  35555. var pieceList = this.option.pieceList;
  35556. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList, true);
  35557. if (pieceIndex != null) {
  35558. return linearMap(pieceIndex, [0, pieceList.length - 1], [0, 1], true);
  35559. }
  35560. },
  35561. category: function (value) {
  35562. var index = this.option.categories
  35563. ? this.option.categoryMap[value]
  35564. : value; // ordinal
  35565. return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index;
  35566. },
  35567. fixed: zrUtil.noop
  35568. };
  35569. /**
  35570. * List available visual types.
  35571. *
  35572. * @public
  35573. * @return {Array.<string>}
  35574. */
  35575. VisualMapping.listVisualTypes = function () {
  35576. var visualTypes = [];
  35577. zrUtil.each(visualHandlers, function (handler, key) {
  35578. visualTypes.push(key);
  35579. });
  35580. return visualTypes;
  35581. };
  35582. /**
  35583. * @public
  35584. */
  35585. VisualMapping.addVisualHandler = function (name, handler) {
  35586. visualHandlers[name] = handler;
  35587. };
  35588. /**
  35589. * @public
  35590. */
  35591. VisualMapping.isValidType = function (visualType) {
  35592. return visualHandlers.hasOwnProperty(visualType);
  35593. };
  35594. /**
  35595. * Convinent method.
  35596. * Visual can be Object or Array or primary type.
  35597. *
  35598. * @public
  35599. */
  35600. VisualMapping.eachVisual = function (visual, callback, context) {
  35601. if (zrUtil.isObject(visual)) {
  35602. zrUtil.each(visual, callback, context);
  35603. }
  35604. else {
  35605. callback.call(context, visual);
  35606. }
  35607. };
  35608. VisualMapping.mapVisual = function (visual, callback, context) {
  35609. var isPrimary;
  35610. var newVisual = zrUtil.isArray(visual)
  35611. ? []
  35612. : zrUtil.isObject(visual)
  35613. ? {}
  35614. : (isPrimary = true, null);
  35615. VisualMapping.eachVisual(visual, function (v, key) {
  35616. var newVal = callback.call(context, v, key);
  35617. isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal);
  35618. });
  35619. return newVisual;
  35620. };
  35621. /**
  35622. * @public
  35623. * @param {Object} obj
  35624. * @return {Object} new object containers visual values.
  35625. * If no visuals, return null.
  35626. */
  35627. VisualMapping.retrieveVisuals = function (obj) {
  35628. var ret = {};
  35629. var hasVisual;
  35630. obj && each(visualHandlers, function (h, visualType) {
  35631. if (obj.hasOwnProperty(visualType)) {
  35632. ret[visualType] = obj[visualType];
  35633. hasVisual = true;
  35634. }
  35635. });
  35636. return hasVisual ? ret : null;
  35637. };
  35638. /**
  35639. * Give order to visual types, considering colorSaturation, colorAlpha depends on color.
  35640. *
  35641. * @public
  35642. * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...}
  35643. * IF Array, like: ['color', 'symbol', 'colorSaturation']
  35644. * @return {Array.<string>} Sorted visual types.
  35645. */
  35646. VisualMapping.prepareVisualTypes = function (visualTypes) {
  35647. if (isObject(visualTypes)) {
  35648. var types = [];
  35649. each(visualTypes, function (item, type) {
  35650. types.push(type);
  35651. });
  35652. visualTypes = types;
  35653. }
  35654. else if (zrUtil.isArray(visualTypes)) {
  35655. visualTypes = visualTypes.slice();
  35656. }
  35657. else {
  35658. return [];
  35659. }
  35660. visualTypes.sort(function (type1, type2) {
  35661. // color should be front of colorSaturation, colorAlpha, ...
  35662. // symbol and symbolSize do not matter.
  35663. return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0)
  35664. ? 1 : -1;
  35665. });
  35666. return visualTypes;
  35667. };
  35668. /**
  35669. * 'color', 'colorSaturation', 'colorAlpha', ... are depends on 'color'.
  35670. * Other visuals are only depends on themself.
  35671. *
  35672. * @public
  35673. * @param {string} visualType1
  35674. * @param {string} visualType2
  35675. * @return {boolean}
  35676. */
  35677. VisualMapping.dependsOn = function (visualType1, visualType2) {
  35678. return visualType2 === 'color'
  35679. ? !!(visualType1 && visualType1.indexOf(visualType2) === 0)
  35680. : visualType1 === visualType2;
  35681. };
  35682. /**
  35683. * @param {number} value
  35684. * @param {Array.<Object>} pieceList [{value: ..., interval: [min, max]}, ...]
  35685. * Always from small to big.
  35686. * @param {boolean} [findClosestWhenOutside=false]
  35687. * @return {number} index
  35688. */
  35689. VisualMapping.findPieceIndex = function (value, pieceList, findClosestWhenOutside) {
  35690. var possibleI;
  35691. var abs = Infinity;
  35692. // value has the higher priority.
  35693. for (var i = 0, len = pieceList.length; i < len; i++) {
  35694. var pieceValue = pieceList[i].value;
  35695. if (pieceValue != null) {
  35696. if (pieceValue === value
  35697. // FIXME
  35698. // It is supposed to compare value according to value type of dimension,
  35699. // but currently value type can exactly be string or number.
  35700. // Compromise for numeric-like string (like '12'), especially
  35701. // in the case that visualMap.categories is ['22', '33'].
  35702. || (typeof pieceValue === 'string' && pieceValue === value + '')
  35703. ) {
  35704. return i;
  35705. }
  35706. findClosestWhenOutside && updatePossible(pieceValue, i);
  35707. }
  35708. }
  35709. for (var i = 0, len = pieceList.length; i < len; i++) {
  35710. var piece = pieceList[i];
  35711. var interval = piece.interval;
  35712. var close = piece.close;
  35713. if (interval) {
  35714. if (interval[0] === -Infinity) {
  35715. if (littleThan(close[1], value, interval[1])) {
  35716. return i;
  35717. }
  35718. }
  35719. else if (interval[1] === Infinity) {
  35720. if (littleThan(close[0], interval[0], value)) {
  35721. return i;
  35722. }
  35723. }
  35724. else if (
  35725. littleThan(close[0], interval[0], value)
  35726. && littleThan(close[1], value, interval[1])
  35727. ) {
  35728. return i;
  35729. }
  35730. findClosestWhenOutside && updatePossible(interval[0], i);
  35731. findClosestWhenOutside && updatePossible(interval[1], i);
  35732. }
  35733. }
  35734. if (findClosestWhenOutside) {
  35735. return value === Infinity
  35736. ? pieceList.length - 1
  35737. : value === -Infinity
  35738. ? 0
  35739. : possibleI;
  35740. }
  35741. function updatePossible(val, index) {
  35742. var newAbs = Math.abs(val - value);
  35743. if (newAbs < abs) {
  35744. abs = newAbs;
  35745. possibleI = index;
  35746. }
  35747. }
  35748. };
  35749. function littleThan(close, a, b) {
  35750. return close ? a <= b : a < b;
  35751. }
  35752. module.exports = VisualMapping;
  35753. /***/ }),
  35754. /* 207 */
  35755. /***/ (function(module, exports, __webpack_require__) {
  35756. var zrUtil = __webpack_require__(4);
  35757. var numberUtil = __webpack_require__(7);
  35758. var layout = __webpack_require__(74);
  35759. var helper = __webpack_require__(200);
  35760. var BoundingRect = __webpack_require__(9);
  35761. var helper = __webpack_require__(200);
  35762. var mathMax = Math.max;
  35763. var mathMin = Math.min;
  35764. var parsePercent = numberUtil.parsePercent;
  35765. var retrieveValue = zrUtil.retrieve;
  35766. var each = zrUtil.each;
  35767. var PATH_BORDER_WIDTH = ['itemStyle', 'normal', 'borderWidth'];
  35768. var PATH_GAP_WIDTH = ['itemStyle', 'normal', 'gapWidth'];
  35769. var PATH_UPPER_LABEL_SHOW = ['upperLabel', 'normal', 'show'];
  35770. var PATH_UPPER_LABEL_HEIGHT = ['upperLabel', 'normal', 'height'];
  35771. /**
  35772. * @public
  35773. */
  35774. function update(ecModel, api, payload) {
  35775. // Layout result in each node:
  35776. // {x, y, width, height, area, borderWidth}
  35777. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  35778. ecModel.eachComponent(condition, function (seriesModel) {
  35779. var ecWidth = api.getWidth();
  35780. var ecHeight = api.getHeight();
  35781. var seriesOption = seriesModel.option;
  35782. var layoutInfo = layout.getLayoutRect(
  35783. seriesModel.getBoxLayoutParams(),
  35784. {
  35785. width: api.getWidth(),
  35786. height: api.getHeight()
  35787. }
  35788. );
  35789. var size = seriesOption.size || []; // Compatible with ec2.
  35790. var containerWidth = parsePercent(
  35791. retrieveValue(layoutInfo.width, size[0]),
  35792. ecWidth
  35793. );
  35794. var containerHeight = parsePercent(
  35795. retrieveValue(layoutInfo.height, size[1]),
  35796. ecHeight
  35797. );
  35798. // Fetch payload info.
  35799. var payloadType = payload && payload.type;
  35800. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  35801. var rootRect = (payloadType === 'treemapRender' || payloadType === 'treemapMove')
  35802. ? payload.rootRect : null;
  35803. var viewRoot = seriesModel.getViewRoot();
  35804. var viewAbovePath = helper.getPathToRoot(viewRoot);
  35805. if (payloadType !== 'treemapMove') {
  35806. var rootSize = payloadType === 'treemapZoomToNode'
  35807. ? estimateRootSize(
  35808. seriesModel, targetInfo, viewRoot, containerWidth, containerHeight
  35809. )
  35810. : rootRect
  35811. ? [rootRect.width, rootRect.height]
  35812. : [containerWidth, containerHeight];
  35813. var sort = seriesOption.sort;
  35814. if (sort && sort !== 'asc' && sort !== 'desc') {
  35815. sort = 'desc';
  35816. }
  35817. var options = {
  35818. squareRatio: seriesOption.squareRatio,
  35819. sort: sort,
  35820. leafDepth: seriesOption.leafDepth
  35821. };
  35822. // layout should be cleared because using updateView but not update.
  35823. viewRoot.hostTree.clearLayouts();
  35824. // TODO
  35825. // optimize: if out of view clip, do not layout.
  35826. // But take care that if do not render node out of view clip,
  35827. // how to calculate start po
  35828. var viewRootLayout = {
  35829. x: 0, y: 0,
  35830. width: rootSize[0], height: rootSize[1],
  35831. area: rootSize[0] * rootSize[1]
  35832. };
  35833. viewRoot.setLayout(viewRootLayout);
  35834. squarify(viewRoot, options, false, 0);
  35835. // Supplement layout.
  35836. var viewRootLayout = viewRoot.getLayout();
  35837. each(viewAbovePath, function (node, index) {
  35838. var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
  35839. node.setLayout(zrUtil.extend(
  35840. {dataExtent: [childValue, childValue], borderWidth: 0, upperHeight: 0},
  35841. viewRootLayout
  35842. ));
  35843. });
  35844. }
  35845. var treeRoot = seriesModel.getData().tree.root;
  35846. treeRoot.setLayout(
  35847. calculateRootPosition(layoutInfo, rootRect, targetInfo),
  35848. true
  35849. );
  35850. seriesModel.setLayoutInfo(layoutInfo);
  35851. // FIXME
  35852. // 现在没有clip功能,暂时取ec高宽。
  35853. prunning(
  35854. treeRoot,
  35855. // Transform to base element coordinate system.
  35856. new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight),
  35857. viewAbovePath,
  35858. viewRoot,
  35859. 0
  35860. );
  35861. });
  35862. }
  35863. /**
  35864. * Layout treemap with squarify algorithm.
  35865. * @see https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf
  35866. * @see https://github.com/mbostock/d3/blob/master/src/layout/treemap.js
  35867. *
  35868. * @protected
  35869. * @param {module:echarts/data/Tree~TreeNode} node
  35870. * @param {Object} options
  35871. * @param {string} options.sort 'asc' or 'desc'
  35872. * @param {number} options.squareRatio
  35873. * @param {boolean} hideChildren
  35874. * @param {number} depth
  35875. */
  35876. function squarify(node, options, hideChildren, depth) {
  35877. var width;
  35878. var height;
  35879. if (node.isRemoved()) {
  35880. return;
  35881. }
  35882. var thisLayout = node.getLayout();
  35883. width = thisLayout.width;
  35884. height = thisLayout.height;
  35885. // Considering border and gap
  35886. var nodeModel = node.getModel();
  35887. var borderWidth = nodeModel.get(PATH_BORDER_WIDTH);
  35888. var halfGapWidth = nodeModel.get(PATH_GAP_WIDTH) / 2;
  35889. var upperLabelHeight = getUpperLabelHeight(nodeModel);
  35890. var upperHeight = Math.max(borderWidth, upperLabelHeight);
  35891. var layoutOffset = borderWidth - halfGapWidth;
  35892. var layoutOffsetUpper = upperHeight - halfGapWidth;
  35893. var nodeModel = node.getModel();
  35894. node.setLayout({
  35895. borderWidth: borderWidth,
  35896. upperHeight: upperHeight,
  35897. upperLabelHeight: upperLabelHeight
  35898. }, true);
  35899. width = mathMax(width - 2 * layoutOffset, 0);
  35900. height = mathMax(height - layoutOffset - layoutOffsetUpper, 0);
  35901. var totalArea = width * height;
  35902. var viewChildren = initChildren(
  35903. node, nodeModel, totalArea, options, hideChildren, depth
  35904. );
  35905. if (!viewChildren.length) {
  35906. return;
  35907. }
  35908. var rect = {x: layoutOffset, y: layoutOffsetUpper, width: width, height: height};
  35909. var rowFixedLength = mathMin(width, height);
  35910. var best = Infinity; // the best row score so far
  35911. var row = [];
  35912. row.area = 0;
  35913. for (var i = 0, len = viewChildren.length; i < len;) {
  35914. var child = viewChildren[i];
  35915. row.push(child);
  35916. row.area += child.getLayout().area;
  35917. var score = worst(row, rowFixedLength, options.squareRatio);
  35918. // continue with this orientation
  35919. if (score <= best) {
  35920. i++;
  35921. best = score;
  35922. }
  35923. // abort, and try a different orientation
  35924. else {
  35925. row.area -= row.pop().getLayout().area;
  35926. position(row, rowFixedLength, rect, halfGapWidth, false);
  35927. rowFixedLength = mathMin(rect.width, rect.height);
  35928. row.length = row.area = 0;
  35929. best = Infinity;
  35930. }
  35931. }
  35932. if (row.length) {
  35933. position(row, rowFixedLength, rect, halfGapWidth, true);
  35934. }
  35935. if (!hideChildren) {
  35936. var childrenVisibleMin = nodeModel.get('childrenVisibleMin');
  35937. if (childrenVisibleMin != null && totalArea < childrenVisibleMin) {
  35938. hideChildren = true;
  35939. }
  35940. }
  35941. for (var i = 0, len = viewChildren.length; i < len; i++) {
  35942. squarify(viewChildren[i], options, hideChildren, depth + 1);
  35943. }
  35944. }
  35945. /**
  35946. * Set area to each child, and calculate data extent for visual coding.
  35947. */
  35948. function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
  35949. var viewChildren = node.children || [];
  35950. var orderBy = options.sort;
  35951. orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
  35952. var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth;
  35953. // leafDepth has higher priority.
  35954. if (hideChildren && !overLeafDepth) {
  35955. return (node.viewChildren = []);
  35956. }
  35957. // Sort children, order by desc.
  35958. viewChildren = zrUtil.filter(viewChildren, function (child) {
  35959. return !child.isRemoved();
  35960. });
  35961. sort(viewChildren, orderBy);
  35962. var info = statistic(nodeModel, viewChildren, orderBy);
  35963. if (info.sum === 0) {
  35964. return (node.viewChildren = []);
  35965. }
  35966. info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
  35967. if (info.sum === 0) {
  35968. return (node.viewChildren = []);
  35969. }
  35970. // Set area to each child.
  35971. for (var i = 0, len = viewChildren.length; i < len; i++) {
  35972. var area = viewChildren[i].getValue() / info.sum * totalArea;
  35973. // Do not use setLayout({...}, true), because it is needed to clear last layout.
  35974. viewChildren[i].setLayout({area: area});
  35975. }
  35976. if (overLeafDepth) {
  35977. viewChildren.length && node.setLayout({isLeafRoot: true}, true);
  35978. viewChildren.length = 0;
  35979. }
  35980. node.viewChildren = viewChildren;
  35981. node.setLayout({dataExtent: info.dataExtent}, true);
  35982. return viewChildren;
  35983. }
  35984. /**
  35985. * Consider 'visibleMin'. Modify viewChildren and get new sum.
  35986. */
  35987. function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
  35988. // visibleMin is not supported yet when no option.sort.
  35989. if (!orderBy) {
  35990. return sum;
  35991. }
  35992. var visibleMin = nodeModel.get('visibleMin');
  35993. var len = orderedChildren.length;
  35994. var deletePoint = len;
  35995. // Always travel from little value to big value.
  35996. for (var i = len - 1; i >= 0; i--) {
  35997. var value = orderedChildren[
  35998. orderBy === 'asc' ? len - i - 1 : i
  35999. ].getValue();
  36000. if (value / sum * totalArea < visibleMin) {
  36001. deletePoint = i;
  36002. sum -= value;
  36003. }
  36004. }
  36005. orderBy === 'asc'
  36006. ? orderedChildren.splice(0, len - deletePoint)
  36007. : orderedChildren.splice(deletePoint, len - deletePoint);
  36008. return sum;
  36009. }
  36010. /**
  36011. * Sort
  36012. */
  36013. function sort(viewChildren, orderBy) {
  36014. if (orderBy) {
  36015. viewChildren.sort(function (a, b) {
  36016. var diff = orderBy === 'asc'
  36017. ? a.getValue() - b.getValue() : b.getValue() - a.getValue();
  36018. return diff === 0
  36019. ? (orderBy === 'asc'
  36020. ? a.dataIndex - b.dataIndex : b.dataIndex - a.dataIndex
  36021. )
  36022. : diff;
  36023. });
  36024. }
  36025. return viewChildren;
  36026. }
  36027. /**
  36028. * Statistic
  36029. */
  36030. function statistic(nodeModel, children, orderBy) {
  36031. // Calculate sum.
  36032. var sum = 0;
  36033. for (var i = 0, len = children.length; i < len; i++) {
  36034. sum += children[i].getValue();
  36035. }
  36036. // Statistic data extent for latter visual coding.
  36037. // Notice: data extent should be calculate based on raw children
  36038. // but not filtered view children, otherwise visual mapping will not
  36039. // be stable when zoom (where children is filtered by visibleMin).
  36040. var dimension = nodeModel.get('visualDimension');
  36041. var dataExtent;
  36042. // The same as area dimension.
  36043. if (!children || !children.length) {
  36044. dataExtent = [NaN, NaN];
  36045. }
  36046. else if (dimension === 'value' && orderBy) {
  36047. dataExtent = [
  36048. children[children.length - 1].getValue(),
  36049. children[0].getValue()
  36050. ];
  36051. orderBy === 'asc' && dataExtent.reverse();
  36052. }
  36053. // Other dimension.
  36054. else {
  36055. var dataExtent = [Infinity, -Infinity];
  36056. each(children, function (child) {
  36057. var value = child.getValue(dimension);
  36058. value < dataExtent[0] && (dataExtent[0] = value);
  36059. value > dataExtent[1] && (dataExtent[1] = value);
  36060. });
  36061. }
  36062. return {sum: sum, dataExtent: dataExtent};
  36063. }
  36064. /**
  36065. * Computes the score for the specified row,
  36066. * as the worst aspect ratio.
  36067. */
  36068. function worst(row, rowFixedLength, ratio) {
  36069. var areaMax = 0;
  36070. var areaMin = Infinity;
  36071. for (var i = 0, area, len = row.length; i < len; i++) {
  36072. area = row[i].getLayout().area;
  36073. if (area) {
  36074. area < areaMin && (areaMin = area);
  36075. area > areaMax && (areaMax = area);
  36076. }
  36077. }
  36078. var squareArea = row.area * row.area;
  36079. var f = rowFixedLength * rowFixedLength * ratio;
  36080. return squareArea
  36081. ? mathMax(
  36082. (f * areaMax) / squareArea,
  36083. squareArea / (f * areaMin)
  36084. )
  36085. : Infinity;
  36086. }
  36087. /**
  36088. * Positions the specified row of nodes. Modifies `rect`.
  36089. */
  36090. function position(row, rowFixedLength, rect, halfGapWidth, flush) {
  36091. // When rowFixedLength === rect.width,
  36092. // it is horizontal subdivision,
  36093. // rowFixedLength is the width of the subdivision,
  36094. // rowOtherLength is the height of the subdivision,
  36095. // and nodes will be positioned from left to right.
  36096. // wh[idx0WhenH] means: when horizontal,
  36097. // wh[idx0WhenH] => wh[0] => 'width'.
  36098. // xy[idx1WhenH] => xy[1] => 'y'.
  36099. var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
  36100. var idx1WhenH = 1 - idx0WhenH;
  36101. var xy = ['x', 'y'];
  36102. var wh = ['width', 'height'];
  36103. var last = rect[xy[idx0WhenH]];
  36104. var rowOtherLength = rowFixedLength
  36105. ? row.area / rowFixedLength : 0;
  36106. if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
  36107. rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
  36108. }
  36109. for (var i = 0, rowLen = row.length; i < rowLen; i++) {
  36110. var node = row[i];
  36111. var nodeLayout = {};
  36112. var step = rowOtherLength
  36113. ? node.getLayout().area / rowOtherLength : 0;
  36114. var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);
  36115. // We use Math.max/min to avoid negative width/height when considering gap width.
  36116. var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
  36117. var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
  36118. var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);
  36119. nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
  36120. nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);
  36121. last += modWH;
  36122. node.setLayout(nodeLayout, true);
  36123. }
  36124. rect[xy[idx1WhenH]] += rowOtherLength;
  36125. rect[wh[idx1WhenH]] -= rowOtherLength;
  36126. }
  36127. // Return [containerWidth, containerHeight] as defualt.
  36128. function estimateRootSize(seriesModel, targetInfo, viewRoot, containerWidth, containerHeight) {
  36129. // If targetInfo.node exists, we zoom to the node,
  36130. // so estimate whold width and heigth by target node.
  36131. var currNode = (targetInfo || {}).node;
  36132. var defaultSize = [containerWidth, containerHeight];
  36133. if (!currNode || currNode === viewRoot) {
  36134. return defaultSize;
  36135. }
  36136. var parent;
  36137. var viewArea = containerWidth * containerHeight;
  36138. var area = viewArea * seriesModel.option.zoomToNodeRatio;
  36139. while (parent = currNode.parentNode) { // jshint ignore:line
  36140. var sum = 0;
  36141. var siblings = parent.children;
  36142. for (var i = 0, len = siblings.length; i < len; i++) {
  36143. sum += siblings[i].getValue();
  36144. }
  36145. var currNodeValue = currNode.getValue();
  36146. if (currNodeValue === 0) {
  36147. return defaultSize;
  36148. }
  36149. area *= sum / currNodeValue;
  36150. // Considering border, suppose aspect ratio is 1.
  36151. var parentModel = parent.getModel();
  36152. var borderWidth = parentModel.get(PATH_BORDER_WIDTH);
  36153. var upperHeight = Math.max(borderWidth, getUpperLabelHeight(parentModel, borderWidth));
  36154. area += 4 * borderWidth * borderWidth
  36155. + (3 * borderWidth + upperHeight) * Math.pow(area, 0.5);
  36156. area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER);
  36157. currNode = parent;
  36158. }
  36159. area < viewArea && (area = viewArea);
  36160. var scale = Math.pow(area / viewArea, 0.5);
  36161. return [containerWidth * scale, containerHeight * scale];
  36162. }
  36163. // Root postion base on coord of containerGroup
  36164. function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
  36165. if (rootRect) {
  36166. return {x: rootRect.x, y: rootRect.y};
  36167. }
  36168. var defaultPosition = {x: 0, y: 0};
  36169. if (!targetInfo) {
  36170. return defaultPosition;
  36171. }
  36172. // If targetInfo is fetched by 'retrieveTargetInfo',
  36173. // old tree and new tree are the same tree,
  36174. // so the node still exists and we can visit it.
  36175. var targetNode = targetInfo.node;
  36176. var layout = targetNode.getLayout();
  36177. if (!layout) {
  36178. return defaultPosition;
  36179. }
  36180. // Transform coord from local to container.
  36181. var targetCenter = [layout.width / 2, layout.height / 2];
  36182. var node = targetNode;
  36183. while (node) {
  36184. var nodeLayout = node.getLayout();
  36185. targetCenter[0] += nodeLayout.x;
  36186. targetCenter[1] += nodeLayout.y;
  36187. node = node.parentNode;
  36188. }
  36189. return {
  36190. x: layoutInfo.width / 2 - targetCenter[0],
  36191. y: layoutInfo.height / 2 - targetCenter[1]
  36192. };
  36193. }
  36194. // Mark nodes visible for prunning when visual coding and rendering.
  36195. // Prunning depends on layout and root position, so we have to do it after layout.
  36196. function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
  36197. var nodeLayout = node.getLayout();
  36198. var nodeInViewAbovePath = viewAbovePath[depth];
  36199. var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
  36200. if (
  36201. (nodeInViewAbovePath && !isAboveViewRoot)
  36202. || (depth === viewAbovePath.length && node !== viewRoot)
  36203. ) {
  36204. return;
  36205. }
  36206. node.setLayout({
  36207. // isInView means: viewRoot sub tree + viewAbovePath
  36208. isInView: true,
  36209. // invisible only means: outside view clip so that the node can not
  36210. // see but still layout for animation preparation but not render.
  36211. invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
  36212. isAboveViewRoot: isAboveViewRoot
  36213. }, true);
  36214. // Transform to child coordinate.
  36215. var childClipRect = new BoundingRect(
  36216. clipRect.x - nodeLayout.x,
  36217. clipRect.y - nodeLayout.y,
  36218. clipRect.width,
  36219. clipRect.height
  36220. );
  36221. each(node.viewChildren || [], function (child) {
  36222. prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
  36223. });
  36224. }
  36225. function getUpperLabelHeight(model) {
  36226. return model.get(PATH_UPPER_LABEL_SHOW) ? model.get(PATH_UPPER_LABEL_HEIGHT) : 0;
  36227. }
  36228. module.exports = update;
  36229. /***/ }),
  36230. /* 208 */
  36231. /***/ (function(module, exports, __webpack_require__) {
  36232. var echarts = __webpack_require__(1);
  36233. var zrUtil = __webpack_require__(4);
  36234. __webpack_require__(209);
  36235. __webpack_require__(212);
  36236. __webpack_require__(217);
  36237. echarts.registerProcessor(__webpack_require__(218));
  36238. echarts.registerVisual(zrUtil.curry(
  36239. __webpack_require__(124), 'graph', 'circle', null
  36240. ));
  36241. echarts.registerVisual(__webpack_require__(219));
  36242. echarts.registerVisual(__webpack_require__(220));
  36243. echarts.registerLayout(__webpack_require__(221));
  36244. echarts.registerLayout(__webpack_require__(224));
  36245. echarts.registerLayout(__webpack_require__(226));
  36246. // Graph view coordinate system
  36247. echarts.registerCoordinateSystem('graphView', {
  36248. create: __webpack_require__(228)
  36249. });
  36250. /***/ }),
  36251. /* 209 */
  36252. /***/ (function(module, exports, __webpack_require__) {
  36253. 'use strict';
  36254. var List = __webpack_require__(101);
  36255. var zrUtil = __webpack_require__(4);
  36256. var modelUtil = __webpack_require__(5);
  36257. var Model = __webpack_require__(14);
  36258. var formatUtil = __webpack_require__(6);
  36259. var createGraphFromNodeEdge = __webpack_require__(210);
  36260. var GraphSeries = __webpack_require__(1).extendSeriesModel({
  36261. type: 'series.graph',
  36262. init: function (option) {
  36263. GraphSeries.superApply(this, 'init', arguments);
  36264. // Provide data for legend select
  36265. this.legendDataProvider = function () {
  36266. return this._categoriesData;
  36267. };
  36268. this.fillDataTextStyle(option.edges || option.links);
  36269. this._updateCategoriesData();
  36270. },
  36271. mergeOption: function (option) {
  36272. GraphSeries.superApply(this, 'mergeOption', arguments);
  36273. this.fillDataTextStyle(option.edges || option.links);
  36274. this._updateCategoriesData();
  36275. },
  36276. mergeDefaultAndTheme: function (option) {
  36277. GraphSeries.superApply(this, 'mergeDefaultAndTheme', arguments);
  36278. modelUtil.defaultEmphasis(option.edgeLabel, ['show']);
  36279. },
  36280. getInitialData: function (option, ecModel) {
  36281. var edges = option.edges || option.links || [];
  36282. var nodes = option.data || option.nodes || [];
  36283. var self = this;
  36284. if (nodes && edges) {
  36285. return createGraphFromNodeEdge(nodes, edges, this, true, beforeLink).data;
  36286. }
  36287. function beforeLink(nodeData, edgeData) {
  36288. // Overwrite nodeData.getItemModel to
  36289. nodeData.wrapMethod('getItemModel', function (model) {
  36290. var categoriesModels = self._categoriesModels;
  36291. var categoryIdx = model.getShallow('category');
  36292. var categoryModel = categoriesModels[categoryIdx];
  36293. if (categoryModel) {
  36294. categoryModel.parentModel = model.parentModel;
  36295. model.parentModel = categoryModel;
  36296. }
  36297. return model;
  36298. });
  36299. var edgeLabelModel = self.getModel('edgeLabel');
  36300. // For option `edgeLabel` can be found by label.xxx.xxx on item mode.
  36301. var fakeSeriesModel = new Model(
  36302. {label: edgeLabelModel.option},
  36303. edgeLabelModel.parentModel,
  36304. ecModel
  36305. );
  36306. edgeData.wrapMethod('getItemModel', function (model) {
  36307. model.customizeGetParent(edgeGetParent);
  36308. return model;
  36309. });
  36310. function edgeGetParent(path) {
  36311. path = this.parsePath(path);
  36312. return (path && path[0] === 'label')
  36313. ? fakeSeriesModel
  36314. : this.parentModel;
  36315. }
  36316. }
  36317. },
  36318. /**
  36319. * @return {module:echarts/data/Graph}
  36320. */
  36321. getGraph: function () {
  36322. return this.getData().graph;
  36323. },
  36324. /**
  36325. * @return {module:echarts/data/List}
  36326. */
  36327. getEdgeData: function () {
  36328. return this.getGraph().edgeData;
  36329. },
  36330. /**
  36331. * @return {module:echarts/data/List}
  36332. */
  36333. getCategoriesData: function () {
  36334. return this._categoriesData;
  36335. },
  36336. /**
  36337. * @override
  36338. */
  36339. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  36340. if (dataType === 'edge') {
  36341. var nodeData = this.getData();
  36342. var params = this.getDataParams(dataIndex, dataType);
  36343. var edge = nodeData.graph.getEdgeByIndex(dataIndex);
  36344. var sourceName = nodeData.getName(edge.node1.dataIndex);
  36345. var targetName = nodeData.getName(edge.node2.dataIndex);
  36346. var html = [];
  36347. sourceName != null && html.push(sourceName);
  36348. targetName != null && html.push(targetName);
  36349. html = formatUtil.encodeHTML(html.join(' > '));
  36350. if (params.value) {
  36351. html += ' : ' + formatUtil.encodeHTML(params.value);
  36352. }
  36353. return html;
  36354. }
  36355. else { // dataType === 'node' or empty
  36356. return GraphSeries.superApply(this, 'formatTooltip', arguments);
  36357. }
  36358. },
  36359. _updateCategoriesData: function () {
  36360. var categories = zrUtil.map(this.option.categories || [], function (category) {
  36361. // Data must has value
  36362. return category.value != null ? category : zrUtil.extend({
  36363. value: 0
  36364. }, category);
  36365. });
  36366. var categoriesData = new List(['value'], this);
  36367. categoriesData.initData(categories);
  36368. this._categoriesData = categoriesData;
  36369. this._categoriesModels = categoriesData.mapArray(function (idx) {
  36370. return categoriesData.getItemModel(idx, true);
  36371. });
  36372. },
  36373. setZoom: function (zoom) {
  36374. this.option.zoom = zoom;
  36375. },
  36376. setCenter: function (center) {
  36377. this.option.center = center;
  36378. },
  36379. isAnimationEnabled: function () {
  36380. return GraphSeries.superCall(this, 'isAnimationEnabled')
  36381. // Not enable animation when do force layout
  36382. && !(this.get('layout') === 'force' && this.get('force.layoutAnimation'));
  36383. },
  36384. defaultOption: {
  36385. zlevel: 0,
  36386. z: 2,
  36387. coordinateSystem: 'view',
  36388. // Default option for all coordinate systems
  36389. // xAxisIndex: 0,
  36390. // yAxisIndex: 0,
  36391. // polarIndex: 0,
  36392. // geoIndex: 0,
  36393. legendHoverLink: true,
  36394. hoverAnimation: true,
  36395. layout: null,
  36396. focusNodeAdjacency: false,
  36397. // Configuration of circular layout
  36398. circular: {
  36399. rotateLabel: false
  36400. },
  36401. // Configuration of force directed layout
  36402. force: {
  36403. initLayout: null,
  36404. // Node repulsion. Can be an array to represent range.
  36405. repulsion: [0, 50],
  36406. gravity: 0.1,
  36407. // Edge length. Can be an array to represent range.
  36408. edgeLength: 30,
  36409. layoutAnimation: true
  36410. },
  36411. left: 'center',
  36412. top: 'center',
  36413. // right: null,
  36414. // bottom: null,
  36415. // width: '80%',
  36416. // height: '80%',
  36417. symbol: 'circle',
  36418. symbolSize: 10,
  36419. edgeSymbol: ['none', 'none'],
  36420. edgeSymbolSize: 10,
  36421. edgeLabel: {
  36422. normal: {
  36423. position: 'middle'
  36424. },
  36425. emphasis: {}
  36426. },
  36427. draggable: false,
  36428. roam: false,
  36429. // Default on center of graph
  36430. center: null,
  36431. zoom: 1,
  36432. // Symbol size scale ratio in roam
  36433. nodeScaleRatio: 0.6,
  36434. // cursor: null,
  36435. // categories: [],
  36436. // data: []
  36437. // Or
  36438. // nodes: []
  36439. //
  36440. // links: []
  36441. // Or
  36442. // edges: []
  36443. label: {
  36444. normal: {
  36445. show: false,
  36446. formatter: '{b}'
  36447. },
  36448. emphasis: {
  36449. show: true
  36450. }
  36451. },
  36452. itemStyle: {
  36453. normal: {},
  36454. emphasis: {}
  36455. },
  36456. lineStyle: {
  36457. normal: {
  36458. color: '#aaa',
  36459. width: 1,
  36460. curveness: 0,
  36461. opacity: 0.5
  36462. },
  36463. emphasis: {}
  36464. }
  36465. }
  36466. });
  36467. module.exports = GraphSeries;
  36468. /***/ }),
  36469. /* 210 */
  36470. /***/ (function(module, exports, __webpack_require__) {
  36471. var List = __webpack_require__(101);
  36472. var Graph = __webpack_require__(211);
  36473. var linkList = __webpack_require__(199);
  36474. var completeDimensions = __webpack_require__(113);
  36475. var CoordinateSystem = __webpack_require__(79);
  36476. var zrUtil = __webpack_require__(4);
  36477. var createListFromArray = __webpack_require__(112);
  36478. module.exports = function (nodes, edges, hostModel, directed, beforeLink) {
  36479. var graph = new Graph(directed);
  36480. for (var i = 0; i < nodes.length; i++) {
  36481. graph.addNode(zrUtil.retrieve(
  36482. // Id, name, dataIndex
  36483. nodes[i].id, nodes[i].name, i
  36484. ), i);
  36485. }
  36486. var linkNameList = [];
  36487. var validEdges = [];
  36488. var linkCount = 0;
  36489. for (var i = 0; i < edges.length; i++) {
  36490. var link = edges[i];
  36491. var source = link.source;
  36492. var target = link.target;
  36493. // addEdge may fail when source or target not exists
  36494. if (graph.addEdge(source, target, linkCount)) {
  36495. validEdges.push(link);
  36496. linkNameList.push(zrUtil.retrieve(link.id, source + ' > ' + target));
  36497. linkCount++;
  36498. }
  36499. }
  36500. var coordSys = hostModel.get('coordinateSystem');
  36501. var nodeData;
  36502. if (coordSys === 'cartesian2d' || coordSys === 'polar') {
  36503. nodeData = createListFromArray(nodes, hostModel, hostModel.ecModel);
  36504. }
  36505. else {
  36506. // FIXME
  36507. var coordSysCtor = CoordinateSystem.get(coordSys);
  36508. // FIXME
  36509. var dimensionNames = completeDimensions(
  36510. ((coordSysCtor && coordSysCtor.type !== 'view') ? (coordSysCtor.dimensions || []) : []).concat(['value']),
  36511. nodes
  36512. );
  36513. nodeData = new List(dimensionNames, hostModel);
  36514. nodeData.initData(nodes);
  36515. }
  36516. var edgeData = new List(['value'], hostModel);
  36517. edgeData.initData(validEdges, linkNameList);
  36518. beforeLink && beforeLink(nodeData, edgeData);
  36519. linkList({
  36520. mainData: nodeData,
  36521. struct: graph,
  36522. structAttr: 'graph',
  36523. datas: {node: nodeData, edge: edgeData},
  36524. datasAttr: {node: 'data', edge: 'edgeData'}
  36525. });
  36526. // Update dataIndex of nodes and edges because invalid edge may be removed
  36527. graph.update();
  36528. return graph;
  36529. };
  36530. /***/ }),
  36531. /* 211 */
  36532. /***/ (function(module, exports, __webpack_require__) {
  36533. 'use strict';
  36534. /**
  36535. * Graph data structure
  36536. *
  36537. * @module echarts/data/Graph
  36538. * @author Yi Shen(https://www.github.com/pissang)
  36539. */
  36540. var zrUtil = __webpack_require__(4);
  36541. // id may be function name of Object, add a prefix to avoid this problem.
  36542. function generateNodeKey (id) {
  36543. return '_EC_' + id;
  36544. }
  36545. /**
  36546. * @alias module:echarts/data/Graph
  36547. * @constructor
  36548. * @param {boolean} directed
  36549. */
  36550. var Graph = function(directed) {
  36551. /**
  36552. * 是否是有向图
  36553. * @type {boolean}
  36554. * @private
  36555. */
  36556. this._directed = directed || false;
  36557. /**
  36558. * @type {Array.<module:echarts/data/Graph.Node>}
  36559. * @readOnly
  36560. */
  36561. this.nodes = [];
  36562. /**
  36563. * @type {Array.<module:echarts/data/Graph.Edge>}
  36564. * @readOnly
  36565. */
  36566. this.edges = [];
  36567. /**
  36568. * @type {Object.<string, module:echarts/data/Graph.Node>}
  36569. * @private
  36570. */
  36571. this._nodesMap = {};
  36572. /**
  36573. * @type {Object.<string, module:echarts/data/Graph.Edge>}
  36574. * @private
  36575. */
  36576. this._edgesMap = {};
  36577. /**
  36578. * @type {module:echarts/data/List}
  36579. * @readOnly
  36580. */
  36581. this.data;
  36582. /**
  36583. * @type {module:echarts/data/List}
  36584. * @readOnly
  36585. */
  36586. this.edgeData;
  36587. };
  36588. var graphProto = Graph.prototype;
  36589. /**
  36590. * @type {string}
  36591. */
  36592. graphProto.type = 'graph';
  36593. /**
  36594. * If is directed graph
  36595. * @return {boolean}
  36596. */
  36597. graphProto.isDirected = function () {
  36598. return this._directed;
  36599. };
  36600. /**
  36601. * Add a new node
  36602. * @param {string} id
  36603. * @param {number} [dataIndex]
  36604. */
  36605. graphProto.addNode = function (id, dataIndex) {
  36606. id = id || ('' + dataIndex);
  36607. var nodesMap = this._nodesMap;
  36608. if (nodesMap[generateNodeKey(id)]) {
  36609. if (true) {
  36610. console.error('Graph nodes have duplicate name or id');
  36611. }
  36612. return;
  36613. }
  36614. var node = new Node(id, dataIndex);
  36615. node.hostGraph = this;
  36616. this.nodes.push(node);
  36617. nodesMap[generateNodeKey(id)] = node;
  36618. return node;
  36619. };
  36620. /**
  36621. * Get node by data index
  36622. * @param {number} dataIndex
  36623. * @return {module:echarts/data/Graph~Node}
  36624. */
  36625. graphProto.getNodeByIndex = function (dataIndex) {
  36626. var rawIdx = this.data.getRawIndex(dataIndex);
  36627. return this.nodes[rawIdx];
  36628. };
  36629. /**
  36630. * Get node by id
  36631. * @param {string} id
  36632. * @return {module:echarts/data/Graph.Node}
  36633. */
  36634. graphProto.getNodeById = function (id) {
  36635. return this._nodesMap[generateNodeKey(id)];
  36636. };
  36637. /**
  36638. * Add a new edge
  36639. * @param {number|string|module:echarts/data/Graph.Node} n1
  36640. * @param {number|string|module:echarts/data/Graph.Node} n2
  36641. * @param {number} [dataIndex=-1]
  36642. * @return {module:echarts/data/Graph.Edge}
  36643. */
  36644. graphProto.addEdge = function (n1, n2, dataIndex) {
  36645. var nodesMap = this._nodesMap;
  36646. var edgesMap = this._edgesMap;
  36647. // PNEDING
  36648. if (typeof n1 === 'number') {
  36649. n1 = this.nodes[n1];
  36650. }
  36651. if (typeof n2 === 'number') {
  36652. n2 = this.nodes[n2];
  36653. }
  36654. if (!(n1 instanceof Node)) {
  36655. n1 = nodesMap[generateNodeKey(n1)];
  36656. }
  36657. if (!(n2 instanceof Node)) {
  36658. n2 = nodesMap[generateNodeKey(n2)];
  36659. }
  36660. if (!n1 || !n2) {
  36661. return;
  36662. }
  36663. var key = n1.id + '-' + n2.id;
  36664. // PENDING
  36665. if (edgesMap[key]) {
  36666. return;
  36667. }
  36668. var edge = new Edge(n1, n2, dataIndex);
  36669. edge.hostGraph = this;
  36670. if (this._directed) {
  36671. n1.outEdges.push(edge);
  36672. n2.inEdges.push(edge);
  36673. }
  36674. n1.edges.push(edge);
  36675. if (n1 !== n2) {
  36676. n2.edges.push(edge);
  36677. }
  36678. this.edges.push(edge);
  36679. edgesMap[key] = edge;
  36680. return edge;
  36681. };
  36682. /**
  36683. * Get edge by data index
  36684. * @param {number} dataIndex
  36685. * @return {module:echarts/data/Graph~Node}
  36686. */
  36687. graphProto.getEdgeByIndex = function (dataIndex) {
  36688. var rawIdx = this.edgeData.getRawIndex(dataIndex);
  36689. return this.edges[rawIdx];
  36690. };
  36691. /**
  36692. * Get edge by two linked nodes
  36693. * @param {module:echarts/data/Graph.Node|string} n1
  36694. * @param {module:echarts/data/Graph.Node|string} n2
  36695. * @return {module:echarts/data/Graph.Edge}
  36696. */
  36697. graphProto.getEdge = function (n1, n2) {
  36698. if (n1 instanceof Node) {
  36699. n1 = n1.id;
  36700. }
  36701. if (n2 instanceof Node) {
  36702. n2 = n2.id;
  36703. }
  36704. var edgesMap = this._edgesMap;
  36705. if (this._directed) {
  36706. return edgesMap[n1 + '-' + n2];
  36707. } else {
  36708. return edgesMap[n1 + '-' + n2]
  36709. || edgesMap[n2 + '-' + n1];
  36710. }
  36711. };
  36712. /**
  36713. * Iterate all nodes
  36714. * @param {Function} cb
  36715. * @param {*} [context]
  36716. */
  36717. graphProto.eachNode = function (cb, context) {
  36718. var nodes = this.nodes;
  36719. var len = nodes.length;
  36720. for (var i = 0; i < len; i++) {
  36721. if (nodes[i].dataIndex >= 0) {
  36722. cb.call(context, nodes[i], i);
  36723. }
  36724. }
  36725. };
  36726. /**
  36727. * Iterate all edges
  36728. * @param {Function} cb
  36729. * @param {*} [context]
  36730. */
  36731. graphProto.eachEdge = function (cb, context) {
  36732. var edges = this.edges;
  36733. var len = edges.length;
  36734. for (var i = 0; i < len; i++) {
  36735. if (edges[i].dataIndex >= 0
  36736. && edges[i].node1.dataIndex >= 0
  36737. && edges[i].node2.dataIndex >= 0
  36738. ) {
  36739. cb.call(context, edges[i], i);
  36740. }
  36741. }
  36742. };
  36743. /**
  36744. * Breadth first traverse
  36745. * @param {Function} cb
  36746. * @param {module:echarts/data/Graph.Node} startNode
  36747. * @param {string} [direction='none'] 'none'|'in'|'out'
  36748. * @param {*} [context]
  36749. */
  36750. graphProto.breadthFirstTraverse = function (
  36751. cb, startNode, direction, context
  36752. ) {
  36753. if (!(startNode instanceof Node)) {
  36754. startNode = this._nodesMap[generateNodeKey(startNode)];
  36755. }
  36756. if (!startNode) {
  36757. return;
  36758. }
  36759. var edgeType = direction === 'out'
  36760. ? 'outEdges' : (direction === 'in' ? 'inEdges' : 'edges');
  36761. for (var i = 0; i < this.nodes.length; i++) {
  36762. this.nodes[i].__visited = false;
  36763. }
  36764. if (cb.call(context, startNode, null)) {
  36765. return;
  36766. }
  36767. var queue = [startNode];
  36768. while (queue.length) {
  36769. var currentNode = queue.shift();
  36770. var edges = currentNode[edgeType];
  36771. for (var i = 0; i < edges.length; i++) {
  36772. var e = edges[i];
  36773. var otherNode = e.node1 === currentNode
  36774. ? e.node2 : e.node1;
  36775. if (!otherNode.__visited) {
  36776. if (cb.call(context, otherNode, currentNode)) {
  36777. // Stop traversing
  36778. return;
  36779. }
  36780. queue.push(otherNode);
  36781. otherNode.__visited = true;
  36782. }
  36783. }
  36784. }
  36785. };
  36786. // TODO
  36787. // graphProto.depthFirstTraverse = function (
  36788. // cb, startNode, direction, context
  36789. // ) {
  36790. // };
  36791. // Filter update
  36792. graphProto.update = function () {
  36793. var data = this.data;
  36794. var edgeData = this.edgeData;
  36795. var nodes = this.nodes;
  36796. var edges = this.edges;
  36797. for (var i = 0, len = nodes.length; i < len; i++) {
  36798. nodes[i].dataIndex = -1;
  36799. }
  36800. for (var i = 0, len = data.count(); i < len; i++) {
  36801. nodes[data.getRawIndex(i)].dataIndex = i;
  36802. }
  36803. edgeData.filterSelf(function (idx) {
  36804. var edge = edges[edgeData.getRawIndex(idx)];
  36805. return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0;
  36806. });
  36807. // Update edge
  36808. for (var i = 0, len = edges.length; i < len; i++) {
  36809. edges[i].dataIndex = -1;
  36810. }
  36811. for (var i = 0, len = edgeData.count(); i < len; i++) {
  36812. edges[edgeData.getRawIndex(i)].dataIndex = i;
  36813. }
  36814. };
  36815. /**
  36816. * @return {module:echarts/data/Graph}
  36817. */
  36818. graphProto.clone = function () {
  36819. var graph = new Graph(this._directed);
  36820. var nodes = this.nodes;
  36821. var edges = this.edges;
  36822. for (var i = 0; i < nodes.length; i++) {
  36823. graph.addNode(nodes[i].id, nodes[i].dataIndex);
  36824. }
  36825. for (var i = 0; i < edges.length; i++) {
  36826. var e = edges[i];
  36827. graph.addEdge(e.node1.id, e.node2.id, e.dataIndex);
  36828. }
  36829. return graph;
  36830. };
  36831. /**
  36832. * @alias module:echarts/data/Graph.Node
  36833. */
  36834. function Node(id, dataIndex) {
  36835. /**
  36836. * @type {string}
  36837. */
  36838. this.id = id == null ? '' : id;
  36839. /**
  36840. * @type {Array.<module:echarts/data/Graph.Edge>}
  36841. */
  36842. this.inEdges = [];
  36843. /**
  36844. * @type {Array.<module:echarts/data/Graph.Edge>}
  36845. */
  36846. this.outEdges = [];
  36847. /**
  36848. * @type {Array.<module:echarts/data/Graph.Edge>}
  36849. */
  36850. this.edges = [];
  36851. /**
  36852. * @type {module:echarts/data/Graph}
  36853. */
  36854. this.hostGraph;
  36855. /**
  36856. * @type {number}
  36857. */
  36858. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  36859. }
  36860. Node.prototype = {
  36861. constructor: Node,
  36862. /**
  36863. * @return {number}
  36864. */
  36865. degree: function () {
  36866. return this.edges.length;
  36867. },
  36868. /**
  36869. * @return {number}
  36870. */
  36871. inDegree: function () {
  36872. return this.inEdges.length;
  36873. },
  36874. /**
  36875. * @return {number}
  36876. */
  36877. outDegree: function () {
  36878. return this.outEdges.length;
  36879. },
  36880. /**
  36881. * @param {string} [path]
  36882. * @return {module:echarts/model/Model}
  36883. */
  36884. getModel: function (path) {
  36885. if (this.dataIndex < 0) {
  36886. return;
  36887. }
  36888. var graph = this.hostGraph;
  36889. var itemModel = graph.data.getItemModel(this.dataIndex);
  36890. return itemModel.getModel(path);
  36891. }
  36892. };
  36893. /**
  36894. * 图边
  36895. * @alias module:echarts/data/Graph.Edge
  36896. * @param {module:echarts/data/Graph.Node} n1
  36897. * @param {module:echarts/data/Graph.Node} n2
  36898. * @param {number} [dataIndex=-1]
  36899. */
  36900. function Edge(n1, n2, dataIndex) {
  36901. /**
  36902. * 节点1,如果是有向图则为源节点
  36903. * @type {module:echarts/data/Graph.Node}
  36904. */
  36905. this.node1 = n1;
  36906. /**
  36907. * 节点2,如果是有向图则为目标节点
  36908. * @type {module:echarts/data/Graph.Node}
  36909. */
  36910. this.node2 = n2;
  36911. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  36912. }
  36913. /**
  36914. * @param {string} [path]
  36915. * @return {module:echarts/model/Model}
  36916. */
  36917. Edge.prototype.getModel = function (path) {
  36918. if (this.dataIndex < 0) {
  36919. return;
  36920. }
  36921. var graph = this.hostGraph;
  36922. var itemModel = graph.edgeData.getItemModel(this.dataIndex);
  36923. return itemModel.getModel(path);
  36924. };
  36925. var createGraphDataProxyMixin = function (hostName, dataName) {
  36926. return {
  36927. /**
  36928. * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
  36929. * @return {number}
  36930. */
  36931. getValue: function (dimension) {
  36932. var data = this[hostName][dataName];
  36933. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  36934. },
  36935. /**
  36936. * @param {Object|string} key
  36937. * @param {*} [value]
  36938. */
  36939. setVisual: function (key, value) {
  36940. this.dataIndex >= 0
  36941. && this[hostName][dataName].setItemVisual(this.dataIndex, key, value);
  36942. },
  36943. /**
  36944. * @param {string} key
  36945. * @return {boolean}
  36946. */
  36947. getVisual: function (key, ignoreParent) {
  36948. return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent);
  36949. },
  36950. /**
  36951. * @param {Object} layout
  36952. * @return {boolean} [merge=false]
  36953. */
  36954. setLayout: function (layout, merge) {
  36955. this.dataIndex >= 0
  36956. && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge);
  36957. },
  36958. /**
  36959. * @return {Object}
  36960. */
  36961. getLayout: function () {
  36962. return this[hostName][dataName].getItemLayout(this.dataIndex);
  36963. },
  36964. /**
  36965. * @return {module:zrender/Element}
  36966. */
  36967. getGraphicEl: function () {
  36968. return this[hostName][dataName].getItemGraphicEl(this.dataIndex);
  36969. },
  36970. /**
  36971. * @return {number}
  36972. */
  36973. getRawIndex: function () {
  36974. return this[hostName][dataName].getRawIndex(this.dataIndex);
  36975. }
  36976. };
  36977. };
  36978. zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data'));
  36979. zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
  36980. Graph.Node = Node;
  36981. Graph.Edge = Edge;
  36982. module.exports = Graph;
  36983. /***/ }),
  36984. /* 212 */
  36985. /***/ (function(module, exports, __webpack_require__) {
  36986. var SymbolDraw = __webpack_require__(119);
  36987. var LineDraw = __webpack_require__(213);
  36988. var RoamController = __webpack_require__(186);
  36989. var roamHelper = __webpack_require__(188);
  36990. var cursorHelper = __webpack_require__(189);
  36991. var graphic = __webpack_require__(20);
  36992. var adjustEdge = __webpack_require__(216);
  36993. var zrUtil = __webpack_require__(4);
  36994. var nodeOpacityPath = ['itemStyle', 'normal', 'opacity'];
  36995. var lineOpacityPath = ['lineStyle', 'normal', 'opacity'];
  36996. function getItemOpacity(item, opacityPath) {
  36997. return item.getVisual('opacity') || item.getModel().get(opacityPath);
  36998. }
  36999. function fadeOutItem(item, opacityPath, opacityRatio) {
  37000. var el = item.getGraphicEl();
  37001. var opacity = getItemOpacity(item, opacityPath);
  37002. if (opacityRatio != null) {
  37003. opacity == null && (opacity = 1);
  37004. opacity *= opacityRatio;
  37005. }
  37006. el.downplay && el.downplay();
  37007. el.traverse(function (child) {
  37008. if (child.type !== 'group') {
  37009. child.setStyle('opacity', opacity);
  37010. }
  37011. });
  37012. }
  37013. function fadeInItem(item, opacityPath) {
  37014. var opacity = getItemOpacity(item, opacityPath);
  37015. var el = item.getGraphicEl();
  37016. el.highlight && el.highlight();
  37017. el.traverse(function (child) {
  37018. if (child.type !== 'group') {
  37019. child.setStyle('opacity', opacity);
  37020. }
  37021. });
  37022. }
  37023. __webpack_require__(1).extendChartView({
  37024. type: 'graph',
  37025. init: function (ecModel, api) {
  37026. var symbolDraw = new SymbolDraw();
  37027. var lineDraw = new LineDraw();
  37028. var group = this.group;
  37029. this._controller = new RoamController(api.getZr());
  37030. this._controllerHost = {target: group};
  37031. group.add(symbolDraw.group);
  37032. group.add(lineDraw.group);
  37033. this._symbolDraw = symbolDraw;
  37034. this._lineDraw = lineDraw;
  37035. this._firstRender = true;
  37036. },
  37037. render: function (seriesModel, ecModel, api) {
  37038. var coordSys = seriesModel.coordinateSystem;
  37039. this._model = seriesModel;
  37040. this._nodeScaleRatio = seriesModel.get('nodeScaleRatio');
  37041. var symbolDraw = this._symbolDraw;
  37042. var lineDraw = this._lineDraw;
  37043. var group = this.group;
  37044. if (coordSys.type === 'view') {
  37045. var groupNewProp = {
  37046. position: coordSys.position,
  37047. scale: coordSys.scale
  37048. };
  37049. if (this._firstRender) {
  37050. group.attr(groupNewProp);
  37051. }
  37052. else {
  37053. graphic.updateProps(group, groupNewProp, seriesModel);
  37054. }
  37055. }
  37056. // Fix edge contact point with node
  37057. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  37058. var data = seriesModel.getData();
  37059. symbolDraw.updateData(data);
  37060. var edgeData = seriesModel.getEdgeData();
  37061. lineDraw.updateData(edgeData);
  37062. this._updateNodeAndLinkScale();
  37063. this._updateController(seriesModel, ecModel, api);
  37064. clearTimeout(this._layoutTimeout);
  37065. var forceLayout = seriesModel.forceLayout;
  37066. var layoutAnimation = seriesModel.get('force.layoutAnimation');
  37067. if (forceLayout) {
  37068. this._startForceLayoutIteration(forceLayout, layoutAnimation);
  37069. }
  37070. data.eachItemGraphicEl(function (el, idx) {
  37071. var itemModel = data.getItemModel(idx);
  37072. // Update draggable
  37073. el.off('drag').off('dragend');
  37074. var draggable = data.getItemModel(idx).get('draggable');
  37075. if (draggable) {
  37076. el.on('drag', function () {
  37077. if (forceLayout) {
  37078. forceLayout.warmUp();
  37079. !this._layouting
  37080. && this._startForceLayoutIteration(forceLayout, layoutAnimation);
  37081. forceLayout.setFixed(idx);
  37082. // Write position back to layout
  37083. data.setItemLayout(idx, el.position);
  37084. }
  37085. }, this).on('dragend', function () {
  37086. if (forceLayout) {
  37087. forceLayout.setUnfixed(idx);
  37088. }
  37089. }, this);
  37090. }
  37091. el.setDraggable(draggable && forceLayout);
  37092. el.off('mouseover', el.__focusNodeAdjacency);
  37093. el.off('mouseout', el.__unfocusNodeAdjacency);
  37094. if (itemModel.get('focusNodeAdjacency')) {
  37095. el.on('mouseover', el.__focusNodeAdjacency = function () {
  37096. api.dispatchAction({
  37097. type: 'focusNodeAdjacency',
  37098. seriesId: seriesModel.id,
  37099. dataIndex: el.dataIndex
  37100. });
  37101. });
  37102. el.on('mouseout', el.__unfocusNodeAdjacency = function () {
  37103. api.dispatchAction({
  37104. type: 'unfocusNodeAdjacency',
  37105. seriesId: seriesModel.id
  37106. });
  37107. });
  37108. }
  37109. }, this);
  37110. var circularRotateLabel = seriesModel.get('layout') === 'circular'
  37111. && seriesModel.get('circular.rotateLabel');
  37112. var cx = data.getLayout('cx');
  37113. var cy = data.getLayout('cy');
  37114. data.eachItemGraphicEl(function (el, idx) {
  37115. var symbolPath = el.getSymbolPath();
  37116. if (circularRotateLabel) {
  37117. var pos = data.getItemLayout(idx);
  37118. var rad = Math.atan2(pos[1] - cy, pos[0] - cx);
  37119. if (rad < 0) {
  37120. rad = Math.PI * 2 + rad;
  37121. }
  37122. var isLeft = pos[0] < cx;
  37123. if (isLeft) {
  37124. rad = rad - Math.PI;
  37125. }
  37126. var textPosition = isLeft ? 'left' : 'right';
  37127. symbolPath.setStyle({
  37128. textRotation: -rad,
  37129. textPosition: textPosition,
  37130. textOrigin: 'center'
  37131. });
  37132. symbolPath.hoverStyle && (symbolPath.hoverStyle.textPosition = textPosition);
  37133. }
  37134. else {
  37135. symbolPath.setStyle({
  37136. textRotation: 0
  37137. });
  37138. }
  37139. });
  37140. this._firstRender = false;
  37141. },
  37142. dispose: function () {
  37143. this._controller && this._controller.dispose();
  37144. this._controllerHost = {};
  37145. },
  37146. focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
  37147. var data = this._model.getData();
  37148. var dataIndex = payload.dataIndex;
  37149. var el = data.getItemGraphicEl(dataIndex);
  37150. if (!el) {
  37151. return;
  37152. }
  37153. var graph = data.graph;
  37154. var dataType = el.dataType;
  37155. if (dataIndex !== null && dataType !== 'edge') {
  37156. graph.eachNode(function (node) {
  37157. fadeOutItem(node, nodeOpacityPath, 0.1);
  37158. });
  37159. graph.eachEdge(function (edge) {
  37160. fadeOutItem(edge, lineOpacityPath, 0.1);
  37161. });
  37162. var node = graph.getNodeByIndex(dataIndex);
  37163. fadeInItem(node, nodeOpacityPath);
  37164. zrUtil.each(node.edges, function (edge) {
  37165. if (edge.dataIndex < 0) {
  37166. return;
  37167. }
  37168. fadeInItem(edge, lineOpacityPath);
  37169. fadeInItem(edge.node1, nodeOpacityPath);
  37170. fadeInItem(edge.node2, nodeOpacityPath);
  37171. });
  37172. }
  37173. },
  37174. unfocusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
  37175. var graph = this._model.getData().graph;
  37176. graph.eachNode(function (node) {
  37177. fadeOutItem(node, nodeOpacityPath);
  37178. });
  37179. graph.eachEdge(function (edge) {
  37180. fadeOutItem(edge, lineOpacityPath);
  37181. });
  37182. },
  37183. _startForceLayoutIteration: function (forceLayout, layoutAnimation) {
  37184. var self = this;
  37185. (function step() {
  37186. forceLayout.step(function (stopped) {
  37187. self.updateLayout(self._model);
  37188. (self._layouting = !stopped) && (
  37189. layoutAnimation
  37190. ? (self._layoutTimeout = setTimeout(step, 16))
  37191. : step()
  37192. );
  37193. });
  37194. })();
  37195. },
  37196. _updateController: function (seriesModel, ecModel, api) {
  37197. var controller = this._controller;
  37198. var controllerHost = this._controllerHost;
  37199. var group = this.group;
  37200. controller.setPointerChecker(function (e, x, y) {
  37201. var rect = group.getBoundingRect();
  37202. rect.applyTransform(group.transform);
  37203. return rect.contain(x, y)
  37204. && !cursorHelper.onIrrelevantElement(e, api, seriesModel);
  37205. });
  37206. if (seriesModel.coordinateSystem.type !== 'view') {
  37207. controller.disable();
  37208. return;
  37209. }
  37210. controller.enable(seriesModel.get('roam'));
  37211. controllerHost.zoomLimit = seriesModel.get('scaleLimit');
  37212. controllerHost.zoom = seriesModel.coordinateSystem.getZoom();
  37213. controller
  37214. .off('pan')
  37215. .off('zoom')
  37216. .on('pan', function (dx, dy) {
  37217. roamHelper.updateViewOnPan(controllerHost, dx, dy);
  37218. api.dispatchAction({
  37219. seriesId: seriesModel.id,
  37220. type: 'graphRoam',
  37221. dx: dx,
  37222. dy: dy
  37223. });
  37224. })
  37225. .on('zoom', function (zoom, mouseX, mouseY) {
  37226. roamHelper.updateViewOnZoom(controllerHost, zoom, mouseX, mouseY);
  37227. api.dispatchAction({
  37228. seriesId: seriesModel.id,
  37229. type: 'graphRoam',
  37230. zoom: zoom,
  37231. originX: mouseX,
  37232. originY: mouseY
  37233. });
  37234. this._updateNodeAndLinkScale();
  37235. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  37236. this._lineDraw.updateLayout();
  37237. }, this);
  37238. },
  37239. _updateNodeAndLinkScale: function () {
  37240. var seriesModel = this._model;
  37241. var data = seriesModel.getData();
  37242. var nodeScale = this._getNodeGlobalScale(seriesModel);
  37243. var invScale = [nodeScale, nodeScale];
  37244. data.eachItemGraphicEl(function (el, idx) {
  37245. el.attr('scale', invScale);
  37246. });
  37247. },
  37248. _getNodeGlobalScale: function (seriesModel) {
  37249. var coordSys = seriesModel.coordinateSystem;
  37250. if (coordSys.type !== 'view') {
  37251. return 1;
  37252. }
  37253. var nodeScaleRatio = this._nodeScaleRatio;
  37254. var groupScale = coordSys.scale;
  37255. var groupZoom = (groupScale && groupScale[0]) || 1;
  37256. // Scale node when zoom changes
  37257. var roamZoom = coordSys.getZoom();
  37258. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  37259. return nodeScale / groupZoom;
  37260. },
  37261. updateLayout: function (seriesModel) {
  37262. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  37263. this._symbolDraw.updateLayout();
  37264. this._lineDraw.updateLayout();
  37265. },
  37266. remove: function (ecModel, api) {
  37267. this._symbolDraw && this._symbolDraw.remove();
  37268. this._lineDraw && this._lineDraw.remove();
  37269. }
  37270. });
  37271. /***/ }),
  37272. /* 213 */
  37273. /***/ (function(module, exports, __webpack_require__) {
  37274. /**
  37275. * @module echarts/chart/helper/LineDraw
  37276. */
  37277. var graphic = __webpack_require__(20);
  37278. var LineGroup = __webpack_require__(214);
  37279. function isPointNaN(pt) {
  37280. return isNaN(pt[0]) || isNaN(pt[1]);
  37281. }
  37282. function lineNeedsDraw(pts) {
  37283. return !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
  37284. }
  37285. /**
  37286. * @alias module:echarts/component/marker/LineDraw
  37287. * @constructor
  37288. */
  37289. function LineDraw(ctor) {
  37290. this._ctor = ctor || LineGroup;
  37291. this.group = new graphic.Group();
  37292. }
  37293. var lineDrawProto = LineDraw.prototype;
  37294. /**
  37295. * @param {module:echarts/data/List} lineData
  37296. */
  37297. lineDrawProto.updateData = function (lineData) {
  37298. var oldLineData = this._lineData;
  37299. var group = this.group;
  37300. var LineCtor = this._ctor;
  37301. var hostModel = lineData.hostModel;
  37302. var seriesScope = {
  37303. lineStyle: hostModel.getModel('lineStyle.normal').getLineStyle(),
  37304. hoverLineStyle: hostModel.getModel('lineStyle.emphasis').getLineStyle(),
  37305. labelModel: hostModel.getModel('label.normal'),
  37306. hoverLabelModel: hostModel.getModel('label.emphasis')
  37307. };
  37308. lineData.diff(oldLineData)
  37309. .add(function (idx) {
  37310. if (!lineNeedsDraw(lineData.getItemLayout(idx))) {
  37311. return;
  37312. }
  37313. var lineGroup = new LineCtor(lineData, idx, seriesScope);
  37314. lineData.setItemGraphicEl(idx, lineGroup);
  37315. group.add(lineGroup);
  37316. })
  37317. .update(function (newIdx, oldIdx) {
  37318. var lineGroup = oldLineData.getItemGraphicEl(oldIdx);
  37319. if (!lineNeedsDraw(lineData.getItemLayout(newIdx))) {
  37320. group.remove(lineGroup);
  37321. return;
  37322. }
  37323. if (!lineGroup) {
  37324. lineGroup = new LineCtor(lineData, newIdx, seriesScope);
  37325. }
  37326. else {
  37327. lineGroup.updateData(lineData, newIdx, seriesScope);
  37328. }
  37329. lineData.setItemGraphicEl(newIdx, lineGroup);
  37330. group.add(lineGroup);
  37331. })
  37332. .remove(function (idx) {
  37333. group.remove(oldLineData.getItemGraphicEl(idx));
  37334. })
  37335. .execute();
  37336. this._lineData = lineData;
  37337. };
  37338. lineDrawProto.updateLayout = function () {
  37339. var lineData = this._lineData;
  37340. lineData.eachItemGraphicEl(function (el, idx) {
  37341. el.updateLayout(lineData, idx);
  37342. }, this);
  37343. };
  37344. lineDrawProto.remove = function () {
  37345. this.group.removeAll();
  37346. };
  37347. module.exports = LineDraw;
  37348. /***/ }),
  37349. /* 214 */
  37350. /***/ (function(module, exports, __webpack_require__) {
  37351. /**
  37352. * @module echarts/chart/helper/Line
  37353. */
  37354. var symbolUtil = __webpack_require__(114);
  37355. var vector = __webpack_require__(10);
  37356. // var matrix = require('zrender/lib/core/matrix');
  37357. var LinePath = __webpack_require__(215);
  37358. var graphic = __webpack_require__(20);
  37359. var zrUtil = __webpack_require__(4);
  37360. var numberUtil = __webpack_require__(7);
  37361. var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
  37362. function makeSymbolTypeKey(symbolCategory) {
  37363. return '_' + symbolCategory + 'Type';
  37364. }
  37365. /**
  37366. * @inner
  37367. */
  37368. function createSymbol(name, lineData, idx) {
  37369. var color = lineData.getItemVisual(idx, 'color');
  37370. var symbolType = lineData.getItemVisual(idx, name);
  37371. var symbolSize = lineData.getItemVisual(idx, name + 'Size');
  37372. if (!symbolType || symbolType === 'none') {
  37373. return;
  37374. }
  37375. if (!zrUtil.isArray(symbolSize)) {
  37376. symbolSize = [symbolSize, symbolSize];
  37377. }
  37378. var symbolPath = symbolUtil.createSymbol(
  37379. symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2,
  37380. symbolSize[0], symbolSize[1], color
  37381. );
  37382. symbolPath.name = name;
  37383. return symbolPath;
  37384. }
  37385. function createLine(points) {
  37386. var line = new LinePath({
  37387. name: 'line'
  37388. });
  37389. setLinePoints(line.shape, points);
  37390. return line;
  37391. }
  37392. function setLinePoints(targetShape, points) {
  37393. var p1 = points[0];
  37394. var p2 = points[1];
  37395. var cp1 = points[2];
  37396. targetShape.x1 = p1[0];
  37397. targetShape.y1 = p1[1];
  37398. targetShape.x2 = p2[0];
  37399. targetShape.y2 = p2[1];
  37400. targetShape.percent = 1;
  37401. if (cp1) {
  37402. targetShape.cpx1 = cp1[0];
  37403. targetShape.cpy1 = cp1[1];
  37404. }
  37405. else {
  37406. targetShape.cpx1 = NaN;
  37407. targetShape.cpy1 = NaN;
  37408. }
  37409. }
  37410. function updateSymbolAndLabelBeforeLineUpdate () {
  37411. var lineGroup = this;
  37412. var symbolFrom = lineGroup.childOfName('fromSymbol');
  37413. var symbolTo = lineGroup.childOfName('toSymbol');
  37414. var label = lineGroup.childOfName('label');
  37415. // Quick reject
  37416. if (!symbolFrom && !symbolTo && label.ignore) {
  37417. return;
  37418. }
  37419. var invScale = 1;
  37420. var parentNode = this.parent;
  37421. while (parentNode) {
  37422. if (parentNode.scale) {
  37423. invScale /= parentNode.scale[0];
  37424. }
  37425. parentNode = parentNode.parent;
  37426. }
  37427. var line = lineGroup.childOfName('line');
  37428. // If line not changed
  37429. // FIXME Parent scale changed
  37430. if (!this.__dirty && !line.__dirty) {
  37431. return;
  37432. }
  37433. var percent = line.shape.percent;
  37434. var fromPos = line.pointAt(0);
  37435. var toPos = line.pointAt(percent);
  37436. var d = vector.sub([], toPos, fromPos);
  37437. vector.normalize(d, d);
  37438. if (symbolFrom) {
  37439. symbolFrom.attr('position', fromPos);
  37440. var tangent = line.tangentAt(0);
  37441. symbolFrom.attr('rotation', Math.PI / 2 - Math.atan2(
  37442. tangent[1], tangent[0]
  37443. ));
  37444. symbolFrom.attr('scale', [invScale * percent, invScale * percent]);
  37445. }
  37446. if (symbolTo) {
  37447. symbolTo.attr('position', toPos);
  37448. var tangent = line.tangentAt(1);
  37449. symbolTo.attr('rotation', -Math.PI / 2 - Math.atan2(
  37450. tangent[1], tangent[0]
  37451. ));
  37452. symbolTo.attr('scale', [invScale * percent, invScale * percent]);
  37453. }
  37454. if (!label.ignore) {
  37455. label.attr('position', toPos);
  37456. var textPosition;
  37457. var textAlign;
  37458. var textVerticalAlign;
  37459. var distance = 5 * invScale;
  37460. // End
  37461. if (label.__position === 'end') {
  37462. textPosition = [d[0] * distance + toPos[0], d[1] * distance + toPos[1]];
  37463. textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
  37464. textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
  37465. }
  37466. // Middle
  37467. else if (label.__position === 'middle') {
  37468. var halfPercent = percent / 2;
  37469. var tangent = line.tangentAt(halfPercent);
  37470. var n = [tangent[1], -tangent[0]];
  37471. var cp = line.pointAt(halfPercent);
  37472. if (n[1] > 0) {
  37473. n[0] = -n[0];
  37474. n[1] = -n[1];
  37475. }
  37476. textPosition = [cp[0] + n[0] * distance, cp[1] + n[1] * distance];
  37477. textAlign = 'center';
  37478. textVerticalAlign = 'bottom';
  37479. var rotation = -Math.atan2(tangent[1], tangent[0]);
  37480. if (toPos[0] < fromPos[0]) {
  37481. rotation = Math.PI + rotation;
  37482. }
  37483. label.attr('rotation', rotation);
  37484. }
  37485. // Start
  37486. else {
  37487. textPosition = [-d[0] * distance + fromPos[0], -d[1] * distance + fromPos[1]];
  37488. textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center');
  37489. textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle');
  37490. }
  37491. label.attr({
  37492. style: {
  37493. // Use the user specified text align and baseline first
  37494. textVerticalAlign: label.__verticalAlign || textVerticalAlign,
  37495. textAlign: label.__textAlign || textAlign
  37496. },
  37497. position: textPosition,
  37498. scale: [invScale, invScale]
  37499. });
  37500. }
  37501. }
  37502. /**
  37503. * @constructor
  37504. * @extends {module:zrender/graphic/Group}
  37505. * @alias {module:echarts/chart/helper/Line}
  37506. */
  37507. function Line(lineData, idx, seriesScope) {
  37508. graphic.Group.call(this);
  37509. this._createLine(lineData, idx, seriesScope);
  37510. }
  37511. var lineProto = Line.prototype;
  37512. // Update symbol position and rotation
  37513. lineProto.beforeUpdate = updateSymbolAndLabelBeforeLineUpdate;
  37514. lineProto._createLine = function (lineData, idx, seriesScope) {
  37515. var seriesModel = lineData.hostModel;
  37516. var linePoints = lineData.getItemLayout(idx);
  37517. var line = createLine(linePoints);
  37518. line.shape.percent = 0;
  37519. graphic.initProps(line, {
  37520. shape: {
  37521. percent: 1
  37522. }
  37523. }, seriesModel, idx);
  37524. this.add(line);
  37525. var label = new graphic.Text({
  37526. name: 'label'
  37527. });
  37528. this.add(label);
  37529. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  37530. var symbol = createSymbol(symbolCategory, lineData, idx);
  37531. // symbols must added after line to make sure
  37532. // it will be updated after line#update.
  37533. // Or symbol position and rotation update in line#beforeUpdate will be one frame slow
  37534. this.add(symbol);
  37535. this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
  37536. }, this);
  37537. this._updateCommonStl(lineData, idx, seriesScope);
  37538. };
  37539. lineProto.updateData = function (lineData, idx, seriesScope) {
  37540. var seriesModel = lineData.hostModel;
  37541. var line = this.childOfName('line');
  37542. var linePoints = lineData.getItemLayout(idx);
  37543. var target = {
  37544. shape: {}
  37545. };
  37546. setLinePoints(target.shape, linePoints);
  37547. graphic.updateProps(line, target, seriesModel, idx);
  37548. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  37549. var symbolType = lineData.getItemVisual(idx, symbolCategory);
  37550. var key = makeSymbolTypeKey(symbolCategory);
  37551. // Symbol changed
  37552. if (this[key] !== symbolType) {
  37553. this.remove(this.childOfName(symbolCategory));
  37554. var symbol = createSymbol(symbolCategory, lineData, idx);
  37555. this.add(symbol);
  37556. }
  37557. this[key] = symbolType;
  37558. }, this);
  37559. this._updateCommonStl(lineData, idx, seriesScope);
  37560. };
  37561. lineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  37562. var seriesModel = lineData.hostModel;
  37563. var line = this.childOfName('line');
  37564. var lineStyle = seriesScope && seriesScope.lineStyle;
  37565. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  37566. var labelModel = seriesScope && seriesScope.labelModel;
  37567. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  37568. // Optimization for large dataset
  37569. if (!seriesScope || lineData.hasItemOption) {
  37570. var itemModel = lineData.getItemModel(idx);
  37571. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  37572. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  37573. labelModel = itemModel.getModel('label.normal');
  37574. hoverLabelModel = itemModel.getModel('label.emphasis');
  37575. }
  37576. var visualColor = lineData.getItemVisual(idx, 'color');
  37577. var visualOpacity = zrUtil.retrieve3(
  37578. lineData.getItemVisual(idx, 'opacity'),
  37579. lineStyle.opacity,
  37580. 1
  37581. );
  37582. line.useStyle(zrUtil.defaults(
  37583. {
  37584. strokeNoScale: true,
  37585. fill: 'none',
  37586. stroke: visualColor,
  37587. opacity: visualOpacity
  37588. },
  37589. lineStyle
  37590. ));
  37591. line.hoverStyle = hoverLineStyle;
  37592. // Update symbol
  37593. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  37594. var symbol = this.childOfName(symbolCategory);
  37595. if (symbol) {
  37596. symbol.setColor(visualColor);
  37597. symbol.setStyle({
  37598. opacity: visualOpacity
  37599. });
  37600. }
  37601. }, this);
  37602. var showLabel = labelModel.getShallow('show');
  37603. var hoverShowLabel = hoverLabelModel.getShallow('show');
  37604. var label = this.childOfName('label');
  37605. var defaultLabelColor;
  37606. var defaultText;
  37607. var normalText;
  37608. var emphasisText;
  37609. if (showLabel || hoverShowLabel) {
  37610. var rawVal = seriesModel.getRawValue(idx);
  37611. defaultText = rawVal == null
  37612. ? defaultText = lineData.getName(idx)
  37613. : isFinite(rawVal)
  37614. ? numberUtil.round(rawVal)
  37615. : rawVal;
  37616. defaultLabelColor = visualColor || '#000';
  37617. normalText = zrUtil.retrieve2(
  37618. seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType),
  37619. defaultText
  37620. );
  37621. emphasisText = zrUtil.retrieve2(
  37622. seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType),
  37623. normalText
  37624. );
  37625. }
  37626. // label.afterUpdate = lineAfterUpdate;
  37627. if (showLabel) {
  37628. var labelStyle = graphic.setTextStyle(label.style, labelModel, {
  37629. text: normalText
  37630. }, {
  37631. autoColor: defaultLabelColor
  37632. });
  37633. label.__textAlign = labelStyle.textAlign;
  37634. label.__verticalAlign = labelStyle.textVerticalAlign;
  37635. // 'start', 'middle', 'end'
  37636. label.__position = labelModel.get('position') || 'middle';
  37637. }
  37638. else {
  37639. label.setStyle('text', null);
  37640. }
  37641. if (hoverShowLabel) {
  37642. // Only these properties supported in this emphasis style here.
  37643. label.hoverStyle = {
  37644. text: emphasisText,
  37645. textFill: hoverLabelModel.getTextColor(true),
  37646. // For merging hover style to normal style, do not use
  37647. // `hoverLabelModel.getFont()` here.
  37648. fontStyle: hoverLabelModel.getShallow('fontStyle'),
  37649. fontWeight: hoverLabelModel.getShallow('fontWeight'),
  37650. fontSize: hoverLabelModel.getShallow('fontSize'),
  37651. fontFamily: hoverLabelModel.getShallow('fontFamily')
  37652. };
  37653. }
  37654. else {
  37655. label.hoverStyle = {
  37656. text: null
  37657. };
  37658. }
  37659. label.ignore = !showLabel && !hoverShowLabel;
  37660. graphic.setHoverStyle(this);
  37661. };
  37662. lineProto.highlight = function () {
  37663. this.trigger('emphasis');
  37664. };
  37665. lineProto.downplay = function () {
  37666. this.trigger('normal');
  37667. };
  37668. lineProto.updateLayout = function (lineData, idx) {
  37669. this.setLinePoints(lineData.getItemLayout(idx));
  37670. };
  37671. lineProto.setLinePoints = function (points) {
  37672. var linePath = this.childOfName('line');
  37673. setLinePoints(linePath.shape, points);
  37674. linePath.dirty();
  37675. };
  37676. zrUtil.inherits(Line, graphic.Group);
  37677. module.exports = Line;
  37678. /***/ }),
  37679. /* 215 */
  37680. /***/ (function(module, exports, __webpack_require__) {
  37681. /**
  37682. * Line path for bezier and straight line draw
  37683. */
  37684. var graphic = __webpack_require__(20);
  37685. var vec2 = __webpack_require__(10);
  37686. var straightLineProto = graphic.Line.prototype;
  37687. var bezierCurveProto = graphic.BezierCurve.prototype;
  37688. function isLine(shape) {
  37689. return isNaN(+shape.cpx1) || isNaN(+shape.cpy1);
  37690. }
  37691. module.exports = graphic.extendShape({
  37692. type: 'ec-line',
  37693. style: {
  37694. stroke: '#000',
  37695. fill: null
  37696. },
  37697. shape: {
  37698. x1: 0,
  37699. y1: 0,
  37700. x2: 0,
  37701. y2: 0,
  37702. percent: 1,
  37703. cpx1: null,
  37704. cpy1: null
  37705. },
  37706. buildPath: function (ctx, shape) {
  37707. (isLine(shape) ? straightLineProto : bezierCurveProto).buildPath(ctx, shape);
  37708. },
  37709. pointAt: function (t) {
  37710. return isLine(this.shape)
  37711. ? straightLineProto.pointAt.call(this, t)
  37712. : bezierCurveProto.pointAt.call(this, t);
  37713. },
  37714. tangentAt: function (t) {
  37715. var shape = this.shape;
  37716. var p = isLine(shape)
  37717. ? [shape.x2 - shape.x1, shape.y2 - shape.y1]
  37718. : bezierCurveProto.tangentAt.call(this, t);
  37719. return vec2.normalize(p, p);
  37720. }
  37721. });
  37722. /***/ }),
  37723. /* 216 */
  37724. /***/ (function(module, exports, __webpack_require__) {
  37725. var curveTool = __webpack_require__(40);
  37726. var vec2 = __webpack_require__(10);
  37727. var v1 = [];
  37728. var v2 = [];
  37729. var v3 = [];
  37730. var quadraticAt = curveTool.quadraticAt;
  37731. var v2DistSquare = vec2.distSquare;
  37732. var mathAbs = Math.abs;
  37733. function intersectCurveCircle(curvePoints, center, radius) {
  37734. var p0 = curvePoints[0];
  37735. var p1 = curvePoints[1];
  37736. var p2 = curvePoints[2];
  37737. var d = Infinity;
  37738. var t;
  37739. var radiusSquare = radius * radius;
  37740. var interval = 0.1;
  37741. for (var _t = 0.1; _t <= 0.9; _t += 0.1) {
  37742. v1[0] = quadraticAt(p0[0], p1[0], p2[0], _t);
  37743. v1[1] = quadraticAt(p0[1], p1[1], p2[1], _t);
  37744. var diff = mathAbs(v2DistSquare(v1, center) - radiusSquare);
  37745. if (diff < d) {
  37746. d = diff;
  37747. t = _t;
  37748. }
  37749. }
  37750. // Assume the segment is monotone,Find root through Bisection method
  37751. // At most 32 iteration
  37752. for (var i = 0; i < 32; i++) {
  37753. // var prev = t - interval;
  37754. var next = t + interval;
  37755. // v1[0] = quadraticAt(p0[0], p1[0], p2[0], prev);
  37756. // v1[1] = quadraticAt(p0[1], p1[1], p2[1], prev);
  37757. v2[0] = quadraticAt(p0[0], p1[0], p2[0], t);
  37758. v2[1] = quadraticAt(p0[1], p1[1], p2[1], t);
  37759. v3[0] = quadraticAt(p0[0], p1[0], p2[0], next);
  37760. v3[1] = quadraticAt(p0[1], p1[1], p2[1], next);
  37761. var diff = v2DistSquare(v2, center) - radiusSquare;
  37762. if (mathAbs(diff) < 1e-2) {
  37763. break;
  37764. }
  37765. // var prevDiff = v2DistSquare(v1, center) - radiusSquare;
  37766. var nextDiff = v2DistSquare(v3, center) - radiusSquare;
  37767. interval /= 2;
  37768. if (diff < 0) {
  37769. if (nextDiff >= 0) {
  37770. t = t + interval;
  37771. }
  37772. else {
  37773. t = t - interval;
  37774. }
  37775. }
  37776. else {
  37777. if (nextDiff >= 0) {
  37778. t = t - interval;
  37779. }
  37780. else {
  37781. t = t + interval;
  37782. }
  37783. }
  37784. }
  37785. return t;
  37786. }
  37787. // Adjust edge to avoid
  37788. module.exports = function (graph, scale) {
  37789. var tmp0 = [];
  37790. var quadraticSubdivide = curveTool.quadraticSubdivide;
  37791. var pts = [[], [], []];
  37792. var pts2 = [[], []];
  37793. var v = [];
  37794. scale /= 2;
  37795. function getSymbolSize(node) {
  37796. var symbolSize = node.getVisual('symbolSize');
  37797. if (symbolSize instanceof Array) {
  37798. symbolSize = (symbolSize[0] + symbolSize[1]) / 2;
  37799. }
  37800. return symbolSize;
  37801. }
  37802. graph.eachEdge(function (edge, idx) {
  37803. var linePoints = edge.getLayout();
  37804. var fromSymbol = edge.getVisual('fromSymbol');
  37805. var toSymbol = edge.getVisual('toSymbol');
  37806. if (!linePoints.__original) {
  37807. linePoints.__original = [
  37808. vec2.clone(linePoints[0]),
  37809. vec2.clone(linePoints[1])
  37810. ];
  37811. if (linePoints[2]) {
  37812. linePoints.__original.push(vec2.clone(linePoints[2]));
  37813. }
  37814. }
  37815. var originalPoints = linePoints.__original;
  37816. // Quadratic curve
  37817. if (linePoints[2] != null) {
  37818. vec2.copy(pts[0], originalPoints[0]);
  37819. vec2.copy(pts[1], originalPoints[2]);
  37820. vec2.copy(pts[2], originalPoints[1]);
  37821. if (fromSymbol && fromSymbol != 'none') {
  37822. var symbolSize = getSymbolSize(edge.node1);
  37823. var t = intersectCurveCircle(pts, originalPoints[0], symbolSize * scale);
  37824. // Subdivide and get the second
  37825. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  37826. pts[0][0] = tmp0[3];
  37827. pts[1][0] = tmp0[4];
  37828. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  37829. pts[0][1] = tmp0[3];
  37830. pts[1][1] = tmp0[4];
  37831. }
  37832. if (toSymbol && toSymbol != 'none') {
  37833. var symbolSize = getSymbolSize(edge.node2);
  37834. var t = intersectCurveCircle(pts, originalPoints[1], symbolSize * scale);
  37835. // Subdivide and get the first
  37836. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  37837. pts[1][0] = tmp0[1];
  37838. pts[2][0] = tmp0[2];
  37839. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  37840. pts[1][1] = tmp0[1];
  37841. pts[2][1] = tmp0[2];
  37842. }
  37843. // Copy back to layout
  37844. vec2.copy(linePoints[0], pts[0]);
  37845. vec2.copy(linePoints[1], pts[2]);
  37846. vec2.copy(linePoints[2], pts[1]);
  37847. }
  37848. // Line
  37849. else {
  37850. vec2.copy(pts2[0], originalPoints[0]);
  37851. vec2.copy(pts2[1], originalPoints[1]);
  37852. vec2.sub(v, pts2[1], pts2[0]);
  37853. vec2.normalize(v, v);
  37854. if (fromSymbol && fromSymbol != 'none') {
  37855. var symbolSize = getSymbolSize(edge.node1);
  37856. vec2.scaleAndAdd(pts2[0], pts2[0], v, symbolSize * scale);
  37857. }
  37858. if (toSymbol && toSymbol != 'none') {
  37859. var symbolSize = getSymbolSize(edge.node2);
  37860. vec2.scaleAndAdd(pts2[1], pts2[1], v, -symbolSize * scale);
  37861. }
  37862. vec2.copy(linePoints[0], pts2[0]);
  37863. vec2.copy(linePoints[1], pts2[1]);
  37864. }
  37865. });
  37866. };
  37867. /***/ }),
  37868. /* 217 */
  37869. /***/ (function(module, exports, __webpack_require__) {
  37870. var echarts = __webpack_require__(1);
  37871. var roamHelper = __webpack_require__(191);
  37872. var actionInfo = {
  37873. type: 'graphRoam',
  37874. event: 'graphRoam',
  37875. update: 'none'
  37876. };
  37877. /**
  37878. * @payload
  37879. * @property {string} name Series name
  37880. * @property {number} [dx]
  37881. * @property {number} [dy]
  37882. * @property {number} [zoom]
  37883. * @property {number} [originX]
  37884. * @property {number} [originY]
  37885. */
  37886. echarts.registerAction(actionInfo, function (payload, ecModel) {
  37887. ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) {
  37888. var coordSys = seriesModel.coordinateSystem;
  37889. var res = roamHelper.updateCenterAndZoom(coordSys, payload);
  37890. seriesModel.setCenter
  37891. && seriesModel.setCenter(res.center);
  37892. seriesModel.setZoom
  37893. && seriesModel.setZoom(res.zoom);
  37894. });
  37895. });
  37896. /**
  37897. * @payload
  37898. * @property {number} [seriesIndex]
  37899. * @property {string} [seriesId]
  37900. * @property {string} [seriesName]
  37901. * @property {number} [dataIndex]
  37902. */
  37903. echarts.registerAction({
  37904. type: 'focusNodeAdjacency',
  37905. event: 'focusNodeAdjacency',
  37906. update: 'series.graph:focusNodeAdjacency'
  37907. }, function () {});
  37908. /**
  37909. * @payload
  37910. * @property {number} [seriesIndex]
  37911. * @property {string} [seriesId]
  37912. * @property {string} [seriesName]
  37913. */
  37914. echarts.registerAction({
  37915. type: 'unfocusNodeAdjacency',
  37916. event: 'unfocusNodeAdjacency',
  37917. update: 'series.graph:unfocusNodeAdjacency'
  37918. }, function () {});
  37919. /***/ }),
  37920. /* 218 */
  37921. /***/ (function(module, exports) {
  37922. module.exports = function (ecModel) {
  37923. var legendModels = ecModel.findComponents({
  37924. mainType: 'legend'
  37925. });
  37926. if (!legendModels || !legendModels.length) {
  37927. return;
  37928. }
  37929. ecModel.eachSeriesByType('graph', function (graphSeries) {
  37930. var categoriesData = graphSeries.getCategoriesData();
  37931. var graph = graphSeries.getGraph();
  37932. var data = graph.data;
  37933. var categoryNames = categoriesData.mapArray(categoriesData.getName);
  37934. data.filterSelf(function (idx) {
  37935. var model = data.getItemModel(idx);
  37936. var category = model.getShallow('category');
  37937. if (category != null) {
  37938. if (typeof category === 'number') {
  37939. category = categoryNames[category];
  37940. }
  37941. // If in any legend component the status is not selected.
  37942. for (var i = 0; i < legendModels.length; i++) {
  37943. if (!legendModels[i].isSelected(category)) {
  37944. return false;
  37945. }
  37946. }
  37947. }
  37948. return true;
  37949. });
  37950. }, this);
  37951. };
  37952. /***/ }),
  37953. /* 219 */
  37954. /***/ (function(module, exports) {
  37955. module.exports = function (ecModel) {
  37956. var paletteScope = {};
  37957. ecModel.eachSeriesByType('graph', function (seriesModel) {
  37958. var categoriesData = seriesModel.getCategoriesData();
  37959. var data = seriesModel.getData();
  37960. var categoryNameIdxMap = {};
  37961. categoriesData.each(function (idx) {
  37962. var name = categoriesData.getName(idx);
  37963. // Add prefix to avoid conflict with Object.prototype.
  37964. categoryNameIdxMap['ec-' + name] = idx;
  37965. var itemModel = categoriesData.getItemModel(idx);
  37966. var color = itemModel.get('itemStyle.normal.color')
  37967. || seriesModel.getColorFromPalette(name, paletteScope);
  37968. categoriesData.setItemVisual(idx, 'color', color);
  37969. });
  37970. // Assign category color to visual
  37971. if (categoriesData.count()) {
  37972. data.each(function (idx) {
  37973. var model = data.getItemModel(idx);
  37974. var category = model.getShallow('category');
  37975. if (category != null) {
  37976. if (typeof category === 'string') {
  37977. category = categoryNameIdxMap['ec-' + category];
  37978. }
  37979. if (!data.getItemVisual(idx, 'color', true)) {
  37980. data.setItemVisual(
  37981. idx, 'color',
  37982. categoriesData.getItemVisual(category, 'color')
  37983. );
  37984. }
  37985. }
  37986. });
  37987. }
  37988. });
  37989. };
  37990. /***/ }),
  37991. /* 220 */
  37992. /***/ (function(module, exports) {
  37993. function normalize(a) {
  37994. if (!(a instanceof Array)) {
  37995. a = [a, a];
  37996. }
  37997. return a;
  37998. }
  37999. module.exports = function (ecModel) {
  38000. ecModel.eachSeriesByType('graph', function (seriesModel) {
  38001. var graph = seriesModel.getGraph();
  38002. var edgeData = seriesModel.getEdgeData();
  38003. var symbolType = normalize(seriesModel.get('edgeSymbol'));
  38004. var symbolSize = normalize(seriesModel.get('edgeSymbolSize'));
  38005. var colorQuery = 'lineStyle.normal.color'.split('.');
  38006. var opacityQuery = 'lineStyle.normal.opacity'.split('.');
  38007. edgeData.setVisual('fromSymbol', symbolType && symbolType[0]);
  38008. edgeData.setVisual('toSymbol', symbolType && symbolType[1]);
  38009. edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  38010. edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  38011. edgeData.setVisual('color', seriesModel.get(colorQuery));
  38012. edgeData.setVisual('opacity', seriesModel.get(opacityQuery));
  38013. edgeData.each(function (idx) {
  38014. var itemModel = edgeData.getItemModel(idx);
  38015. var edge = graph.getEdgeByIndex(idx);
  38016. var symbolType = normalize(itemModel.getShallow('symbol', true));
  38017. var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
  38018. // Edge visual must after node visual
  38019. var color = itemModel.get(colorQuery);
  38020. var opacity = itemModel.get(opacityQuery);
  38021. switch (color) {
  38022. case 'source':
  38023. color = edge.node1.getVisual('color');
  38024. break;
  38025. case 'target':
  38026. color = edge.node2.getVisual('color');
  38027. break;
  38028. }
  38029. symbolType[0] && edge.setVisual('fromSymbol', symbolType[0]);
  38030. symbolType[1] && edge.setVisual('toSymbol', symbolType[1]);
  38031. symbolSize[0] && edge.setVisual('fromSymbolSize', symbolSize[0]);
  38032. symbolSize[1] && edge.setVisual('toSymbolSize', symbolSize[1]);
  38033. edge.setVisual('color', color);
  38034. edge.setVisual('opacity', opacity);
  38035. });
  38036. });
  38037. };
  38038. /***/ }),
  38039. /* 221 */
  38040. /***/ (function(module, exports, __webpack_require__) {
  38041. var simpleLayoutHelper = __webpack_require__(222);
  38042. var simpleLayoutEdge = __webpack_require__(223);
  38043. module.exports = function (ecModel, api) {
  38044. ecModel.eachSeriesByType('graph', function (seriesModel) {
  38045. var layout = seriesModel.get('layout');
  38046. var coordSys = seriesModel.coordinateSystem;
  38047. if (coordSys && coordSys.type !== 'view') {
  38048. var data = seriesModel.getData();
  38049. var dimensions = coordSys.dimensions;
  38050. data.each(dimensions, function () {
  38051. var hasValue;
  38052. var args = arguments;
  38053. var value = [];
  38054. for (var i = 0; i < dimensions.length; i++) {
  38055. if (!isNaN(args[i])) {
  38056. hasValue = true;
  38057. }
  38058. value.push(args[i]);
  38059. }
  38060. var idx = args[args.length - 1];
  38061. if (hasValue) {
  38062. data.setItemLayout(idx, coordSys.dataToPoint(value));
  38063. }
  38064. else {
  38065. // Also {Array.<number>}, not undefined to avoid if...else... statement
  38066. data.setItemLayout(idx, [NaN, NaN]);
  38067. }
  38068. });
  38069. simpleLayoutEdge(data.graph);
  38070. }
  38071. else if (!layout || layout === 'none') {
  38072. simpleLayoutHelper(seriesModel);
  38073. }
  38074. });
  38075. };
  38076. /***/ }),
  38077. /* 222 */
  38078. /***/ (function(module, exports, __webpack_require__) {
  38079. var simpleLayoutEdge = __webpack_require__(223);
  38080. module.exports = function (seriesModel) {
  38081. var coordSys = seriesModel.coordinateSystem;
  38082. if (coordSys && coordSys.type !== 'view') {
  38083. return;
  38084. }
  38085. var graph = seriesModel.getGraph();
  38086. graph.eachNode(function (node) {
  38087. var model = node.getModel();
  38088. node.setLayout([+model.get('x'), +model.get('y')]);
  38089. });
  38090. simpleLayoutEdge(graph);
  38091. };
  38092. /***/ }),
  38093. /* 223 */
  38094. /***/ (function(module, exports, __webpack_require__) {
  38095. var vec2 = __webpack_require__(10);
  38096. module.exports = function (graph) {
  38097. graph.eachEdge(function (edge) {
  38098. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  38099. var p1 = vec2.clone(edge.node1.getLayout());
  38100. var p2 = vec2.clone(edge.node2.getLayout());
  38101. var points = [p1, p2];
  38102. if (+curveness) {
  38103. points.push([
  38104. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness,
  38105. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness
  38106. ]);
  38107. }
  38108. edge.setLayout(points);
  38109. });
  38110. };
  38111. /***/ }),
  38112. /* 224 */
  38113. /***/ (function(module, exports, __webpack_require__) {
  38114. var circularLayoutHelper = __webpack_require__(225);
  38115. module.exports = function (ecModel) {
  38116. ecModel.eachSeriesByType('graph', function (seriesModel) {
  38117. if (seriesModel.get('layout') === 'circular') {
  38118. circularLayoutHelper(seriesModel);
  38119. }
  38120. });
  38121. };
  38122. /***/ }),
  38123. /* 225 */
  38124. /***/ (function(module, exports, __webpack_require__) {
  38125. var vec2 = __webpack_require__(10);
  38126. module.exports = function (seriesModel) {
  38127. var coordSys = seriesModel.coordinateSystem;
  38128. if (coordSys && coordSys.type !== 'view') {
  38129. return;
  38130. }
  38131. var rect = coordSys.getBoundingRect();
  38132. var nodeData = seriesModel.getData();
  38133. var graph = nodeData.graph;
  38134. var angle = 0;
  38135. var sum = nodeData.getSum('value');
  38136. var unitAngle = Math.PI * 2 / (sum || nodeData.count());
  38137. var cx = rect.width / 2 + rect.x;
  38138. var cy = rect.height / 2 + rect.y;
  38139. var r = Math.min(rect.width, rect.height) / 2;
  38140. graph.eachNode(function (node) {
  38141. var value = node.getValue('value');
  38142. angle += unitAngle * (sum ? value : 1) / 2;
  38143. node.setLayout([
  38144. r * Math.cos(angle) + cx,
  38145. r * Math.sin(angle) + cy
  38146. ]);
  38147. angle += unitAngle * (sum ? value : 1) / 2;
  38148. });
  38149. nodeData.setLayout({
  38150. cx: cx,
  38151. cy: cy
  38152. });
  38153. graph.eachEdge(function (edge) {
  38154. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  38155. var p1 = vec2.clone(edge.node1.getLayout());
  38156. var p2 = vec2.clone(edge.node2.getLayout());
  38157. var cp1;
  38158. var x12 = (p1[0] + p2[0]) / 2;
  38159. var y12 = (p1[1] + p2[1]) / 2;
  38160. if (+curveness) {
  38161. curveness *= 3;
  38162. cp1 = [
  38163. cx * curveness + x12 * (1 - curveness),
  38164. cy * curveness + y12 * (1 - curveness)
  38165. ];
  38166. }
  38167. edge.setLayout([p1, p2, cp1]);
  38168. });
  38169. };
  38170. /***/ }),
  38171. /* 226 */
  38172. /***/ (function(module, exports, __webpack_require__) {
  38173. var forceHelper = __webpack_require__(227);
  38174. var numberUtil = __webpack_require__(7);
  38175. var simpleLayoutHelper = __webpack_require__(222);
  38176. var circularLayoutHelper = __webpack_require__(225);
  38177. var vec2 = __webpack_require__(10);
  38178. var zrUtil = __webpack_require__(4);
  38179. module.exports = function (ecModel) {
  38180. ecModel.eachSeriesByType('graph', function (graphSeries) {
  38181. var coordSys = graphSeries.coordinateSystem;
  38182. if (coordSys && coordSys.type !== 'view') {
  38183. return;
  38184. }
  38185. if (graphSeries.get('layout') === 'force') {
  38186. var preservedPoints = graphSeries.preservedPoints || {};
  38187. var graph = graphSeries.getGraph();
  38188. var nodeData = graph.data;
  38189. var edgeData = graph.edgeData;
  38190. var forceModel = graphSeries.getModel('force');
  38191. var initLayout = forceModel.get('initLayout');
  38192. if (graphSeries.preservedPoints) {
  38193. nodeData.each(function (idx) {
  38194. var id = nodeData.getId(idx);
  38195. nodeData.setItemLayout(idx, preservedPoints[id] || [NaN, NaN]);
  38196. });
  38197. }
  38198. else if (!initLayout || initLayout === 'none') {
  38199. simpleLayoutHelper(graphSeries);
  38200. }
  38201. else if (initLayout === 'circular') {
  38202. circularLayoutHelper(graphSeries);
  38203. }
  38204. var nodeDataExtent = nodeData.getDataExtent('value');
  38205. var edgeDataExtent = edgeData.getDataExtent('value');
  38206. // var edgeDataExtent = edgeData.getDataExtent('value');
  38207. var repulsion = forceModel.get('repulsion');
  38208. var edgeLength = forceModel.get('edgeLength');
  38209. if (!zrUtil.isArray(repulsion)) {
  38210. repulsion = [repulsion, repulsion];
  38211. }
  38212. if (!zrUtil.isArray(edgeLength)) {
  38213. edgeLength = [edgeLength, edgeLength];
  38214. }
  38215. // Larger value has smaller length
  38216. edgeLength = [edgeLength[1], edgeLength[0]];
  38217. var nodes = nodeData.mapArray('value', function (value, idx) {
  38218. var point = nodeData.getItemLayout(idx);
  38219. // var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]);
  38220. var rep = numberUtil.linearMap(value, nodeDataExtent, repulsion);
  38221. if (isNaN(rep)) {
  38222. rep = (repulsion[0] + repulsion[1]) / 2;
  38223. }
  38224. return {
  38225. w: rep,
  38226. rep: rep,
  38227. fixed: nodeData.getItemModel(idx).get('fixed'),
  38228. p: (!point || isNaN(point[0]) || isNaN(point[1])) ? null : point
  38229. };
  38230. });
  38231. var edges = edgeData.mapArray('value', function (value, idx) {
  38232. var edge = graph.getEdgeByIndex(idx);
  38233. var d = numberUtil.linearMap(value, edgeDataExtent, edgeLength);
  38234. if (isNaN(d)) {
  38235. d = (edgeLength[0] + edgeLength[1]) / 2;
  38236. }
  38237. return {
  38238. n1: nodes[edge.node1.dataIndex],
  38239. n2: nodes[edge.node2.dataIndex],
  38240. d: d,
  38241. curveness: edge.getModel().get('lineStyle.normal.curveness') || 0
  38242. };
  38243. });
  38244. var coordSys = graphSeries.coordinateSystem;
  38245. var rect = coordSys.getBoundingRect();
  38246. var forceInstance = forceHelper(nodes, edges, {
  38247. rect: rect,
  38248. gravity: forceModel.get('gravity')
  38249. });
  38250. var oldStep = forceInstance.step;
  38251. forceInstance.step = function (cb) {
  38252. for (var i = 0, l = nodes.length; i < l; i++) {
  38253. if (nodes[i].fixed) {
  38254. // Write back to layout instance
  38255. vec2.copy(nodes[i].p, graph.getNodeByIndex(i).getLayout());
  38256. }
  38257. }
  38258. oldStep(function (nodes, edges, stopped) {
  38259. for (var i = 0, l = nodes.length; i < l; i++) {
  38260. if (!nodes[i].fixed) {
  38261. graph.getNodeByIndex(i).setLayout(nodes[i].p);
  38262. }
  38263. preservedPoints[nodeData.getId(i)] = nodes[i].p;
  38264. }
  38265. for (var i = 0, l = edges.length; i < l; i++) {
  38266. var e = edges[i];
  38267. var edge = graph.getEdgeByIndex(i);
  38268. var p1 = e.n1.p;
  38269. var p2 = e.n2.p;
  38270. var points = edge.getLayout();
  38271. points = points ? points.slice() : [];
  38272. points[0] = points[0] || [];
  38273. points[1] = points[1] || [];
  38274. vec2.copy(points[0], p1);
  38275. vec2.copy(points[1], p2);
  38276. if (+e.curveness) {
  38277. points[2] = [
  38278. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness,
  38279. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness
  38280. ];
  38281. }
  38282. edge.setLayout(points);
  38283. }
  38284. // Update layout
  38285. cb && cb(stopped);
  38286. });
  38287. };
  38288. graphSeries.forceLayout = forceInstance;
  38289. graphSeries.preservedPoints = preservedPoints;
  38290. // Step to get the layout
  38291. forceInstance.step();
  38292. }
  38293. else {
  38294. // Remove prev injected forceLayout instance
  38295. graphSeries.forceLayout = null;
  38296. }
  38297. });
  38298. };
  38299. /***/ }),
  38300. /* 227 */
  38301. /***/ (function(module, exports, __webpack_require__) {
  38302. var vec2 = __webpack_require__(10);
  38303. var scaleAndAdd = vec2.scaleAndAdd;
  38304. // function adjacentNode(n, e) {
  38305. // return e.n1 === n ? e.n2 : e.n1;
  38306. // }
  38307. module.exports = function (nodes, edges, opts) {
  38308. var rect = opts.rect;
  38309. var width = rect.width;
  38310. var height = rect.height;
  38311. var center = [rect.x + width / 2, rect.y + height / 2];
  38312. // var scale = opts.scale || 1;
  38313. var gravity = opts.gravity == null ? 0.1 : opts.gravity;
  38314. // for (var i = 0; i < edges.length; i++) {
  38315. // var e = edges[i];
  38316. // var n1 = e.n1;
  38317. // var n2 = e.n2;
  38318. // n1.edges = n1.edges || [];
  38319. // n2.edges = n2.edges || [];
  38320. // n1.edges.push(e);
  38321. // n2.edges.push(e);
  38322. // }
  38323. // Init position
  38324. for (var i = 0; i < nodes.length; i++) {
  38325. var n = nodes[i];
  38326. if (!n.p) {
  38327. // Use the position from first adjecent node with defined position
  38328. // Or use a random position
  38329. // From d3
  38330. // if (n.edges) {
  38331. // var j = -1;
  38332. // while (++j < n.edges.length) {
  38333. // var e = n.edges[j];
  38334. // var other = adjacentNode(n, e);
  38335. // if (other.p) {
  38336. // n.p = vec2.clone(other.p);
  38337. // break;
  38338. // }
  38339. // }
  38340. // }
  38341. // if (!n.p) {
  38342. n.p = vec2.create(
  38343. width * (Math.random() - 0.5) + center[0],
  38344. height * (Math.random() - 0.5) + center[1]
  38345. );
  38346. // }
  38347. }
  38348. n.pp = vec2.clone(n.p);
  38349. n.edges = null;
  38350. }
  38351. // Formula in 'Graph Drawing by Force-directed Placement'
  38352. // var k = scale * Math.sqrt(width * height / nodes.length);
  38353. // var k2 = k * k;
  38354. var friction = 0.6;
  38355. return {
  38356. warmUp: function () {
  38357. friction = 0.5;
  38358. },
  38359. setFixed: function (idx) {
  38360. nodes[idx].fixed = true;
  38361. },
  38362. setUnfixed: function (idx) {
  38363. nodes[idx].fixed = false;
  38364. },
  38365. step: function (cb) {
  38366. var v12 = [];
  38367. var nLen = nodes.length;
  38368. for (var i = 0; i < edges.length; i++) {
  38369. var e = edges[i];
  38370. var n1 = e.n1;
  38371. var n2 = e.n2;
  38372. vec2.sub(v12, n2.p, n1.p);
  38373. var d = vec2.len(v12) - e.d;
  38374. var w = n2.w / (n1.w + n2.w);
  38375. vec2.normalize(v12, v12);
  38376. !n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
  38377. !n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction);
  38378. }
  38379. // Gravity
  38380. for (var i = 0; i < nLen; i++) {
  38381. var n = nodes[i];
  38382. if (!n.fixed) {
  38383. vec2.sub(v12, center, n.p);
  38384. // var d = vec2.len(v12);
  38385. // vec2.scale(v12, v12, 1 / d);
  38386. // var gravityFactor = gravity;
  38387. vec2.scaleAndAdd(n.p, n.p, v12, gravity * friction);
  38388. }
  38389. }
  38390. // Repulsive
  38391. // PENDING
  38392. for (var i = 0; i < nLen; i++) {
  38393. var n1 = nodes[i];
  38394. for (var j = i + 1; j < nLen; j++) {
  38395. var n2 = nodes[j];
  38396. vec2.sub(v12, n2.p, n1.p);
  38397. var d = vec2.len(v12);
  38398. if (d === 0) {
  38399. // Random repulse
  38400. vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5);
  38401. d = 1;
  38402. }
  38403. var repFact = (n1.rep + n2.rep) / d / d;
  38404. !n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact);
  38405. !n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact);
  38406. }
  38407. }
  38408. var v = [];
  38409. for (var i = 0; i < nLen; i++) {
  38410. var n = nodes[i];
  38411. if (!n.fixed) {
  38412. vec2.sub(v, n.p, n.pp);
  38413. vec2.scaleAndAdd(n.p, n.p, v, friction);
  38414. vec2.copy(n.pp, n.p);
  38415. }
  38416. }
  38417. friction = friction * 0.992;
  38418. cb && cb(nodes, edges, friction < 0.01);
  38419. }
  38420. };
  38421. };
  38422. /***/ }),
  38423. /* 228 */
  38424. /***/ (function(module, exports, __webpack_require__) {
  38425. // FIXME Where to create the simple view coordinate system
  38426. var View = __webpack_require__(179);
  38427. var layout = __webpack_require__(74);
  38428. var bbox = __webpack_require__(41);
  38429. function getViewRect(seriesModel, api, aspect) {
  38430. var option = seriesModel.getBoxLayoutParams();
  38431. option.aspect = aspect;
  38432. return layout.getLayoutRect(option, {
  38433. width: api.getWidth(),
  38434. height: api.getHeight()
  38435. });
  38436. }
  38437. module.exports = function (ecModel, api) {
  38438. var viewList = [];
  38439. ecModel.eachSeriesByType('graph', function (seriesModel) {
  38440. var coordSysType = seriesModel.get('coordinateSystem');
  38441. if (!coordSysType || coordSysType === 'view') {
  38442. var data = seriesModel.getData();
  38443. var positions = data.mapArray(function (idx) {
  38444. var itemModel = data.getItemModel(idx);
  38445. return [+itemModel.get('x'), +itemModel.get('y')];
  38446. });
  38447. var min = [];
  38448. var max = [];
  38449. bbox.fromPoints(positions, min, max);
  38450. // If width or height is 0
  38451. if (max[0] - min[0] === 0) {
  38452. max[0] += 1;
  38453. min[0] -= 1;
  38454. }
  38455. if (max[1] - min[1] === 0) {
  38456. max[1] += 1;
  38457. min[1] -= 1;
  38458. }
  38459. var aspect = (max[0] - min[0]) / (max[1] - min[1]);
  38460. // FIXME If get view rect after data processed?
  38461. var viewRect = getViewRect(seriesModel, api, aspect);
  38462. // Position may be NaN, use view rect instead
  38463. if (isNaN(aspect)) {
  38464. min = [viewRect.x, viewRect.y];
  38465. max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
  38466. }
  38467. var bbWidth = max[0] - min[0];
  38468. var bbHeight = max[1] - min[1];
  38469. var viewWidth = viewRect.width;
  38470. var viewHeight = viewRect.height;
  38471. var viewCoordSys = seriesModel.coordinateSystem = new View();
  38472. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  38473. viewCoordSys.setBoundingRect(
  38474. min[0], min[1], bbWidth, bbHeight
  38475. );
  38476. viewCoordSys.setViewRect(
  38477. viewRect.x, viewRect.y, viewWidth, viewHeight
  38478. );
  38479. // Update roam info
  38480. viewCoordSys.setCenter(seriesModel.get('center'));
  38481. viewCoordSys.setZoom(seriesModel.get('zoom'));
  38482. viewList.push(viewCoordSys);
  38483. }
  38484. });
  38485. return viewList;
  38486. };
  38487. /***/ }),
  38488. /* 229 */
  38489. /***/ (function(module, exports, __webpack_require__) {
  38490. __webpack_require__(230);
  38491. __webpack_require__(231);
  38492. /***/ }),
  38493. /* 230 */
  38494. /***/ (function(module, exports, __webpack_require__) {
  38495. var List = __webpack_require__(101);
  38496. var SeriesModel = __webpack_require__(83);
  38497. var zrUtil = __webpack_require__(4);
  38498. var GaugeSeries = SeriesModel.extend({
  38499. type: 'series.gauge',
  38500. getInitialData: function (option, ecModel) {
  38501. var list = new List(['value'], this);
  38502. var dataOpt = option.data || [];
  38503. if (!zrUtil.isArray(dataOpt)) {
  38504. dataOpt = [dataOpt];
  38505. }
  38506. // Only use the first data item
  38507. list.initData(dataOpt);
  38508. return list;
  38509. },
  38510. defaultOption: {
  38511. zlevel: 0,
  38512. z: 2,
  38513. // 默认全局居中
  38514. center: ['50%', '50%'],
  38515. legendHoverLink: true,
  38516. radius: '75%',
  38517. startAngle: 225,
  38518. endAngle: -45,
  38519. clockwise: true,
  38520. // 最小值
  38521. min: 0,
  38522. // 最大值
  38523. max: 100,
  38524. // 分割段数,默认为10
  38525. splitNumber: 10,
  38526. // 坐标轴线
  38527. axisLine: {
  38528. // 默认显示,属性show控制显示与否
  38529. show: true,
  38530. lineStyle: { // 属性lineStyle控制线条样式
  38531. color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']],
  38532. width: 30
  38533. }
  38534. },
  38535. // 分隔线
  38536. splitLine: {
  38537. // 默认显示,属性show控制显示与否
  38538. show: true,
  38539. // 属性length控制线长
  38540. length: 30,
  38541. // 属性lineStyle(详见lineStyle)控制线条样式
  38542. lineStyle: {
  38543. color: '#eee',
  38544. width: 2,
  38545. type: 'solid'
  38546. }
  38547. },
  38548. // 坐标轴小标记
  38549. axisTick: {
  38550. // 属性show控制显示与否,默认不显示
  38551. show: true,
  38552. // 每份split细分多少段
  38553. splitNumber: 5,
  38554. // 属性length控制线长
  38555. length: 8,
  38556. // 属性lineStyle控制线条样式
  38557. lineStyle: {
  38558. color: '#eee',
  38559. width: 1,
  38560. type: 'solid'
  38561. }
  38562. },
  38563. axisLabel: {
  38564. show: true,
  38565. distance: 5,
  38566. // formatter: null,
  38567. color: 'auto'
  38568. },
  38569. pointer: {
  38570. show: true,
  38571. length: '80%',
  38572. width: 8
  38573. },
  38574. itemStyle: {
  38575. normal: {
  38576. color: 'auto'
  38577. }
  38578. },
  38579. title: {
  38580. show: true,
  38581. // x, y,单位px
  38582. offsetCenter: [0, '-40%'],
  38583. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  38584. color: '#333',
  38585. fontSize: 15
  38586. },
  38587. detail: {
  38588. show: true,
  38589. backgroundColor: 'rgba(0,0,0,0)',
  38590. borderWidth: 0,
  38591. borderColor: '#ccc',
  38592. width: 100,
  38593. height: null, // self-adaption
  38594. padding: [5, 10],
  38595. // x, y,单位px
  38596. offsetCenter: [0, '40%'],
  38597. // formatter: null,
  38598. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  38599. color: 'auto',
  38600. fontSize: 30
  38601. }
  38602. }
  38603. });
  38604. module.exports = GaugeSeries;
  38605. /***/ }),
  38606. /* 231 */
  38607. /***/ (function(module, exports, __webpack_require__) {
  38608. var PointerPath = __webpack_require__(232);
  38609. var graphic = __webpack_require__(20);
  38610. var numberUtil = __webpack_require__(7);
  38611. var parsePercent = numberUtil.parsePercent;
  38612. function parsePosition(seriesModel, api) {
  38613. var center = seriesModel.get('center');
  38614. var width = api.getWidth();
  38615. var height = api.getHeight();
  38616. var size = Math.min(width, height);
  38617. var cx = parsePercent(center[0], api.getWidth());
  38618. var cy = parsePercent(center[1], api.getHeight());
  38619. var r = parsePercent(seriesModel.get('radius'), size / 2);
  38620. return {
  38621. cx: cx,
  38622. cy: cy,
  38623. r: r
  38624. };
  38625. }
  38626. function formatLabel(label, labelFormatter) {
  38627. if (labelFormatter) {
  38628. if (typeof labelFormatter === 'string') {
  38629. label = labelFormatter.replace('{value}', label != null ? label : '');
  38630. }
  38631. else if (typeof labelFormatter === 'function') {
  38632. label = labelFormatter(label);
  38633. }
  38634. }
  38635. return label;
  38636. }
  38637. var PI2 = Math.PI * 2;
  38638. var GaugeView = __webpack_require__(85).extend({
  38639. type: 'gauge',
  38640. render: function (seriesModel, ecModel, api) {
  38641. this.group.removeAll();
  38642. var colorList = seriesModel.get('axisLine.lineStyle.color');
  38643. var posInfo = parsePosition(seriesModel, api);
  38644. this._renderMain(
  38645. seriesModel, ecModel, api, colorList, posInfo
  38646. );
  38647. },
  38648. dispose: function () {},
  38649. _renderMain: function (seriesModel, ecModel, api, colorList, posInfo) {
  38650. var group = this.group;
  38651. var axisLineModel = seriesModel.getModel('axisLine');
  38652. var lineStyleModel = axisLineModel.getModel('lineStyle');
  38653. var clockwise = seriesModel.get('clockwise');
  38654. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  38655. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  38656. var angleRangeSpan = (endAngle - startAngle) % PI2;
  38657. var prevEndAngle = startAngle;
  38658. var axisLineWidth = lineStyleModel.get('width');
  38659. for (var i = 0; i < colorList.length; i++) {
  38660. // Clamp
  38661. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  38662. var endAngle = startAngle + angleRangeSpan * percent;
  38663. var sector = new graphic.Sector({
  38664. shape: {
  38665. startAngle: prevEndAngle,
  38666. endAngle: endAngle,
  38667. cx: posInfo.cx,
  38668. cy: posInfo.cy,
  38669. clockwise: clockwise,
  38670. r0: posInfo.r - axisLineWidth,
  38671. r: posInfo.r
  38672. },
  38673. silent: true
  38674. });
  38675. sector.setStyle({
  38676. fill: colorList[i][1]
  38677. });
  38678. sector.setStyle(lineStyleModel.getLineStyle(
  38679. // Because we use sector to simulate arc
  38680. // so the properties for stroking are useless
  38681. ['color', 'borderWidth', 'borderColor']
  38682. ));
  38683. group.add(sector);
  38684. prevEndAngle = endAngle;
  38685. }
  38686. var getColor = function (percent) {
  38687. // Less than 0
  38688. if (percent <= 0) {
  38689. return colorList[0][1];
  38690. }
  38691. for (var i = 0; i < colorList.length; i++) {
  38692. if (colorList[i][0] >= percent
  38693. && (i === 0 ? 0 : colorList[i - 1][0]) < percent
  38694. ) {
  38695. return colorList[i][1];
  38696. }
  38697. }
  38698. // More than 1
  38699. return colorList[i - 1][1];
  38700. };
  38701. if (!clockwise) {
  38702. var tmp = startAngle;
  38703. startAngle = endAngle;
  38704. endAngle = tmp;
  38705. }
  38706. this._renderTicks(
  38707. seriesModel, ecModel, api, getColor, posInfo,
  38708. startAngle, endAngle, clockwise
  38709. );
  38710. this._renderPointer(
  38711. seriesModel, ecModel, api, getColor, posInfo,
  38712. startAngle, endAngle, clockwise
  38713. );
  38714. this._renderTitle(
  38715. seriesModel, ecModel, api, getColor, posInfo
  38716. );
  38717. this._renderDetail(
  38718. seriesModel, ecModel, api, getColor, posInfo
  38719. );
  38720. },
  38721. _renderTicks: function (
  38722. seriesModel, ecModel, api, getColor, posInfo,
  38723. startAngle, endAngle, clockwise
  38724. ) {
  38725. var group = this.group;
  38726. var cx = posInfo.cx;
  38727. var cy = posInfo.cy;
  38728. var r = posInfo.r;
  38729. var minVal = +seriesModel.get('min');
  38730. var maxVal = +seriesModel.get('max');
  38731. var splitLineModel = seriesModel.getModel('splitLine');
  38732. var tickModel = seriesModel.getModel('axisTick');
  38733. var labelModel = seriesModel.getModel('axisLabel');
  38734. var splitNumber = seriesModel.get('splitNumber');
  38735. var subSplitNumber = tickModel.get('splitNumber');
  38736. var splitLineLen = parsePercent(
  38737. splitLineModel.get('length'), r
  38738. );
  38739. var tickLen = parsePercent(
  38740. tickModel.get('length'), r
  38741. );
  38742. var angle = startAngle;
  38743. var step = (endAngle - startAngle) / splitNumber;
  38744. var subStep = step / subSplitNumber;
  38745. var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
  38746. var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
  38747. for (var i = 0; i <= splitNumber; i++) {
  38748. var unitX = Math.cos(angle);
  38749. var unitY = Math.sin(angle);
  38750. // Split line
  38751. if (splitLineModel.get('show')) {
  38752. var splitLine = new graphic.Line({
  38753. shape: {
  38754. x1: unitX * r + cx,
  38755. y1: unitY * r + cy,
  38756. x2: unitX * (r - splitLineLen) + cx,
  38757. y2: unitY * (r - splitLineLen) + cy
  38758. },
  38759. style: splitLineStyle,
  38760. silent: true
  38761. });
  38762. if (splitLineStyle.stroke === 'auto') {
  38763. splitLine.setStyle({
  38764. stroke: getColor(i / splitNumber)
  38765. });
  38766. }
  38767. group.add(splitLine);
  38768. }
  38769. // Label
  38770. if (labelModel.get('show')) {
  38771. var label = formatLabel(
  38772. numberUtil.round(i / splitNumber * (maxVal - minVal) + minVal),
  38773. labelModel.get('formatter')
  38774. );
  38775. var distance = labelModel.get('distance');
  38776. var autoColor = getColor(i / splitNumber);
  38777. group.add(new graphic.Text({
  38778. style: graphic.setTextStyle({}, labelModel, {
  38779. text: label,
  38780. x: unitX * (r - splitLineLen - distance) + cx,
  38781. y: unitY * (r - splitLineLen - distance) + cy,
  38782. textVerticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
  38783. textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
  38784. }, {autoColor: autoColor}),
  38785. silent: true
  38786. }));
  38787. }
  38788. // Axis tick
  38789. if (tickModel.get('show') && i !== splitNumber) {
  38790. for (var j = 0; j <= subSplitNumber; j++) {
  38791. var unitX = Math.cos(angle);
  38792. var unitY = Math.sin(angle);
  38793. var tickLine = new graphic.Line({
  38794. shape: {
  38795. x1: unitX * r + cx,
  38796. y1: unitY * r + cy,
  38797. x2: unitX * (r - tickLen) + cx,
  38798. y2: unitY * (r - tickLen) + cy
  38799. },
  38800. silent: true,
  38801. style: tickLineStyle
  38802. });
  38803. if (tickLineStyle.stroke === 'auto') {
  38804. tickLine.setStyle({
  38805. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  38806. });
  38807. }
  38808. group.add(tickLine);
  38809. angle += subStep;
  38810. }
  38811. angle -= subStep;
  38812. }
  38813. else {
  38814. angle += step;
  38815. }
  38816. }
  38817. },
  38818. _renderPointer: function (
  38819. seriesModel, ecModel, api, getColor, posInfo,
  38820. startAngle, endAngle, clockwise
  38821. ) {
  38822. var group = this.group;
  38823. var oldData = this._data;
  38824. if (!seriesModel.get('pointer.show')) {
  38825. // Remove old element
  38826. oldData && oldData.eachItemGraphicEl(function (el) {
  38827. group.remove(el);
  38828. });
  38829. return;
  38830. }
  38831. var valueExtent = [+seriesModel.get('min'), +seriesModel.get('max')];
  38832. var angleExtent = [startAngle, endAngle];
  38833. var data = seriesModel.getData();
  38834. data.diff(oldData)
  38835. .add(function (idx) {
  38836. var pointer = new PointerPath({
  38837. shape: {
  38838. angle: startAngle
  38839. }
  38840. });
  38841. graphic.initProps(pointer, {
  38842. shape: {
  38843. angle: numberUtil.linearMap(data.get('value', idx), valueExtent, angleExtent, true)
  38844. }
  38845. }, seriesModel);
  38846. group.add(pointer);
  38847. data.setItemGraphicEl(idx, pointer);
  38848. })
  38849. .update(function (newIdx, oldIdx) {
  38850. var pointer = oldData.getItemGraphicEl(oldIdx);
  38851. graphic.updateProps(pointer, {
  38852. shape: {
  38853. angle: numberUtil.linearMap(data.get('value', newIdx), valueExtent, angleExtent, true)
  38854. }
  38855. }, seriesModel);
  38856. group.add(pointer);
  38857. data.setItemGraphicEl(newIdx, pointer);
  38858. })
  38859. .remove(function (idx) {
  38860. var pointer = oldData.getItemGraphicEl(idx);
  38861. group.remove(pointer);
  38862. })
  38863. .execute();
  38864. data.eachItemGraphicEl(function (pointer, idx) {
  38865. var itemModel = data.getItemModel(idx);
  38866. var pointerModel = itemModel.getModel('pointer');
  38867. pointer.setShape({
  38868. x: posInfo.cx,
  38869. y: posInfo.cy,
  38870. width: parsePercent(
  38871. pointerModel.get('width'), posInfo.r
  38872. ),
  38873. r: parsePercent(pointerModel.get('length'), posInfo.r)
  38874. });
  38875. pointer.useStyle(itemModel.getModel('itemStyle.normal').getItemStyle());
  38876. if (pointer.style.fill === 'auto') {
  38877. pointer.setStyle('fill', getColor(
  38878. numberUtil.linearMap(data.get('value', idx), valueExtent, [0, 1], true)
  38879. ));
  38880. }
  38881. graphic.setHoverStyle(
  38882. pointer, itemModel.getModel('itemStyle.emphasis').getItemStyle()
  38883. );
  38884. });
  38885. this._data = data;
  38886. },
  38887. _renderTitle: function (
  38888. seriesModel, ecModel, api, getColor, posInfo
  38889. ) {
  38890. var titleModel = seriesModel.getModel('title');
  38891. if (titleModel.get('show')) {
  38892. var offsetCenter = titleModel.get('offsetCenter');
  38893. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  38894. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  38895. var minVal = +seriesModel.get('min');
  38896. var maxVal = +seriesModel.get('max');
  38897. var value = seriesModel.getData().get('value', 0);
  38898. var autoColor = getColor(
  38899. numberUtil.linearMap(value, [minVal, maxVal], [0, 1], true)
  38900. );
  38901. this.group.add(new graphic.Text({
  38902. silent: true,
  38903. style: graphic.setTextStyle({}, titleModel, {
  38904. x: x,
  38905. y: y,
  38906. // FIXME First data name ?
  38907. text: seriesModel.getData().getName(0),
  38908. textAlign: 'center',
  38909. textVerticalAlign: 'middle'
  38910. }, {autoColor: autoColor, forceRich: true})
  38911. }));
  38912. }
  38913. },
  38914. _renderDetail: function (
  38915. seriesModel, ecModel, api, getColor, posInfo
  38916. ) {
  38917. var detailModel = seriesModel.getModel('detail');
  38918. var minVal = +seriesModel.get('min');
  38919. var maxVal = +seriesModel.get('max');
  38920. if (detailModel.get('show')) {
  38921. var offsetCenter = detailModel.get('offsetCenter');
  38922. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  38923. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  38924. var width = parsePercent(detailModel.get('width'), posInfo.r);
  38925. var height = parsePercent(detailModel.get('height'), posInfo.r);
  38926. var value = seriesModel.getData().get('value', 0);
  38927. var autoColor = getColor(
  38928. numberUtil.linearMap(value, [minVal, maxVal], [0, 1], true)
  38929. );
  38930. this.group.add(new graphic.Text({
  38931. silent: true,
  38932. style: graphic.setTextStyle({}, detailModel, {
  38933. x: x,
  38934. y: y,
  38935. text: formatLabel(
  38936. // FIXME First data name ?
  38937. value, detailModel.get('formatter')
  38938. ),
  38939. textWidth: isNaN(width) ? null : width,
  38940. textHeight: isNaN(height) ? null : height,
  38941. textAlign: 'center',
  38942. textVerticalAlign: 'middle'
  38943. }, {autoColor: autoColor, forceRich: true})
  38944. }));
  38945. }
  38946. }
  38947. });
  38948. module.exports = GaugeView;
  38949. /***/ }),
  38950. /* 232 */
  38951. /***/ (function(module, exports, __webpack_require__) {
  38952. module.exports = __webpack_require__(22).extend({
  38953. type: 'echartsGaugePointer',
  38954. shape: {
  38955. angle: 0,
  38956. width: 10,
  38957. r: 10,
  38958. x: 0,
  38959. y: 0
  38960. },
  38961. buildPath: function (ctx, shape) {
  38962. var mathCos = Math.cos;
  38963. var mathSin = Math.sin;
  38964. var r = shape.r;
  38965. var width = shape.width;
  38966. var angle = shape.angle;
  38967. var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2);
  38968. var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2);
  38969. angle = shape.angle - Math.PI / 2;
  38970. ctx.moveTo(x, y);
  38971. ctx.lineTo(
  38972. shape.x + mathCos(angle) * width,
  38973. shape.y + mathSin(angle) * width
  38974. );
  38975. ctx.lineTo(
  38976. shape.x + mathCos(shape.angle) * r,
  38977. shape.y + mathSin(shape.angle) * r
  38978. );
  38979. ctx.lineTo(
  38980. shape.x - mathCos(angle) * width,
  38981. shape.y - mathSin(angle) * width
  38982. );
  38983. ctx.lineTo(x, y);
  38984. return;
  38985. }
  38986. });
  38987. /***/ }),
  38988. /* 233 */
  38989. /***/ (function(module, exports, __webpack_require__) {
  38990. var zrUtil = __webpack_require__(4);
  38991. var echarts = __webpack_require__(1);
  38992. __webpack_require__(234);
  38993. __webpack_require__(235);
  38994. echarts.registerVisual(zrUtil.curry(__webpack_require__(154), 'funnel'));
  38995. echarts.registerLayout(__webpack_require__(236));
  38996. echarts.registerProcessor(zrUtil.curry(__webpack_require__(157), 'funnel'));
  38997. /***/ }),
  38998. /* 234 */
  38999. /***/ (function(module, exports, __webpack_require__) {
  39000. 'use strict';
  39001. var List = __webpack_require__(101);
  39002. var modelUtil = __webpack_require__(5);
  39003. var completeDimensions = __webpack_require__(113);
  39004. var FunnelSeries = __webpack_require__(1).extendSeriesModel({
  39005. type: 'series.funnel',
  39006. init: function (option) {
  39007. FunnelSeries.superApply(this, 'init', arguments);
  39008. // Enable legend selection for each data item
  39009. // Use a function instead of direct access because data reference may changed
  39010. this.legendDataProvider = function () {
  39011. return this.getRawData();
  39012. };
  39013. // Extend labelLine emphasis
  39014. this._defaultLabelLine(option);
  39015. },
  39016. getInitialData: function (option, ecModel) {
  39017. var dimensions = completeDimensions(['value'], option.data);
  39018. var list = new List(dimensions, this);
  39019. list.initData(option.data);
  39020. return list;
  39021. },
  39022. _defaultLabelLine: function (option) {
  39023. // Extend labelLine emphasis
  39024. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  39025. var labelLineNormalOpt = option.labelLine.normal;
  39026. var labelLineEmphasisOpt = option.labelLine.emphasis;
  39027. // Not show label line if `label.normal.show = false`
  39028. labelLineNormalOpt.show = labelLineNormalOpt.show
  39029. && option.label.normal.show;
  39030. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  39031. && option.label.emphasis.show;
  39032. },
  39033. // Overwrite
  39034. getDataParams: function (dataIndex) {
  39035. var data = this.getData();
  39036. var params = FunnelSeries.superCall(this, 'getDataParams', dataIndex);
  39037. var sum = data.getSum('value');
  39038. // Percent is 0 if sum is 0
  39039. params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2);
  39040. params.$vars.push('percent');
  39041. return params;
  39042. },
  39043. defaultOption: {
  39044. zlevel: 0, // 一级层叠
  39045. z: 2, // 二级层叠
  39046. legendHoverLink: true,
  39047. left: 80,
  39048. top: 60,
  39049. right: 80,
  39050. bottom: 60,
  39051. // width: {totalWidth} - left - right,
  39052. // height: {totalHeight} - top - bottom,
  39053. // 默认取数据最小最大值
  39054. // min: 0,
  39055. // max: 100,
  39056. minSize: '0%',
  39057. maxSize: '100%',
  39058. sort: 'descending', // 'ascending', 'descending'
  39059. gap: 0,
  39060. funnelAlign: 'center',
  39061. label: {
  39062. normal: {
  39063. show: true,
  39064. position: 'outer'
  39065. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  39066. },
  39067. emphasis: {
  39068. show: true
  39069. }
  39070. },
  39071. labelLine: {
  39072. normal: {
  39073. show: true,
  39074. length: 20,
  39075. lineStyle: {
  39076. // color: 各异,
  39077. width: 1,
  39078. type: 'solid'
  39079. }
  39080. },
  39081. emphasis: {}
  39082. },
  39083. itemStyle: {
  39084. normal: {
  39085. // color: 各异,
  39086. borderColor: '#fff',
  39087. borderWidth: 1
  39088. },
  39089. emphasis: {
  39090. // color: 各异,
  39091. }
  39092. }
  39093. }
  39094. });
  39095. module.exports = FunnelSeries;
  39096. /***/ }),
  39097. /* 235 */
  39098. /***/ (function(module, exports, __webpack_require__) {
  39099. var graphic = __webpack_require__(20);
  39100. var zrUtil = __webpack_require__(4);
  39101. /**
  39102. * Piece of pie including Sector, Label, LabelLine
  39103. * @constructor
  39104. * @extends {module:zrender/graphic/Group}
  39105. */
  39106. function FunnelPiece(data, idx) {
  39107. graphic.Group.call(this);
  39108. var polygon = new graphic.Polygon();
  39109. var labelLine = new graphic.Polyline();
  39110. var text = new graphic.Text();
  39111. this.add(polygon);
  39112. this.add(labelLine);
  39113. this.add(text);
  39114. this.updateData(data, idx, true);
  39115. // Hover to change label and labelLine
  39116. function onEmphasis() {
  39117. labelLine.ignore = labelLine.hoverIgnore;
  39118. text.ignore = text.hoverIgnore;
  39119. }
  39120. function onNormal() {
  39121. labelLine.ignore = labelLine.normalIgnore;
  39122. text.ignore = text.normalIgnore;
  39123. }
  39124. this.on('emphasis', onEmphasis)
  39125. .on('normal', onNormal)
  39126. .on('mouseover', onEmphasis)
  39127. .on('mouseout', onNormal);
  39128. }
  39129. var funnelPieceProto = FunnelPiece.prototype;
  39130. var opacityAccessPath = ['itemStyle', 'normal', 'opacity'];
  39131. funnelPieceProto.updateData = function (data, idx, firstCreate) {
  39132. var polygon = this.childAt(0);
  39133. var seriesModel = data.hostModel;
  39134. var itemModel = data.getItemModel(idx);
  39135. var layout = data.getItemLayout(idx);
  39136. var opacity = data.getItemModel(idx).get(opacityAccessPath);
  39137. opacity = opacity == null ? 1 : opacity;
  39138. // Reset style
  39139. polygon.useStyle({});
  39140. if (firstCreate) {
  39141. polygon.setShape({
  39142. points: layout.points
  39143. });
  39144. polygon.setStyle({ opacity : 0 });
  39145. graphic.initProps(polygon, {
  39146. style: {
  39147. opacity: opacity
  39148. }
  39149. }, seriesModel, idx);
  39150. }
  39151. else {
  39152. graphic.updateProps(polygon, {
  39153. style: {
  39154. opacity: opacity
  39155. },
  39156. shape: {
  39157. points: layout.points
  39158. }
  39159. }, seriesModel, idx);
  39160. }
  39161. // Update common style
  39162. var itemStyleModel = itemModel.getModel('itemStyle');
  39163. var visualColor = data.getItemVisual(idx, 'color');
  39164. polygon.setStyle(
  39165. zrUtil.defaults(
  39166. {
  39167. lineJoin: 'round',
  39168. fill: visualColor
  39169. },
  39170. itemStyleModel.getModel('normal').getItemStyle(['opacity'])
  39171. )
  39172. );
  39173. polygon.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  39174. this._updateLabel(data, idx);
  39175. graphic.setHoverStyle(this);
  39176. };
  39177. funnelPieceProto._updateLabel = function (data, idx) {
  39178. var labelLine = this.childAt(1);
  39179. var labelText = this.childAt(2);
  39180. var seriesModel = data.hostModel;
  39181. var itemModel = data.getItemModel(idx);
  39182. var layout = data.getItemLayout(idx);
  39183. var labelLayout = layout.label;
  39184. var visualColor = data.getItemVisual(idx, 'color');
  39185. graphic.updateProps(labelLine, {
  39186. shape: {
  39187. points: labelLayout.linePoints || labelLayout.linePoints
  39188. }
  39189. }, seriesModel, idx);
  39190. graphic.updateProps(labelText, {
  39191. style: {
  39192. x: labelLayout.x,
  39193. y: labelLayout.y
  39194. }
  39195. }, seriesModel, idx);
  39196. labelText.attr({
  39197. rotation: labelLayout.rotation,
  39198. origin: [labelLayout.x, labelLayout.y],
  39199. z2: 10
  39200. });
  39201. var labelModel = itemModel.getModel('label.normal');
  39202. var labelHoverModel = itemModel.getModel('label.emphasis');
  39203. var labelLineModel = itemModel.getModel('labelLine.normal');
  39204. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  39205. var visualColor = data.getItemVisual(idx, 'color');
  39206. graphic.setLabelStyle(
  39207. labelText.style, labelText.hoverStyle = {}, labelModel, labelHoverModel,
  39208. {
  39209. labelFetcher: data.hostModel,
  39210. labelDataIndex: idx,
  39211. defaultText: data.getName(idx),
  39212. autoColor: visualColor,
  39213. useInsideStyle: !!labelLayout.inside
  39214. },
  39215. {
  39216. textAlign: labelLayout.textAlign,
  39217. textVerticalAlign: labelLayout.verticalAlign
  39218. }
  39219. );
  39220. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  39221. labelText.hoverIgnore = !labelHoverModel.get('show');
  39222. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  39223. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  39224. // Default use item visual color
  39225. labelLine.setStyle({
  39226. stroke: visualColor
  39227. });
  39228. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  39229. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  39230. };
  39231. zrUtil.inherits(FunnelPiece, graphic.Group);
  39232. var Funnel = __webpack_require__(85).extend({
  39233. type: 'funnel',
  39234. render: function (seriesModel, ecModel, api) {
  39235. var data = seriesModel.getData();
  39236. var oldData = this._data;
  39237. var group = this.group;
  39238. data.diff(oldData)
  39239. .add(function (idx) {
  39240. var funnelPiece = new FunnelPiece(data, idx);
  39241. data.setItemGraphicEl(idx, funnelPiece);
  39242. group.add(funnelPiece);
  39243. })
  39244. .update(function (newIdx, oldIdx) {
  39245. var piePiece = oldData.getItemGraphicEl(oldIdx);
  39246. piePiece.updateData(data, newIdx);
  39247. group.add(piePiece);
  39248. data.setItemGraphicEl(newIdx, piePiece);
  39249. })
  39250. .remove(function (idx) {
  39251. var piePiece = oldData.getItemGraphicEl(idx);
  39252. group.remove(piePiece);
  39253. })
  39254. .execute();
  39255. this._data = data;
  39256. },
  39257. remove: function () {
  39258. this.group.removeAll();
  39259. this._data = null;
  39260. },
  39261. dispose: function () {}
  39262. });
  39263. module.exports = Funnel;
  39264. /***/ }),
  39265. /* 236 */
  39266. /***/ (function(module, exports, __webpack_require__) {
  39267. var layout = __webpack_require__(74);
  39268. var number = __webpack_require__(7);
  39269. var parsePercent = number.parsePercent;
  39270. function getViewRect(seriesModel, api) {
  39271. return layout.getLayoutRect(
  39272. seriesModel.getBoxLayoutParams(), {
  39273. width: api.getWidth(),
  39274. height: api.getHeight()
  39275. }
  39276. );
  39277. }
  39278. function getSortedIndices(data, sort) {
  39279. var valueArr = data.mapArray('value', function (val) {
  39280. return val;
  39281. });
  39282. var indices = [];
  39283. var isAscending = sort === 'ascending';
  39284. for (var i = 0, len = data.count(); i < len; i++) {
  39285. indices[i] = i;
  39286. }
  39287. // Add custom sortable function & none sortable opetion by "options.sort"
  39288. if (typeof sort === 'function') {
  39289. indices.sort(sort);
  39290. } else if (sort !== 'none') {
  39291. indices.sort(function (a, b) {
  39292. return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
  39293. });
  39294. }
  39295. return indices;
  39296. }
  39297. function labelLayout(data) {
  39298. data.each(function (idx) {
  39299. var itemModel = data.getItemModel(idx);
  39300. var labelModel = itemModel.getModel('label.normal');
  39301. var labelPosition = labelModel.get('position');
  39302. var labelLineModel = itemModel.getModel('labelLine.normal');
  39303. var layout = data.getItemLayout(idx);
  39304. var points = layout.points;
  39305. var isLabelInside = labelPosition === 'inner'
  39306. || labelPosition === 'inside' || labelPosition === 'center';
  39307. var textAlign;
  39308. var textX;
  39309. var textY;
  39310. var linePoints;
  39311. if (isLabelInside) {
  39312. textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
  39313. textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
  39314. textAlign = 'center';
  39315. linePoints = [
  39316. [textX, textY], [textX, textY]
  39317. ];
  39318. }
  39319. else {
  39320. var x1;
  39321. var y1;
  39322. var x2;
  39323. var labelLineLen = labelLineModel.get('length');
  39324. if (labelPosition === 'left') {
  39325. // Left side
  39326. x1 = (points[3][0] + points[0][0]) / 2;
  39327. y1 = (points[3][1] + points[0][1]) / 2;
  39328. x2 = x1 - labelLineLen;
  39329. textX = x2 - 5;
  39330. textAlign = 'right';
  39331. }
  39332. else {
  39333. // Right side
  39334. x1 = (points[1][0] + points[2][0]) / 2;
  39335. y1 = (points[1][1] + points[2][1]) / 2;
  39336. x2 = x1 + labelLineLen;
  39337. textX = x2 + 5;
  39338. textAlign = 'left';
  39339. }
  39340. var y2 = y1;
  39341. linePoints = [[x1, y1], [x2, y2]];
  39342. textY = y2;
  39343. }
  39344. layout.label = {
  39345. linePoints: linePoints,
  39346. x: textX,
  39347. y: textY,
  39348. verticalAlign: 'middle',
  39349. textAlign: textAlign,
  39350. inside: isLabelInside
  39351. };
  39352. });
  39353. }
  39354. module.exports = function (ecModel, api, payload) {
  39355. ecModel.eachSeriesByType('funnel', function (seriesModel) {
  39356. var data = seriesModel.getData();
  39357. var sort = seriesModel.get('sort');
  39358. var viewRect = getViewRect(seriesModel, api);
  39359. var indices = getSortedIndices(data, sort);
  39360. var sizeExtent = [
  39361. parsePercent(seriesModel.get('minSize'), viewRect.width),
  39362. parsePercent(seriesModel.get('maxSize'), viewRect.width)
  39363. ];
  39364. var dataExtent = data.getDataExtent('value');
  39365. var min = seriesModel.get('min');
  39366. var max = seriesModel.get('max');
  39367. if (min == null) {
  39368. min = Math.min(dataExtent[0], 0);
  39369. }
  39370. if (max == null) {
  39371. max = dataExtent[1];
  39372. }
  39373. var funnelAlign = seriesModel.get('funnelAlign');
  39374. var gap = seriesModel.get('gap');
  39375. var itemHeight = (viewRect.height - gap * (data.count() - 1)) / data.count();
  39376. var y = viewRect.y;
  39377. var getLinePoints = function (idx, offY) {
  39378. // End point index is data.count() and we assign it 0
  39379. var val = data.get('value', idx) || 0;
  39380. var itemWidth = number.linearMap(val, [min, max], sizeExtent, true);
  39381. var x0;
  39382. switch (funnelAlign) {
  39383. case 'left':
  39384. x0 = viewRect.x;
  39385. break;
  39386. case 'center':
  39387. x0 = viewRect.x + (viewRect.width - itemWidth) / 2;
  39388. break;
  39389. case 'right':
  39390. x0 = viewRect.x + viewRect.width - itemWidth;
  39391. break;
  39392. }
  39393. return [
  39394. [x0, offY],
  39395. [x0 + itemWidth, offY]
  39396. ];
  39397. };
  39398. if (sort === 'ascending') {
  39399. // From bottom to top
  39400. itemHeight = -itemHeight;
  39401. gap = -gap;
  39402. y += viewRect.height;
  39403. indices = indices.reverse();
  39404. }
  39405. for (var i = 0; i < indices.length; i++) {
  39406. var idx = indices[i];
  39407. var nextIdx = indices[i + 1];
  39408. var start = getLinePoints(idx, y);
  39409. var end = getLinePoints(nextIdx, y + itemHeight);
  39410. y += itemHeight + gap;
  39411. data.setItemLayout(idx, {
  39412. points: start.concat(end.slice().reverse())
  39413. });
  39414. }
  39415. labelLayout(data);
  39416. });
  39417. };
  39418. /***/ }),
  39419. /* 237 */
  39420. /***/ (function(module, exports, __webpack_require__) {
  39421. var echarts = __webpack_require__(1);
  39422. __webpack_require__(238);
  39423. __webpack_require__(251);
  39424. __webpack_require__(252);
  39425. echarts.registerVisual(__webpack_require__(253));
  39426. /***/ }),
  39427. /* 238 */
  39428. /***/ (function(module, exports, __webpack_require__) {
  39429. __webpack_require__(239);
  39430. __webpack_require__(243);
  39431. __webpack_require__(245);
  39432. var echarts = __webpack_require__(1);
  39433. var zrUtil = __webpack_require__(4);
  39434. var throttle = __webpack_require__(86);
  39435. var CLICK_THRESHOLD = 5; // > 4
  39436. // Parallel view
  39437. echarts.extendComponentView({
  39438. type: 'parallel',
  39439. render: function (parallelModel, ecModel, api) {
  39440. this._model = parallelModel;
  39441. this._api = api;
  39442. if (!this._handlers) {
  39443. this._handlers = {};
  39444. zrUtil.each(handlers, function (handler, eventName) {
  39445. api.getZr().on(eventName, this._handlers[eventName] = zrUtil.bind(handler, this));
  39446. }, this);
  39447. }
  39448. throttle.createOrUpdate(
  39449. this,
  39450. '_throttledDispatchExpand',
  39451. parallelModel.get('axisExpandRate'),
  39452. 'fixRate'
  39453. );
  39454. },
  39455. dispose: function (ecModel, api) {
  39456. zrUtil.each(this._handlers, function (handler, eventName) {
  39457. api.getZr().off(eventName, handler);
  39458. });
  39459. this._handlers = null;
  39460. },
  39461. /**
  39462. * @param {Object} [opt] If null, cancle the last action triggering for debounce.
  39463. */
  39464. _throttledDispatchExpand: function (opt) {
  39465. this._dispatchExpand(opt);
  39466. },
  39467. _dispatchExpand: function (opt) {
  39468. opt && this._api.dispatchAction(
  39469. zrUtil.extend({type: 'parallelAxisExpand'}, opt)
  39470. );
  39471. }
  39472. });
  39473. var handlers = {
  39474. mousedown: function (e) {
  39475. if (checkTrigger(this, 'click')) {
  39476. this._mouseDownPoint = [e.offsetX, e.offsetY];
  39477. }
  39478. },
  39479. mouseup: function (e) {
  39480. var mouseDownPoint = this._mouseDownPoint;
  39481. if (checkTrigger(this, 'click') && mouseDownPoint) {
  39482. var point = [e.offsetX, e.offsetY];
  39483. var dist = Math.pow(mouseDownPoint[0] - point[0], 2)
  39484. + Math.pow(mouseDownPoint[1] - point[1], 2);
  39485. if (dist > CLICK_THRESHOLD) {
  39486. return;
  39487. }
  39488. var result = this._model.coordinateSystem.getSlidedAxisExpandWindow(
  39489. [e.offsetX, e.offsetY]
  39490. );
  39491. result.behavior !== 'none' && this._dispatchExpand({
  39492. axisExpandWindow: result.axisExpandWindow
  39493. });
  39494. }
  39495. this._mouseDownPoint = null;
  39496. },
  39497. mousemove: function (e) {
  39498. // Should do nothing when brushing.
  39499. if (this._mouseDownPoint || !checkTrigger(this, 'mousemove')) {
  39500. return;
  39501. }
  39502. var model = this._model;
  39503. var result = model.coordinateSystem.getSlidedAxisExpandWindow(
  39504. [e.offsetX, e.offsetY]
  39505. );
  39506. var behavior = result.behavior;
  39507. behavior === 'jump' && this._throttledDispatchExpand.debounceNextCall(model.get('axisExpandDebounce'));
  39508. this._throttledDispatchExpand(
  39509. behavior === 'none'
  39510. ? null // Cancle the last trigger, in case that mouse slide out of the area quickly.
  39511. : {
  39512. axisExpandWindow: result.axisExpandWindow,
  39513. // Jumping uses animation, and sliding suppresses animation.
  39514. animation: behavior === 'jump' ? null : false
  39515. }
  39516. );
  39517. }
  39518. };
  39519. function checkTrigger(view, triggerOn) {
  39520. var model = view._model;
  39521. return model.get('axisExpandable') && model.get('axisExpandTriggerOn') === triggerOn;
  39522. }
  39523. echarts.registerPreprocessor(
  39524. __webpack_require__(250)
  39525. );
  39526. /***/ }),
  39527. /* 239 */
  39528. /***/ (function(module, exports, __webpack_require__) {
  39529. /**
  39530. * Parallel coordinate system creater.
  39531. */
  39532. var Parallel = __webpack_require__(240);
  39533. function create(ecModel, api) {
  39534. var coordSysList = [];
  39535. ecModel.eachComponent('parallel', function (parallelModel, idx) {
  39536. var coordSys = new Parallel(parallelModel, ecModel, api);
  39537. coordSys.name = 'parallel_' + idx;
  39538. coordSys.resize(parallelModel, api);
  39539. parallelModel.coordinateSystem = coordSys;
  39540. coordSys.model = parallelModel;
  39541. coordSysList.push(coordSys);
  39542. });
  39543. // Inject the coordinateSystems into seriesModel
  39544. ecModel.eachSeries(function (seriesModel) {
  39545. if (seriesModel.get('coordinateSystem') === 'parallel') {
  39546. var parallelModel = ecModel.queryComponents({
  39547. mainType: 'parallel',
  39548. index: seriesModel.get('parallelIndex'),
  39549. id: seriesModel.get('parallelId')
  39550. })[0];
  39551. seriesModel.coordinateSystem = parallelModel.coordinateSystem;
  39552. }
  39553. });
  39554. return coordSysList;
  39555. }
  39556. __webpack_require__(79).register('parallel', {create: create});
  39557. /***/ }),
  39558. /* 240 */
  39559. /***/ (function(module, exports, __webpack_require__) {
  39560. /**
  39561. * Parallel Coordinates
  39562. * <https://en.wikipedia.org/wiki/Parallel_coordinates>
  39563. */
  39564. var layoutUtil = __webpack_require__(74);
  39565. var axisHelper = __webpack_require__(104);
  39566. var zrUtil = __webpack_require__(4);
  39567. var ParallelAxis = __webpack_require__(241);
  39568. var graphic = __webpack_require__(20);
  39569. var matrix = __webpack_require__(11);
  39570. var numberUtil = __webpack_require__(7);
  39571. var sliderMove = __webpack_require__(242);
  39572. var each = zrUtil.each;
  39573. var mathMin = Math.min;
  39574. var mathMax = Math.max;
  39575. var mathFloor = Math.floor;
  39576. var mathCeil = Math.ceil;
  39577. var round = numberUtil.round;
  39578. var PI = Math.PI;
  39579. function Parallel(parallelModel, ecModel, api) {
  39580. /**
  39581. * key: dimension
  39582. * @type {Object.<string, module:echarts/coord/parallel/Axis>}
  39583. * @private
  39584. */
  39585. this._axesMap = zrUtil.createHashMap();
  39586. /**
  39587. * key: dimension
  39588. * value: {position: [], rotation, }
  39589. * @type {Object.<string, Object>}
  39590. * @private
  39591. */
  39592. this._axesLayout = {};
  39593. /**
  39594. * Always follow axis order.
  39595. * @type {Array.<string>}
  39596. * @readOnly
  39597. */
  39598. this.dimensions = parallelModel.dimensions;
  39599. /**
  39600. * @type {module:zrender/core/BoundingRect}
  39601. */
  39602. this._rect;
  39603. /**
  39604. * @type {module:echarts/coord/parallel/ParallelModel}
  39605. */
  39606. this._model = parallelModel;
  39607. this._init(parallelModel, ecModel, api);
  39608. }
  39609. Parallel.prototype = {
  39610. type: 'parallel',
  39611. constructor: Parallel,
  39612. /**
  39613. * Initialize cartesian coordinate systems
  39614. * @private
  39615. */
  39616. _init: function (parallelModel, ecModel, api) {
  39617. var dimensions = parallelModel.dimensions;
  39618. var parallelAxisIndex = parallelModel.parallelAxisIndex;
  39619. each(dimensions, function (dim, idx) {
  39620. var axisIndex = parallelAxisIndex[idx];
  39621. var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
  39622. var axis = this._axesMap.set(dim, new ParallelAxis(
  39623. dim,
  39624. axisHelper.createScaleByModel(axisModel),
  39625. [0, 0],
  39626. axisModel.get('type'),
  39627. axisIndex
  39628. ));
  39629. var isCategory = axis.type === 'category';
  39630. axis.onBand = isCategory && axisModel.get('boundaryGap');
  39631. axis.inverse = axisModel.get('inverse');
  39632. // Injection
  39633. axisModel.axis = axis;
  39634. axis.model = axisModel;
  39635. axis.coordinateSystem = axisModel.coordinateSystem = this;
  39636. }, this);
  39637. },
  39638. /**
  39639. * Update axis scale after data processed
  39640. * @param {module:echarts/model/Global} ecModel
  39641. * @param {module:echarts/ExtensionAPI} api
  39642. */
  39643. update: function (ecModel, api) {
  39644. this._updateAxesFromSeries(this._model, ecModel);
  39645. },
  39646. /**
  39647. * @override
  39648. */
  39649. containPoint: function (point) {
  39650. var layoutInfo = this._makeLayoutInfo();
  39651. var axisBase = layoutInfo.axisBase;
  39652. var layoutBase = layoutInfo.layoutBase;
  39653. var pixelDimIndex = layoutInfo.pixelDimIndex;
  39654. var pAxis = point[1 - pixelDimIndex];
  39655. var pLayout = point[pixelDimIndex];
  39656. return pAxis >= axisBase
  39657. && pAxis <= axisBase + layoutInfo.axisLength
  39658. && pLayout >= layoutBase
  39659. && pLayout <= layoutBase + layoutInfo.layoutLength;
  39660. },
  39661. /**
  39662. * Update properties from series
  39663. * @private
  39664. */
  39665. _updateAxesFromSeries: function (parallelModel, ecModel) {
  39666. ecModel.eachSeries(function (seriesModel) {
  39667. if (!parallelModel.contains(seriesModel, ecModel)) {
  39668. return;
  39669. }
  39670. var data = seriesModel.getData();
  39671. each(this.dimensions, function (dim) {
  39672. var axis = this._axesMap.get(dim);
  39673. axis.scale.unionExtentFromData(data, dim);
  39674. axisHelper.niceScaleExtent(axis.scale, axis.model);
  39675. }, this);
  39676. }, this);
  39677. },
  39678. /**
  39679. * Resize the parallel coordinate system.
  39680. * @param {module:echarts/coord/parallel/ParallelModel} parallelModel
  39681. * @param {module:echarts/ExtensionAPI} api
  39682. */
  39683. resize: function (parallelModel, api) {
  39684. this._rect = layoutUtil.getLayoutRect(
  39685. parallelModel.getBoxLayoutParams(),
  39686. {
  39687. width: api.getWidth(),
  39688. height: api.getHeight()
  39689. }
  39690. );
  39691. this._layoutAxes();
  39692. },
  39693. /**
  39694. * @return {module:zrender/core/BoundingRect}
  39695. */
  39696. getRect: function () {
  39697. return this._rect;
  39698. },
  39699. /**
  39700. * @private
  39701. */
  39702. _makeLayoutInfo: function () {
  39703. var parallelModel = this._model;
  39704. var rect = this._rect;
  39705. var xy = ['x', 'y'];
  39706. var wh = ['width', 'height'];
  39707. var layout = parallelModel.get('layout');
  39708. var pixelDimIndex = layout === 'horizontal' ? 0 : 1;
  39709. var layoutLength = rect[wh[pixelDimIndex]];
  39710. var layoutExtent = [0, layoutLength];
  39711. var axisCount = this.dimensions.length;
  39712. var axisExpandWidth = restrict(parallelModel.get('axisExpandWidth'), layoutExtent);
  39713. var axisExpandCount = restrict(parallelModel.get('axisExpandCount') || 0, [0, axisCount]);
  39714. var axisExpandable = parallelModel.get('axisExpandable')
  39715. && axisCount > 3
  39716. && axisCount > axisExpandCount
  39717. && axisExpandCount > 1
  39718. && axisExpandWidth > 0
  39719. && layoutLength > 0;
  39720. // `axisExpandWindow` is According to the coordinates of [0, axisExpandLength],
  39721. // for sake of consider the case that axisCollapseWidth is 0 (when screen is narrow),
  39722. // where collapsed axes should be overlapped.
  39723. var axisExpandWindow = parallelModel.get('axisExpandWindow');
  39724. var winSize;
  39725. if (!axisExpandWindow) {
  39726. winSize = restrict(axisExpandWidth * (axisExpandCount - 1), layoutExtent);
  39727. var axisExpandCenter = parallelModel.get('axisExpandCenter') || mathFloor(axisCount / 2);
  39728. axisExpandWindow = [axisExpandWidth * axisExpandCenter - winSize / 2];
  39729. axisExpandWindow[1] = axisExpandWindow[0] + winSize;
  39730. }
  39731. else {
  39732. winSize = restrict(axisExpandWindow[1] - axisExpandWindow[0], layoutExtent);
  39733. axisExpandWindow[1] = axisExpandWindow[0] + winSize;
  39734. }
  39735. var axisCollapseWidth = (layoutLength - winSize) / (axisCount - axisExpandCount);
  39736. // Avoid axisCollapseWidth is too small.
  39737. axisCollapseWidth < 3 && (axisCollapseWidth = 0);
  39738. // Find the first and last indices > ewin[0] and < ewin[1].
  39739. var winInnerIndices = [
  39740. mathFloor(round(axisExpandWindow[0] / axisExpandWidth, 1)) + 1,
  39741. mathCeil(round(axisExpandWindow[1] / axisExpandWidth, 1)) - 1
  39742. ];
  39743. // Pos in ec coordinates.
  39744. var axisExpandWindow0Pos = axisCollapseWidth / axisExpandWidth * axisExpandWindow[0];
  39745. return {
  39746. layout: layout,
  39747. pixelDimIndex: pixelDimIndex,
  39748. layoutBase: rect[xy[pixelDimIndex]],
  39749. layoutLength: layoutLength,
  39750. axisBase: rect[xy[1 - pixelDimIndex]],
  39751. axisLength: rect[wh[1 - pixelDimIndex]],
  39752. axisExpandable: axisExpandable,
  39753. axisExpandWidth: axisExpandWidth,
  39754. axisCollapseWidth: axisCollapseWidth,
  39755. axisExpandWindow: axisExpandWindow,
  39756. axisCount: axisCount,
  39757. winInnerIndices: winInnerIndices,
  39758. axisExpandWindow0Pos: axisExpandWindow0Pos
  39759. };
  39760. },
  39761. /**
  39762. * @private
  39763. */
  39764. _layoutAxes: function () {
  39765. var rect = this._rect;
  39766. var axes = this._axesMap;
  39767. var dimensions = this.dimensions;
  39768. var layoutInfo = this._makeLayoutInfo();
  39769. var layout = layoutInfo.layout;
  39770. axes.each(function (axis) {
  39771. var axisExtent = [0, layoutInfo.axisLength];
  39772. var idx = axis.inverse ? 1 : 0;
  39773. axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);
  39774. });
  39775. each(dimensions, function (dim, idx) {
  39776. var posInfo = (layoutInfo.axisExpandable
  39777. ? layoutAxisWithExpand : layoutAxisWithoutExpand
  39778. )(idx, layoutInfo);
  39779. var positionTable = {
  39780. horizontal: {
  39781. x: posInfo.position,
  39782. y: layoutInfo.axisLength
  39783. },
  39784. vertical: {
  39785. x: 0,
  39786. y: posInfo.position
  39787. }
  39788. };
  39789. var rotationTable = {
  39790. horizontal: PI / 2,
  39791. vertical: 0
  39792. };
  39793. var position = [
  39794. positionTable[layout].x + rect.x,
  39795. positionTable[layout].y + rect.y
  39796. ];
  39797. var rotation = rotationTable[layout];
  39798. var transform = matrix.create();
  39799. matrix.rotate(transform, transform, rotation);
  39800. matrix.translate(transform, transform, position);
  39801. // TODO
  39802. // tick等排布信息。
  39803. // TODO
  39804. // 根据axis order 更新 dimensions顺序。
  39805. this._axesLayout[dim] = {
  39806. position: position,
  39807. rotation: rotation,
  39808. transform: transform,
  39809. axisNameAvailableWidth: posInfo.axisNameAvailableWidth,
  39810. axisLabelShow: posInfo.axisLabelShow,
  39811. nameTruncateMaxWidth: posInfo.nameTruncateMaxWidth,
  39812. tickDirection: 1,
  39813. labelDirection: 1,
  39814. labelInterval: axes.get(dim).getLabelInterval()
  39815. };
  39816. }, this);
  39817. },
  39818. /**
  39819. * Get axis by dim.
  39820. * @param {string} dim
  39821. * @return {module:echarts/coord/parallel/ParallelAxis} [description]
  39822. */
  39823. getAxis: function (dim) {
  39824. return this._axesMap.get(dim);
  39825. },
  39826. /**
  39827. * Convert a dim value of a single item of series data to Point.
  39828. * @param {*} value
  39829. * @param {string} dim
  39830. * @return {Array}
  39831. */
  39832. dataToPoint: function (value, dim) {
  39833. return this.axisCoordToPoint(
  39834. this._axesMap.get(dim).dataToCoord(value),
  39835. dim
  39836. );
  39837. },
  39838. /**
  39839. * Travel data for one time, get activeState of each data item.
  39840. * @param {module:echarts/data/List} data
  39841. * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal'
  39842. * {number} dataIndex
  39843. * @param {Object} context
  39844. */
  39845. eachActiveState: function (data, callback, context) {
  39846. var dimensions = this.dimensions;
  39847. var axesMap = this._axesMap;
  39848. var hasActiveSet = this.hasAxisBrushed();
  39849. for (var i = 0, len = data.count(); i < len; i++) {
  39850. var values = data.getValues(dimensions, i);
  39851. var activeState;
  39852. if (!hasActiveSet) {
  39853. activeState = 'normal';
  39854. }
  39855. else {
  39856. activeState = 'active';
  39857. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  39858. var dimName = dimensions[j];
  39859. var state = axesMap.get(dimName).model.getActiveState(values[j], j);
  39860. if (state === 'inactive') {
  39861. activeState = 'inactive';
  39862. break;
  39863. }
  39864. }
  39865. }
  39866. callback.call(context, activeState, i);
  39867. }
  39868. },
  39869. /**
  39870. * Whether has any activeSet.
  39871. * @return {boolean}
  39872. */
  39873. hasAxisBrushed: function () {
  39874. var dimensions = this.dimensions;
  39875. var axesMap = this._axesMap;
  39876. var hasActiveSet = false;
  39877. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  39878. if (axesMap.get(dimensions[j]).model.getActiveState() !== 'normal') {
  39879. hasActiveSet = true;
  39880. }
  39881. }
  39882. return hasActiveSet;
  39883. },
  39884. /**
  39885. * Convert coords of each axis to Point.
  39886. * Return point. For example: [10, 20]
  39887. * @param {Array.<number>} coords
  39888. * @param {string} dim
  39889. * @return {Array.<number>}
  39890. */
  39891. axisCoordToPoint: function (coord, dim) {
  39892. var axisLayout = this._axesLayout[dim];
  39893. return graphic.applyTransform([coord, 0], axisLayout.transform);
  39894. },
  39895. /**
  39896. * Get axis layout.
  39897. */
  39898. getAxisLayout: function (dim) {
  39899. return zrUtil.clone(this._axesLayout[dim]);
  39900. },
  39901. /**
  39902. * @param {Array.<number>} point
  39903. * @return {Object} {axisExpandWindow, delta, behavior: 'jump' | 'slide' | 'none'}.
  39904. */
  39905. getSlidedAxisExpandWindow: function (point) {
  39906. var layoutInfo = this._makeLayoutInfo();
  39907. var pixelDimIndex = layoutInfo.pixelDimIndex;
  39908. var axisExpandWindow = layoutInfo.axisExpandWindow.slice();
  39909. var winSize = axisExpandWindow[1] - axisExpandWindow[0];
  39910. var extent = [0, layoutInfo.axisExpandWidth * (layoutInfo.axisCount - 1)];
  39911. // Out of the area of coordinate system.
  39912. if (!this.containPoint(point)) {
  39913. return {behavior: 'none', axisExpandWindow: axisExpandWindow};
  39914. }
  39915. // Conver the point from global to expand coordinates.
  39916. var pointCoord = point[pixelDimIndex] - layoutInfo.layoutBase - layoutInfo.axisExpandWindow0Pos;
  39917. // For dragging operation convenience, the window should not be
  39918. // slided when mouse is the center area of the window.
  39919. var delta;
  39920. var behavior = 'slide';
  39921. var axisCollapseWidth = layoutInfo.axisCollapseWidth;
  39922. var triggerArea = this._model.get('axisExpandSlideTriggerArea');
  39923. // But consider touch device, jump is necessary.
  39924. var useJump = triggerArea[0] != null;
  39925. if (axisCollapseWidth) {
  39926. if (useJump && axisCollapseWidth && pointCoord < winSize * triggerArea[0]) {
  39927. behavior = 'jump';
  39928. delta = pointCoord - winSize * triggerArea[2];
  39929. }
  39930. else if (useJump && axisCollapseWidth && pointCoord > winSize * (1 - triggerArea[0])) {
  39931. behavior = 'jump';
  39932. delta = pointCoord - winSize * (1 - triggerArea[2]);
  39933. }
  39934. else {
  39935. (delta = pointCoord - winSize * triggerArea[1]) >= 0
  39936. && (delta = pointCoord - winSize * (1 - triggerArea[1])) <= 0
  39937. && (delta = 0);
  39938. }
  39939. delta *= layoutInfo.axisExpandWidth / axisCollapseWidth;
  39940. delta
  39941. ? sliderMove(delta, axisExpandWindow, extent, 'all')
  39942. // Avoid nonsense triger on mousemove.
  39943. : (behavior = 'none');
  39944. }
  39945. // When screen is too narrow, make it visible and slidable, although it is hard to interact.
  39946. else {
  39947. var winSize = axisExpandWindow[1] - axisExpandWindow[0];
  39948. var pos = extent[1] * pointCoord / winSize;
  39949. axisExpandWindow = [mathMax(0, pos - winSize / 2)];
  39950. axisExpandWindow[1] = mathMin(extent[1], axisExpandWindow[0] + winSize);
  39951. axisExpandWindow[0] = axisExpandWindow[1] - winSize;
  39952. }
  39953. return {
  39954. axisExpandWindow: axisExpandWindow,
  39955. behavior: behavior
  39956. };
  39957. }
  39958. };
  39959. function restrict(len, extent) {
  39960. return mathMin(mathMax(len, extent[0]), extent[1]);
  39961. }
  39962. function layoutAxisWithoutExpand(axisIndex, layoutInfo) {
  39963. var step = layoutInfo.layoutLength / (layoutInfo.axisCount - 1);
  39964. return {
  39965. position: step * axisIndex,
  39966. axisNameAvailableWidth: step,
  39967. axisLabelShow: true
  39968. };
  39969. }
  39970. function layoutAxisWithExpand(axisIndex, layoutInfo) {
  39971. var layoutLength = layoutInfo.layoutLength;
  39972. var axisExpandWidth = layoutInfo.axisExpandWidth;
  39973. var axisCount = layoutInfo.axisCount;
  39974. var axisCollapseWidth = layoutInfo.axisCollapseWidth;
  39975. var winInnerIndices = layoutInfo.winInnerIndices;
  39976. var position;
  39977. var axisNameAvailableWidth = axisCollapseWidth;
  39978. var axisLabelShow = false;
  39979. var nameTruncateMaxWidth;
  39980. if (axisIndex < winInnerIndices[0]) {
  39981. position = axisIndex * axisCollapseWidth;
  39982. nameTruncateMaxWidth = axisCollapseWidth;
  39983. }
  39984. else if (axisIndex <= winInnerIndices[1]) {
  39985. position = layoutInfo.axisExpandWindow0Pos
  39986. + axisIndex * axisExpandWidth - layoutInfo.axisExpandWindow[0];
  39987. axisNameAvailableWidth = axisExpandWidth;
  39988. axisLabelShow = true;
  39989. }
  39990. else {
  39991. position = layoutLength - (axisCount - 1 - axisIndex) * axisCollapseWidth;
  39992. nameTruncateMaxWidth = axisCollapseWidth;
  39993. }
  39994. return {
  39995. position: position,
  39996. axisNameAvailableWidth: axisNameAvailableWidth,
  39997. axisLabelShow: axisLabelShow,
  39998. nameTruncateMaxWidth: nameTruncateMaxWidth
  39999. };
  40000. }
  40001. module.exports = Parallel;
  40002. /***/ }),
  40003. /* 241 */
  40004. /***/ (function(module, exports, __webpack_require__) {
  40005. var zrUtil = __webpack_require__(4);
  40006. var Axis = __webpack_require__(103);
  40007. /**
  40008. * @constructor module:echarts/coord/parallel/ParallelAxis
  40009. * @extends {module:echarts/coord/Axis}
  40010. * @param {string} dim
  40011. * @param {*} scale
  40012. * @param {Array.<number>} coordExtent
  40013. * @param {string} axisType
  40014. */
  40015. var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) {
  40016. Axis.call(this, dim, scale, coordExtent);
  40017. /**
  40018. * Axis type
  40019. * - 'category'
  40020. * - 'value'
  40021. * - 'time'
  40022. * - 'log'
  40023. * @type {string}
  40024. */
  40025. this.type = axisType || 'value';
  40026. /**
  40027. * @type {number}
  40028. * @readOnly
  40029. */
  40030. this.axisIndex = axisIndex;
  40031. };
  40032. ParallelAxis.prototype = {
  40033. constructor: ParallelAxis,
  40034. /**
  40035. * Axis model
  40036. * @param {module:echarts/coord/parallel/AxisModel}
  40037. */
  40038. model: null
  40039. };
  40040. zrUtil.inherits(ParallelAxis, Axis);
  40041. module.exports = ParallelAxis;
  40042. /***/ }),
  40043. /* 242 */
  40044. /***/ (function(module, exports) {
  40045. /**
  40046. * Calculate slider move result.
  40047. * Usage:
  40048. * (1) If both handle0 and handle1 are needed to be moved, set minSpan the same as
  40049. * maxSpan and the same as `Math.abs(handleEnd[1] - handleEnds[0])`.
  40050. * (2) If handle0 is forbidden to cross handle1, set minSpan as `0`.
  40051. *
  40052. * @param {number} delta Move length.
  40053. * @param {Array.<number>} handleEnds handleEnds[0] can be bigger then handleEnds[1].
  40054. * handleEnds will be modified in this method.
  40055. * @param {Array.<number>} extent handleEnds is restricted by extent.
  40056. * extent[0] should less or equals than extent[1].
  40057. * @param {number|string} handleIndex Can be 'all', means that both move the two handleEnds,
  40058. * where the input minSpan and maxSpan will not work.
  40059. * @param {number} [minSpan] The range of dataZoom can not be smaller than that.
  40060. * If not set, handle0 and cross handle1. If set as a non-negative
  40061. * number (including `0`), handles will push each other when reaching
  40062. * the minSpan.
  40063. * @param {number} [maxSpan] The range of dataZoom can not be larger than that.
  40064. * @return {Array.<number>} The input handleEnds.
  40065. */
  40066. module.exports = function (delta, handleEnds, extent, handleIndex, minSpan, maxSpan) {
  40067. // Normalize firstly.
  40068. handleEnds[0] = restrict(handleEnds[0], extent);
  40069. handleEnds[1] = restrict(handleEnds[1], extent);
  40070. delta = delta || 0;
  40071. var extentSpan = extent[1] - extent[0];
  40072. // Notice maxSpan and minSpan can be null/undefined.
  40073. if (minSpan != null) {
  40074. minSpan = restrict(minSpan, [0, extentSpan]);
  40075. }
  40076. if (maxSpan != null) {
  40077. maxSpan = Math.max(maxSpan, minSpan != null ? minSpan : 0);
  40078. }
  40079. if (handleIndex === 'all') {
  40080. minSpan = maxSpan = Math.abs(handleEnds[1] - handleEnds[0]);
  40081. handleIndex = 0;
  40082. }
  40083. var originalDistSign = getSpanSign(handleEnds, handleIndex);
  40084. handleEnds[handleIndex] += delta;
  40085. // Restrict in extent.
  40086. var extentMinSpan = minSpan || 0;
  40087. var realExtent = extent.slice();
  40088. originalDistSign.sign < 0 ? (realExtent[0] += extentMinSpan) : (realExtent[1] -= extentMinSpan);
  40089. handleEnds[handleIndex] = restrict(handleEnds[handleIndex], realExtent);
  40090. // Expand span.
  40091. var currDistSign = getSpanSign(handleEnds, handleIndex);
  40092. if (minSpan != null && (
  40093. currDistSign.sign !== originalDistSign.sign || currDistSign.span < minSpan
  40094. )) {
  40095. // If minSpan exists, 'cross' is forbinden.
  40096. handleEnds[1 - handleIndex] = handleEnds[handleIndex] + originalDistSign.sign * minSpan;
  40097. }
  40098. // Shrink span.
  40099. var currDistSign = getSpanSign(handleEnds, handleIndex);
  40100. if (maxSpan != null && currDistSign.span > maxSpan) {
  40101. handleEnds[1 - handleIndex] = handleEnds[handleIndex] + currDistSign.sign * maxSpan;
  40102. }
  40103. return handleEnds;
  40104. };
  40105. function getSpanSign(handleEnds, handleIndex) {
  40106. var dist = handleEnds[handleIndex] - handleEnds[1 - handleIndex];
  40107. // If `handleEnds[0] === handleEnds[1]`, always believe that handleEnd[0]
  40108. // is at left of handleEnds[1] for non-cross case.
  40109. return {span: Math.abs(dist), sign: dist > 0 ? -1 : dist < 0 ? 1 : handleIndex ? -1 : 1};
  40110. }
  40111. function restrict(value, extend) {
  40112. return Math.min(extend[1], Math.max(extend[0], value));
  40113. }
  40114. /***/ }),
  40115. /* 243 */
  40116. /***/ (function(module, exports, __webpack_require__) {
  40117. var zrUtil = __webpack_require__(4);
  40118. var Component = __webpack_require__(72);
  40119. __webpack_require__(244);
  40120. Component.extend({
  40121. type: 'parallel',
  40122. dependencies: ['parallelAxis'],
  40123. /**
  40124. * @type {module:echarts/coord/parallel/Parallel}
  40125. */
  40126. coordinateSystem: null,
  40127. /**
  40128. * Each item like: 'dim0', 'dim1', 'dim2', ...
  40129. * @type {Array.<string>}
  40130. * @readOnly
  40131. */
  40132. dimensions: null,
  40133. /**
  40134. * Coresponding to dimensions.
  40135. * @type {Array.<number>}
  40136. * @readOnly
  40137. */
  40138. parallelAxisIndex: null,
  40139. layoutMode: 'box',
  40140. defaultOption: {
  40141. zlevel: 0,
  40142. z: 0,
  40143. left: 80,
  40144. top: 60,
  40145. right: 80,
  40146. bottom: 60,
  40147. // width: {totalWidth} - left - right,
  40148. // height: {totalHeight} - top - bottom,
  40149. layout: 'horizontal', // 'horizontal' or 'vertical'
  40150. // FIXME
  40151. // naming?
  40152. axisExpandable: false,
  40153. axisExpandCenter: null,
  40154. axisExpandCount: 0,
  40155. axisExpandWidth: 50, // FIXME '10%' ?
  40156. axisExpandRate: 17,
  40157. axisExpandDebounce: 50,
  40158. // [out, in, jumpTarget]. In percentage. If use [null, 0.05], null means full.
  40159. // Do not doc to user until necessary.
  40160. axisExpandSlideTriggerArea: [-0.15, 0.05, 0.4],
  40161. axisExpandTriggerOn: 'click', // 'mousemove' or 'click'
  40162. parallelAxisDefault: null
  40163. },
  40164. /**
  40165. * @override
  40166. */
  40167. init: function () {
  40168. Component.prototype.init.apply(this, arguments);
  40169. this.mergeOption({});
  40170. },
  40171. /**
  40172. * @override
  40173. */
  40174. mergeOption: function (newOption) {
  40175. var thisOption = this.option;
  40176. newOption && zrUtil.merge(thisOption, newOption, true);
  40177. this._initDimensions();
  40178. },
  40179. /**
  40180. * Whether series or axis is in this coordinate system.
  40181. * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model
  40182. * @param {module:echarts/model/Global} ecModel
  40183. */
  40184. contains: function (model, ecModel) {
  40185. var parallelIndex = model.get('parallelIndex');
  40186. return parallelIndex != null
  40187. && ecModel.getComponent('parallel', parallelIndex) === this;
  40188. },
  40189. setAxisExpand: function (opt) {
  40190. zrUtil.each(
  40191. ['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth', 'axisExpandWindow'],
  40192. function (name) {
  40193. if (opt.hasOwnProperty(name)) {
  40194. this.option[name] = opt[name];
  40195. }
  40196. },
  40197. this
  40198. );
  40199. },
  40200. /**
  40201. * @private
  40202. */
  40203. _initDimensions: function () {
  40204. var dimensions = this.dimensions = [];
  40205. var parallelAxisIndex = this.parallelAxisIndex = [];
  40206. var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) {
  40207. // Can not use this.contains here, because
  40208. // initialization has not been completed yet.
  40209. return axisModel.get('parallelIndex') === this.componentIndex;
  40210. });
  40211. zrUtil.each(axisModels, function (axisModel) {
  40212. dimensions.push('dim' + axisModel.get('dim'));
  40213. parallelAxisIndex.push(axisModel.componentIndex);
  40214. });
  40215. }
  40216. });
  40217. /***/ }),
  40218. /* 244 */
  40219. /***/ (function(module, exports, __webpack_require__) {
  40220. var ComponentModel = __webpack_require__(72);
  40221. var zrUtil = __webpack_require__(4);
  40222. var makeStyleMapper = __webpack_require__(17);
  40223. var axisModelCreator = __webpack_require__(134);
  40224. var numberUtil = __webpack_require__(7);
  40225. var AxisModel = ComponentModel.extend({
  40226. type: 'baseParallelAxis',
  40227. /**
  40228. * @type {module:echarts/coord/parallel/Axis}
  40229. */
  40230. axis: null,
  40231. /**
  40232. * @type {Array.<Array.<number>}
  40233. * @readOnly
  40234. */
  40235. activeIntervals: [],
  40236. /**
  40237. * @return {Object}
  40238. */
  40239. getAreaSelectStyle: function () {
  40240. return makeStyleMapper(
  40241. [
  40242. ['fill', 'color'],
  40243. ['lineWidth', 'borderWidth'],
  40244. ['stroke', 'borderColor'],
  40245. ['width', 'width'],
  40246. ['opacity', 'opacity']
  40247. ]
  40248. ).call(this.getModel('areaSelectStyle'));
  40249. },
  40250. /**
  40251. * The code of this feature is put on AxisModel but not ParallelAxis,
  40252. * because axisModel can be alive after echarts updating but instance of
  40253. * ParallelAxis having been disposed. this._activeInterval should be kept
  40254. * when action dispatched (i.e. legend click).
  40255. *
  40256. * @param {Array.<Array<number>>} intervals interval.length === 0
  40257. * means set all active.
  40258. * @public
  40259. */
  40260. setActiveIntervals: function (intervals) {
  40261. var activeIntervals = this.activeIntervals = zrUtil.clone(intervals);
  40262. // Normalize
  40263. if (activeIntervals) {
  40264. for (var i = activeIntervals.length - 1; i >= 0; i--) {
  40265. numberUtil.asc(activeIntervals[i]);
  40266. }
  40267. }
  40268. },
  40269. /**
  40270. * @param {number|string} [value] When attempting to detect 'no activeIntervals set',
  40271. * value can not be input.
  40272. * @return {string} 'normal': no activeIntervals set,
  40273. * 'active',
  40274. * 'inactive'.
  40275. * @public
  40276. */
  40277. getActiveState: function (value) {
  40278. var activeIntervals = this.activeIntervals;
  40279. if (!activeIntervals.length) {
  40280. return 'normal';
  40281. }
  40282. if (value == null) {
  40283. return 'inactive';
  40284. }
  40285. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  40286. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  40287. return 'active';
  40288. }
  40289. }
  40290. return 'inactive';
  40291. }
  40292. });
  40293. var defaultOption = {
  40294. type: 'value',
  40295. /**
  40296. * @type {Array.<number>}
  40297. */
  40298. dim: null, // 0, 1, 2, ...
  40299. // parallelIndex: null,
  40300. areaSelectStyle: {
  40301. width: 20,
  40302. borderWidth: 1,
  40303. borderColor: 'rgba(160,197,232)',
  40304. color: 'rgba(160,197,232)',
  40305. opacity: 0.3
  40306. },
  40307. realtime: true, // Whether realtime update view when select.
  40308. z: 10
  40309. };
  40310. zrUtil.merge(AxisModel.prototype, __webpack_require__(115));
  40311. function getAxisType(axisName, option) {
  40312. return option.type || (option.data ? 'category' : 'value');
  40313. }
  40314. axisModelCreator('parallel', AxisModel, getAxisType, defaultOption);
  40315. module.exports = AxisModel;
  40316. /***/ }),
  40317. /* 245 */
  40318. /***/ (function(module, exports, __webpack_require__) {
  40319. __webpack_require__(239);
  40320. __webpack_require__(246);
  40321. __webpack_require__(247);
  40322. /***/ }),
  40323. /* 246 */
  40324. /***/ (function(module, exports, __webpack_require__) {
  40325. var echarts = __webpack_require__(1);
  40326. /**
  40327. * @payload
  40328. * @property {string} parallelAxisId
  40329. * @property {Array.<Array.<number>>} intervals
  40330. */
  40331. var actionInfo = {
  40332. type: 'axisAreaSelect',
  40333. event: 'axisAreaSelected',
  40334. update: 'updateVisual'
  40335. };
  40336. echarts.registerAction(actionInfo, function (payload, ecModel) {
  40337. ecModel.eachComponent(
  40338. {mainType: 'parallelAxis', query: payload},
  40339. function (parallelAxisModel) {
  40340. parallelAxisModel.axis.model.setActiveIntervals(payload.intervals);
  40341. }
  40342. );
  40343. });
  40344. /**
  40345. * @payload
  40346. */
  40347. echarts.registerAction('parallelAxisExpand', function (payload, ecModel) {
  40348. ecModel.eachComponent(
  40349. {mainType: 'parallel', query: payload},
  40350. function (parallelModel) {
  40351. parallelModel.setAxisExpand(payload);
  40352. }
  40353. );
  40354. });
  40355. /***/ }),
  40356. /* 247 */
  40357. /***/ (function(module, exports, __webpack_require__) {
  40358. var zrUtil = __webpack_require__(4);
  40359. var AxisBuilder = __webpack_require__(138);
  40360. var BrushController = __webpack_require__(248);
  40361. var brushHelper = __webpack_require__(249);
  40362. var graphic = __webpack_require__(20);
  40363. var elementList = ['axisLine', 'axisTickLabel', 'axisName'];
  40364. var AxisView = __webpack_require__(1).extendComponentView({
  40365. type: 'parallelAxis',
  40366. /**
  40367. * @override
  40368. */
  40369. init: function (ecModel, api) {
  40370. AxisView.superApply(this, 'init', arguments);
  40371. /**
  40372. * @type {module:echarts/component/helper/BrushController}
  40373. */
  40374. (this._brushController = new BrushController(api.getZr()))
  40375. .on('brush', zrUtil.bind(this._onBrush, this));
  40376. },
  40377. /**
  40378. * @override
  40379. */
  40380. render: function (axisModel, ecModel, api, payload) {
  40381. if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
  40382. return;
  40383. }
  40384. this.axisModel = axisModel;
  40385. this.api = api;
  40386. this.group.removeAll();
  40387. var oldAxisGroup = this._axisGroup;
  40388. this._axisGroup = new graphic.Group();
  40389. this.group.add(this._axisGroup);
  40390. if (!axisModel.get('show')) {
  40391. return;
  40392. }
  40393. var coordSysModel = getCoordSysModel(axisModel, ecModel);
  40394. var coordSys = coordSysModel.coordinateSystem;
  40395. var areaSelectStyle = axisModel.getAreaSelectStyle();
  40396. var areaWidth = areaSelectStyle.width;
  40397. var dim = axisModel.axis.dim;
  40398. var axisLayout = coordSys.getAxisLayout(dim);
  40399. var builderOpt = zrUtil.extend(
  40400. {strokeContainThreshold: areaWidth},
  40401. axisLayout
  40402. );
  40403. var axisBuilder = new AxisBuilder(axisModel, builderOpt);
  40404. zrUtil.each(elementList, axisBuilder.add, axisBuilder);
  40405. this._axisGroup.add(axisBuilder.getGroup());
  40406. this._refreshBrushController(
  40407. builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api
  40408. );
  40409. var animationModel = (payload && payload.animation === false) ? null : axisModel;
  40410. graphic.groupTransition(oldAxisGroup, this._axisGroup, animationModel);
  40411. },
  40412. /**
  40413. * @override
  40414. */
  40415. updateVisual: function (axisModel, ecModel, api, payload) {
  40416. this._brushController && this._brushController
  40417. .updateCovers(getCoverInfoList(axisModel));
  40418. },
  40419. _refreshBrushController: function (
  40420. builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api
  40421. ) {
  40422. // After filtering, axis may change, select area needs to be update.
  40423. var extent = axisModel.axis.getExtent();
  40424. var extentLen = extent[1] - extent[0];
  40425. var extra = Math.min(30, Math.abs(extentLen) * 0.1); // Arbitrary value.
  40426. // width/height might be negative, which will be
  40427. // normalized in BoundingRect.
  40428. var rect = graphic.BoundingRect.create({
  40429. x: extent[0],
  40430. y: -areaWidth / 2,
  40431. width: extentLen,
  40432. height: areaWidth
  40433. });
  40434. rect.x -= extra;
  40435. rect.width += 2 * extra;
  40436. this._brushController
  40437. .mount({
  40438. enableGlobalPan: true,
  40439. rotation: builderOpt.rotation,
  40440. position: builderOpt.position
  40441. })
  40442. .setPanels([{
  40443. panelId: 'pl',
  40444. clipPath: brushHelper.makeRectPanelClipPath(rect),
  40445. isTargetByCursor: brushHelper.makeRectIsTargetByCursor(rect, api, coordSysModel),
  40446. getLinearBrushOtherExtent: brushHelper.makeLinearBrushOtherExtent(rect, 0)
  40447. }])
  40448. .enableBrush({
  40449. brushType: 'lineX',
  40450. brushStyle: areaSelectStyle,
  40451. removeOnClick: true
  40452. })
  40453. .updateCovers(getCoverInfoList(axisModel));
  40454. },
  40455. _onBrush: function (coverInfoList, opt) {
  40456. // Do not cache these object, because the mey be changed.
  40457. var axisModel = this.axisModel;
  40458. var axis = axisModel.axis;
  40459. var intervals = zrUtil.map(coverInfoList, function (coverInfo) {
  40460. return [
  40461. axis.coordToData(coverInfo.range[0], true),
  40462. axis.coordToData(coverInfo.range[1], true)
  40463. ];
  40464. });
  40465. // If realtime is true, action is not dispatched on drag end, because
  40466. // the drag end emits the same params with the last drag move event,
  40467. // and may have some delay when using touch pad.
  40468. if (!axisModel.option.realtime === opt.isEnd || opt.removeOnClick) { // jshint ignore:line
  40469. this.api.dispatchAction({
  40470. type: 'axisAreaSelect',
  40471. parallelAxisId: axisModel.id,
  40472. intervals: intervals
  40473. });
  40474. }
  40475. },
  40476. /**
  40477. * @override
  40478. */
  40479. dispose: function () {
  40480. this._brushController.dispose();
  40481. }
  40482. });
  40483. function fromAxisAreaSelect(axisModel, ecModel, payload) {
  40484. return payload
  40485. && payload.type === 'axisAreaSelect'
  40486. && ecModel.findComponents(
  40487. {mainType: 'parallelAxis', query: payload}
  40488. )[0] === axisModel;
  40489. }
  40490. function getCoverInfoList(axisModel) {
  40491. var axis = axisModel.axis;
  40492. return zrUtil.map(axisModel.activeIntervals, function (interval) {
  40493. return {
  40494. brushType: 'lineX',
  40495. panelId: 'pl',
  40496. range: [
  40497. axis.dataToCoord(interval[0], true),
  40498. axis.dataToCoord(interval[1], true)
  40499. ]
  40500. };
  40501. });
  40502. }
  40503. function getCoordSysModel(axisModel, ecModel) {
  40504. return ecModel.getComponent(
  40505. 'parallel', axisModel.get('parallelIndex')
  40506. );
  40507. }
  40508. module.exports = AxisView;
  40509. /***/ }),
  40510. /* 248 */
  40511. /***/ (function(module, exports, __webpack_require__) {
  40512. /**
  40513. * Box selection tool.
  40514. *
  40515. * @module echarts/component/helper/BrushController
  40516. */
  40517. var Eventful = __webpack_require__(27);
  40518. var zrUtil = __webpack_require__(4);
  40519. var graphic = __webpack_require__(20);
  40520. var interactionMutex = __webpack_require__(187);
  40521. var DataDiffer = __webpack_require__(102);
  40522. var curry = zrUtil.curry;
  40523. var each = zrUtil.each;
  40524. var map = zrUtil.map;
  40525. var mathMin = Math.min;
  40526. var mathMax = Math.max;
  40527. var mathPow = Math.pow;
  40528. var COVER_Z = 10000;
  40529. var UNSELECT_THRESHOLD = 6;
  40530. var MIN_RESIZE_LINE_WIDTH = 6;
  40531. var MUTEX_RESOURCE_KEY = 'globalPan';
  40532. var DIRECTION_MAP = {
  40533. w: [0, 0],
  40534. e: [0, 1],
  40535. n: [1, 0],
  40536. s: [1, 1]
  40537. };
  40538. var CURSOR_MAP = {
  40539. w: 'ew',
  40540. e: 'ew',
  40541. n: 'ns',
  40542. s: 'ns',
  40543. ne: 'nesw',
  40544. sw: 'nesw',
  40545. nw: 'nwse',
  40546. se: 'nwse'
  40547. };
  40548. var DEFAULT_BRUSH_OPT = {
  40549. brushStyle: {
  40550. lineWidth: 2,
  40551. stroke: 'rgba(0,0,0,0.3)',
  40552. fill: 'rgba(0,0,0,0.1)'
  40553. },
  40554. transformable: true,
  40555. brushMode: 'single',
  40556. removeOnClick: false
  40557. };
  40558. var baseUID = 0;
  40559. /**
  40560. * @alias module:echarts/component/helper/BrushController
  40561. * @constructor
  40562. * @mixin {module:zrender/mixin/Eventful}
  40563. * @event module:echarts/component/helper/BrushController#brush
  40564. * params:
  40565. * areas: Array.<Array>, coord relates to container group,
  40566. * If no container specified, to global.
  40567. * opt {
  40568. * isEnd: boolean,
  40569. * removeOnClick: boolean
  40570. * }
  40571. *
  40572. * @param {module:zrender/zrender~ZRender} zr
  40573. */
  40574. function BrushController(zr) {
  40575. if (true) {
  40576. zrUtil.assert(zr);
  40577. }
  40578. Eventful.call(this);
  40579. /**
  40580. * @type {module:zrender/zrender~ZRender}
  40581. * @private
  40582. */
  40583. this._zr = zr;
  40584. /**
  40585. * @type {module:zrender/container/Group}
  40586. * @readOnly
  40587. */
  40588. this.group = new graphic.Group();
  40589. /**
  40590. * Only for drawing (after enabledBrush).
  40591. * 'line', 'rect', 'polygon' or false
  40592. * If passing false/null/undefined, disable brush.
  40593. * If passing 'auto', determined by panel.defaultBrushType
  40594. * @private
  40595. * @type {string}
  40596. */
  40597. this._brushType;
  40598. /**
  40599. * Only for drawing (after enabledBrush).
  40600. *
  40601. * @private
  40602. * @type {Object}
  40603. */
  40604. this._brushOption;
  40605. /**
  40606. * @private
  40607. * @type {Object}
  40608. */
  40609. this._panels;
  40610. /**
  40611. * @private
  40612. * @type {Array.<nubmer>}
  40613. */
  40614. this._track = [];
  40615. /**
  40616. * @private
  40617. * @type {boolean}
  40618. */
  40619. this._dragging;
  40620. /**
  40621. * @private
  40622. * @type {Array}
  40623. */
  40624. this._covers = [];
  40625. /**
  40626. * @private
  40627. * @type {moudule:zrender/container/Group}
  40628. */
  40629. this._creatingCover;
  40630. /**
  40631. * `true` means global panel
  40632. * @private
  40633. * @type {module:zrender/container/Group|boolean}
  40634. */
  40635. this._creatingPanel;
  40636. /**
  40637. * @private
  40638. * @type {boolean}
  40639. */
  40640. this._enableGlobalPan;
  40641. /**
  40642. * @private
  40643. * @type {boolean}
  40644. */
  40645. if (true) {
  40646. this._mounted;
  40647. }
  40648. /**
  40649. * @private
  40650. * @type {string}
  40651. */
  40652. this._uid = 'brushController_' + baseUID++;
  40653. /**
  40654. * @private
  40655. * @type {Object}
  40656. */
  40657. this._handlers = {};
  40658. each(mouseHandlers, function (handler, eventName) {
  40659. this._handlers[eventName] = zrUtil.bind(handler, this);
  40660. }, this);
  40661. }
  40662. BrushController.prototype = {
  40663. constructor: BrushController,
  40664. /**
  40665. * If set to null/undefined/false, select disabled.
  40666. * @param {Object} brushOption
  40667. * @param {string|boolean} brushOption.brushType 'line', 'rect', 'polygon' or false
  40668. * If passing false/null/undefined, disable brush.
  40669. * If passing 'auto', determined by panel.defaultBrushType.
  40670. * ('auto' can not be used in global panel)
  40671. * @param {number} [brushOption.brushMode='single'] 'single' or 'multiple'
  40672. * @param {boolean} [brushOption.transformable=true]
  40673. * @param {boolean} [brushOption.removeOnClick=false]
  40674. * @param {Object} [brushOption.brushStyle]
  40675. * @param {number} [brushOption.brushStyle.width]
  40676. * @param {number} [brushOption.brushStyle.lineWidth]
  40677. * @param {string} [brushOption.brushStyle.stroke]
  40678. * @param {string} [brushOption.brushStyle.fill]
  40679. * @param {number} [brushOption.z]
  40680. */
  40681. enableBrush: function (brushOption) {
  40682. if (true) {
  40683. zrUtil.assert(this._mounted);
  40684. }
  40685. this._brushType && doDisableBrush(this);
  40686. brushOption.brushType && doEnableBrush(this, brushOption);
  40687. return this;
  40688. },
  40689. /**
  40690. * @param {Array.<Object>} panelOpts If not pass, it is global brush.
  40691. * Each items: {
  40692. * panelId, // mandatory.
  40693. * clipPath, // mandatory. function.
  40694. * isTargetByCursor, // mandatory. function.
  40695. * defaultBrushType, // optional, only used when brushType is 'auto'.
  40696. * getLinearBrushOtherExtent, // optional. function.
  40697. * }
  40698. */
  40699. setPanels: function (panelOpts) {
  40700. if (panelOpts && panelOpts.length) {
  40701. var panels = this._panels = {};
  40702. zrUtil.each(panelOpts, function (panelOpts) {
  40703. panels[panelOpts.panelId] = zrUtil.clone(panelOpts);
  40704. });
  40705. }
  40706. else {
  40707. this._panels = null;
  40708. }
  40709. return this;
  40710. },
  40711. /**
  40712. * @param {Object} [opt]
  40713. * @return {boolean} [opt.enableGlobalPan=false]
  40714. */
  40715. mount: function (opt) {
  40716. opt = opt || {};
  40717. if (true) {
  40718. this._mounted = true; // should be at first.
  40719. }
  40720. this._enableGlobalPan = opt.enableGlobalPan;
  40721. var thisGroup = this.group;
  40722. this._zr.add(thisGroup);
  40723. thisGroup.attr({
  40724. position: opt.position || [0, 0],
  40725. rotation: opt.rotation || 0,
  40726. scale: opt.scale || [1, 1]
  40727. });
  40728. this._transform = thisGroup.getLocalTransform();
  40729. return this;
  40730. },
  40731. eachCover: function (cb, context) {
  40732. each(this._covers, cb, context);
  40733. },
  40734. /**
  40735. * Update covers.
  40736. * @param {Array.<Object>} brushOptionList Like:
  40737. * [
  40738. * {id: 'xx', brushType: 'line', range: [23, 44], brushStyle, transformable},
  40739. * {id: 'yy', brushType: 'rect', range: [[23, 44], [23, 54]]},
  40740. * ...
  40741. * ]
  40742. * `brushType` is required in each cover info. (can not be 'auto')
  40743. * `id` is not mandatory.
  40744. * `brushStyle`, `transformable` is not mandatory, use DEFAULT_BRUSH_OPT by default.
  40745. * If brushOptionList is null/undefined, all covers removed.
  40746. */
  40747. updateCovers: function (brushOptionList) {
  40748. if (true) {
  40749. zrUtil.assert(this._mounted);
  40750. }
  40751. brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
  40752. return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  40753. });
  40754. var tmpIdPrefix = '\0-brush-index-';
  40755. var oldCovers = this._covers;
  40756. var newCovers = this._covers = [];
  40757. var controller = this;
  40758. var creatingCover = this._creatingCover;
  40759. (new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
  40760. .add(addOrUpdate)
  40761. .update(addOrUpdate)
  40762. .remove(remove)
  40763. .execute();
  40764. return this;
  40765. function getKey(brushOption, index) {
  40766. return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
  40767. + '-' + brushOption.brushType;
  40768. }
  40769. function oldGetKey(cover, index) {
  40770. return getKey(cover.__brushOption, index);
  40771. }
  40772. function addOrUpdate(newIndex, oldIndex) {
  40773. var newBrushOption = brushOptionList[newIndex];
  40774. // Consider setOption in event listener of brushSelect,
  40775. // where updating cover when creating should be forbiden.
  40776. if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
  40777. newCovers[newIndex] = oldCovers[oldIndex];
  40778. }
  40779. else {
  40780. var cover = newCovers[newIndex] = oldIndex != null
  40781. ? (
  40782. oldCovers[oldIndex].__brushOption = newBrushOption,
  40783. oldCovers[oldIndex]
  40784. )
  40785. : endCreating(controller, createCover(controller, newBrushOption));
  40786. updateCoverAfterCreation(controller, cover);
  40787. }
  40788. }
  40789. function remove(oldIndex) {
  40790. if (oldCovers[oldIndex] !== creatingCover) {
  40791. controller.group.remove(oldCovers[oldIndex]);
  40792. }
  40793. }
  40794. },
  40795. unmount: function () {
  40796. if (true) {
  40797. if (!this._mounted) {
  40798. return;
  40799. }
  40800. }
  40801. this.enableBrush(false);
  40802. // container may 'removeAll' outside.
  40803. clearCovers(this);
  40804. this._zr.remove(this.group);
  40805. if (true) {
  40806. this._mounted = false; // should be at last.
  40807. }
  40808. return this;
  40809. },
  40810. dispose: function () {
  40811. this.unmount();
  40812. this.off();
  40813. }
  40814. };
  40815. zrUtil.mixin(BrushController, Eventful);
  40816. function doEnableBrush(controller, brushOption) {
  40817. var zr = controller._zr;
  40818. // Consider roam, which takes globalPan too.
  40819. if (!controller._enableGlobalPan) {
  40820. interactionMutex.take(zr, MUTEX_RESOURCE_KEY, controller._uid);
  40821. }
  40822. each(controller._handlers, function (handler, eventName) {
  40823. zr.on(eventName, handler);
  40824. });
  40825. controller._brushType = brushOption.brushType;
  40826. controller._brushOption = zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  40827. }
  40828. function doDisableBrush(controller) {
  40829. var zr = controller._zr;
  40830. interactionMutex.release(zr, MUTEX_RESOURCE_KEY, controller._uid);
  40831. each(controller._handlers, function (handler, eventName) {
  40832. zr.off(eventName, handler);
  40833. });
  40834. controller._brushType = controller._brushOption = null;
  40835. }
  40836. function createCover(controller, brushOption) {
  40837. var cover = coverRenderers[brushOption.brushType].createCover(controller, brushOption);
  40838. cover.__brushOption = brushOption;
  40839. updateZ(cover, brushOption);
  40840. controller.group.add(cover);
  40841. return cover;
  40842. }
  40843. function endCreating(controller, creatingCover) {
  40844. var coverRenderer = getCoverRenderer(creatingCover);
  40845. if (coverRenderer.endCreating) {
  40846. coverRenderer.endCreating(controller, creatingCover);
  40847. updateZ(creatingCover, creatingCover.__brushOption);
  40848. }
  40849. return creatingCover;
  40850. }
  40851. function updateCoverShape(controller, cover) {
  40852. var brushOption = cover.__brushOption;
  40853. getCoverRenderer(cover).updateCoverShape(
  40854. controller, cover, brushOption.range, brushOption
  40855. );
  40856. }
  40857. function updateZ(cover, brushOption) {
  40858. var z = brushOption.z;
  40859. z == null && (z = COVER_Z);
  40860. cover.traverse(function (el) {
  40861. el.z = z;
  40862. el.z2 = z; // Consider in given container.
  40863. });
  40864. }
  40865. function updateCoverAfterCreation(controller, cover) {
  40866. getCoverRenderer(cover).updateCommon(controller, cover);
  40867. updateCoverShape(controller, cover);
  40868. }
  40869. function getCoverRenderer(cover) {
  40870. return coverRenderers[cover.__brushOption.brushType];
  40871. }
  40872. // return target panel or `true` (means global panel)
  40873. function getPanelByPoint(controller, e, localCursorPoint) {
  40874. var panels = controller._panels;
  40875. if (!panels) {
  40876. return true; // Global panel
  40877. }
  40878. var panel;
  40879. var transform = controller._transform;
  40880. each(panels, function (pn) {
  40881. pn.isTargetByCursor(e, localCursorPoint, transform) && (panel = pn);
  40882. });
  40883. return panel;
  40884. }
  40885. // Return a panel or true
  40886. function getPanelByCover(controller, cover) {
  40887. var panels = controller._panels;
  40888. if (!panels) {
  40889. return true; // Global panel
  40890. }
  40891. var panelId = cover.__brushOption.panelId;
  40892. // User may give cover without coord sys info,
  40893. // which is then treated as global panel.
  40894. return panelId != null ? panels[panelId] : true;
  40895. }
  40896. function clearCovers(controller) {
  40897. var covers = controller._covers;
  40898. var originalLength = covers.length;
  40899. each(covers, function (cover) {
  40900. controller.group.remove(cover);
  40901. }, controller);
  40902. covers.length = 0;
  40903. return !!originalLength;
  40904. }
  40905. function trigger(controller, opt) {
  40906. var areas = map(controller._covers, function (cover) {
  40907. var brushOption = cover.__brushOption;
  40908. var range = zrUtil.clone(brushOption.range);
  40909. return {
  40910. brushType: brushOption.brushType,
  40911. panelId: brushOption.panelId,
  40912. range: range
  40913. };
  40914. });
  40915. controller.trigger('brush', areas, {
  40916. isEnd: !!opt.isEnd,
  40917. removeOnClick: !!opt.removeOnClick
  40918. });
  40919. }
  40920. function shouldShowCover(controller) {
  40921. var track = controller._track;
  40922. if (!track.length) {
  40923. return false;
  40924. }
  40925. var p2 = track[track.length - 1];
  40926. var p1 = track[0];
  40927. var dx = p2[0] - p1[0];
  40928. var dy = p2[1] - p1[1];
  40929. var dist = mathPow(dx * dx + dy * dy, 0.5);
  40930. return dist > UNSELECT_THRESHOLD;
  40931. }
  40932. function getTrackEnds(track) {
  40933. var tail = track.length - 1;
  40934. tail < 0 && (tail = 0);
  40935. return [track[0], track[tail]];
  40936. }
  40937. function createBaseRectCover(doDrift, controller, brushOption, edgeNames) {
  40938. var cover = new graphic.Group();
  40939. cover.add(new graphic.Rect({
  40940. name: 'main',
  40941. style: makeStyle(brushOption),
  40942. silent: true,
  40943. draggable: true,
  40944. cursor: 'move',
  40945. drift: curry(doDrift, controller, cover, 'nswe'),
  40946. ondragend: curry(trigger, controller, {isEnd: true})
  40947. }));
  40948. each(
  40949. edgeNames,
  40950. function (name) {
  40951. cover.add(new graphic.Rect({
  40952. name: name,
  40953. style: {opacity: 0},
  40954. draggable: true,
  40955. silent: true,
  40956. invisible: true,
  40957. drift: curry(doDrift, controller, cover, name),
  40958. ondragend: curry(trigger, controller, {isEnd: true})
  40959. }));
  40960. }
  40961. );
  40962. return cover;
  40963. }
  40964. function updateBaseRect(controller, cover, localRange, brushOption) {
  40965. var lineWidth = brushOption.brushStyle.lineWidth || 0;
  40966. var handleSize = mathMax(lineWidth, MIN_RESIZE_LINE_WIDTH);
  40967. var x = localRange[0][0];
  40968. var y = localRange[1][0];
  40969. var xa = x - lineWidth / 2;
  40970. var ya = y - lineWidth / 2;
  40971. var x2 = localRange[0][1];
  40972. var y2 = localRange[1][1];
  40973. var x2a = x2 - handleSize + lineWidth / 2;
  40974. var y2a = y2 - handleSize + lineWidth / 2;
  40975. var width = x2 - x;
  40976. var height = y2 - y;
  40977. var widtha = width + lineWidth;
  40978. var heighta = height + lineWidth;
  40979. updateRectShape(controller, cover, 'main', x, y, width, height);
  40980. if (brushOption.transformable) {
  40981. updateRectShape(controller, cover, 'w', xa, ya, handleSize, heighta);
  40982. updateRectShape(controller, cover, 'e', x2a, ya, handleSize, heighta);
  40983. updateRectShape(controller, cover, 'n', xa, ya, widtha, handleSize);
  40984. updateRectShape(controller, cover, 's', xa, y2a, widtha, handleSize);
  40985. updateRectShape(controller, cover, 'nw', xa, ya, handleSize, handleSize);
  40986. updateRectShape(controller, cover, 'ne', x2a, ya, handleSize, handleSize);
  40987. updateRectShape(controller, cover, 'sw', xa, y2a, handleSize, handleSize);
  40988. updateRectShape(controller, cover, 'se', x2a, y2a, handleSize, handleSize);
  40989. }
  40990. }
  40991. function updateCommon(controller, cover) {
  40992. var brushOption = cover.__brushOption;
  40993. var transformable = brushOption.transformable;
  40994. var mainEl = cover.childAt(0);
  40995. mainEl.useStyle(makeStyle(brushOption));
  40996. mainEl.attr({
  40997. silent: !transformable,
  40998. cursor: transformable ? 'move' : 'default'
  40999. });
  41000. each(
  41001. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw'],
  41002. function (name) {
  41003. var el = cover.childOfName(name);
  41004. var globalDir = getGlobalDirection(controller, name);
  41005. el && el.attr({
  41006. silent: !transformable,
  41007. invisible: !transformable,
  41008. cursor: transformable ? CURSOR_MAP[globalDir] + '-resize' : null
  41009. });
  41010. }
  41011. );
  41012. }
  41013. function updateRectShape(controller, cover, name, x, y, w, h) {
  41014. var el = cover.childOfName(name);
  41015. el && el.setShape(pointsToRect(
  41016. clipByPanel(controller, cover, [[x, y], [x + w, y + h]])
  41017. ));
  41018. }
  41019. function makeStyle(brushOption) {
  41020. return zrUtil.defaults({strokeNoScale: true}, brushOption.brushStyle);
  41021. }
  41022. function formatRectRange(x, y, x2, y2) {
  41023. var min = [mathMin(x, x2), mathMin(y, y2)];
  41024. var max = [mathMax(x, x2), mathMax(y, y2)];
  41025. return [
  41026. [min[0], max[0]], // x range
  41027. [min[1], max[1]] // y range
  41028. ];
  41029. }
  41030. function getTransform(controller) {
  41031. return graphic.getTransform(controller.group);
  41032. }
  41033. function getGlobalDirection(controller, localDirection) {
  41034. if (localDirection.length > 1) {
  41035. localDirection = localDirection.split('');
  41036. var globalDir = [
  41037. getGlobalDirection(controller, localDirection[0]),
  41038. getGlobalDirection(controller, localDirection[1])
  41039. ];
  41040. (globalDir[0] === 'e' || globalDir[0] === 'w') && globalDir.reverse();
  41041. return globalDir.join('');
  41042. }
  41043. else {
  41044. var map = {w: 'left', e: 'right', n: 'top', s: 'bottom'};
  41045. var inverseMap = {left: 'w', right: 'e', top: 'n', bottom: 's'};
  41046. var globalDir = graphic.transformDirection(
  41047. map[localDirection], getTransform(controller)
  41048. );
  41049. return inverseMap[globalDir];
  41050. }
  41051. }
  41052. function driftRect(toRectRange, fromRectRange, controller, cover, name, dx, dy, e) {
  41053. var brushOption = cover.__brushOption;
  41054. var rectRange = toRectRange(brushOption.range);
  41055. var localDelta = toLocalDelta(controller, dx, dy);
  41056. each(name.split(''), function (namePart) {
  41057. var ind = DIRECTION_MAP[namePart];
  41058. rectRange[ind[0]][ind[1]] += localDelta[ind[0]];
  41059. });
  41060. brushOption.range = fromRectRange(formatRectRange(
  41061. rectRange[0][0], rectRange[1][0], rectRange[0][1], rectRange[1][1]
  41062. ));
  41063. updateCoverAfterCreation(controller, cover);
  41064. trigger(controller, {isEnd: false});
  41065. }
  41066. function driftPolygon(controller, cover, dx, dy, e) {
  41067. var range = cover.__brushOption.range;
  41068. var localDelta = toLocalDelta(controller, dx, dy);
  41069. each(range, function (point) {
  41070. point[0] += localDelta[0];
  41071. point[1] += localDelta[1];
  41072. });
  41073. updateCoverAfterCreation(controller, cover);
  41074. trigger(controller, {isEnd: false});
  41075. }
  41076. function toLocalDelta(controller, dx, dy) {
  41077. var thisGroup = controller.group;
  41078. var localD = thisGroup.transformCoordToLocal(dx, dy);
  41079. var localZero = thisGroup.transformCoordToLocal(0, 0);
  41080. return [localD[0] - localZero[0], localD[1] - localZero[1]];
  41081. }
  41082. function clipByPanel(controller, cover, data) {
  41083. var panel = getPanelByCover(controller, cover);
  41084. return (panel && panel !== true)
  41085. ? panel.clipPath(data, controller._transform)
  41086. : zrUtil.clone(data);
  41087. }
  41088. function pointsToRect(points) {
  41089. var xmin = mathMin(points[0][0], points[1][0]);
  41090. var ymin = mathMin(points[0][1], points[1][1]);
  41091. var xmax = mathMax(points[0][0], points[1][0]);
  41092. var ymax = mathMax(points[0][1], points[1][1]);
  41093. return {
  41094. x: xmin,
  41095. y: ymin,
  41096. width: xmax - xmin,
  41097. height: ymax - ymin
  41098. };
  41099. }
  41100. function resetCursor(controller, e, localCursorPoint) {
  41101. // Check active
  41102. if (!controller._brushType) {
  41103. return;
  41104. }
  41105. var zr = controller._zr;
  41106. var covers = controller._covers;
  41107. var currPanel = getPanelByPoint(controller, e, localCursorPoint);
  41108. // Check whether in covers.
  41109. if (!controller._dragging) {
  41110. for (var i = 0; i < covers.length; i++) {
  41111. var brushOption = covers[i].__brushOption;
  41112. if (currPanel
  41113. && (currPanel === true || brushOption.panelId === currPanel.panelId)
  41114. && coverRenderers[brushOption.brushType].contain(
  41115. covers[i], localCursorPoint[0], localCursorPoint[1]
  41116. )
  41117. ) {
  41118. // Use cursor style set on cover.
  41119. return;
  41120. }
  41121. }
  41122. }
  41123. currPanel && zr.setCursorStyle('crosshair');
  41124. }
  41125. function preventDefault(e) {
  41126. var rawE = e.event;
  41127. rawE.preventDefault && rawE.preventDefault();
  41128. }
  41129. function mainShapeContain(cover, x, y) {
  41130. return cover.childOfName('main').contain(x, y);
  41131. }
  41132. function updateCoverByMouse(controller, e, localCursorPoint, isEnd) {
  41133. var creatingCover = controller._creatingCover;
  41134. var panel = controller._creatingPanel;
  41135. var thisBrushOption = controller._brushOption;
  41136. var eventParams;
  41137. controller._track.push(localCursorPoint.slice());
  41138. if (shouldShowCover(controller) || creatingCover) {
  41139. if (panel && !creatingCover) {
  41140. thisBrushOption.brushMode === 'single' && clearCovers(controller);
  41141. var brushOption = zrUtil.clone(thisBrushOption);
  41142. brushOption.brushType = determineBrushType(brushOption.brushType, panel);
  41143. brushOption.panelId = panel === true ? null : panel.panelId;
  41144. creatingCover = controller._creatingCover = createCover(controller, brushOption);
  41145. controller._covers.push(creatingCover);
  41146. }
  41147. if (creatingCover) {
  41148. var coverRenderer = coverRenderers[determineBrushType(controller._brushType, panel)];
  41149. var coverBrushOption = creatingCover.__brushOption;
  41150. coverBrushOption.range = coverRenderer.getCreatingRange(
  41151. clipByPanel(controller, creatingCover, controller._track)
  41152. );
  41153. if (isEnd) {
  41154. endCreating(controller, creatingCover);
  41155. coverRenderer.updateCommon(controller, creatingCover);
  41156. }
  41157. updateCoverShape(controller, creatingCover);
  41158. eventParams = {isEnd: isEnd};
  41159. }
  41160. }
  41161. else if (
  41162. isEnd
  41163. && thisBrushOption.brushMode === 'single'
  41164. && thisBrushOption.removeOnClick
  41165. ) {
  41166. // Help user to remove covers easily, only by a tiny drag, in 'single' mode.
  41167. // But a single click do not clear covers, because user may have casual
  41168. // clicks (for example, click on other component and do not expect covers
  41169. // disappear).
  41170. // Only some cover removed, trigger action, but not every click trigger action.
  41171. if (getPanelByPoint(controller, e, localCursorPoint) && clearCovers(controller)) {
  41172. eventParams = {isEnd: isEnd, removeOnClick: true};
  41173. }
  41174. }
  41175. return eventParams;
  41176. }
  41177. function determineBrushType(brushType, panel) {
  41178. if (brushType === 'auto') {
  41179. if (true) {
  41180. zrUtil.assert(
  41181. panel && panel.defaultBrushType,
  41182. 'MUST have defaultBrushType when brushType is "atuo"'
  41183. );
  41184. }
  41185. return panel.defaultBrushType;
  41186. }
  41187. return brushType;
  41188. }
  41189. var mouseHandlers = {
  41190. mousedown: function (e) {
  41191. if (this._dragging) {
  41192. // In case some browser do not support globalOut,
  41193. // and release mose out side the browser.
  41194. handleDragEnd.call(this, e);
  41195. }
  41196. else if (!e.target || !e.target.draggable) {
  41197. preventDefault(e);
  41198. var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
  41199. this._creatingCover = null;
  41200. var panel = this._creatingPanel = getPanelByPoint(this, e, localCursorPoint);
  41201. if (panel) {
  41202. this._dragging = true;
  41203. this._track = [localCursorPoint.slice()];
  41204. }
  41205. }
  41206. },
  41207. mousemove: function (e) {
  41208. var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
  41209. resetCursor(this, e, localCursorPoint);
  41210. if (this._dragging) {
  41211. preventDefault(e);
  41212. var eventParams = updateCoverByMouse(this, e, localCursorPoint, false);
  41213. eventParams && trigger(this, eventParams);
  41214. }
  41215. },
  41216. mouseup: handleDragEnd //,
  41217. // FIXME
  41218. // in tooltip, globalout should not be triggered.
  41219. // globalout: handleDragEnd
  41220. };
  41221. function handleDragEnd(e) {
  41222. if (this._dragging) {
  41223. preventDefault(e);
  41224. var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
  41225. var eventParams = updateCoverByMouse(this, e, localCursorPoint, true);
  41226. this._dragging = false;
  41227. this._track = [];
  41228. this._creatingCover = null;
  41229. // trigger event shoule be at final, after procedure will be nested.
  41230. eventParams && trigger(this, eventParams);
  41231. }
  41232. }
  41233. /**
  41234. * key: brushType
  41235. * @type {Object}
  41236. */
  41237. var coverRenderers = {
  41238. lineX: getLineRenderer(0),
  41239. lineY: getLineRenderer(1),
  41240. rect: {
  41241. createCover: function (controller, brushOption) {
  41242. return createBaseRectCover(
  41243. curry(
  41244. driftRect,
  41245. function (range) {
  41246. return range;
  41247. },
  41248. function (range) {
  41249. return range;
  41250. }
  41251. ),
  41252. controller,
  41253. brushOption,
  41254. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw']
  41255. );
  41256. },
  41257. getCreatingRange: function (localTrack) {
  41258. var ends = getTrackEnds(localTrack);
  41259. return formatRectRange(ends[1][0], ends[1][1], ends[0][0], ends[0][1]);
  41260. },
  41261. updateCoverShape: function (controller, cover, localRange, brushOption) {
  41262. updateBaseRect(controller, cover, localRange, brushOption);
  41263. },
  41264. updateCommon: updateCommon,
  41265. contain: mainShapeContain
  41266. },
  41267. polygon: {
  41268. createCover: function (controller, brushOption) {
  41269. var cover = new graphic.Group();
  41270. // Do not use graphic.Polygon because graphic.Polyline do not close the
  41271. // border of the shape when drawing, which is a better experience for user.
  41272. cover.add(new graphic.Polyline({
  41273. name: 'main',
  41274. style: makeStyle(brushOption),
  41275. silent: true
  41276. }));
  41277. return cover;
  41278. },
  41279. getCreatingRange: function (localTrack) {
  41280. return localTrack;
  41281. },
  41282. endCreating: function (controller, cover) {
  41283. cover.remove(cover.childAt(0));
  41284. // Use graphic.Polygon close the shape.
  41285. cover.add(new graphic.Polygon({
  41286. name: 'main',
  41287. draggable: true,
  41288. drift: curry(driftPolygon, controller, cover),
  41289. ondragend: curry(trigger, controller, {isEnd: true})
  41290. }));
  41291. },
  41292. updateCoverShape: function (controller, cover, localRange, brushOption) {
  41293. cover.childAt(0).setShape({
  41294. points: clipByPanel(controller, cover, localRange)
  41295. });
  41296. },
  41297. updateCommon: updateCommon,
  41298. contain: mainShapeContain
  41299. }
  41300. };
  41301. function getLineRenderer(xyIndex) {
  41302. return {
  41303. createCover: function (controller, brushOption) {
  41304. return createBaseRectCover(
  41305. curry(
  41306. driftRect,
  41307. function (range) {
  41308. var rectRange = [range, [0, 100]];
  41309. xyIndex && rectRange.reverse();
  41310. return rectRange;
  41311. },
  41312. function (rectRange) {
  41313. return rectRange[xyIndex];
  41314. }
  41315. ),
  41316. controller,
  41317. brushOption,
  41318. [['w', 'e'], ['n', 's']][xyIndex]
  41319. );
  41320. },
  41321. getCreatingRange: function (localTrack) {
  41322. var ends = getTrackEnds(localTrack);
  41323. var min = mathMin(ends[0][xyIndex], ends[1][xyIndex]);
  41324. var max = mathMax(ends[0][xyIndex], ends[1][xyIndex]);
  41325. return [min, max];
  41326. },
  41327. updateCoverShape: function (controller, cover, localRange, brushOption) {
  41328. var otherExtent;
  41329. // If brushWidth not specified, fit the panel.
  41330. var panel = getPanelByCover(controller, cover);
  41331. if (panel !== true && panel.getLinearBrushOtherExtent) {
  41332. otherExtent = panel.getLinearBrushOtherExtent(
  41333. xyIndex, controller._transform
  41334. );
  41335. }
  41336. else {
  41337. var zr = controller._zr;
  41338. otherExtent = [0, [zr.getWidth(), zr.getHeight()][1 - xyIndex]];
  41339. }
  41340. var rectRange = [localRange, otherExtent];
  41341. xyIndex && rectRange.reverse();
  41342. updateBaseRect(controller, cover, rectRange, brushOption);
  41343. },
  41344. updateCommon: updateCommon,
  41345. contain: mainShapeContain
  41346. };
  41347. }
  41348. module.exports = BrushController;
  41349. /***/ }),
  41350. /* 249 */
  41351. /***/ (function(module, exports, __webpack_require__) {
  41352. var cursorHelper = __webpack_require__(189);
  41353. var BoundingRect = __webpack_require__(9);
  41354. var graphicUtil = __webpack_require__(20);
  41355. var helper = {};
  41356. helper.makeRectPanelClipPath = function (rect) {
  41357. rect = normalizeRect(rect);
  41358. return function (localPoints, transform) {
  41359. return graphicUtil.clipPointsByRect(localPoints, rect);
  41360. };
  41361. };
  41362. helper.makeLinearBrushOtherExtent = function (rect, specifiedXYIndex) {
  41363. rect = normalizeRect(rect);
  41364. return function (xyIndex) {
  41365. var idx = specifiedXYIndex != null ? specifiedXYIndex : xyIndex;
  41366. var brushWidth = idx ? rect.width : rect.height;
  41367. var base = idx ? rect.x : rect.y;
  41368. return [base, base + (brushWidth || 0)];
  41369. };
  41370. };
  41371. helper.makeRectIsTargetByCursor = function (rect, api, targetModel) {
  41372. rect = normalizeRect(rect);
  41373. return function (e, localCursorPoint, transform) {
  41374. return rect.contain(localCursorPoint[0], localCursorPoint[1])
  41375. && !cursorHelper.onIrrelevantElement(e, api, targetModel);
  41376. };
  41377. };
  41378. // Consider width/height is negative.
  41379. function normalizeRect(rect) {
  41380. return BoundingRect.create(rect);
  41381. }
  41382. module.exports = helper;
  41383. /***/ }),
  41384. /* 250 */
  41385. /***/ (function(module, exports, __webpack_require__) {
  41386. var zrUtil = __webpack_require__(4);
  41387. var modelUtil = __webpack_require__(5);
  41388. module.exports = function (option) {
  41389. createParallelIfNeeded(option);
  41390. mergeAxisOptionFromParallel(option);
  41391. };
  41392. /**
  41393. * Create a parallel coordinate if not exists.
  41394. * @inner
  41395. */
  41396. function createParallelIfNeeded(option) {
  41397. if (option.parallel) {
  41398. return;
  41399. }
  41400. var hasParallelSeries = false;
  41401. zrUtil.each(option.series, function (seriesOpt) {
  41402. if (seriesOpt && seriesOpt.type === 'parallel') {
  41403. hasParallelSeries = true;
  41404. }
  41405. });
  41406. if (hasParallelSeries) {
  41407. option.parallel = [{}];
  41408. }
  41409. }
  41410. /**
  41411. * Merge aixs definition from parallel option (if exists) to axis option.
  41412. * @inner
  41413. */
  41414. function mergeAxisOptionFromParallel(option) {
  41415. var axes = modelUtil.normalizeToArray(option.parallelAxis);
  41416. zrUtil.each(axes, function (axisOption) {
  41417. if (!zrUtil.isObject(axisOption)) {
  41418. return;
  41419. }
  41420. var parallelIndex = axisOption.parallelIndex || 0;
  41421. var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex];
  41422. if (parallelOption && parallelOption.parallelAxisDefault) {
  41423. zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false);
  41424. }
  41425. });
  41426. }
  41427. /***/ }),
  41428. /* 251 */
  41429. /***/ (function(module, exports, __webpack_require__) {
  41430. var List = __webpack_require__(101);
  41431. var zrUtil = __webpack_require__(4);
  41432. var SeriesModel = __webpack_require__(83);
  41433. var completeDimensions = __webpack_require__(113);
  41434. module.exports = SeriesModel.extend({
  41435. type: 'series.parallel',
  41436. dependencies: ['parallel'],
  41437. visualColorAccessPath: 'lineStyle.normal.color',
  41438. getInitialData: function (option, ecModel) {
  41439. var parallelModel = ecModel.getComponent(
  41440. 'parallel', this.get('parallelIndex')
  41441. );
  41442. var parallelAxisIndices = parallelModel.parallelAxisIndex;
  41443. var rawData = option.data;
  41444. var modelDims = parallelModel.dimensions;
  41445. var dataDims = generateDataDims(modelDims, rawData);
  41446. var dataDimsInfo = zrUtil.map(dataDims, function (dim, dimIndex) {
  41447. var modelDimsIndex = zrUtil.indexOf(modelDims, dim);
  41448. var axisModel = modelDimsIndex >= 0 && ecModel.getComponent(
  41449. 'parallelAxis', parallelAxisIndices[modelDimsIndex]
  41450. );
  41451. if (axisModel && axisModel.get('type') === 'category') {
  41452. translateCategoryValue(axisModel, dim, rawData);
  41453. return {name: dim, type: 'ordinal'};
  41454. }
  41455. else if (modelDimsIndex < 0) {
  41456. return completeDimensions.guessOrdinal(rawData, dimIndex)
  41457. ? {name: dim, type: 'ordinal'}
  41458. : dim;
  41459. }
  41460. else {
  41461. return dim;
  41462. }
  41463. });
  41464. var list = new List(dataDimsInfo, this);
  41465. list.initData(rawData);
  41466. // Anication is forbiden in progressive data mode.
  41467. if (this.option.progressive) {
  41468. this.option.animation = false;
  41469. }
  41470. return list;
  41471. },
  41472. /**
  41473. * User can get data raw indices on 'axisAreaSelected' event received.
  41474. *
  41475. * @public
  41476. * @param {string} activeState 'active' or 'inactive' or 'normal'
  41477. * @return {Array.<number>} Raw indices
  41478. */
  41479. getRawIndicesByActiveState: function (activeState) {
  41480. var coordSys = this.coordinateSystem;
  41481. var data = this.getData();
  41482. var indices = [];
  41483. coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
  41484. if (activeState === theActiveState) {
  41485. indices.push(data.getRawIndex(dataIndex));
  41486. }
  41487. });
  41488. return indices;
  41489. },
  41490. defaultOption: {
  41491. zlevel: 0, // 一级层叠
  41492. z: 2, // 二级层叠
  41493. coordinateSystem: 'parallel',
  41494. parallelIndex: 0,
  41495. label: {
  41496. normal: {
  41497. show: false
  41498. },
  41499. emphasis: {
  41500. show: false
  41501. }
  41502. },
  41503. inactiveOpacity: 0.05,
  41504. activeOpacity: 1,
  41505. lineStyle: {
  41506. normal: {
  41507. width: 1,
  41508. opacity: 0.45,
  41509. type: 'solid'
  41510. }
  41511. },
  41512. progressive: false, // 100
  41513. smooth: false,
  41514. animationEasing: 'linear'
  41515. }
  41516. });
  41517. function translateCategoryValue(axisModel, dim, rawData) {
  41518. var axisData = axisModel.get('data');
  41519. var numberDim = convertDimNameToNumber(dim);
  41520. if (axisData && axisData.length) {
  41521. zrUtil.each(rawData, function (dataItem) {
  41522. if (!dataItem) {
  41523. return;
  41524. }
  41525. // FIXME
  41526. // time consuming, should use hash?
  41527. var index = zrUtil.indexOf(axisData, dataItem[numberDim]);
  41528. dataItem[numberDim] = index >= 0 ? index : NaN;
  41529. });
  41530. }
  41531. // FIXME
  41532. // 如果没有设置axis data, 应自动算出,或者提示。
  41533. }
  41534. function convertDimNameToNumber(dimName) {
  41535. return +dimName.replace('dim', '');
  41536. }
  41537. function generateDataDims(modelDims, rawData) {
  41538. // parallelModel.dimension should not be regarded as data
  41539. // dimensions. Consider dimensions = ['dim4', 'dim2', 'dim6'];
  41540. // We detect max dim by parallelModel.dimensions and fist
  41541. // item in rawData arbitrarily.
  41542. var maxDimNum = 0;
  41543. zrUtil.each(modelDims, function (dimName) {
  41544. var numberDim = convertDimNameToNumber(dimName);
  41545. numberDim > maxDimNum && (maxDimNum = numberDim);
  41546. });
  41547. var firstItem = rawData[0];
  41548. if (firstItem && firstItem.length - 1 > maxDimNum) {
  41549. maxDimNum = firstItem.length - 1;
  41550. }
  41551. var dataDims = [];
  41552. for (var i = 0; i <= maxDimNum; i++) {
  41553. dataDims.push('dim' + i);
  41554. }
  41555. return dataDims;
  41556. }
  41557. /***/ }),
  41558. /* 252 */
  41559. /***/ (function(module, exports, __webpack_require__) {
  41560. var graphic = __webpack_require__(20);
  41561. var zrUtil = __webpack_require__(4);
  41562. var SMOOTH = 0.3;
  41563. var ParallelView = __webpack_require__(85).extend({
  41564. type: 'parallel',
  41565. init: function () {
  41566. /**
  41567. * @type {module:zrender/container/Group}
  41568. * @private
  41569. */
  41570. this._dataGroup = new graphic.Group();
  41571. this.group.add(this._dataGroup);
  41572. /**
  41573. * @type {module:echarts/data/List}
  41574. */
  41575. this._data;
  41576. },
  41577. /**
  41578. * @override
  41579. */
  41580. render: function (seriesModel, ecModel, api, payload) {
  41581. this._renderForNormal(seriesModel, payload);
  41582. // this[
  41583. // seriesModel.option.progressive
  41584. // ? '_renderForProgressive'
  41585. // : '_renderForNormal'
  41586. // ](seriesModel);
  41587. },
  41588. dispose: function () {},
  41589. /**
  41590. * @private
  41591. */
  41592. _renderForNormal: function (seriesModel, payload) {
  41593. var dataGroup = this._dataGroup;
  41594. var data = seriesModel.getData();
  41595. var oldData = this._data;
  41596. var coordSys = seriesModel.coordinateSystem;
  41597. var dimensions = coordSys.dimensions;
  41598. var option = seriesModel.option;
  41599. var smooth = option.smooth ? SMOOTH : null;
  41600. // Consider switch between progressive and not.
  41601. // oldData && oldData.__plProgressive && dataGroup.removeAll();
  41602. data.diff(oldData)
  41603. .add(add)
  41604. .update(update)
  41605. .remove(remove)
  41606. .execute();
  41607. // Update style
  41608. updateElCommon(data, smooth);
  41609. // First create
  41610. if (!this._data) {
  41611. var clipPath = createGridClipShape(
  41612. coordSys, seriesModel, function () {
  41613. // Callback will be invoked immediately if there is no animation
  41614. setTimeout(function () {
  41615. dataGroup.removeClipPath();
  41616. });
  41617. }
  41618. );
  41619. dataGroup.setClipPath(clipPath);
  41620. }
  41621. this._data = data;
  41622. function add(newDataIndex) {
  41623. addEl(data, dataGroup, newDataIndex, dimensions, coordSys, null, smooth);
  41624. }
  41625. function update(newDataIndex, oldDataIndex) {
  41626. var line = oldData.getItemGraphicEl(oldDataIndex);
  41627. var points = createLinePoints(data, newDataIndex, dimensions, coordSys);
  41628. data.setItemGraphicEl(newDataIndex, line);
  41629. var animationModel = (payload && payload.animation === false) ? null : seriesModel;
  41630. graphic.updateProps(line, {shape: {points: points}}, animationModel, newDataIndex);
  41631. }
  41632. function remove(oldDataIndex) {
  41633. var line = oldData.getItemGraphicEl(oldDataIndex);
  41634. dataGroup.remove(line);
  41635. }
  41636. },
  41637. /**
  41638. * @private
  41639. */
  41640. // _renderForProgressive: function (seriesModel) {
  41641. // var dataGroup = this._dataGroup;
  41642. // var data = seriesModel.getData();
  41643. // var oldData = this._data;
  41644. // var coordSys = seriesModel.coordinateSystem;
  41645. // var dimensions = coordSys.dimensions;
  41646. // var option = seriesModel.option;
  41647. // var progressive = option.progressive;
  41648. // var smooth = option.smooth ? SMOOTH : null;
  41649. // // In progressive animation is disabled, so use simple data diff,
  41650. // // which effects performance less.
  41651. // // (Typically performance for data with length 7000+ like:
  41652. // // simpleDiff: 60ms, addEl: 184ms,
  41653. // // in RMBP 2.4GHz intel i7, OSX 10.9 chrome 50.0.2661.102 (64-bit))
  41654. // if (simpleDiff(oldData, data, dimensions)) {
  41655. // dataGroup.removeAll();
  41656. // data.each(function (dataIndex) {
  41657. // addEl(data, dataGroup, dataIndex, dimensions, coordSys);
  41658. // });
  41659. // }
  41660. // updateElCommon(data, progressive, smooth);
  41661. // // Consider switch between progressive and not.
  41662. // data.__plProgressive = true;
  41663. // this._data = data;
  41664. // },
  41665. /**
  41666. * @override
  41667. */
  41668. remove: function () {
  41669. this._dataGroup && this._dataGroup.removeAll();
  41670. this._data = null;
  41671. }
  41672. });
  41673. function createGridClipShape(coordSys, seriesModel, cb) {
  41674. var parallelModel = coordSys.model;
  41675. var rect = coordSys.getRect();
  41676. var rectEl = new graphic.Rect({
  41677. shape: {
  41678. x: rect.x,
  41679. y: rect.y,
  41680. width: rect.width,
  41681. height: rect.height
  41682. }
  41683. });
  41684. var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height';
  41685. rectEl.setShape(dim, 0);
  41686. graphic.initProps(rectEl, {
  41687. shape: {
  41688. width: rect.width,
  41689. height: rect.height
  41690. }
  41691. }, seriesModel, cb);
  41692. return rectEl;
  41693. }
  41694. function createLinePoints(data, dataIndex, dimensions, coordSys) {
  41695. var points = [];
  41696. for (var i = 0; i < dimensions.length; i++) {
  41697. var dimName = dimensions[i];
  41698. var value = data.get(dimName, dataIndex);
  41699. if (!isEmptyValue(value, coordSys.getAxis(dimName).type)) {
  41700. points.push(coordSys.dataToPoint(value, dimName));
  41701. }
  41702. }
  41703. return points;
  41704. }
  41705. function addEl(data, dataGroup, dataIndex, dimensions, coordSys) {
  41706. var points = createLinePoints(data, dataIndex, dimensions, coordSys);
  41707. var line = new graphic.Polyline({
  41708. shape: {points: points},
  41709. silent: true,
  41710. z2: 10
  41711. });
  41712. dataGroup.add(line);
  41713. data.setItemGraphicEl(dataIndex, line);
  41714. }
  41715. function updateElCommon(data, smooth) {
  41716. var seriesStyleModel = data.hostModel.getModel('lineStyle.normal');
  41717. var lineStyle = seriesStyleModel.getLineStyle();
  41718. data.eachItemGraphicEl(function (line, dataIndex) {
  41719. if (data.hasItemOption) {
  41720. var itemModel = data.getItemModel(dataIndex);
  41721. var lineStyleModel = itemModel.getModel('lineStyle.normal', seriesStyleModel);
  41722. lineStyle = lineStyleModel.getLineStyle(['color', 'stroke']);
  41723. }
  41724. line.useStyle(zrUtil.extend(lineStyle, {
  41725. fill: null,
  41726. // lineStyle.color have been set to itemVisual in module:echarts/visual/seriesColor.
  41727. stroke: data.getItemVisual(dataIndex, 'color'),
  41728. // lineStyle.opacity have been set to itemVisual in parallelVisual.
  41729. opacity: data.getItemVisual(dataIndex, 'opacity')
  41730. }));
  41731. line.shape.smooth = smooth;
  41732. });
  41733. }
  41734. // function simpleDiff(oldData, newData, dimensions) {
  41735. // var oldLen;
  41736. // if (!oldData
  41737. // || !oldData.__plProgressive
  41738. // || (oldLen = oldData.count()) !== newData.count()
  41739. // ) {
  41740. // return true;
  41741. // }
  41742. // var dimLen = dimensions.length;
  41743. // for (var i = 0; i < oldLen; i++) {
  41744. // for (var j = 0; j < dimLen; j++) {
  41745. // if (oldData.get(dimensions[j], i) !== newData.get(dimensions[j], i)) {
  41746. // return true;
  41747. // }
  41748. // }
  41749. // }
  41750. // return false;
  41751. // }
  41752. // FIXME
  41753. // 公用方法?
  41754. function isEmptyValue(val, axisType) {
  41755. return axisType === 'category'
  41756. ? val == null
  41757. : (val == null || isNaN(val)); // axisType === 'value'
  41758. }
  41759. module.exports = ParallelView;
  41760. /***/ }),
  41761. /* 253 */
  41762. /***/ (function(module, exports) {
  41763. var opacityAccessPath = ['lineStyle', 'normal', 'opacity'];
  41764. module.exports = function (ecModel) {
  41765. ecModel.eachSeriesByType('parallel', function (seriesModel) {
  41766. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  41767. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  41768. var globalColors = ecModel.get('color');
  41769. var color = lineStyleModel.get('color')
  41770. || itemStyleModel.get('color')
  41771. || globalColors[seriesModel.seriesIndex % globalColors.length];
  41772. var inactiveOpacity = seriesModel.get('inactiveOpacity');
  41773. var activeOpacity = seriesModel.get('activeOpacity');
  41774. var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle();
  41775. var coordSys = seriesModel.coordinateSystem;
  41776. var data = seriesModel.getData();
  41777. var opacityMap = {
  41778. normal: lineStyle.opacity,
  41779. active: activeOpacity,
  41780. inactive: inactiveOpacity
  41781. };
  41782. coordSys.eachActiveState(data, function (activeState, dataIndex) {
  41783. var itemModel = data.getItemModel(dataIndex);
  41784. var opacity = opacityMap[activeState];
  41785. if (activeState === 'normal') {
  41786. var itemOpacity = itemModel.get(opacityAccessPath, true);
  41787. itemOpacity != null && (opacity = itemOpacity);
  41788. }
  41789. data.setItemVisual(dataIndex, 'opacity', opacity);
  41790. });
  41791. data.setVisual('color', color);
  41792. });
  41793. };
  41794. /***/ }),
  41795. /* 254 */
  41796. /***/ (function(module, exports, __webpack_require__) {
  41797. var echarts = __webpack_require__(1);
  41798. __webpack_require__(255);
  41799. __webpack_require__(256);
  41800. echarts.registerLayout(__webpack_require__(257));
  41801. echarts.registerVisual(__webpack_require__(259));
  41802. /***/ }),
  41803. /* 255 */
  41804. /***/ (function(module, exports, __webpack_require__) {
  41805. /**
  41806. * @file Get initial data and define sankey view's series model
  41807. * @author Deqing Li(annong035@gmail.com)
  41808. */
  41809. var SeriesModel = __webpack_require__(83);
  41810. var createGraphFromNodeEdge = __webpack_require__(210);
  41811. var encodeHTML = __webpack_require__(6).encodeHTML;
  41812. var SankeySeries = SeriesModel.extend({
  41813. type: 'series.sankey',
  41814. layoutInfo: null,
  41815. /**
  41816. * Init a graph data structure from data in option series
  41817. *
  41818. * @param {Object} option the object used to config echarts view
  41819. * @return {module:echarts/data/List} storage initial data
  41820. */
  41821. getInitialData: function (option) {
  41822. var links = option.edges || option.links;
  41823. var nodes = option.data || option.nodes;
  41824. if (nodes && links) {
  41825. var graph = createGraphFromNodeEdge(nodes, links, this, true);
  41826. return graph.data;
  41827. }
  41828. },
  41829. /**
  41830. * Return the graphic data structure
  41831. *
  41832. * @return {module:echarts/data/Graph} graphic data structure
  41833. */
  41834. getGraph: function () {
  41835. return this.getData().graph;
  41836. },
  41837. /**
  41838. * Get edge data of graphic data structure
  41839. *
  41840. * @return {module:echarts/data/List} data structure of list
  41841. */
  41842. getEdgeData: function () {
  41843. return this.getGraph().edgeData;
  41844. },
  41845. /**
  41846. * @override
  41847. */
  41848. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  41849. // dataType === 'node' or empty do not show tooltip by default
  41850. if (dataType === 'edge') {
  41851. var params = this.getDataParams(dataIndex, dataType);
  41852. var rawDataOpt = params.data;
  41853. var html = rawDataOpt.source + ' -- ' + rawDataOpt.target;
  41854. if (params.value) {
  41855. html += ' : ' + params.value;
  41856. }
  41857. return encodeHTML(html);
  41858. }
  41859. return SankeySeries.superCall(this, 'formatTooltip', dataIndex, multipleSeries);
  41860. },
  41861. defaultOption: {
  41862. zlevel: 0,
  41863. z: 2,
  41864. coordinateSystem: 'view',
  41865. layout: null,
  41866. // the position of the whole view
  41867. left: '5%',
  41868. top: '5%',
  41869. right: '20%',
  41870. bottom: '5%',
  41871. // the dx of the node
  41872. nodeWidth: 20,
  41873. // the vertical distance between two nodes
  41874. nodeGap: 8,
  41875. // the number of iterations to change the position of the node
  41876. layoutIterations: 32,
  41877. label: {
  41878. normal: {
  41879. show: true,
  41880. position: 'right',
  41881. color: '#000',
  41882. fontSize: 12
  41883. },
  41884. emphasis: {
  41885. show: true
  41886. }
  41887. },
  41888. itemStyle: {
  41889. normal: {
  41890. borderWidth: 1,
  41891. borderColor: '#333'
  41892. }
  41893. },
  41894. lineStyle: {
  41895. normal: {
  41896. color: '#314656',
  41897. opacity: 0.2,
  41898. curveness: 0.5
  41899. },
  41900. emphasis: {
  41901. opacity: 0.6
  41902. }
  41903. },
  41904. animationEasing: 'linear',
  41905. animationDuration: 1000
  41906. }
  41907. });
  41908. module.exports = SankeySeries;
  41909. /***/ }),
  41910. /* 256 */
  41911. /***/ (function(module, exports, __webpack_require__) {
  41912. /**
  41913. * @file The file used to draw sankey view
  41914. * @author Deqing Li(annong035@gmail.com)
  41915. */
  41916. var graphic = __webpack_require__(20);
  41917. var SankeyShape = graphic.extendShape({
  41918. shape: {
  41919. x1: 0, y1: 0,
  41920. x2: 0, y2: 0,
  41921. cpx1: 0, cpy1: 0,
  41922. cpx2: 0, cpy2: 0,
  41923. extent: 0
  41924. },
  41925. buildPath: function (ctx, shape) {
  41926. var halfExtent = shape.extent / 2;
  41927. ctx.moveTo(shape.x1, shape.y1 - halfExtent);
  41928. ctx.bezierCurveTo(
  41929. shape.cpx1, shape.cpy1 - halfExtent,
  41930. shape.cpx2, shape.cpy2 - halfExtent,
  41931. shape.x2, shape.y2 - halfExtent
  41932. );
  41933. ctx.lineTo(shape.x2, shape.y2 + halfExtent);
  41934. ctx.bezierCurveTo(
  41935. shape.cpx2, shape.cpy2 + halfExtent,
  41936. shape.cpx1, shape.cpy1 + halfExtent,
  41937. shape.x1, shape.y1 + halfExtent
  41938. );
  41939. ctx.closePath();
  41940. }
  41941. });
  41942. module.exports = __webpack_require__(1).extendChartView({
  41943. type: 'sankey',
  41944. /**
  41945. * @private
  41946. * @type {module:echarts/chart/sankey/SankeySeries}
  41947. */
  41948. _model: null,
  41949. render: function (seriesModel, ecModel, api) {
  41950. var graph = seriesModel.getGraph();
  41951. var group = this.group;
  41952. var layoutInfo = seriesModel.layoutInfo;
  41953. var nodeData = seriesModel.getData();
  41954. var edgeData = seriesModel.getData('edge');
  41955. this._model = seriesModel;
  41956. group.removeAll();
  41957. group.position = [layoutInfo.x, layoutInfo.y];
  41958. // generate a bezire Curve for each edge
  41959. graph.eachEdge(function (edge) {
  41960. var curve = new SankeyShape();
  41961. curve.dataIndex = edge.dataIndex;
  41962. curve.seriesIndex = seriesModel.seriesIndex;
  41963. curve.dataType = 'edge';
  41964. var lineStyleModel = edge.getModel('lineStyle.normal');
  41965. var curvature = lineStyleModel.get('curveness');
  41966. var n1Layout = edge.node1.getLayout();
  41967. var n2Layout = edge.node2.getLayout();
  41968. var edgeLayout = edge.getLayout();
  41969. curve.shape.extent = Math.max(1, edgeLayout.dy);
  41970. var x1 = n1Layout.x + n1Layout.dx;
  41971. var y1 = n1Layout.y + edgeLayout.sy + edgeLayout.dy / 2;
  41972. var x2 = n2Layout.x;
  41973. var y2 = n2Layout.y + edgeLayout.ty + edgeLayout.dy / 2;
  41974. var cpx1 = x1 * (1 - curvature) + x2 * curvature;
  41975. var cpy1 = y1;
  41976. var cpx2 = x1 * curvature + x2 * (1 - curvature);
  41977. var cpy2 = y2;
  41978. curve.setShape({
  41979. x1: x1,
  41980. y1: y1,
  41981. x2: x2,
  41982. y2: y2,
  41983. cpx1: cpx1,
  41984. cpy1: cpy1,
  41985. cpx2: cpx2,
  41986. cpy2: cpy2
  41987. });
  41988. curve.setStyle(lineStyleModel.getItemStyle());
  41989. // Special color, use source node color or target node color
  41990. switch (curve.style.fill) {
  41991. case 'source':
  41992. curve.style.fill = edge.node1.getVisual('color');
  41993. break;
  41994. case 'target':
  41995. curve.style.fill = edge.node2.getVisual('color');
  41996. break;
  41997. }
  41998. graphic.setHoverStyle(curve, edge.getModel('lineStyle.emphasis').getItemStyle());
  41999. group.add(curve);
  42000. edgeData.setItemGraphicEl(edge.dataIndex, curve);
  42001. });
  42002. // generate a rect for each node
  42003. graph.eachNode(function (node) {
  42004. var layout = node.getLayout();
  42005. var itemModel = node.getModel();
  42006. var labelModel = itemModel.getModel('label.normal');
  42007. var labelHoverModel = itemModel.getModel('label.emphasis');
  42008. var rect = new graphic.Rect({
  42009. shape: {
  42010. x: layout.x,
  42011. y: layout.y,
  42012. width: node.getLayout().dx,
  42013. height: node.getLayout().dy
  42014. },
  42015. style: itemModel.getModel('itemStyle.normal').getItemStyle()
  42016. });
  42017. var hoverStyle = node.getModel('itemStyle.emphasis').getItemStyle();
  42018. graphic.setLabelStyle(
  42019. rect.style, hoverStyle, labelModel, labelHoverModel,
  42020. {
  42021. labelFetcher: seriesModel,
  42022. labelDataIndex: node.dataIndex,
  42023. defaultText: node.id,
  42024. isRectText: true
  42025. }
  42026. );
  42027. rect.setStyle('fill', node.getVisual('color'));
  42028. graphic.setHoverStyle(rect, hoverStyle);
  42029. group.add(rect);
  42030. nodeData.setItemGraphicEl(node.dataIndex, rect);
  42031. rect.dataType = 'node';
  42032. });
  42033. if (!this._data && seriesModel.get('animation')) {
  42034. group.setClipPath(createGridClipShape(group.getBoundingRect(), seriesModel, function () {
  42035. group.removeClipPath();
  42036. }));
  42037. }
  42038. this._data = seriesModel.getData();
  42039. },
  42040. dispose: function () {}
  42041. });
  42042. // add animation to the view
  42043. function createGridClipShape(rect, seriesModel, cb) {
  42044. var rectEl = new graphic.Rect({
  42045. shape: {
  42046. x: rect.x - 10,
  42047. y: rect.y - 10,
  42048. width: 0,
  42049. height: rect.height + 20
  42050. }
  42051. });
  42052. graphic.initProps(rectEl, {
  42053. shape: {
  42054. width: rect.width + 20,
  42055. height: rect.height + 20
  42056. }
  42057. }, seriesModel, cb);
  42058. return rectEl;
  42059. }
  42060. /***/ }),
  42061. /* 257 */
  42062. /***/ (function(module, exports, __webpack_require__) {
  42063. /**
  42064. * @file The layout algorithm of sankey view
  42065. * @author Deqing Li(annong035@gmail.com)
  42066. */
  42067. var layout = __webpack_require__(74);
  42068. var nest = __webpack_require__(258);
  42069. var zrUtil = __webpack_require__(4);
  42070. module.exports = function (ecModel, api, payload) {
  42071. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  42072. var nodeWidth = seriesModel.get('nodeWidth');
  42073. var nodeGap = seriesModel.get('nodeGap');
  42074. var layoutInfo = getViewRect(seriesModel, api);
  42075. seriesModel.layoutInfo = layoutInfo;
  42076. var width = layoutInfo.width;
  42077. var height = layoutInfo.height;
  42078. var graph = seriesModel.getGraph();
  42079. var nodes = graph.nodes;
  42080. var edges = graph.edges;
  42081. computeNodeValues(nodes);
  42082. var filteredNodes = zrUtil.filter(nodes, function (node) {
  42083. return node.getLayout().value === 0;
  42084. });
  42085. var iterations = filteredNodes.length !== 0
  42086. ? 0 : seriesModel.get('layoutIterations');
  42087. layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations);
  42088. });
  42089. };
  42090. /**
  42091. * Get the layout position of the whole view
  42092. *
  42093. * @param {module:echarts/model/Series} seriesModel the model object of sankey series
  42094. * @param {module:echarts/ExtensionAPI} api provide the API list that the developer can call
  42095. * @return {module:zrender/core/BoundingRect} size of rect to draw the sankey view
  42096. */
  42097. function getViewRect(seriesModel, api) {
  42098. return layout.getLayoutRect(
  42099. seriesModel.getBoxLayoutParams(), {
  42100. width: api.getWidth(),
  42101. height: api.getHeight()
  42102. }
  42103. );
  42104. }
  42105. function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations) {
  42106. computeNodeBreadths(nodes, nodeWidth, width);
  42107. computeNodeDepths(nodes, edges, height, nodeGap, iterations);
  42108. computeEdgeDepths(nodes);
  42109. }
  42110. /**
  42111. * Compute the value of each node by summing the associated edge's value
  42112. *
  42113. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  42114. */
  42115. function computeNodeValues(nodes) {
  42116. zrUtil.each(nodes, function (node) {
  42117. var value1 = sum(node.outEdges, getEdgeValue);
  42118. var value2 = sum(node.inEdges, getEdgeValue);
  42119. var value = Math.max(value1, value2);
  42120. node.setLayout({value: value}, true);
  42121. });
  42122. }
  42123. /**
  42124. * Compute the x-position for each node
  42125. *
  42126. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  42127. * @param {number} nodeWidth the dx of the node
  42128. * @param {number} width the whole width of the area to draw the view
  42129. */
  42130. function computeNodeBreadths(nodes, nodeWidth, width) {
  42131. var remainNodes = nodes;
  42132. var nextNode = null;
  42133. var x = 0;
  42134. var kx = 0;
  42135. while (remainNodes.length) {
  42136. nextNode = [];
  42137. for (var i = 0, len = remainNodes.length; i < len; i++) {
  42138. var node = remainNodes[i];
  42139. node.setLayout({x: x}, true);
  42140. node.setLayout({dx: nodeWidth}, true);
  42141. for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) {
  42142. nextNode.push(node.outEdges[j].node2);
  42143. }
  42144. }
  42145. remainNodes = nextNode;
  42146. ++x;
  42147. }
  42148. moveSinksRight(nodes, x);
  42149. kx = (width - nodeWidth) / (x - 1);
  42150. scaleNodeBreadths(nodes, kx);
  42151. }
  42152. /**
  42153. * All the node without outEgdes are assigned maximum x-position and
  42154. * be aligned in the last column.
  42155. *
  42156. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  42157. * @param {number} x value (x-1) use to assign to node without outEdges
  42158. * as x-position
  42159. */
  42160. function moveSinksRight(nodes, x) {
  42161. zrUtil.each(nodes, function (node) {
  42162. if (!node.outEdges.length) {
  42163. node.setLayout({x: x - 1}, true);
  42164. }
  42165. });
  42166. }
  42167. /**
  42168. * Scale node x-position to the width
  42169. *
  42170. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  42171. * @param {number} kx multiple used to scale nodes
  42172. */
  42173. function scaleNodeBreadths(nodes, kx) {
  42174. zrUtil.each(nodes, function (node) {
  42175. var nodeX = node.getLayout().x * kx;
  42176. node.setLayout({x: nodeX}, true);
  42177. });
  42178. }
  42179. /**
  42180. * Using Gauss-Seidel iterations method to compute the node depth(y-position)
  42181. *
  42182. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  42183. * @param {module:echarts/data/Graph~Edge} edges edge of sankey view
  42184. * @param {number} height the whole height of the area to draw the view
  42185. * @param {number} nodeGap the vertical distance between two nodes
  42186. * in the same column.
  42187. * @param {number} iterations the number of iterations for the algorithm
  42188. */
  42189. function computeNodeDepths(nodes, edges, height, nodeGap, iterations) {
  42190. var nodesByBreadth = nest()
  42191. .key(function (d) {
  42192. return d.getLayout().x;
  42193. })
  42194. .sortKeys(ascending)
  42195. .entries(nodes)
  42196. .map(function (d) {
  42197. return d.values;
  42198. });
  42199. initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap);
  42200. resolveCollisions(nodesByBreadth, nodeGap, height);
  42201. for (var alpha = 1; iterations > 0; iterations--) {
  42202. // 0.99 is a experience parameter, ensure that each iterations of
  42203. // changes as small as possible.
  42204. alpha *= 0.99;
  42205. relaxRightToLeft(nodesByBreadth, alpha);
  42206. resolveCollisions(nodesByBreadth, nodeGap, height);
  42207. relaxLeftToRight(nodesByBreadth, alpha);
  42208. resolveCollisions(nodesByBreadth, nodeGap, height);
  42209. }
  42210. }
  42211. /**
  42212. * Compute the original y-position for each node
  42213. *
  42214. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  42215. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  42216. * group by the array of all sankey nodes based on the nodes x-position.
  42217. * @param {module:echarts/data/Graph~Edge} edges edge of sankey view
  42218. * @param {number} height the whole height of the area to draw the view
  42219. * @param {number} nodeGap the vertical distance between two nodes
  42220. */
  42221. function initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap) {
  42222. var kyArray = [];
  42223. zrUtil.each(nodesByBreadth, function (nodes) {
  42224. var n = nodes.length;
  42225. var sum = 0;
  42226. zrUtil.each(nodes, function (node) {
  42227. sum += node.getLayout().value;
  42228. });
  42229. var ky = (height - (n - 1) * nodeGap) / sum;
  42230. kyArray.push(ky);
  42231. });
  42232. kyArray.sort(function (a, b) {
  42233. return a - b;
  42234. });
  42235. var ky0 = kyArray[0];
  42236. zrUtil.each(nodesByBreadth, function (nodes) {
  42237. zrUtil.each(nodes, function (node, i) {
  42238. node.setLayout({y: i}, true);
  42239. var nodeDy = node.getLayout().value * ky0;
  42240. node.setLayout({dy: nodeDy}, true);
  42241. });
  42242. });
  42243. zrUtil.each(edges, function (edge) {
  42244. var edgeDy = +edge.getValue() * ky0;
  42245. edge.setLayout({dy: edgeDy}, true);
  42246. });
  42247. }
  42248. /**
  42249. * Resolve the collision of initialized depth (y-position)
  42250. *
  42251. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  42252. * group by the array of all sankey nodes based on the nodes x-position.
  42253. * @param {number} nodeGap the vertical distance between two nodes
  42254. * @param {number} height the whole height of the area to draw the view
  42255. */
  42256. function resolveCollisions(nodesByBreadth, nodeGap, height) {
  42257. zrUtil.each(nodesByBreadth, function (nodes) {
  42258. var node;
  42259. var dy;
  42260. var y0 = 0;
  42261. var n = nodes.length;
  42262. var i;
  42263. nodes.sort(ascendingDepth);
  42264. for (i = 0; i < n; i++) {
  42265. node = nodes[i];
  42266. dy = y0 - node.getLayout().y;
  42267. if (dy > 0) {
  42268. var nodeY = node.getLayout().y + dy;
  42269. node.setLayout({y: nodeY}, true);
  42270. }
  42271. y0 = node.getLayout().y + node.getLayout().dy + nodeGap;
  42272. }
  42273. // if the bottommost node goes outside the bounds, push it back up
  42274. dy = y0 - nodeGap - height;
  42275. if (dy > 0) {
  42276. var nodeY = node.getLayout().y - dy;
  42277. node.setLayout({y: nodeY}, true);
  42278. y0 = node.getLayout().y;
  42279. for (i = n - 2; i >= 0; --i) {
  42280. node = nodes[i];
  42281. dy = node.getLayout().y + node.getLayout().dy + nodeGap - y0;
  42282. if (dy > 0) {
  42283. nodeY = node.getLayout().y - dy;
  42284. node.setLayout({y: nodeY}, true);
  42285. }
  42286. y0 = node.getLayout().y;
  42287. }
  42288. }
  42289. });
  42290. }
  42291. /**
  42292. * Change the y-position of the nodes, except most the right side nodes
  42293. *
  42294. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  42295. * group by the array of all sankey nodes based on the node x-position.
  42296. * @param {number} alpha parameter used to adjust the nodes y-position
  42297. */
  42298. function relaxRightToLeft(nodesByBreadth, alpha) {
  42299. zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) {
  42300. zrUtil.each(nodes, function (node) {
  42301. if (node.outEdges.length) {
  42302. var y = sum(node.outEdges, weightedTarget) / sum(node.outEdges, getEdgeValue);
  42303. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  42304. node.setLayout({y: nodeY}, true);
  42305. }
  42306. });
  42307. });
  42308. }
  42309. function weightedTarget(edge) {
  42310. return center(edge.node2) * edge.getValue();
  42311. }
  42312. /**
  42313. * Change the y-position of the nodes, except most the left side nodes
  42314. *
  42315. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  42316. * group by the array of all sankey nodes based on the node x-position.
  42317. * @param {number} alpha parameter used to adjust the nodes y-position
  42318. */
  42319. function relaxLeftToRight(nodesByBreadth, alpha) {
  42320. zrUtil.each(nodesByBreadth, function (nodes) {
  42321. zrUtil.each(nodes, function (node) {
  42322. if (node.inEdges.length) {
  42323. var y = sum(node.inEdges, weightedSource) / sum(node.inEdges, getEdgeValue);
  42324. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  42325. node.setLayout({y: nodeY}, true);
  42326. }
  42327. });
  42328. });
  42329. }
  42330. function weightedSource(edge) {
  42331. return center(edge.node1) * edge.getValue();
  42332. }
  42333. /**
  42334. * Compute the depth(y-position) of each edge
  42335. *
  42336. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  42337. */
  42338. function computeEdgeDepths(nodes) {
  42339. zrUtil.each(nodes, function (node) {
  42340. node.outEdges.sort(ascendingTargetDepth);
  42341. node.inEdges.sort(ascendingSourceDepth);
  42342. });
  42343. zrUtil.each(nodes, function (node) {
  42344. var sy = 0;
  42345. var ty = 0;
  42346. zrUtil.each(node.outEdges, function (edge) {
  42347. edge.setLayout({sy: sy}, true);
  42348. sy += edge.getLayout().dy;
  42349. });
  42350. zrUtil.each(node.inEdges, function (edge) {
  42351. edge.setLayout({ty: ty}, true);
  42352. ty += edge.getLayout().dy;
  42353. });
  42354. });
  42355. }
  42356. function ascendingTargetDepth(a, b) {
  42357. return a.node2.getLayout().y - b.node2.getLayout().y;
  42358. }
  42359. function ascendingSourceDepth(a, b) {
  42360. return a.node1.getLayout().y - b.node1.getLayout().y;
  42361. }
  42362. function sum(array, f) {
  42363. var sum = 0;
  42364. var len = array.length;
  42365. var i = -1;
  42366. while (++i < len) {
  42367. var value = +f.call(array, array[i], i);
  42368. if (!isNaN(value)) {
  42369. sum += value;
  42370. }
  42371. }
  42372. return sum;
  42373. }
  42374. function center(node) {
  42375. return node.getLayout().y + node.getLayout().dy / 2;
  42376. }
  42377. function ascendingDepth(a, b) {
  42378. return a.getLayout().y - b.getLayout().y;
  42379. }
  42380. function ascending(a, b) {
  42381. return a < b ? -1 : a > b ? 1 : a === b ? 0 : NaN;
  42382. }
  42383. function getEdgeValue(edge) {
  42384. return edge.getValue();
  42385. }
  42386. /***/ }),
  42387. /* 258 */
  42388. /***/ (function(module, exports, __webpack_require__) {
  42389. var zrUtil = __webpack_require__(4);
  42390. /**
  42391. * nest helper used to group by the array.
  42392. * can specified the keys and sort the keys.
  42393. */
  42394. function nest() {
  42395. var keysFunction = [];
  42396. var sortKeysFunction = [];
  42397. /**
  42398. * map an Array into the mapObject.
  42399. * @param {Array} array
  42400. * @param {number} depth
  42401. */
  42402. function map(array, depth) {
  42403. if (depth >= keysFunction.length) {
  42404. return array;
  42405. }
  42406. var i = -1;
  42407. var n = array.length;
  42408. var keyFunction = keysFunction[depth++];
  42409. var mapObject = {};
  42410. var valuesByKey = {};
  42411. while (++i < n) {
  42412. var keyValue = keyFunction(array[i]);
  42413. var values = valuesByKey[keyValue];
  42414. if (values) {
  42415. values.push(array[i]);
  42416. }
  42417. else {
  42418. valuesByKey[keyValue] = [array[i]];
  42419. }
  42420. }
  42421. zrUtil.each(valuesByKey, function (value, key) {
  42422. mapObject[key] = map(value, depth);
  42423. });
  42424. return mapObject;
  42425. }
  42426. /**
  42427. * transform the Map Object to multidimensional Array
  42428. * @param {Object} map
  42429. * @param {number} depth
  42430. */
  42431. function entriesMap(mapObject, depth) {
  42432. if (depth >= keysFunction.length) {
  42433. return mapObject;
  42434. }
  42435. var array = [];
  42436. var sortKeyFunction = sortKeysFunction[depth++];
  42437. zrUtil.each(mapObject, function (value, key) {
  42438. array.push({
  42439. key: key, values: entriesMap(value, depth)
  42440. });
  42441. });
  42442. if (sortKeyFunction) {
  42443. return array.sort(function (a, b) {
  42444. return sortKeyFunction(a.key, b.key);
  42445. });
  42446. }
  42447. else {
  42448. return array;
  42449. }
  42450. }
  42451. return {
  42452. /**
  42453. * specified the key to groupby the arrays.
  42454. * users can specified one more keys.
  42455. * @param {Function} d
  42456. */
  42457. key: function (d) {
  42458. keysFunction.push(d);
  42459. return this;
  42460. },
  42461. /**
  42462. * specified the comparator to sort the keys
  42463. * @param {Function} order
  42464. */
  42465. sortKeys: function (order) {
  42466. sortKeysFunction[keysFunction.length - 1] = order;
  42467. return this;
  42468. },
  42469. /**
  42470. * the array to be grouped by.
  42471. * @param {Array} array
  42472. */
  42473. entries: function (array) {
  42474. return entriesMap(map(array, 0), 0);
  42475. }
  42476. };
  42477. }
  42478. module.exports = nest;
  42479. /***/ }),
  42480. /* 259 */
  42481. /***/ (function(module, exports, __webpack_require__) {
  42482. /**
  42483. * @file Visual encoding for sankey view
  42484. * @author Deqing Li(annong035@gmail.com)
  42485. */
  42486. var VisualMapping = __webpack_require__(206);
  42487. var zrUtil = __webpack_require__(4);
  42488. module.exports = function (ecModel, payload) {
  42489. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  42490. var graph = seriesModel.getGraph();
  42491. var nodes = graph.nodes;
  42492. nodes.sort(function (a, b) {
  42493. return a.getLayout().value - b.getLayout().value;
  42494. });
  42495. var minValue = nodes[0].getLayout().value;
  42496. var maxValue = nodes[nodes.length - 1].getLayout().value;
  42497. zrUtil.each(nodes, function (node) {
  42498. var mapping = new VisualMapping({
  42499. type: 'color',
  42500. mappingMethod: 'linear',
  42501. dataExtent: [minValue, maxValue],
  42502. visual: seriesModel.get('color')
  42503. });
  42504. var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value);
  42505. node.setVisual('color', mapValueToColor);
  42506. // If set itemStyle.normal.color
  42507. var itemModel = node.getModel();
  42508. var customColor = itemModel.get('itemStyle.normal.color');
  42509. if (customColor != null) {
  42510. node.setVisual('color', customColor);
  42511. }
  42512. });
  42513. });
  42514. };
  42515. /***/ }),
  42516. /* 260 */
  42517. /***/ (function(module, exports, __webpack_require__) {
  42518. var echarts = __webpack_require__(1);
  42519. __webpack_require__(261);
  42520. __webpack_require__(264);
  42521. echarts.registerVisual(__webpack_require__(265));
  42522. echarts.registerLayout(__webpack_require__(266));
  42523. /***/ }),
  42524. /* 261 */
  42525. /***/ (function(module, exports, __webpack_require__) {
  42526. 'use strict';
  42527. var zrUtil = __webpack_require__(4);
  42528. var SeriesModel = __webpack_require__(83);
  42529. var whiskerBoxCommon = __webpack_require__(262);
  42530. var BoxplotSeries = SeriesModel.extend({
  42531. type: 'series.boxplot',
  42532. dependencies: ['xAxis', 'yAxis', 'grid'],
  42533. // TODO
  42534. // box width represents group size, so dimension should have 'size'.
  42535. /**
  42536. * @see <https://en.wikipedia.org/wiki/Box_plot>
  42537. * The meanings of 'min' and 'max' depend on user,
  42538. * and echarts do not need to know it.
  42539. * @readOnly
  42540. */
  42541. defaultValueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'],
  42542. /**
  42543. * @type {Array.<string>}
  42544. * @readOnly
  42545. */
  42546. dimensions: null,
  42547. /**
  42548. * @override
  42549. */
  42550. defaultOption: {
  42551. zlevel: 0, // 一级层叠
  42552. z: 2, // 二级层叠
  42553. coordinateSystem: 'cartesian2d',
  42554. legendHoverLink: true,
  42555. hoverAnimation: true,
  42556. // xAxisIndex: 0,
  42557. // yAxisIndex: 0,
  42558. layout: null, // 'horizontal' or 'vertical'
  42559. boxWidth: [7, 50], // [min, max] can be percent of band width.
  42560. itemStyle: {
  42561. normal: {
  42562. color: '#fff',
  42563. borderWidth: 1
  42564. },
  42565. emphasis: {
  42566. borderWidth: 2,
  42567. shadowBlur: 5,
  42568. shadowOffsetX: 2,
  42569. shadowOffsetY: 2,
  42570. shadowColor: 'rgba(0,0,0,0.4)'
  42571. }
  42572. },
  42573. animationEasing: 'elasticOut',
  42574. animationDuration: 800
  42575. }
  42576. });
  42577. zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true);
  42578. module.exports = BoxplotSeries;
  42579. /***/ }),
  42580. /* 262 */
  42581. /***/ (function(module, exports, __webpack_require__) {
  42582. 'use strict';
  42583. var List = __webpack_require__(101);
  42584. var completeDimensions = __webpack_require__(113);
  42585. var WhiskerBoxDraw = __webpack_require__(263);
  42586. var zrUtil = __webpack_require__(4);
  42587. var seriesModelMixin = {
  42588. /**
  42589. * @private
  42590. * @type {string}
  42591. */
  42592. _baseAxisDim: null,
  42593. /**
  42594. * @override
  42595. */
  42596. getInitialData: function (option, ecModel) {
  42597. // When both types of xAxis and yAxis are 'value', layout is
  42598. // needed to be specified by user. Otherwise, layout can be
  42599. // judged by which axis is category.
  42600. var categories;
  42601. var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
  42602. var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
  42603. var xAxisType = xAxisModel.get('type');
  42604. var yAxisType = yAxisModel.get('type');
  42605. var addOrdinal;
  42606. // FIXME
  42607. // 考虑时间轴
  42608. if (xAxisType === 'category') {
  42609. option.layout = 'horizontal';
  42610. categories = xAxisModel.getCategories();
  42611. addOrdinal = true;
  42612. }
  42613. else if (yAxisType === 'category') {
  42614. option.layout = 'vertical';
  42615. categories = yAxisModel.getCategories();
  42616. addOrdinal = true;
  42617. }
  42618. else {
  42619. option.layout = option.layout || 'horizontal';
  42620. }
  42621. var coordDims = ['x', 'y'];
  42622. var baseAxisDimIndex = option.layout === 'horizontal' ? 0 : 1;
  42623. var baseAxisDim = this._baseAxisDim = coordDims[baseAxisDimIndex];
  42624. var otherAxisDim = coordDims[1 - baseAxisDimIndex];
  42625. var data = option.data;
  42626. addOrdinal && zrUtil.each(data, function (item, index) {
  42627. if (item.value && zrUtil.isArray(item.value)) {
  42628. item.value.unshift(index);
  42629. } else {
  42630. zrUtil.isArray(item) && item.unshift(index);
  42631. }
  42632. });
  42633. var defaultValueDimensions = this.defaultValueDimensions;
  42634. var dimensions = [{
  42635. name: baseAxisDim,
  42636. otherDims: {
  42637. tooltip: false
  42638. },
  42639. dimsDef: ['base']
  42640. }, {
  42641. name: otherAxisDim,
  42642. dimsDef: defaultValueDimensions.slice()
  42643. }];
  42644. dimensions = completeDimensions(dimensions, data, {
  42645. encodeDef: this.get('encode'),
  42646. dimsDef: this.get('dimensions'),
  42647. // Consider empty data entry.
  42648. dimCount: defaultValueDimensions.length + 1
  42649. });
  42650. var list = new List(dimensions, this);
  42651. list.initData(data, categories ? categories.slice() : null);
  42652. return list;
  42653. },
  42654. /**
  42655. * If horizontal, base axis is x, otherwise y.
  42656. * @override
  42657. */
  42658. getBaseAxis: function () {
  42659. var dim = this._baseAxisDim;
  42660. return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
  42661. }
  42662. };
  42663. var viewMixin = {
  42664. init: function () {
  42665. /**
  42666. * Old data.
  42667. * @private
  42668. * @type {module:echarts/chart/helper/WhiskerBoxDraw}
  42669. */
  42670. var whiskerBoxDraw = this._whiskerBoxDraw = new WhiskerBoxDraw(
  42671. this.getStyleUpdater()
  42672. );
  42673. this.group.add(whiskerBoxDraw.group);
  42674. },
  42675. render: function (seriesModel, ecModel, api) {
  42676. this._whiskerBoxDraw.updateData(seriesModel.getData());
  42677. },
  42678. remove: function (ecModel) {
  42679. this._whiskerBoxDraw.remove();
  42680. }
  42681. };
  42682. module.exports = {
  42683. seriesModelMixin: seriesModelMixin,
  42684. viewMixin: viewMixin
  42685. };
  42686. /***/ }),
  42687. /* 263 */
  42688. /***/ (function(module, exports, __webpack_require__) {
  42689. /**
  42690. * @module echarts/chart/helper/Symbol
  42691. */
  42692. var zrUtil = __webpack_require__(4);
  42693. var graphic = __webpack_require__(20);
  42694. var Path = __webpack_require__(22);
  42695. var WhiskerPath = Path.extend({
  42696. type: 'whiskerInBox',
  42697. shape: {},
  42698. buildPath: function (ctx, shape) {
  42699. for (var i in shape) {
  42700. if (shape.hasOwnProperty(i) && i.indexOf('ends') === 0) {
  42701. var pts = shape[i];
  42702. ctx.moveTo(pts[0][0], pts[0][1]);
  42703. ctx.lineTo(pts[1][0], pts[1][1]);
  42704. }
  42705. }
  42706. }
  42707. });
  42708. /**
  42709. * @constructor
  42710. * @alias {module:echarts/chart/helper/WhiskerBox}
  42711. * @param {module:echarts/data/List} data
  42712. * @param {number} idx
  42713. * @param {Function} styleUpdater
  42714. * @param {boolean} isInit
  42715. * @extends {module:zrender/graphic/Group}
  42716. */
  42717. function WhiskerBox(data, idx, styleUpdater, isInit) {
  42718. graphic.Group.call(this);
  42719. /**
  42720. * @type {number}
  42721. * @readOnly
  42722. */
  42723. this.bodyIndex;
  42724. /**
  42725. * @type {number}
  42726. * @readOnly
  42727. */
  42728. this.whiskerIndex;
  42729. /**
  42730. * @type {Function}
  42731. */
  42732. this.styleUpdater = styleUpdater;
  42733. this._createContent(data, idx, isInit);
  42734. this.updateData(data, idx, isInit);
  42735. /**
  42736. * Last series model.
  42737. * @type {module:echarts/model/Series}
  42738. */
  42739. this._seriesModel;
  42740. }
  42741. var whiskerBoxProto = WhiskerBox.prototype;
  42742. whiskerBoxProto._createContent = function (data, idx, isInit) {
  42743. var itemLayout = data.getItemLayout(idx);
  42744. var constDim = itemLayout.chartLayout === 'horizontal' ? 1 : 0;
  42745. var count = 0;
  42746. // Whisker element.
  42747. this.add(new graphic.Polygon({
  42748. shape: {
  42749. points: isInit
  42750. ? transInit(itemLayout.bodyEnds, constDim, itemLayout)
  42751. : itemLayout.bodyEnds
  42752. },
  42753. style: {strokeNoScale: true},
  42754. z2: 100
  42755. }));
  42756. this.bodyIndex = count++;
  42757. // Box element.
  42758. var whiskerEnds = zrUtil.map(itemLayout.whiskerEnds, function (ends) {
  42759. return isInit ? transInit(ends, constDim, itemLayout) : ends;
  42760. });
  42761. this.add(new WhiskerPath({
  42762. shape: makeWhiskerEndsShape(whiskerEnds),
  42763. style: {strokeNoScale: true},
  42764. z2: 100
  42765. }));
  42766. this.whiskerIndex = count++;
  42767. };
  42768. function transInit(points, dim, itemLayout) {
  42769. return zrUtil.map(points, function (point) {
  42770. point = point.slice();
  42771. point[dim] = itemLayout.initBaseline;
  42772. return point;
  42773. });
  42774. }
  42775. function makeWhiskerEndsShape(whiskerEnds) {
  42776. // zr animation only support 2-dim array.
  42777. var shape = {};
  42778. zrUtil.each(whiskerEnds, function (ends, i) {
  42779. shape['ends' + i] = ends;
  42780. });
  42781. return shape;
  42782. }
  42783. /**
  42784. * Update symbol properties
  42785. * @param {module:echarts/data/List} data
  42786. * @param {number} idx
  42787. */
  42788. whiskerBoxProto.updateData = function (data, idx, isInit) {
  42789. var seriesModel = this._seriesModel = data.hostModel;
  42790. var itemLayout = data.getItemLayout(idx);
  42791. var updateMethod = graphic[isInit ? 'initProps' : 'updateProps'];
  42792. // this.childAt(this.bodyIndex).stopAnimation(true);
  42793. // this.childAt(this.whiskerIndex).stopAnimation(true);
  42794. updateMethod(
  42795. this.childAt(this.bodyIndex),
  42796. {shape: {points: itemLayout.bodyEnds}},
  42797. seriesModel, idx
  42798. );
  42799. updateMethod(
  42800. this.childAt(this.whiskerIndex),
  42801. {shape: makeWhiskerEndsShape(itemLayout.whiskerEnds)},
  42802. seriesModel, idx
  42803. );
  42804. this.styleUpdater.call(null, this, data, idx);
  42805. };
  42806. zrUtil.inherits(WhiskerBox, graphic.Group);
  42807. /**
  42808. * @constructor
  42809. * @alias module:echarts/chart/helper/WhiskerBoxDraw
  42810. */
  42811. function WhiskerBoxDraw(styleUpdater) {
  42812. this.group = new graphic.Group();
  42813. this.styleUpdater = styleUpdater;
  42814. }
  42815. var whiskerBoxDrawProto = WhiskerBoxDraw.prototype;
  42816. /**
  42817. * Update symbols draw by new data
  42818. * @param {module:echarts/data/List} data
  42819. */
  42820. whiskerBoxDrawProto.updateData = function (data) {
  42821. var group = this.group;
  42822. var oldData = this._data;
  42823. var styleUpdater = this.styleUpdater;
  42824. data.diff(oldData)
  42825. .add(function (newIdx) {
  42826. if (data.hasValue(newIdx)) {
  42827. var symbolEl = new WhiskerBox(data, newIdx, styleUpdater, true);
  42828. data.setItemGraphicEl(newIdx, symbolEl);
  42829. group.add(symbolEl);
  42830. }
  42831. })
  42832. .update(function (newIdx, oldIdx) {
  42833. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  42834. // Empty data
  42835. if (!data.hasValue(newIdx)) {
  42836. group.remove(symbolEl);
  42837. return;
  42838. }
  42839. if (!symbolEl) {
  42840. symbolEl = new WhiskerBox(data, newIdx, styleUpdater);
  42841. }
  42842. else {
  42843. symbolEl.updateData(data, newIdx);
  42844. }
  42845. // Add back
  42846. group.add(symbolEl);
  42847. data.setItemGraphicEl(newIdx, symbolEl);
  42848. })
  42849. .remove(function (oldIdx) {
  42850. var el = oldData.getItemGraphicEl(oldIdx);
  42851. el && group.remove(el);
  42852. })
  42853. .execute();
  42854. this._data = data;
  42855. };
  42856. /**
  42857. * Remove symbols.
  42858. * @param {module:echarts/data/List} data
  42859. */
  42860. whiskerBoxDrawProto.remove = function () {
  42861. var group = this.group;
  42862. var data = this._data;
  42863. this._data = null;
  42864. data && data.eachItemGraphicEl(function (el) {
  42865. el && group.remove(el);
  42866. });
  42867. };
  42868. module.exports = WhiskerBoxDraw;
  42869. /***/ }),
  42870. /* 264 */
  42871. /***/ (function(module, exports, __webpack_require__) {
  42872. 'use strict';
  42873. var zrUtil = __webpack_require__(4);
  42874. var ChartView = __webpack_require__(85);
  42875. var graphic = __webpack_require__(20);
  42876. var whiskerBoxCommon = __webpack_require__(262);
  42877. var BoxplotView = ChartView.extend({
  42878. type: 'boxplot',
  42879. getStyleUpdater: function () {
  42880. return updateStyle;
  42881. },
  42882. dispose: zrUtil.noop
  42883. });
  42884. zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true);
  42885. // Update common properties
  42886. var normalStyleAccessPath = ['itemStyle', 'normal'];
  42887. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  42888. function updateStyle(itemGroup, data, idx) {
  42889. var itemModel = data.getItemModel(idx);
  42890. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  42891. var borderColor = data.getItemVisual(idx, 'color');
  42892. // Exclude borderColor.
  42893. var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']);
  42894. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  42895. whiskerEl.style.set(itemStyle);
  42896. whiskerEl.style.stroke = borderColor;
  42897. whiskerEl.dirty();
  42898. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  42899. bodyEl.style.set(itemStyle);
  42900. bodyEl.style.stroke = borderColor;
  42901. bodyEl.dirty();
  42902. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  42903. graphic.setHoverStyle(itemGroup, hoverStyle);
  42904. }
  42905. module.exports = BoxplotView;
  42906. /***/ }),
  42907. /* 265 */
  42908. /***/ (function(module, exports) {
  42909. var borderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  42910. module.exports = function (ecModel, api) {
  42911. var globalColors = ecModel.get('color');
  42912. ecModel.eachRawSeriesByType('boxplot', function (seriesModel) {
  42913. var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length];
  42914. var data = seriesModel.getData();
  42915. data.setVisual({
  42916. legendSymbol: 'roundRect',
  42917. // Use name 'color' but not 'borderColor' for legend usage and
  42918. // visual coding from other component like dataRange.
  42919. color: seriesModel.get(borderColorQuery) || defaulColor
  42920. });
  42921. // Only visible series has each data be visual encoded
  42922. if (!ecModel.isSeriesFiltered(seriesModel)) {
  42923. data.each(function (idx) {
  42924. var itemModel = data.getItemModel(idx);
  42925. data.setItemVisual(
  42926. idx,
  42927. {color: itemModel.get(borderColorQuery, true)}
  42928. );
  42929. });
  42930. }
  42931. });
  42932. };
  42933. /***/ }),
  42934. /* 266 */
  42935. /***/ (function(module, exports, __webpack_require__) {
  42936. var zrUtil = __webpack_require__(4);
  42937. var numberUtil = __webpack_require__(7);
  42938. var parsePercent = numberUtil.parsePercent;
  42939. var each = zrUtil.each;
  42940. module.exports = function (ecModel) {
  42941. var groupResult = groupSeriesByAxis(ecModel);
  42942. each(groupResult, function (groupItem) {
  42943. var seriesModels = groupItem.seriesModels;
  42944. if (!seriesModels.length) {
  42945. return;
  42946. }
  42947. calculateBase(groupItem);
  42948. each(seriesModels, function (seriesModel, idx) {
  42949. layoutSingleSeries(
  42950. seriesModel,
  42951. groupItem.boxOffsetList[idx],
  42952. groupItem.boxWidthList[idx]
  42953. );
  42954. });
  42955. });
  42956. };
  42957. /**
  42958. * Group series by axis.
  42959. */
  42960. function groupSeriesByAxis(ecModel) {
  42961. var result = [];
  42962. var axisList = [];
  42963. ecModel.eachSeriesByType('boxplot', function (seriesModel) {
  42964. var baseAxis = seriesModel.getBaseAxis();
  42965. var idx = zrUtil.indexOf(axisList, baseAxis);
  42966. if (idx < 0) {
  42967. idx = axisList.length;
  42968. axisList[idx] = baseAxis;
  42969. result[idx] = {axis: baseAxis, seriesModels: []};
  42970. }
  42971. result[idx].seriesModels.push(seriesModel);
  42972. });
  42973. return result;
  42974. }
  42975. /**
  42976. * Calculate offset and box width for each series.
  42977. */
  42978. function calculateBase(groupItem) {
  42979. var extent;
  42980. var baseAxis = groupItem.axis;
  42981. var seriesModels = groupItem.seriesModels;
  42982. var seriesCount = seriesModels.length;
  42983. var boxWidthList = groupItem.boxWidthList = [];
  42984. var boxOffsetList = groupItem.boxOffsetList = [];
  42985. var boundList = [];
  42986. var bandWidth;
  42987. if (baseAxis.type === 'category') {
  42988. bandWidth = baseAxis.getBandWidth();
  42989. }
  42990. else {
  42991. var maxDataCount = 0;
  42992. each(seriesModels, function (seriesModel) {
  42993. maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
  42994. });
  42995. extent = baseAxis.getExtent(),
  42996. Math.abs(extent[1] - extent[0]) / maxDataCount;
  42997. }
  42998. each(seriesModels, function (seriesModel) {
  42999. var boxWidthBound = seriesModel.get('boxWidth');
  43000. if (!zrUtil.isArray(boxWidthBound)) {
  43001. boxWidthBound = [boxWidthBound, boxWidthBound];
  43002. }
  43003. boundList.push([
  43004. parsePercent(boxWidthBound[0], bandWidth) || 0,
  43005. parsePercent(boxWidthBound[1], bandWidth) || 0
  43006. ]);
  43007. });
  43008. var availableWidth = bandWidth * 0.8 - 2;
  43009. var boxGap = availableWidth / seriesCount * 0.3;
  43010. var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
  43011. var base = boxWidth / 2 - availableWidth / 2;
  43012. each(seriesModels, function (seriesModel, idx) {
  43013. boxOffsetList.push(base);
  43014. base += boxGap + boxWidth;
  43015. boxWidthList.push(
  43016. Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
  43017. );
  43018. });
  43019. }
  43020. /**
  43021. * Calculate points location for each series.
  43022. */
  43023. function layoutSingleSeries(seriesModel, offset, boxWidth) {
  43024. var coordSys = seriesModel.coordinateSystem;
  43025. var data = seriesModel.getData();
  43026. var halfWidth = boxWidth / 2;
  43027. var chartLayout = seriesModel.get('layout');
  43028. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  43029. var constDim = 1 - variableDim;
  43030. var coordDims = ['x', 'y'];
  43031. var vDims = [];
  43032. var cDim;
  43033. zrUtil.each(data.dimensions, function (dimName) {
  43034. var dimInfo = data.getDimensionInfo(dimName);
  43035. var coordDim = dimInfo.coordDim;
  43036. if (coordDim === coordDims[constDim]) {
  43037. vDims.push(dimName);
  43038. }
  43039. else if (coordDim === coordDims[variableDim]) {
  43040. cDim = dimName;
  43041. }
  43042. });
  43043. if (cDim == null || vDims.length < 5) {
  43044. return;
  43045. }
  43046. data.each([cDim].concat(vDims), function () {
  43047. var args = arguments;
  43048. var axisDimVal = args[0];
  43049. var idx = args[vDims.length + 1];
  43050. var median = getPoint(args[3]);
  43051. var end1 = getPoint(args[1]);
  43052. var end5 = getPoint(args[5]);
  43053. var whiskerEnds = [
  43054. [end1, getPoint(args[2])],
  43055. [end5, getPoint(args[4])]
  43056. ];
  43057. layEndLine(end1);
  43058. layEndLine(end5);
  43059. layEndLine(median);
  43060. var bodyEnds = [];
  43061. addBodyEnd(whiskerEnds[0][1], 0);
  43062. addBodyEnd(whiskerEnds[1][1], 1);
  43063. data.setItemLayout(idx, {
  43064. chartLayout: chartLayout,
  43065. initBaseline: median[constDim],
  43066. median: median,
  43067. bodyEnds: bodyEnds,
  43068. whiskerEnds: whiskerEnds
  43069. });
  43070. function getPoint(val) {
  43071. var p = [];
  43072. p[variableDim] = axisDimVal;
  43073. p[constDim] = val;
  43074. var point;
  43075. if (isNaN(axisDimVal) || isNaN(val)) {
  43076. point = [NaN, NaN];
  43077. }
  43078. else {
  43079. point = coordSys.dataToPoint(p);
  43080. point[variableDim] += offset;
  43081. }
  43082. return point;
  43083. }
  43084. function addBodyEnd(point, start) {
  43085. var point1 = point.slice();
  43086. var point2 = point.slice();
  43087. point1[variableDim] += halfWidth;
  43088. point2[variableDim] -= halfWidth;
  43089. start
  43090. ? bodyEnds.push(point1, point2)
  43091. : bodyEnds.push(point2, point1);
  43092. }
  43093. function layEndLine(endCenter) {
  43094. var line = [endCenter.slice(), endCenter.slice()];
  43095. line[0][variableDim] -= halfWidth;
  43096. line[1][variableDim] += halfWidth;
  43097. whiskerEnds.push(line);
  43098. }
  43099. });
  43100. }
  43101. /***/ }),
  43102. /* 267 */
  43103. /***/ (function(module, exports, __webpack_require__) {
  43104. var echarts = __webpack_require__(1);
  43105. __webpack_require__(268);
  43106. __webpack_require__(269);
  43107. echarts.registerPreprocessor(
  43108. __webpack_require__(270)
  43109. );
  43110. echarts.registerVisual(__webpack_require__(271));
  43111. echarts.registerLayout(__webpack_require__(272));
  43112. /***/ }),
  43113. /* 268 */
  43114. /***/ (function(module, exports, __webpack_require__) {
  43115. 'use strict';
  43116. var zrUtil = __webpack_require__(4);
  43117. var SeriesModel = __webpack_require__(83);
  43118. var whiskerBoxCommon = __webpack_require__(262);
  43119. var CandlestickSeries = SeriesModel.extend({
  43120. type: 'series.candlestick',
  43121. dependencies: ['xAxis', 'yAxis', 'grid'],
  43122. /**
  43123. * @readOnly
  43124. */
  43125. defaultValueDimensions: ['open', 'close', 'lowest', 'highest'],
  43126. /**
  43127. * @type {Array.<string>}
  43128. * @readOnly
  43129. */
  43130. dimensions: null,
  43131. /**
  43132. * @override
  43133. */
  43134. defaultOption: {
  43135. zlevel: 0, // 一级层叠
  43136. z: 2, // 二级层叠
  43137. coordinateSystem: 'cartesian2d',
  43138. legendHoverLink: true,
  43139. hoverAnimation: true,
  43140. // xAxisIndex: 0,
  43141. // yAxisIndex: 0,
  43142. layout: null, // 'horizontal' or 'vertical'
  43143. itemStyle: {
  43144. normal: {
  43145. color: '#c23531', // 阳线 positive
  43146. color0: '#314656', // 阴线 negative '#c23531', '#314656'
  43147. borderWidth: 1,
  43148. // FIXME
  43149. // ec2中使用的是lineStyle.color 和 lineStyle.color0
  43150. borderColor: '#c23531',
  43151. borderColor0: '#314656'
  43152. },
  43153. emphasis: {
  43154. borderWidth: 2
  43155. }
  43156. },
  43157. barMaxWidth: null,
  43158. barMinWidth: null,
  43159. barWidth: null,
  43160. animationUpdate: false,
  43161. animationEasing: 'linear',
  43162. animationDuration: 300
  43163. },
  43164. /**
  43165. * Get dimension for shadow in dataZoom
  43166. * @return {string} dimension name
  43167. */
  43168. getShadowDim: function () {
  43169. return 'open';
  43170. },
  43171. brushSelector: function (dataIndex, data, selectors) {
  43172. var itemLayout = data.getItemLayout(dataIndex);
  43173. return selectors.rect(itemLayout.brushRect);
  43174. }
  43175. });
  43176. zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true);
  43177. module.exports = CandlestickSeries;
  43178. /***/ }),
  43179. /* 269 */
  43180. /***/ (function(module, exports, __webpack_require__) {
  43181. 'use strict';
  43182. var zrUtil = __webpack_require__(4);
  43183. var ChartView = __webpack_require__(85);
  43184. var graphic = __webpack_require__(20);
  43185. var whiskerBoxCommon = __webpack_require__(262);
  43186. var CandlestickView = ChartView.extend({
  43187. type: 'candlestick',
  43188. getStyleUpdater: function () {
  43189. return updateStyle;
  43190. },
  43191. dispose: zrUtil.noop
  43192. });
  43193. zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true);
  43194. // Update common properties
  43195. var normalStyleAccessPath = ['itemStyle', 'normal'];
  43196. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  43197. function updateStyle(itemGroup, data, idx) {
  43198. var itemModel = data.getItemModel(idx);
  43199. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  43200. var color = data.getItemVisual(idx, 'color');
  43201. var borderColor = data.getItemVisual(idx, 'borderColor') || color;
  43202. // Color must be excluded.
  43203. // Because symbol provide setColor individually to set fill and stroke
  43204. var itemStyle = normalItemStyleModel.getItemStyle(
  43205. ['color', 'color0', 'borderColor', 'borderColor0']
  43206. );
  43207. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  43208. whiskerEl.useStyle(itemStyle);
  43209. whiskerEl.style.stroke = borderColor;
  43210. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  43211. bodyEl.useStyle(itemStyle);
  43212. bodyEl.style.fill = color;
  43213. bodyEl.style.stroke = borderColor;
  43214. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  43215. graphic.setHoverStyle(itemGroup, hoverStyle);
  43216. }
  43217. module.exports = CandlestickView;
  43218. /***/ }),
  43219. /* 270 */
  43220. /***/ (function(module, exports, __webpack_require__) {
  43221. var zrUtil = __webpack_require__(4);
  43222. module.exports = function (option) {
  43223. if (!option || !zrUtil.isArray(option.series)) {
  43224. return;
  43225. }
  43226. // Translate 'k' to 'candlestick'.
  43227. zrUtil.each(option.series, function (seriesItem) {
  43228. if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') {
  43229. seriesItem.type = 'candlestick';
  43230. }
  43231. });
  43232. };
  43233. /***/ }),
  43234. /* 271 */
  43235. /***/ (function(module, exports) {
  43236. var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  43237. var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0'];
  43238. var positiveColorQuery = ['itemStyle', 'normal', 'color'];
  43239. var negativeColorQuery = ['itemStyle', 'normal', 'color0'];
  43240. module.exports = function (ecModel, api) {
  43241. ecModel.eachRawSeriesByType('candlestick', function (seriesModel) {
  43242. var data = seriesModel.getData();
  43243. data.setVisual({
  43244. legendSymbol: 'roundRect'
  43245. });
  43246. // Only visible series has each data be visual encoded
  43247. if (!ecModel.isSeriesFiltered(seriesModel)) {
  43248. data.each(function (idx) {
  43249. var itemModel = data.getItemModel(idx);
  43250. var sign = data.getItemLayout(idx).sign;
  43251. data.setItemVisual(
  43252. idx,
  43253. {
  43254. color: itemModel.get(
  43255. sign > 0 ? positiveColorQuery : negativeColorQuery
  43256. ),
  43257. borderColor: itemModel.get(
  43258. sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery
  43259. )
  43260. }
  43261. );
  43262. });
  43263. }
  43264. });
  43265. };
  43266. /***/ }),
  43267. /* 272 */
  43268. /***/ (function(module, exports, __webpack_require__) {
  43269. var zrUtil = __webpack_require__(4);
  43270. var retrieve = __webpack_require__(4).retrieve;
  43271. var parsePercent = __webpack_require__(7).parsePercent;
  43272. var graphic = __webpack_require__(20);
  43273. module.exports = function (ecModel) {
  43274. ecModel.eachSeriesByType('candlestick', function (seriesModel) {
  43275. var coordSys = seriesModel.coordinateSystem;
  43276. var data = seriesModel.getData();
  43277. var candleWidth = calculateCandleWidth(seriesModel, data);
  43278. var chartLayout = seriesModel.get('layout');
  43279. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  43280. var constDim = 1 - variableDim;
  43281. var coordDims = ['x', 'y'];
  43282. var vDims = [];
  43283. var cDim;
  43284. zrUtil.each(data.dimensions, function (dimName) {
  43285. var dimInfo = data.getDimensionInfo(dimName);
  43286. var coordDim = dimInfo.coordDim;
  43287. if (coordDim === coordDims[constDim]) {
  43288. vDims.push(dimName);
  43289. }
  43290. else if (coordDim === coordDims[variableDim]) {
  43291. cDim = dimName;
  43292. }
  43293. });
  43294. if (cDim == null || vDims.length < 4) {
  43295. return;
  43296. }
  43297. var dataIndex = 0;
  43298. data.each([cDim].concat(vDims), function () {
  43299. var args = arguments;
  43300. var axisDimVal = args[0];
  43301. var idx = args[vDims.length + 1];
  43302. var openVal = args[1];
  43303. var closeVal = args[2];
  43304. var lowestVal = args[3];
  43305. var highestVal = args[4];
  43306. var ocLow = Math.min(openVal, closeVal);
  43307. var ocHigh = Math.max(openVal, closeVal);
  43308. var ocLowPoint = getPoint(ocLow);
  43309. var ocHighPoint = getPoint(ocHigh);
  43310. var lowestPoint = getPoint(lowestVal);
  43311. var highestPoint = getPoint(highestVal);
  43312. var whiskerEnds = [
  43313. [
  43314. subPixelOptimizePoint(highestPoint),
  43315. subPixelOptimizePoint(ocHighPoint)
  43316. ],
  43317. [
  43318. subPixelOptimizePoint(lowestPoint),
  43319. subPixelOptimizePoint(ocLowPoint)
  43320. ]
  43321. ];
  43322. var bodyEnds = [];
  43323. addBodyEnd(ocHighPoint, 0);
  43324. addBodyEnd(ocLowPoint, 1);
  43325. var sign;
  43326. if (openVal > closeVal) {
  43327. sign = -1;
  43328. }
  43329. else if (openVal < closeVal) {
  43330. sign = 1;
  43331. }
  43332. else {
  43333. // If close === open, compare with close of last record
  43334. if (dataIndex > 0) {
  43335. sign = data.getItemModel(dataIndex - 1).get()[2]
  43336. <= closeVal
  43337. ? 1
  43338. : -1;
  43339. }
  43340. else {
  43341. // No record of previous, set to be positive
  43342. sign = 1;
  43343. }
  43344. }
  43345. data.setItemLayout(idx, {
  43346. chartLayout: chartLayout,
  43347. sign: sign,
  43348. initBaseline: openVal > closeVal
  43349. ? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
  43350. bodyEnds: bodyEnds,
  43351. whiskerEnds: whiskerEnds,
  43352. brushRect: makeBrushRect()
  43353. });
  43354. ++dataIndex;
  43355. function getPoint(val) {
  43356. var p = [];
  43357. p[variableDim] = axisDimVal;
  43358. p[constDim] = val;
  43359. return (isNaN(axisDimVal) || isNaN(val))
  43360. ? [NaN, NaN]
  43361. : coordSys.dataToPoint(p);
  43362. }
  43363. function addBodyEnd(point, start) {
  43364. var point1 = point.slice();
  43365. var point2 = point.slice();
  43366. point1[variableDim] = graphic.subPixelOptimize(
  43367. point1[variableDim] + candleWidth / 2, 1, false
  43368. );
  43369. point2[variableDim] = graphic.subPixelOptimize(
  43370. point2[variableDim] - candleWidth / 2, 1, true
  43371. );
  43372. start
  43373. ? bodyEnds.push(point1, point2)
  43374. : bodyEnds.push(point2, point1);
  43375. }
  43376. function makeBrushRect() {
  43377. var pmin = getPoint(Math.min(openVal, closeVal, lowestVal, highestVal));
  43378. var pmax = getPoint(Math.max(openVal, closeVal, lowestVal, highestVal));
  43379. pmin[variableDim] -= candleWidth / 2;
  43380. pmax[variableDim] -= candleWidth / 2;
  43381. return {
  43382. x: pmin[0],
  43383. y: pmin[1],
  43384. width: constDim ? candleWidth : pmax[0] - pmin[0],
  43385. height: constDim ? pmax[1] - pmin[1] : candleWidth
  43386. };
  43387. }
  43388. function subPixelOptimizePoint(point) {
  43389. point[variableDim] = graphic.subPixelOptimize(point[variableDim], 1);
  43390. return point;
  43391. }
  43392. }, true);
  43393. });
  43394. };
  43395. function calculateCandleWidth(seriesModel, data) {
  43396. var baseAxis = seriesModel.getBaseAxis();
  43397. var extent;
  43398. var bandWidth = baseAxis.type === 'category'
  43399. ? baseAxis.getBandWidth()
  43400. : (
  43401. extent = baseAxis.getExtent(),
  43402. Math.abs(extent[1] - extent[0]) / data.count()
  43403. );
  43404. var barMaxWidth = parsePercent(
  43405. retrieve(seriesModel.get('barMaxWidth'), bandWidth),
  43406. bandWidth
  43407. );
  43408. var barMinWidth = parsePercent(
  43409. retrieve(seriesModel.get('barMinWidth'), 1),
  43410. bandWidth
  43411. );
  43412. var barWidth = seriesModel.get('barWidth');
  43413. return barWidth != null
  43414. ? parsePercent(barWidth, bandWidth)
  43415. // Put max outer to ensure bar visible in spite of overlap.
  43416. : Math.max(Math.min(bandWidth / 2, barMaxWidth), barMinWidth);
  43417. }
  43418. /***/ }),
  43419. /* 273 */
  43420. /***/ (function(module, exports, __webpack_require__) {
  43421. var zrUtil = __webpack_require__(4);
  43422. var echarts = __webpack_require__(1);
  43423. __webpack_require__(274);
  43424. __webpack_require__(275);
  43425. echarts.registerVisual(zrUtil.curry(
  43426. __webpack_require__(124), 'effectScatter', 'circle', null
  43427. ));
  43428. echarts.registerLayout(zrUtil.curry(
  43429. __webpack_require__(125), 'effectScatter'
  43430. ));
  43431. /***/ }),
  43432. /* 274 */
  43433. /***/ (function(module, exports, __webpack_require__) {
  43434. 'use strict';
  43435. var createListFromArray = __webpack_require__(112);
  43436. var SeriesModel = __webpack_require__(83);
  43437. module.exports = SeriesModel.extend({
  43438. type: 'series.effectScatter',
  43439. dependencies: ['grid', 'polar'],
  43440. getInitialData: function (option, ecModel) {
  43441. var list = createListFromArray(option.data, this, ecModel);
  43442. return list;
  43443. },
  43444. brushSelector: 'point',
  43445. defaultOption: {
  43446. coordinateSystem: 'cartesian2d',
  43447. zlevel: 0,
  43448. z: 2,
  43449. legendHoverLink: true,
  43450. effectType: 'ripple',
  43451. progressive: 0,
  43452. // When to show the effect, option: 'render'|'emphasis'
  43453. showEffectOn: 'render',
  43454. // Ripple effect config
  43455. rippleEffect: {
  43456. period: 4,
  43457. // Scale of ripple
  43458. scale: 2.5,
  43459. // Brush type can be fill or stroke
  43460. brushType: 'fill'
  43461. },
  43462. // Cartesian coordinate system
  43463. // xAxisIndex: 0,
  43464. // yAxisIndex: 0,
  43465. // Polar coordinate system
  43466. // polarIndex: 0,
  43467. // Geo coordinate system
  43468. // geoIndex: 0,
  43469. // symbol: null, // 图形类型
  43470. symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  43471. // symbolRotate: null, // 图形旋转控制
  43472. // large: false,
  43473. // Available when large is true
  43474. // largeThreshold: 2000,
  43475. // itemStyle: {
  43476. // normal: {
  43477. // opacity: 1
  43478. // }
  43479. // }
  43480. }
  43481. });
  43482. /***/ }),
  43483. /* 275 */
  43484. /***/ (function(module, exports, __webpack_require__) {
  43485. var SymbolDraw = __webpack_require__(119);
  43486. var EffectSymbol = __webpack_require__(276);
  43487. __webpack_require__(1).extendChartView({
  43488. type: 'effectScatter',
  43489. init: function () {
  43490. this._symbolDraw = new SymbolDraw(EffectSymbol);
  43491. },
  43492. render: function (seriesModel, ecModel, api) {
  43493. var data = seriesModel.getData();
  43494. var effectSymbolDraw = this._symbolDraw;
  43495. effectSymbolDraw.updateData(data);
  43496. this.group.add(effectSymbolDraw.group);
  43497. },
  43498. updateLayout: function () {
  43499. this._symbolDraw.updateLayout();
  43500. },
  43501. remove: function (ecModel, api) {
  43502. this._symbolDraw && this._symbolDraw.remove(api);
  43503. },
  43504. dispose: function () {}
  43505. });
  43506. /***/ }),
  43507. /* 276 */
  43508. /***/ (function(module, exports, __webpack_require__) {
  43509. /**
  43510. * Symbol with ripple effect
  43511. * @module echarts/chart/helper/EffectSymbol
  43512. */
  43513. var zrUtil = __webpack_require__(4);
  43514. var symbolUtil = __webpack_require__(114);
  43515. var graphic = __webpack_require__(20);
  43516. var numberUtil = __webpack_require__(7);
  43517. var Symbol = __webpack_require__(120);
  43518. var Group = graphic.Group;
  43519. var EFFECT_RIPPLE_NUMBER = 3;
  43520. function normalizeSymbolSize(symbolSize) {
  43521. if (!zrUtil.isArray(symbolSize)) {
  43522. symbolSize = [+symbolSize, +symbolSize];
  43523. }
  43524. return symbolSize;
  43525. }
  43526. function updateRipplePath(rippleGroup, effectCfg) {
  43527. rippleGroup.eachChild(function (ripplePath) {
  43528. ripplePath.attr({
  43529. z: effectCfg.z,
  43530. zlevel: effectCfg.zlevel,
  43531. style: {
  43532. stroke: effectCfg.brushType === 'stroke' ? effectCfg.color : null,
  43533. fill: effectCfg.brushType === 'fill' ? effectCfg.color : null
  43534. }
  43535. });
  43536. });
  43537. }
  43538. /**
  43539. * @constructor
  43540. * @param {module:echarts/data/List} data
  43541. * @param {number} idx
  43542. * @extends {module:zrender/graphic/Group}
  43543. */
  43544. function EffectSymbol(data, idx) {
  43545. Group.call(this);
  43546. var symbol = new Symbol(data, idx);
  43547. var rippleGroup = new Group();
  43548. this.add(symbol);
  43549. this.add(rippleGroup);
  43550. rippleGroup.beforeUpdate = function () {
  43551. this.attr(symbol.getScale());
  43552. };
  43553. this.updateData(data, idx);
  43554. }
  43555. var effectSymbolProto = EffectSymbol.prototype;
  43556. effectSymbolProto.stopEffectAnimation = function () {
  43557. this.childAt(1).removeAll();
  43558. };
  43559. effectSymbolProto.startEffectAnimation = function (effectCfg) {
  43560. var symbolType = effectCfg.symbolType;
  43561. var color = effectCfg.color;
  43562. var rippleGroup = this.childAt(1);
  43563. for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
  43564. // var ripplePath = symbolUtil.createSymbol(
  43565. // symbolType, -0.5, -0.5, 1, 1, color
  43566. // );
  43567. // If width/height are set too small (e.g., set to 1) on ios10
  43568. // and macOS Sierra, a circle stroke become a rect, no matter what
  43569. // the scale is set. So we set width/height as 2. See #4136.
  43570. var ripplePath = symbolUtil.createSymbol(
  43571. symbolType, -1, -1, 2, 2, color
  43572. );
  43573. ripplePath.attr({
  43574. style: {
  43575. strokeNoScale: true
  43576. },
  43577. z2: 99,
  43578. silent: true,
  43579. scale: [0.5, 0.5]
  43580. });
  43581. var delay = -i / EFFECT_RIPPLE_NUMBER * effectCfg.period + effectCfg.effectOffset;
  43582. // TODO Configurable effectCfg.period
  43583. ripplePath.animate('', true)
  43584. .when(effectCfg.period, {
  43585. scale: [effectCfg.rippleScale / 2, effectCfg.rippleScale / 2]
  43586. })
  43587. .delay(delay)
  43588. .start();
  43589. ripplePath.animateStyle(true)
  43590. .when(effectCfg.period, {
  43591. opacity: 0
  43592. })
  43593. .delay(delay)
  43594. .start();
  43595. rippleGroup.add(ripplePath);
  43596. }
  43597. updateRipplePath(rippleGroup, effectCfg);
  43598. };
  43599. /**
  43600. * Update effect symbol
  43601. */
  43602. effectSymbolProto.updateEffectAnimation = function (effectCfg) {
  43603. var oldEffectCfg = this._effectCfg;
  43604. var rippleGroup = this.childAt(1);
  43605. // Must reinitialize effect if following configuration changed
  43606. var DIFFICULT_PROPS = ['symbolType', 'period', 'rippleScale'];
  43607. for (var i = 0; i < DIFFICULT_PROPS.length; i++) {
  43608. var propName = DIFFICULT_PROPS[i];
  43609. if (oldEffectCfg[propName] !== effectCfg[propName]) {
  43610. this.stopEffectAnimation();
  43611. this.startEffectAnimation(effectCfg);
  43612. return;
  43613. }
  43614. }
  43615. updateRipplePath(rippleGroup, effectCfg);
  43616. };
  43617. /**
  43618. * Highlight symbol
  43619. */
  43620. effectSymbolProto.highlight = function () {
  43621. this.trigger('emphasis');
  43622. };
  43623. /**
  43624. * Downplay symbol
  43625. */
  43626. effectSymbolProto.downplay = function () {
  43627. this.trigger('normal');
  43628. };
  43629. /**
  43630. * Update symbol properties
  43631. * @param {module:echarts/data/List} data
  43632. * @param {number} idx
  43633. */
  43634. effectSymbolProto.updateData = function (data, idx) {
  43635. var seriesModel = data.hostModel;
  43636. this.childAt(0).updateData(data, idx);
  43637. var rippleGroup = this.childAt(1);
  43638. var itemModel = data.getItemModel(idx);
  43639. var symbolType = data.getItemVisual(idx, 'symbol');
  43640. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  43641. var color = data.getItemVisual(idx, 'color');
  43642. rippleGroup.attr('scale', symbolSize);
  43643. rippleGroup.traverse(function (ripplePath) {
  43644. ripplePath.attr({
  43645. fill: color
  43646. });
  43647. });
  43648. var symbolOffset = itemModel.getShallow('symbolOffset');
  43649. if (symbolOffset) {
  43650. var pos = rippleGroup.position;
  43651. pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  43652. pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  43653. }
  43654. rippleGroup.rotation = (itemModel.getShallow('symbolRotate') || 0) * Math.PI / 180 || 0;
  43655. var effectCfg = {};
  43656. effectCfg.showEffectOn = seriesModel.get('showEffectOn');
  43657. effectCfg.rippleScale = itemModel.get('rippleEffect.scale');
  43658. effectCfg.brushType = itemModel.get('rippleEffect.brushType');
  43659. effectCfg.period = itemModel.get('rippleEffect.period') * 1000;
  43660. effectCfg.effectOffset = idx / data.count();
  43661. effectCfg.z = itemModel.getShallow('z') || 0;
  43662. effectCfg.zlevel = itemModel.getShallow('zlevel') || 0;
  43663. effectCfg.symbolType = symbolType;
  43664. effectCfg.color = color;
  43665. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  43666. if (effectCfg.showEffectOn === 'render') {
  43667. this._effectCfg
  43668. ? this.updateEffectAnimation(effectCfg)
  43669. : this.startEffectAnimation(effectCfg);
  43670. this._effectCfg = effectCfg;
  43671. }
  43672. else {
  43673. // Not keep old effect config
  43674. this._effectCfg = null;
  43675. this.stopEffectAnimation();
  43676. var symbol = this.childAt(0);
  43677. var onEmphasis = function () {
  43678. symbol.highlight();
  43679. if (effectCfg.showEffectOn !== 'render') {
  43680. this.startEffectAnimation(effectCfg);
  43681. }
  43682. };
  43683. var onNormal = function () {
  43684. symbol.downplay();
  43685. if (effectCfg.showEffectOn !== 'render') {
  43686. this.stopEffectAnimation();
  43687. }
  43688. };
  43689. this.on('mouseover', onEmphasis, this)
  43690. .on('mouseout', onNormal, this)
  43691. .on('emphasis', onEmphasis, this)
  43692. .on('normal', onNormal, this);
  43693. }
  43694. this._effectCfg = effectCfg;
  43695. };
  43696. effectSymbolProto.fadeOut = function (cb) {
  43697. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  43698. cb && cb();
  43699. };
  43700. zrUtil.inherits(EffectSymbol, Group);
  43701. module.exports = EffectSymbol;
  43702. /***/ }),
  43703. /* 277 */
  43704. /***/ (function(module, exports, __webpack_require__) {
  43705. __webpack_require__(278);
  43706. __webpack_require__(279);
  43707. var echarts = __webpack_require__(1);
  43708. echarts.registerLayout(
  43709. __webpack_require__(284)
  43710. );
  43711. echarts.registerVisual(
  43712. __webpack_require__(285)
  43713. );
  43714. /***/ }),
  43715. /* 278 */
  43716. /***/ (function(module, exports, __webpack_require__) {
  43717. 'use strict';
  43718. var SeriesModel = __webpack_require__(83);
  43719. var List = __webpack_require__(101);
  43720. var zrUtil = __webpack_require__(4);
  43721. var formatUtil = __webpack_require__(6);
  43722. var CoordinateSystem = __webpack_require__(79);
  43723. // Convert [ [{coord: []}, {coord: []}] ]
  43724. // to [ { coords: [[]] } ]
  43725. function preprocessOption (seriesOpt) {
  43726. var data = seriesOpt.data;
  43727. if (data && data[0] && data[0][0] && data[0][0].coord) {
  43728. if (true) {
  43729. console.warn('Lines data configuration has been changed to'
  43730. + ' { coords:[[1,2],[2,3]] }');
  43731. }
  43732. seriesOpt.data = zrUtil.map(data, function (itemOpt) {
  43733. var coords = [
  43734. itemOpt[0].coord, itemOpt[1].coord
  43735. ];
  43736. var target = {
  43737. coords: coords
  43738. };
  43739. if (itemOpt[0].name) {
  43740. target.fromName = itemOpt[0].name;
  43741. }
  43742. if (itemOpt[1].name) {
  43743. target.toName = itemOpt[1].name;
  43744. }
  43745. return zrUtil.mergeAll([target, itemOpt[0], itemOpt[1]]);
  43746. });
  43747. }
  43748. }
  43749. var LinesSeries = SeriesModel.extend({
  43750. type: 'series.lines',
  43751. dependencies: ['grid', 'polar'],
  43752. visualColorAccessPath: 'lineStyle.normal.color',
  43753. init: function (option) {
  43754. // Not using preprocessor because mergeOption may not have series.type
  43755. preprocessOption(option);
  43756. LinesSeries.superApply(this, 'init', arguments);
  43757. },
  43758. mergeOption: function (option) {
  43759. preprocessOption(option);
  43760. LinesSeries.superApply(this, 'mergeOption', arguments);
  43761. },
  43762. getInitialData: function (option, ecModel) {
  43763. if (true) {
  43764. var CoordSys = CoordinateSystem.get(option.coordinateSystem);
  43765. if (!CoordSys) {
  43766. throw new Error('Unkown coordinate system ' + option.coordinateSystem);
  43767. }
  43768. }
  43769. var lineData = new List(['value'], this);
  43770. lineData.hasItemOption = false;
  43771. lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
  43772. // dataItem is simply coords
  43773. if (dataItem instanceof Array) {
  43774. return NaN;
  43775. }
  43776. else {
  43777. lineData.hasItemOption = true;
  43778. var value = dataItem.value;
  43779. if (value != null) {
  43780. return value instanceof Array ? value[dimIndex] : value;
  43781. }
  43782. }
  43783. });
  43784. return lineData;
  43785. },
  43786. formatTooltip: function (dataIndex) {
  43787. var data = this.getData();
  43788. var itemModel = data.getItemModel(dataIndex);
  43789. var name = itemModel.get('name');
  43790. if (name) {
  43791. return name;
  43792. }
  43793. var fromName = itemModel.get('fromName');
  43794. var toName = itemModel.get('toName');
  43795. var html = [];
  43796. fromName != null && html.push(fromName);
  43797. toName != null && html.push(toName);
  43798. return formatUtil.encodeHTML(html.join(' > '));
  43799. },
  43800. defaultOption: {
  43801. coordinateSystem: 'geo',
  43802. zlevel: 0,
  43803. z: 2,
  43804. legendHoverLink: true,
  43805. hoverAnimation: true,
  43806. // Cartesian coordinate system
  43807. xAxisIndex: 0,
  43808. yAxisIndex: 0,
  43809. symbol: ['none', 'none'],
  43810. symbolSize: [10, 10],
  43811. // Geo coordinate system
  43812. geoIndex: 0,
  43813. effect: {
  43814. show: false,
  43815. period: 4,
  43816. // Animation delay. support callback
  43817. // delay: 0,
  43818. // If move with constant speed px/sec
  43819. // period will be ignored if this property is > 0,
  43820. constantSpeed: 0,
  43821. symbol: 'circle',
  43822. symbolSize: 3,
  43823. loop: true,
  43824. // Length of trail, 0 - 1
  43825. trailLength: 0.2
  43826. // Same with lineStyle.normal.color
  43827. // color
  43828. },
  43829. large: false,
  43830. // Available when large is true
  43831. largeThreshold: 2000,
  43832. // If lines are polyline
  43833. // polyline not support curveness, label, animation
  43834. polyline: false,
  43835. label: {
  43836. normal: {
  43837. show: false,
  43838. position: 'end'
  43839. // distance: 5,
  43840. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  43841. }
  43842. },
  43843. lineStyle: {
  43844. normal: {
  43845. opacity: 0.5
  43846. }
  43847. }
  43848. }
  43849. });
  43850. /***/ }),
  43851. /* 279 */
  43852. /***/ (function(module, exports, __webpack_require__) {
  43853. var LineDraw = __webpack_require__(213);
  43854. var EffectLine = __webpack_require__(280);
  43855. var Line = __webpack_require__(214);
  43856. var Polyline = __webpack_require__(281);
  43857. var EffectPolyline = __webpack_require__(282);
  43858. var LargeLineDraw = __webpack_require__(283);
  43859. __webpack_require__(1).extendChartView({
  43860. type: 'lines',
  43861. init: function () {},
  43862. render: function (seriesModel, ecModel, api) {
  43863. var data = seriesModel.getData();
  43864. var lineDraw = this._lineDraw;
  43865. var hasEffect = seriesModel.get('effect.show');
  43866. var isPolyline = seriesModel.get('polyline');
  43867. var isLarge = seriesModel.get('large') && data.count() >= seriesModel.get('largeThreshold');
  43868. if (true) {
  43869. if (hasEffect && isLarge) {
  43870. console.warn('Large lines not support effect');
  43871. }
  43872. }
  43873. if (hasEffect !== this._hasEffet || isPolyline !== this._isPolyline || isLarge !== this._isLarge) {
  43874. if (lineDraw) {
  43875. lineDraw.remove();
  43876. }
  43877. lineDraw = this._lineDraw = isLarge
  43878. ? new LargeLineDraw()
  43879. : new LineDraw(
  43880. isPolyline
  43881. ? (hasEffect ? EffectPolyline : Polyline)
  43882. : (hasEffect ? EffectLine : Line)
  43883. );
  43884. this._hasEffet = hasEffect;
  43885. this._isPolyline = isPolyline;
  43886. this._isLarge = isLarge;
  43887. }
  43888. var zlevel = seriesModel.get('zlevel');
  43889. var trailLength = seriesModel.get('effect.trailLength');
  43890. var zr = api.getZr();
  43891. // Avoid the drag cause ghost shadow
  43892. // FIXME Better way ?
  43893. // SVG doesn't support
  43894. var isSvg = zr.painter.getType() === 'svg';
  43895. if (!isSvg) {
  43896. zr.painter.getLayer(zlevel).clear(true);
  43897. }
  43898. // Config layer with motion blur
  43899. if (this._lastZlevel != null && !isSvg) {
  43900. zr.configLayer(this._lastZlevel, {
  43901. motionBlur: false
  43902. });
  43903. }
  43904. if (hasEffect && trailLength) {
  43905. if (true) {
  43906. var notInIndividual = false;
  43907. ecModel.eachSeries(function (otherSeriesModel) {
  43908. if (otherSeriesModel !== seriesModel && otherSeriesModel.get('zlevel') === zlevel) {
  43909. notInIndividual = true;
  43910. }
  43911. });
  43912. notInIndividual && console.warn('Lines with trail effect should have an individual zlevel');
  43913. }
  43914. if (!isSvg) {
  43915. zr.configLayer(zlevel, {
  43916. motionBlur: true,
  43917. lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
  43918. });
  43919. }
  43920. }
  43921. this.group.add(lineDraw.group);
  43922. lineDraw.updateData(data);
  43923. this._lastZlevel = zlevel;
  43924. },
  43925. updateLayout: function (seriesModel, ecModel, api) {
  43926. this._lineDraw.updateLayout(seriesModel);
  43927. // Not use motion when dragging or zooming
  43928. var zr = api.getZr();
  43929. var isSvg = zr.painter.getType() === 'svg';
  43930. if (!isSvg) {
  43931. zr.painter.getLayer(this._lastZlevel).clear(true);
  43932. }
  43933. },
  43934. remove: function (ecModel, api) {
  43935. this._lineDraw && this._lineDraw.remove(api, true);
  43936. // Clear motion when lineDraw is removed
  43937. var zr = api.getZr();
  43938. var isSvg = zr.painter.getType() === 'svg';
  43939. if (!isSvg) {
  43940. zr.painter.getLayer(this._lastZlevel).clear(true);
  43941. }
  43942. },
  43943. dispose: function () {}
  43944. });
  43945. /***/ }),
  43946. /* 280 */
  43947. /***/ (function(module, exports, __webpack_require__) {
  43948. /**
  43949. * Provide effect for line
  43950. * @module echarts/chart/helper/EffectLine
  43951. */
  43952. var graphic = __webpack_require__(20);
  43953. var Line = __webpack_require__(214);
  43954. var zrUtil = __webpack_require__(4);
  43955. var symbolUtil = __webpack_require__(114);
  43956. var vec2 = __webpack_require__(10);
  43957. var curveUtil = __webpack_require__(40);
  43958. /**
  43959. * @constructor
  43960. * @extends {module:zrender/graphic/Group}
  43961. * @alias {module:echarts/chart/helper/Line}
  43962. */
  43963. function EffectLine(lineData, idx, seriesScope) {
  43964. graphic.Group.call(this);
  43965. this.add(this.createLine(lineData, idx, seriesScope));
  43966. this._updateEffectSymbol(lineData, idx);
  43967. }
  43968. var effectLineProto = EffectLine.prototype;
  43969. effectLineProto.createLine = function (lineData, idx, seriesScope) {
  43970. return new Line(lineData, idx, seriesScope);
  43971. };
  43972. effectLineProto._updateEffectSymbol = function (lineData, idx) {
  43973. var itemModel = lineData.getItemModel(idx);
  43974. var effectModel = itemModel.getModel('effect');
  43975. var size = effectModel.get('symbolSize');
  43976. var symbolType = effectModel.get('symbol');
  43977. if (!zrUtil.isArray(size)) {
  43978. size = [size, size];
  43979. }
  43980. var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color');
  43981. var symbol = this.childAt(1);
  43982. if (this._symbolType !== symbolType) {
  43983. // Remove previous
  43984. this.remove(symbol);
  43985. symbol = symbolUtil.createSymbol(
  43986. symbolType, -0.5, -0.5, 1, 1, color
  43987. );
  43988. symbol.z2 = 100;
  43989. symbol.culling = true;
  43990. this.add(symbol);
  43991. }
  43992. // Symbol may be removed if loop is false
  43993. if (!symbol) {
  43994. return;
  43995. }
  43996. // Shadow color is same with color in default
  43997. symbol.setStyle('shadowColor', color);
  43998. symbol.setStyle(effectModel.getItemStyle(['color']));
  43999. symbol.attr('scale', size);
  44000. symbol.setColor(color);
  44001. symbol.attr('scale', size);
  44002. this._symbolType = symbolType;
  44003. this._updateEffectAnimation(lineData, effectModel, idx);
  44004. };
  44005. effectLineProto._updateEffectAnimation = function (lineData, effectModel, idx) {
  44006. var symbol = this.childAt(1);
  44007. if (!symbol) {
  44008. return;
  44009. }
  44010. var self = this;
  44011. var points = lineData.getItemLayout(idx);
  44012. var period = effectModel.get('period') * 1000;
  44013. var loop = effectModel.get('loop');
  44014. var constantSpeed = effectModel.get('constantSpeed');
  44015. var delayExpr = zrUtil.retrieve(effectModel.get('delay'), function (idx) {
  44016. return idx / lineData.count() * period / 3;
  44017. });
  44018. var isDelayFunc = typeof delayExpr === 'function';
  44019. // Ignore when updating
  44020. symbol.ignore = true;
  44021. this.updateAnimationPoints(symbol, points);
  44022. if (constantSpeed > 0) {
  44023. period = this.getLineLength(symbol) / constantSpeed * 1000;
  44024. }
  44025. if (period !== this._period || loop !== this._loop) {
  44026. symbol.stopAnimation();
  44027. var delay = delayExpr;
  44028. if (isDelayFunc) {
  44029. delay = delayExpr(idx);
  44030. }
  44031. if (symbol.__t > 0) {
  44032. delay = -period * symbol.__t;
  44033. }
  44034. symbol.__t = 0;
  44035. var animator = symbol.animate('', loop)
  44036. .when(period, {
  44037. __t: 1
  44038. })
  44039. .delay(delay)
  44040. .during(function () {
  44041. self.updateSymbolPosition(symbol);
  44042. });
  44043. if (!loop) {
  44044. animator.done(function () {
  44045. self.remove(symbol);
  44046. });
  44047. }
  44048. animator.start();
  44049. }
  44050. this._period = period;
  44051. this._loop = loop;
  44052. };
  44053. effectLineProto.getLineLength = function (symbol) {
  44054. // Not so accurate
  44055. return (vec2.dist(symbol.__p1, symbol.__cp1)
  44056. + vec2.dist(symbol.__cp1, symbol.__p2));
  44057. };
  44058. effectLineProto.updateAnimationPoints = function (symbol, points) {
  44059. symbol.__p1 = points[0];
  44060. symbol.__p2 = points[1];
  44061. symbol.__cp1 = points[2] || [
  44062. (points[0][0] + points[1][0]) / 2,
  44063. (points[0][1] + points[1][1]) / 2
  44064. ];
  44065. };
  44066. effectLineProto.updateData = function (lineData, idx, seriesScope) {
  44067. this.childAt(0).updateData(lineData, idx, seriesScope);
  44068. this._updateEffectSymbol(lineData, idx);
  44069. };
  44070. effectLineProto.updateSymbolPosition = function (symbol) {
  44071. var p1 = symbol.__p1;
  44072. var p2 = symbol.__p2;
  44073. var cp1 = symbol.__cp1;
  44074. var t = symbol.__t;
  44075. var pos = symbol.position;
  44076. var quadraticAt = curveUtil.quadraticAt;
  44077. var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
  44078. pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
  44079. pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t);
  44080. // Tangent
  44081. var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t);
  44082. var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t);
  44083. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  44084. symbol.ignore = false;
  44085. };
  44086. effectLineProto.updateLayout = function (lineData, idx) {
  44087. this.childAt(0).updateLayout(lineData, idx);
  44088. var effectModel = lineData.getItemModel(idx).getModel('effect');
  44089. this._updateEffectAnimation(lineData, effectModel, idx);
  44090. };
  44091. zrUtil.inherits(EffectLine, graphic.Group);
  44092. module.exports = EffectLine;
  44093. /***/ }),
  44094. /* 281 */
  44095. /***/ (function(module, exports, __webpack_require__) {
  44096. /**
  44097. * @module echarts/chart/helper/Line
  44098. */
  44099. var graphic = __webpack_require__(20);
  44100. var zrUtil = __webpack_require__(4);
  44101. /**
  44102. * @constructor
  44103. * @extends {module:zrender/graphic/Group}
  44104. * @alias {module:echarts/chart/helper/Polyline}
  44105. */
  44106. function Polyline(lineData, idx, seriesScope) {
  44107. graphic.Group.call(this);
  44108. this._createPolyline(lineData, idx, seriesScope);
  44109. }
  44110. var polylineProto = Polyline.prototype;
  44111. polylineProto._createPolyline = function (lineData, idx, seriesScope) {
  44112. // var seriesModel = lineData.hostModel;
  44113. var points = lineData.getItemLayout(idx);
  44114. var line = new graphic.Polyline({
  44115. shape: {
  44116. points: points
  44117. }
  44118. });
  44119. this.add(line);
  44120. this._updateCommonStl(lineData, idx, seriesScope);
  44121. };
  44122. polylineProto.updateData = function (lineData, idx, seriesScope) {
  44123. var seriesModel = lineData.hostModel;
  44124. var line = this.childAt(0);
  44125. var target = {
  44126. shape: {
  44127. points: lineData.getItemLayout(idx)
  44128. }
  44129. };
  44130. graphic.updateProps(line, target, seriesModel, idx);
  44131. this._updateCommonStl(lineData, idx, seriesScope);
  44132. };
  44133. polylineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  44134. var line = this.childAt(0);
  44135. var itemModel = lineData.getItemModel(idx);
  44136. var visualColor = lineData.getItemVisual(idx, 'color');
  44137. var lineStyle = seriesScope && seriesScope.lineStyle;
  44138. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  44139. if (!seriesScope || lineData.hasItemOption) {
  44140. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  44141. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  44142. }
  44143. line.useStyle(zrUtil.defaults(
  44144. {
  44145. strokeNoScale: true,
  44146. fill: 'none',
  44147. stroke: visualColor
  44148. },
  44149. lineStyle
  44150. ));
  44151. line.hoverStyle = hoverLineStyle;
  44152. graphic.setHoverStyle(this);
  44153. };
  44154. polylineProto.updateLayout = function (lineData, idx) {
  44155. var polyline = this.childAt(0);
  44156. polyline.setShape('points', lineData.getItemLayout(idx));
  44157. };
  44158. zrUtil.inherits(Polyline, graphic.Group);
  44159. module.exports = Polyline;
  44160. /***/ }),
  44161. /* 282 */
  44162. /***/ (function(module, exports, __webpack_require__) {
  44163. /**
  44164. * Provide effect for line
  44165. * @module echarts/chart/helper/EffectLine
  44166. */
  44167. var Polyline = __webpack_require__(281);
  44168. var zrUtil = __webpack_require__(4);
  44169. var EffectLine = __webpack_require__(280);
  44170. var vec2 = __webpack_require__(10);
  44171. /**
  44172. * @constructor
  44173. * @extends {module:echarts/chart/helper/EffectLine}
  44174. * @alias {module:echarts/chart/helper/Polyline}
  44175. */
  44176. function EffectPolyline(lineData, idx, seriesScope) {
  44177. EffectLine.call(this, lineData, idx, seriesScope);
  44178. this._lastFrame = 0;
  44179. this._lastFramePercent = 0;
  44180. }
  44181. var effectPolylineProto = EffectPolyline.prototype;
  44182. // Overwrite
  44183. effectPolylineProto.createLine = function (lineData, idx, seriesScope) {
  44184. return new Polyline(lineData, idx, seriesScope);
  44185. };
  44186. // Overwrite
  44187. effectPolylineProto.updateAnimationPoints = function (symbol, points) {
  44188. this._points = points;
  44189. var accLenArr = [0];
  44190. var len = 0;
  44191. for (var i = 1; i < points.length; i++) {
  44192. var p1 = points[i - 1];
  44193. var p2 = points[i];
  44194. len += vec2.dist(p1, p2);
  44195. accLenArr.push(len);
  44196. }
  44197. if (len === 0) {
  44198. return;
  44199. }
  44200. for (var i = 0; i < accLenArr.length; i++) {
  44201. accLenArr[i] /= len;
  44202. }
  44203. this._offsets = accLenArr;
  44204. this._length = len;
  44205. };
  44206. // Overwrite
  44207. effectPolylineProto.getLineLength = function (symbol) {
  44208. return this._length;
  44209. };
  44210. // Overwrite
  44211. effectPolylineProto.updateSymbolPosition = function (symbol) {
  44212. var t = symbol.__t;
  44213. var points = this._points;
  44214. var offsets = this._offsets;
  44215. var len = points.length;
  44216. if (!offsets) {
  44217. // Has length 0
  44218. return;
  44219. }
  44220. var lastFrame = this._lastFrame;
  44221. var frame;
  44222. if (t < this._lastFramePercent) {
  44223. // Start from the next frame
  44224. // PENDING start from lastFrame ?
  44225. var start = Math.min(lastFrame + 1, len - 1);
  44226. for (frame = start; frame >= 0; frame--) {
  44227. if (offsets[frame] <= t) {
  44228. break;
  44229. }
  44230. }
  44231. // PENDING really need to do this ?
  44232. frame = Math.min(frame, len - 2);
  44233. }
  44234. else {
  44235. for (var frame = lastFrame; frame < len; frame++) {
  44236. if (offsets[frame] > t) {
  44237. break;
  44238. }
  44239. }
  44240. frame = Math.min(frame - 1, len - 2);
  44241. }
  44242. vec2.lerp(
  44243. symbol.position, points[frame], points[frame + 1],
  44244. (t - offsets[frame]) / (offsets[frame + 1] - offsets[frame])
  44245. );
  44246. var tx = points[frame + 1][0] - points[frame][0];
  44247. var ty = points[frame + 1][1] - points[frame][1];
  44248. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  44249. this._lastFrame = frame;
  44250. this._lastFramePercent = t;
  44251. symbol.ignore = false;
  44252. };
  44253. zrUtil.inherits(EffectPolyline, EffectLine);
  44254. module.exports = EffectPolyline;
  44255. /***/ }),
  44256. /* 283 */
  44257. /***/ (function(module, exports, __webpack_require__) {
  44258. // TODO Batch by color
  44259. var graphic = __webpack_require__(20);
  44260. var quadraticContain = __webpack_require__(45);
  44261. var lineContain = __webpack_require__(43);
  44262. var LargeLineShape = graphic.extendShape({
  44263. shape: {
  44264. polyline: false,
  44265. segs: []
  44266. },
  44267. buildPath: function (path, shape) {
  44268. var segs = shape.segs;
  44269. var isPolyline = shape.polyline;
  44270. for (var i = 0; i < segs.length; i++) {
  44271. var seg = segs[i];
  44272. if (isPolyline) {
  44273. path.moveTo(seg[0][0], seg[0][1]);
  44274. for (var j = 1; j < seg.length; j++) {
  44275. path.lineTo(seg[j][0], seg[j][1]);
  44276. }
  44277. }
  44278. else {
  44279. path.moveTo(seg[0][0], seg[0][1]);
  44280. if (seg.length > 2) {
  44281. path.quadraticCurveTo(seg[2][0], seg[2][1], seg[1][0], seg[1][1]);
  44282. }
  44283. else {
  44284. path.lineTo(seg[1][0], seg[1][1]);
  44285. }
  44286. }
  44287. }
  44288. },
  44289. findDataIndex: function (x, y) {
  44290. var shape = this.shape;
  44291. var segs = shape.segs;
  44292. var isPolyline = shape.polyline;
  44293. var lineWidth = Math.max(this.style.lineWidth, 1);
  44294. // Not consider transform
  44295. for (var i = 0; i < segs.length; i++) {
  44296. var seg = segs[i];
  44297. if (isPolyline) {
  44298. for (var j = 1; j < seg.length; j++) {
  44299. if (lineContain.containStroke(
  44300. seg[j - 1][0], seg[j - 1][1], seg[j][0], seg[j][1], lineWidth, x, y
  44301. )) {
  44302. return i;
  44303. }
  44304. }
  44305. }
  44306. else {
  44307. if (seg.length > 2) {
  44308. if (quadraticContain.containStroke(
  44309. seg[0][0], seg[0][1], seg[2][0], seg[2][1], seg[1][0], seg[1][1], lineWidth, x, y
  44310. )) {
  44311. return i;
  44312. }
  44313. }
  44314. else {
  44315. if (lineContain.containStroke(
  44316. seg[0][0], seg[0][1], seg[1][0], seg[1][1], lineWidth, x, y
  44317. )) {
  44318. return i;
  44319. }
  44320. }
  44321. }
  44322. }
  44323. return -1;
  44324. }
  44325. });
  44326. function LargeLineDraw() {
  44327. this.group = new graphic.Group();
  44328. this._lineEl = new LargeLineShape();
  44329. }
  44330. var largeLineProto = LargeLineDraw.prototype;
  44331. /**
  44332. * Update symbols draw by new data
  44333. * @param {module:echarts/data/List} data
  44334. */
  44335. largeLineProto.updateData = function (data) {
  44336. this.group.removeAll();
  44337. var lineEl = this._lineEl;
  44338. var seriesModel = data.hostModel;
  44339. lineEl.setShape({
  44340. segs: data.mapArray(data.getItemLayout),
  44341. polyline: seriesModel.get('polyline')
  44342. });
  44343. lineEl.useStyle(
  44344. seriesModel.getModel('lineStyle.normal').getLineStyle()
  44345. );
  44346. var visualColor = data.getVisual('color');
  44347. if (visualColor) {
  44348. lineEl.setStyle('stroke', visualColor);
  44349. }
  44350. lineEl.setStyle('fill');
  44351. // Enable tooltip
  44352. // PENDING May have performance issue when path is extremely large
  44353. lineEl.seriesIndex = seriesModel.seriesIndex;
  44354. lineEl.on('mousemove', function (e) {
  44355. lineEl.dataIndex = null;
  44356. var dataIndex = lineEl.findDataIndex(e.offsetX, e.offsetY);
  44357. if (dataIndex > 0) {
  44358. // Provide dataIndex for tooltip
  44359. lineEl.dataIndex = dataIndex;
  44360. }
  44361. });
  44362. // Add back
  44363. this.group.add(lineEl);
  44364. };
  44365. largeLineProto.updateLayout = function (seriesModel) {
  44366. var data = seriesModel.getData();
  44367. this._lineEl.setShape({
  44368. segs: data.mapArray(data.getItemLayout)
  44369. });
  44370. };
  44371. largeLineProto.remove = function () {
  44372. this.group.removeAll();
  44373. };
  44374. module.exports = LargeLineDraw;
  44375. /***/ }),
  44376. /* 284 */
  44377. /***/ (function(module, exports, __webpack_require__) {
  44378. module.exports = function (ecModel) {
  44379. ecModel.eachSeriesByType('lines', function (seriesModel) {
  44380. var coordSys = seriesModel.coordinateSystem;
  44381. var lineData = seriesModel.getData();
  44382. // FIXME Use data dimensions ?
  44383. lineData.each(function (idx) {
  44384. var itemModel = lineData.getItemModel(idx);
  44385. var coords = (itemModel.option instanceof Array) ?
  44386. itemModel.option : itemModel.get('coords');
  44387. if (true) {
  44388. if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
  44389. throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
  44390. }
  44391. }
  44392. var pts = [];
  44393. if (seriesModel.get('polyline')) {
  44394. for (var i = 0; i < coords.length; i++) {
  44395. pts.push(coordSys.dataToPoint(coords[i]));
  44396. }
  44397. }
  44398. else {
  44399. pts[0] = coordSys.dataToPoint(coords[0]);
  44400. pts[1] = coordSys.dataToPoint(coords[1]);
  44401. var curveness = itemModel.get('lineStyle.normal.curveness');
  44402. if (+curveness) {
  44403. pts[2] = [
  44404. (pts[0][0] + pts[1][0]) / 2 - (pts[0][1] - pts[1][1]) * curveness,
  44405. (pts[0][1] + pts[1][1]) / 2 - (pts[1][0] - pts[0][0]) * curveness
  44406. ];
  44407. }
  44408. }
  44409. lineData.setItemLayout(idx, pts);
  44410. });
  44411. });
  44412. };
  44413. /***/ }),
  44414. /* 285 */
  44415. /***/ (function(module, exports) {
  44416. function normalize(a) {
  44417. if (!(a instanceof Array)) {
  44418. a = [a, a];
  44419. }
  44420. return a;
  44421. }
  44422. module.exports = function (ecModel) {
  44423. ecModel.eachSeriesByType('lines', function (seriesModel) {
  44424. var data = seriesModel.getData();
  44425. var symbolType = normalize(seriesModel.get('symbol'));
  44426. var symbolSize = normalize(seriesModel.get('symbolSize'));
  44427. var opacityQuery = 'lineStyle.normal.opacity'.split('.');
  44428. data.setVisual('fromSymbol', symbolType && symbolType[0]);
  44429. data.setVisual('toSymbol', symbolType && symbolType[1]);
  44430. data.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  44431. data.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  44432. data.setVisual('opacity', seriesModel.get(opacityQuery));
  44433. data.each(function (idx) {
  44434. var itemModel = data.getItemModel(idx);
  44435. var symbolType = normalize(itemModel.getShallow('symbol', true));
  44436. var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
  44437. var opacity = itemModel.get(opacityQuery);
  44438. symbolType[0] && data.setItemVisual(idx, 'fromSymbol', symbolType[0]);
  44439. symbolType[1] && data.setItemVisual(idx, 'toSymbol', symbolType[1]);
  44440. symbolSize[0] && data.setItemVisual(idx, 'fromSymbolSize', symbolSize[0]);
  44441. symbolSize[1] && data.setItemVisual(idx, 'toSymbolSize', symbolSize[1]);
  44442. data.setItemVisual(idx, 'opacity', opacity);
  44443. });
  44444. });
  44445. };
  44446. /***/ }),
  44447. /* 286 */
  44448. /***/ (function(module, exports, __webpack_require__) {
  44449. __webpack_require__(287);
  44450. __webpack_require__(288);
  44451. /***/ }),
  44452. /* 287 */
  44453. /***/ (function(module, exports, __webpack_require__) {
  44454. var SeriesModel = __webpack_require__(83);
  44455. var createListFromArray = __webpack_require__(112);
  44456. module.exports = SeriesModel.extend({
  44457. type: 'series.heatmap',
  44458. getInitialData: function (option, ecModel) {
  44459. return createListFromArray(option.data, this, ecModel);
  44460. },
  44461. defaultOption: {
  44462. // Cartesian2D or geo
  44463. coordinateSystem: 'cartesian2d',
  44464. zlevel: 0,
  44465. z: 2,
  44466. // Cartesian coordinate system
  44467. // xAxisIndex: 0,
  44468. // yAxisIndex: 0,
  44469. // Geo coordinate system
  44470. geoIndex: 0,
  44471. blurSize: 30,
  44472. pointSize: 20,
  44473. maxOpacity: 1,
  44474. minOpacity: 0
  44475. }
  44476. });
  44477. /***/ }),
  44478. /* 288 */
  44479. /***/ (function(module, exports, __webpack_require__) {
  44480. var graphic = __webpack_require__(20);
  44481. var HeatmapLayer = __webpack_require__(289);
  44482. var zrUtil = __webpack_require__(4);
  44483. function getIsInPiecewiseRange(dataExtent, pieceList, selected) {
  44484. var dataSpan = dataExtent[1] - dataExtent[0];
  44485. pieceList = zrUtil.map(pieceList, function (piece) {
  44486. return {
  44487. interval: [
  44488. (piece.interval[0] - dataExtent[0]) / dataSpan,
  44489. (piece.interval[1] - dataExtent[0]) / dataSpan
  44490. ]
  44491. };
  44492. });
  44493. var len = pieceList.length;
  44494. var lastIndex = 0;
  44495. return function (val) {
  44496. // Try to find in the location of the last found
  44497. for (var i = lastIndex; i < len; i++) {
  44498. var interval = pieceList[i].interval;
  44499. if (interval[0] <= val && val <= interval[1]) {
  44500. lastIndex = i;
  44501. break;
  44502. }
  44503. }
  44504. if (i === len) { // Not found, back interation
  44505. for (var i = lastIndex - 1; i >= 0; i--) {
  44506. var interval = pieceList[i].interval;
  44507. if (interval[0] <= val && val <= interval[1]) {
  44508. lastIndex = i;
  44509. break;
  44510. }
  44511. }
  44512. }
  44513. return i >= 0 && i < len && selected[i];
  44514. };
  44515. }
  44516. function getIsInContinuousRange(dataExtent, range) {
  44517. var dataSpan = dataExtent[1] - dataExtent[0];
  44518. range = [
  44519. (range[0] - dataExtent[0]) / dataSpan,
  44520. (range[1] - dataExtent[0]) / dataSpan
  44521. ];
  44522. return function (val) {
  44523. return val >= range[0] && val <= range[1];
  44524. };
  44525. }
  44526. function isGeoCoordSys(coordSys) {
  44527. var dimensions = coordSys.dimensions;
  44528. // Not use coorSys.type === 'geo' because coordSys maybe extended
  44529. return dimensions[0] === 'lng' && dimensions[1] === 'lat';
  44530. }
  44531. module.exports = __webpack_require__(1).extendChartView({
  44532. type: 'heatmap',
  44533. render: function (seriesModel, ecModel, api) {
  44534. var visualMapOfThisSeries;
  44535. ecModel.eachComponent('visualMap', function (visualMap) {
  44536. visualMap.eachTargetSeries(function (targetSeries) {
  44537. if (targetSeries === seriesModel) {
  44538. visualMapOfThisSeries = visualMap;
  44539. }
  44540. });
  44541. });
  44542. if (true) {
  44543. if (!visualMapOfThisSeries) {
  44544. throw new Error('Heatmap must use with visualMap');
  44545. }
  44546. }
  44547. this.group.removeAll();
  44548. var coordSys = seriesModel.coordinateSystem;
  44549. if (coordSys.type === 'cartesian2d' || coordSys.type === 'calendar') {
  44550. this._renderOnCartesianAndCalendar(coordSys, seriesModel, api);
  44551. }
  44552. else if (isGeoCoordSys(coordSys)) {
  44553. this._renderOnGeo(
  44554. coordSys, seriesModel, visualMapOfThisSeries, api
  44555. );
  44556. }
  44557. },
  44558. dispose: function () {},
  44559. _renderOnCartesianAndCalendar: function (coordSys, seriesModel, api) {
  44560. if (coordSys.type === 'cartesian2d') {
  44561. var xAxis = coordSys.getAxis('x');
  44562. var yAxis = coordSys.getAxis('y');
  44563. if (true) {
  44564. if (!(xAxis.type === 'category' && yAxis.type === 'category')) {
  44565. throw new Error('Heatmap on cartesian must have two category axes');
  44566. }
  44567. if (!(xAxis.onBand && yAxis.onBand)) {
  44568. throw new Error('Heatmap on cartesian must have two axes with boundaryGap true');
  44569. }
  44570. }
  44571. var width = xAxis.getBandWidth();
  44572. var height = yAxis.getBandWidth();
  44573. }
  44574. var group = this.group;
  44575. var data = seriesModel.getData();
  44576. var itemStyleQuery = 'itemStyle.normal';
  44577. var hoverItemStyleQuery = 'itemStyle.emphasis';
  44578. var labelQuery = 'label.normal';
  44579. var hoverLabelQuery = 'label.emphasis';
  44580. var style = seriesModel.getModel(itemStyleQuery).getItemStyle(['color']);
  44581. var hoverStl = seriesModel.getModel(hoverItemStyleQuery).getItemStyle();
  44582. var labelModel = seriesModel.getModel('label.normal');
  44583. var hoverLabelModel = seriesModel.getModel('label.emphasis');
  44584. var coordSysType = coordSys.type;
  44585. var dataDims = coordSysType === 'cartesian2d'
  44586. ? [
  44587. seriesModel.coordDimToDataDim('x')[0],
  44588. seriesModel.coordDimToDataDim('y')[0],
  44589. seriesModel.coordDimToDataDim('value')[0]
  44590. ]
  44591. : [
  44592. seriesModel.coordDimToDataDim('time')[0],
  44593. seriesModel.coordDimToDataDim('value')[0]
  44594. ];
  44595. data.each(function (idx) {
  44596. var rect;
  44597. if (coordSysType === 'cartesian2d') {
  44598. // Ignore empty data
  44599. if (isNaN(data.get(dataDims[2], idx))) {
  44600. return;
  44601. }
  44602. var point = coordSys.dataToPoint([
  44603. data.get(dataDims[0], idx),
  44604. data.get(dataDims[1], idx)
  44605. ]);
  44606. rect = new graphic.Rect({
  44607. shape: {
  44608. x: point[0] - width / 2,
  44609. y: point[1] - height / 2,
  44610. width: width,
  44611. height: height
  44612. },
  44613. style: {
  44614. fill: data.getItemVisual(idx, 'color'),
  44615. opacity: data.getItemVisual(idx, 'opacity')
  44616. }
  44617. });
  44618. }
  44619. else {
  44620. // Ignore empty data
  44621. if (isNaN(data.get(dataDims[1], idx))) {
  44622. return;
  44623. }
  44624. rect = new graphic.Rect({
  44625. z2: 1,
  44626. shape: coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape,
  44627. style: {
  44628. fill: data.getItemVisual(idx, 'color'),
  44629. opacity: data.getItemVisual(idx, 'opacity')
  44630. }
  44631. });
  44632. }
  44633. var itemModel = data.getItemModel(idx);
  44634. // Optimization for large datset
  44635. if (data.hasItemOption) {
  44636. style = itemModel.getModel(itemStyleQuery).getItemStyle(['color']);
  44637. hoverStl = itemModel.getModel(hoverItemStyleQuery).getItemStyle();
  44638. labelModel = itemModel.getModel(labelQuery);
  44639. hoverLabelModel = itemModel.getModel(hoverLabelQuery);
  44640. }
  44641. var rawValue = seriesModel.getRawValue(idx);
  44642. var defaultText = '-';
  44643. if (rawValue && rawValue[2] != null) {
  44644. defaultText = rawValue[2];
  44645. }
  44646. graphic.setLabelStyle(
  44647. style, hoverStl, labelModel, hoverLabelModel,
  44648. {
  44649. labelFetcher: seriesModel,
  44650. labelDataIndex: idx,
  44651. defaultText: defaultText,
  44652. isRectText: true
  44653. }
  44654. );
  44655. rect.setStyle(style);
  44656. graphic.setHoverStyle(rect, data.hasItemOption ? hoverStl : zrUtil.extend({}, hoverStl));
  44657. group.add(rect);
  44658. data.setItemGraphicEl(idx, rect);
  44659. });
  44660. },
  44661. _renderOnGeo: function (geo, seriesModel, visualMapModel, api) {
  44662. var inRangeVisuals = visualMapModel.targetVisuals.inRange;
  44663. var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange;
  44664. // if (!visualMapping) {
  44665. // throw new Error('Data range must have color visuals');
  44666. // }
  44667. var data = seriesModel.getData();
  44668. var hmLayer = this._hmLayer || (this._hmLayer || new HeatmapLayer());
  44669. hmLayer.blurSize = seriesModel.get('blurSize');
  44670. hmLayer.pointSize = seriesModel.get('pointSize');
  44671. hmLayer.minOpacity = seriesModel.get('minOpacity');
  44672. hmLayer.maxOpacity = seriesModel.get('maxOpacity');
  44673. var rect = geo.getViewRect().clone();
  44674. var roamTransform = geo.getRoamTransform().transform;
  44675. rect.applyTransform(roamTransform);
  44676. // Clamp on viewport
  44677. var x = Math.max(rect.x, 0);
  44678. var y = Math.max(rect.y, 0);
  44679. var x2 = Math.min(rect.width + rect.x, api.getWidth());
  44680. var y2 = Math.min(rect.height + rect.y, api.getHeight());
  44681. var width = x2 - x;
  44682. var height = y2 - y;
  44683. var points = data.mapArray(['lng', 'lat', 'value'], function (lng, lat, value) {
  44684. var pt = geo.dataToPoint([lng, lat]);
  44685. pt[0] -= x;
  44686. pt[1] -= y;
  44687. pt.push(value);
  44688. return pt;
  44689. });
  44690. var dataExtent = visualMapModel.getExtent();
  44691. var isInRange = visualMapModel.type === 'visualMap.continuous'
  44692. ? getIsInContinuousRange(dataExtent, visualMapModel.option.range)
  44693. : getIsInPiecewiseRange(
  44694. dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected
  44695. );
  44696. hmLayer.update(
  44697. points, width, height,
  44698. inRangeVisuals.color.getNormalizer(),
  44699. {
  44700. inRange: inRangeVisuals.color.getColorMapper(),
  44701. outOfRange: outOfRangeVisuals.color.getColorMapper()
  44702. },
  44703. isInRange
  44704. );
  44705. var img = new graphic.Image({
  44706. style: {
  44707. width: width,
  44708. height: height,
  44709. x: x,
  44710. y: y,
  44711. image: hmLayer.canvas
  44712. },
  44713. silent: true
  44714. });
  44715. this.group.add(img);
  44716. }
  44717. });
  44718. /***/ }),
  44719. /* 289 */
  44720. /***/ (function(module, exports, __webpack_require__) {
  44721. /**
  44722. * @file defines echarts Heatmap Chart
  44723. * @author Ovilia (me@zhangwenli.com)
  44724. * Inspired by https://github.com/mourner/simpleheat
  44725. *
  44726. * @module
  44727. */
  44728. var GRADIENT_LEVELS = 256;
  44729. var zrUtil = __webpack_require__(4);
  44730. /**
  44731. * Heatmap Chart
  44732. *
  44733. * @class
  44734. */
  44735. function Heatmap() {
  44736. var canvas = zrUtil.createCanvas();
  44737. this.canvas = canvas;
  44738. this.blurSize = 30;
  44739. this.pointSize = 20;
  44740. this.maxOpacity = 1;
  44741. this.minOpacity = 0;
  44742. this._gradientPixels = {};
  44743. }
  44744. Heatmap.prototype = {
  44745. /**
  44746. * Renders Heatmap and returns the rendered canvas
  44747. * @param {Array} data array of data, each has x, y, value
  44748. * @param {number} width canvas width
  44749. * @param {number} height canvas height
  44750. */
  44751. update: function(data, width, height, normalize, colorFunc, isInRange) {
  44752. var brush = this._getBrush();
  44753. var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
  44754. var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
  44755. var r = this.pointSize + this.blurSize;
  44756. var canvas = this.canvas;
  44757. var ctx = canvas.getContext('2d');
  44758. var len = data.length;
  44759. canvas.width = width;
  44760. canvas.height = height;
  44761. for (var i = 0; i < len; ++i) {
  44762. var p = data[i];
  44763. var x = p[0];
  44764. var y = p[1];
  44765. var value = p[2];
  44766. // calculate alpha using value
  44767. var alpha = normalize(value);
  44768. // draw with the circle brush with alpha
  44769. ctx.globalAlpha = alpha;
  44770. ctx.drawImage(brush, x - r, y - r);
  44771. }
  44772. if (!canvas.width || !canvas.height) {
  44773. // Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
  44774. // 'CanvasRenderingContext2D': The source height is 0."
  44775. return canvas;
  44776. }
  44777. // colorize the canvas using alpha value and set with gradient
  44778. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  44779. var pixels = imageData.data;
  44780. var offset = 0;
  44781. var pixelLen = pixels.length;
  44782. var minOpacity = this.minOpacity;
  44783. var maxOpacity = this.maxOpacity;
  44784. var diffOpacity = maxOpacity - minOpacity;
  44785. while(offset < pixelLen) {
  44786. var alpha = pixels[offset + 3] / 256;
  44787. var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
  44788. // Simple optimize to ignore the empty data
  44789. if (alpha > 0) {
  44790. var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
  44791. // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
  44792. alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
  44793. pixels[offset++] = gradient[gradientOffset];
  44794. pixels[offset++] = gradient[gradientOffset + 1];
  44795. pixels[offset++] = gradient[gradientOffset + 2];
  44796. pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
  44797. }
  44798. else {
  44799. offset += 4;
  44800. }
  44801. }
  44802. ctx.putImageData(imageData, 0, 0);
  44803. return canvas;
  44804. },
  44805. /**
  44806. * get canvas of a black circle brush used for canvas to draw later
  44807. * @private
  44808. * @returns {Object} circle brush canvas
  44809. */
  44810. _getBrush: function() {
  44811. var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas());
  44812. // set brush size
  44813. var r = this.pointSize + this.blurSize;
  44814. var d = r * 2;
  44815. brushCanvas.width = d;
  44816. brushCanvas.height = d;
  44817. var ctx = brushCanvas.getContext('2d');
  44818. ctx.clearRect(0, 0, d, d);
  44819. // in order to render shadow without the distinct circle,
  44820. // draw the distinct circle in an invisible place,
  44821. // and use shadowOffset to draw shadow in the center of the canvas
  44822. ctx.shadowOffsetX = d;
  44823. ctx.shadowBlur = this.blurSize;
  44824. // draw the shadow in black, and use alpha and shadow blur to generate
  44825. // color in color map
  44826. ctx.shadowColor = '#000';
  44827. // draw circle in the left to the canvas
  44828. ctx.beginPath();
  44829. ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
  44830. ctx.closePath();
  44831. ctx.fill();
  44832. return brushCanvas;
  44833. },
  44834. /**
  44835. * get gradient color map
  44836. * @private
  44837. */
  44838. _getGradient: function (data, colorFunc, state) {
  44839. var gradientPixels = this._gradientPixels;
  44840. var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
  44841. var color = [0, 0, 0, 0];
  44842. var off = 0;
  44843. for (var i = 0; i < 256; i++) {
  44844. colorFunc[state](i / 255, true, color);
  44845. pixelsSingleState[off++] = color[0];
  44846. pixelsSingleState[off++] = color[1];
  44847. pixelsSingleState[off++] = color[2];
  44848. pixelsSingleState[off++] = color[3];
  44849. }
  44850. return pixelsSingleState;
  44851. }
  44852. };
  44853. module.exports = Heatmap;
  44854. /***/ }),
  44855. /* 290 */
  44856. /***/ (function(module, exports, __webpack_require__) {
  44857. var zrUtil = __webpack_require__(4);
  44858. __webpack_require__(128);
  44859. __webpack_require__(291);
  44860. __webpack_require__(292);
  44861. var barLayoutGrid = __webpack_require__(148);
  44862. var echarts = __webpack_require__(1);
  44863. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'pictorialBar'));
  44864. echarts.registerVisual(zrUtil.curry(
  44865. __webpack_require__(124), 'pictorialBar', 'roundRect', null
  44866. ));
  44867. // In case developer forget to include grid component
  44868. __webpack_require__(127);
  44869. /***/ }),
  44870. /* 291 */
  44871. /***/ (function(module, exports, __webpack_require__) {
  44872. var PictorialBarSeries = __webpack_require__(144).extend({
  44873. type: 'series.pictorialBar',
  44874. dependencies: ['grid'],
  44875. defaultOption: {
  44876. symbol: 'circle', // Customized bar shape
  44877. symbolSize: null, // Can be ['100%', '100%'], null means auto.
  44878. symbolRotate: null,
  44879. symbolPosition: null, // 'start' or 'end' or 'center', null means auto.
  44880. symbolOffset: null,
  44881. symbolMargin: null, // start margin and end margin. Can be a number or a percent string.
  44882. // Auto margin by defualt.
  44883. symbolRepeat: false, // false/null/undefined, means no repeat.
  44884. // Can be true, means auto calculate repeat times and cut by data.
  44885. // Can be a number, specifies repeat times, and do not cut by data.
  44886. // Can be 'fixed', means auto calculate repeat times but do not cut by data.
  44887. symbolRepeatDirection: 'end', // 'end' means from 'start' to 'end'.
  44888. symbolClip: false,
  44889. symbolBoundingData: null, // Can be 60 or -40 or [-40, 60]
  44890. symbolPatternSize: 400, // 400 * 400 px
  44891. barGap: '-100%', // In most case, overlap is needed.
  44892. // z can be set in data item, which is z2 actually.
  44893. // Disable progressive
  44894. progressive: 0,
  44895. hoverAnimation: false // Open only when needed.
  44896. },
  44897. getInitialData: function (option) {
  44898. // Disable stack.
  44899. option.stack = null;
  44900. return PictorialBarSeries.superApply(this, 'getInitialData', arguments);
  44901. }
  44902. });
  44903. module.exports = PictorialBarSeries;
  44904. /***/ }),
  44905. /* 292 */
  44906. /***/ (function(module, exports, __webpack_require__) {
  44907. var zrUtil = __webpack_require__(4);
  44908. var graphic = __webpack_require__(20);
  44909. var symbolUtil = __webpack_require__(114);
  44910. var numberUtil = __webpack_require__(7);
  44911. var helper = __webpack_require__(146);
  44912. var parsePercent = numberUtil.parsePercent;
  44913. var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'normal', 'borderWidth'];
  44914. // index: +isHorizontal
  44915. var LAYOUT_ATTRS = [
  44916. {xy: 'x', wh: 'width', index: 0, posDesc: ['left', 'right']},
  44917. {xy: 'y', wh: 'height', index: 1, posDesc: ['top', 'bottom']}
  44918. ];
  44919. var pathForLineWidth = new graphic.Circle();
  44920. var BarView = __webpack_require__(1).extendChartView({
  44921. type: 'pictorialBar',
  44922. render: function (seriesModel, ecModel, api) {
  44923. var group = this.group;
  44924. var data = seriesModel.getData();
  44925. var oldData = this._data;
  44926. var cartesian = seriesModel.coordinateSystem;
  44927. var baseAxis = cartesian.getBaseAxis();
  44928. var isHorizontal = !!baseAxis.isHorizontal();
  44929. var coordSysRect = cartesian.grid.getRect();
  44930. var opt = {
  44931. ecSize: {width: api.getWidth(), height: api.getHeight()},
  44932. seriesModel: seriesModel,
  44933. coordSys: cartesian,
  44934. coordSysExtent: [
  44935. [coordSysRect.x, coordSysRect.x + coordSysRect.width],
  44936. [coordSysRect.y, coordSysRect.y + coordSysRect.height]
  44937. ],
  44938. isHorizontal: isHorizontal,
  44939. valueDim: LAYOUT_ATTRS[+isHorizontal],
  44940. categoryDim: LAYOUT_ATTRS[1 - isHorizontal]
  44941. };
  44942. data.diff(oldData)
  44943. .add(function (dataIndex) {
  44944. if (!data.hasValue(dataIndex)) {
  44945. return;
  44946. }
  44947. var itemModel = getItemModel(data, dataIndex);
  44948. var symbolMeta = getSymbolMeta(data, dataIndex, itemModel, opt);
  44949. var bar = createBar(data, opt, symbolMeta);
  44950. data.setItemGraphicEl(dataIndex, bar);
  44951. group.add(bar);
  44952. updateCommon(bar, opt, symbolMeta);
  44953. })
  44954. .update(function (newIndex, oldIndex) {
  44955. var bar = oldData.getItemGraphicEl(oldIndex);
  44956. if (!data.hasValue(newIndex)) {
  44957. group.remove(bar);
  44958. return;
  44959. }
  44960. var itemModel = getItemModel(data, newIndex);
  44961. var symbolMeta = getSymbolMeta(data, newIndex, itemModel, opt);
  44962. var pictorialShapeStr = getShapeStr(data, symbolMeta);
  44963. if (bar && pictorialShapeStr !== bar.__pictorialShapeStr) {
  44964. group.remove(bar);
  44965. data.setItemGraphicEl(newIndex, null);
  44966. bar = null;
  44967. }
  44968. if (bar) {
  44969. updateBar(bar, opt, symbolMeta);
  44970. }
  44971. else {
  44972. bar = createBar(data, opt, symbolMeta, true);
  44973. }
  44974. data.setItemGraphicEl(newIndex, bar);
  44975. bar.__pictorialSymbolMeta = symbolMeta;
  44976. // Add back
  44977. group.add(bar);
  44978. updateCommon(bar, opt, symbolMeta);
  44979. })
  44980. .remove(function (dataIndex) {
  44981. var bar = oldData.getItemGraphicEl(dataIndex);
  44982. bar && removeBar(oldData, dataIndex, bar.__pictorialSymbolMeta.animationModel, bar);
  44983. })
  44984. .execute();
  44985. this._data = data;
  44986. return this.group;
  44987. },
  44988. dispose: zrUtil.noop,
  44989. remove: function (ecModel, api) {
  44990. var group = this.group;
  44991. var data = this._data;
  44992. if (ecModel.get('animation')) {
  44993. if (data) {
  44994. data.eachItemGraphicEl(function (bar) {
  44995. removeBar(data, bar.dataIndex, ecModel, bar);
  44996. });
  44997. }
  44998. }
  44999. else {
  45000. group.removeAll();
  45001. }
  45002. }
  45003. });
  45004. // Set or calculate default value about symbol, and calculate layout info.
  45005. function getSymbolMeta(data, dataIndex, itemModel, opt) {
  45006. var layout = data.getItemLayout(dataIndex);
  45007. var symbolRepeat = itemModel.get('symbolRepeat');
  45008. var symbolClip = itemModel.get('symbolClip');
  45009. var symbolPosition = itemModel.get('symbolPosition') || 'start';
  45010. var symbolRotate = itemModel.get('symbolRotate');
  45011. var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  45012. var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
  45013. var isAnimationEnabled = itemModel.isAnimationEnabled();
  45014. var symbolMeta = {
  45015. dataIndex: dataIndex,
  45016. layout: layout,
  45017. itemModel: itemModel,
  45018. symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
  45019. color: data.getItemVisual(dataIndex, 'color'),
  45020. symbolClip: symbolClip,
  45021. symbolRepeat: symbolRepeat,
  45022. symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
  45023. symbolPatternSize: symbolPatternSize,
  45024. rotation: rotation,
  45025. animationModel: isAnimationEnabled ? itemModel : null,
  45026. hoverAnimation: isAnimationEnabled && itemModel.get('hoverAnimation'),
  45027. z2: itemModel.getShallow('z', true) || 0
  45028. };
  45029. prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
  45030. prepareSymbolSize(
  45031. data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength,
  45032. symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta
  45033. );
  45034. prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
  45035. var symbolSize = symbolMeta.symbolSize;
  45036. var symbolOffset = itemModel.get('symbolOffset');
  45037. if (zrUtil.isArray(symbolOffset)) {
  45038. symbolOffset = [
  45039. parsePercent(symbolOffset[0], symbolSize[0]),
  45040. parsePercent(symbolOffset[1], symbolSize[1])
  45041. ];
  45042. }
  45043. prepareLayoutInfo(
  45044. itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
  45045. symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength,
  45046. opt, symbolMeta
  45047. );
  45048. return symbolMeta;
  45049. }
  45050. // bar length can be negative.
  45051. function prepareBarLength(itemModel, symbolRepeat, layout, opt, output) {
  45052. var valueDim = opt.valueDim;
  45053. var symbolBoundingData = itemModel.get('symbolBoundingData');
  45054. var valueAxis = opt.coordSys.getOtherAxis(opt.coordSys.getBaseAxis());
  45055. var zeroPx = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
  45056. var pxSignIdx = 1 - +(layout[valueDim.wh] <= 0);
  45057. var boundingLength;
  45058. if (zrUtil.isArray(symbolBoundingData)) {
  45059. var symbolBoundingExtent = [
  45060. convertToCoordOnAxis(valueAxis, symbolBoundingData[0]) - zeroPx,
  45061. convertToCoordOnAxis(valueAxis, symbolBoundingData[1]) - zeroPx
  45062. ];
  45063. symbolBoundingExtent[1] < symbolBoundingExtent[0] && (symbolBoundingExtent.reverse());
  45064. boundingLength = symbolBoundingExtent[pxSignIdx];
  45065. }
  45066. else if (symbolBoundingData != null) {
  45067. boundingLength = convertToCoordOnAxis(valueAxis, symbolBoundingData) - zeroPx;
  45068. }
  45069. else if (symbolRepeat) {
  45070. boundingLength = opt.coordSysExtent[valueDim.index][pxSignIdx] - zeroPx;
  45071. }
  45072. else {
  45073. boundingLength = layout[valueDim.wh];
  45074. }
  45075. output.boundingLength = boundingLength;
  45076. if (symbolRepeat) {
  45077. output.repeatCutLength = layout[valueDim.wh];
  45078. }
  45079. output.pxSign = boundingLength > 0 ? 1 : boundingLength < 0 ? -1 : 0;
  45080. }
  45081. function convertToCoordOnAxis(axis, value) {
  45082. return axis.toGlobalCoord(axis.dataToCoord(axis.scale.parse(value)));
  45083. }
  45084. // Support ['100%', '100%']
  45085. function prepareSymbolSize(
  45086. data, dataIndex, layout, symbolRepeat, symbolClip, boundingLength,
  45087. pxSign, symbolPatternSize, opt, output
  45088. ) {
  45089. var valueDim = opt.valueDim;
  45090. var categoryDim = opt.categoryDim;
  45091. var categorySize = Math.abs(layout[categoryDim.wh]);
  45092. var symbolSize = data.getItemVisual(dataIndex, 'symbolSize');
  45093. if (zrUtil.isArray(symbolSize)) {
  45094. symbolSize = symbolSize.slice();
  45095. }
  45096. else {
  45097. if (symbolSize == null) {
  45098. symbolSize = '100%';
  45099. }
  45100. symbolSize = [symbolSize, symbolSize];
  45101. }
  45102. // Note: percentage symbolSize (like '100%') do not consider lineWidth, because it is
  45103. // to complicated to calculate real percent value if considering scaled lineWidth.
  45104. // So the actual size will bigger than layout size if lineWidth is bigger than zero,
  45105. // which can be tolerated in pictorial chart.
  45106. symbolSize[categoryDim.index] = parsePercent(
  45107. symbolSize[categoryDim.index],
  45108. categorySize
  45109. );
  45110. symbolSize[valueDim.index] = parsePercent(
  45111. symbolSize[valueDim.index],
  45112. symbolRepeat ? categorySize : Math.abs(boundingLength)
  45113. );
  45114. output.symbolSize = symbolSize;
  45115. // If x or y is less than zero, show reversed shape.
  45116. var symbolScale = output.symbolScale = [
  45117. symbolSize[0] / symbolPatternSize,
  45118. symbolSize[1] / symbolPatternSize
  45119. ];
  45120. // Follow convention, 'right' and 'top' is the normal scale.
  45121. symbolScale[valueDim.index] *= (opt.isHorizontal ? -1 : 1) * pxSign;
  45122. }
  45123. function prepareLineWidth(itemModel, symbolScale, rotation, opt, output) {
  45124. // In symbols are drawn with scale, so do not need to care about the case that width
  45125. // or height are too small. But symbol use strokeNoScale, where acture lineWidth should
  45126. // be calculated.
  45127. var valueLineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
  45128. if (valueLineWidth) {
  45129. pathForLineWidth.attr({
  45130. scale: symbolScale.slice(),
  45131. rotation: rotation
  45132. });
  45133. pathForLineWidth.updateTransform();
  45134. valueLineWidth /= pathForLineWidth.getLineScale();
  45135. valueLineWidth *= symbolScale[opt.valueDim.index];
  45136. }
  45137. output.valueLineWidth = valueLineWidth;
  45138. }
  45139. function prepareLayoutInfo(
  45140. itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
  45141. symbolPosition, valueLineWidth, boundingLength, repeatCutLength, opt, output
  45142. ) {
  45143. var categoryDim = opt.categoryDim;
  45144. var valueDim = opt.valueDim;
  45145. var pxSign = output.pxSign;
  45146. var unitLength = Math.max(symbolSize[valueDim.index] + valueLineWidth, 0);
  45147. var pathLen = unitLength;
  45148. // Note: rotation will not effect the layout of symbols, because user may
  45149. // want symbols to rotate on its center, which should not be translated
  45150. // when rotating.
  45151. if (symbolRepeat) {
  45152. var absBoundingLength = Math.abs(boundingLength);
  45153. var symbolMargin = zrUtil.retrieve(itemModel.get('symbolMargin'), '15%') + '';
  45154. var hasEndGap = false;
  45155. if (symbolMargin.lastIndexOf('!') === symbolMargin.length - 1) {
  45156. hasEndGap = true;
  45157. symbolMargin = symbolMargin.slice(0, symbolMargin.length - 1);
  45158. }
  45159. symbolMargin = parsePercent(symbolMargin, symbolSize[valueDim.index]);
  45160. var uLenWithMargin = Math.max(unitLength + symbolMargin * 2, 0);
  45161. // When symbol margin is less than 0, margin at both ends will be subtracted
  45162. // to ensure that all of the symbols will not be overflow the given area.
  45163. var endFix = hasEndGap ? 0 : symbolMargin * 2;
  45164. // Both final repeatTimes and final symbolMargin area calculated based on
  45165. // boundingLength.
  45166. var repeatSpecified = numberUtil.isNumeric(symbolRepeat);
  45167. var repeatTimes = repeatSpecified
  45168. ? symbolRepeat
  45169. : toIntTimes((absBoundingLength + endFix) / uLenWithMargin);
  45170. // Adjust calculate margin, to ensure each symbol is displayed
  45171. // entirely in the given layout area.
  45172. var mDiff = absBoundingLength - repeatTimes * unitLength;
  45173. symbolMargin = mDiff / 2 / (hasEndGap ? repeatTimes : repeatTimes - 1);
  45174. uLenWithMargin = unitLength + symbolMargin * 2;
  45175. endFix = hasEndGap ? 0 : symbolMargin * 2;
  45176. // Update repeatTimes when not all symbol will be shown.
  45177. if (!repeatSpecified && symbolRepeat !== 'fixed') {
  45178. repeatTimes = repeatCutLength
  45179. ? toIntTimes((Math.abs(repeatCutLength) + endFix) / uLenWithMargin)
  45180. : 0;
  45181. }
  45182. pathLen = repeatTimes * uLenWithMargin - endFix;
  45183. output.repeatTimes = repeatTimes;
  45184. output.symbolMargin = symbolMargin;
  45185. }
  45186. var sizeFix = pxSign * (pathLen / 2);
  45187. var pathPosition = output.pathPosition = [];
  45188. pathPosition[categoryDim.index] = layout[categoryDim.wh] / 2;
  45189. pathPosition[valueDim.index] = symbolPosition === 'start'
  45190. ? sizeFix
  45191. : symbolPosition === 'end'
  45192. ? boundingLength - sizeFix
  45193. : boundingLength / 2; // 'center'
  45194. if (symbolOffset) {
  45195. pathPosition[0] += symbolOffset[0];
  45196. pathPosition[1] += symbolOffset[1];
  45197. }
  45198. var bundlePosition = output.bundlePosition = [];
  45199. bundlePosition[categoryDim.index] = layout[categoryDim.xy];
  45200. bundlePosition[valueDim.index] = layout[valueDim.xy];
  45201. var barRectShape = output.barRectShape = zrUtil.extend({}, layout);
  45202. barRectShape[valueDim.wh] = pxSign * Math.max(
  45203. Math.abs(layout[valueDim.wh]), Math.abs(pathPosition[valueDim.index] + sizeFix)
  45204. );
  45205. barRectShape[categoryDim.wh] = layout[categoryDim.wh];
  45206. var clipShape = output.clipShape = {};
  45207. // Consider that symbol may be overflow layout rect.
  45208. clipShape[categoryDim.xy] = -layout[categoryDim.xy];
  45209. clipShape[categoryDim.wh] = opt.ecSize[categoryDim.wh];
  45210. clipShape[valueDim.xy] = 0;
  45211. clipShape[valueDim.wh] = layout[valueDim.wh];
  45212. }
  45213. function createPath(symbolMeta) {
  45214. var symbolPatternSize = symbolMeta.symbolPatternSize;
  45215. var path = symbolUtil.createSymbol(
  45216. // Consider texture img, make a big size.
  45217. symbolMeta.symbolType,
  45218. -symbolPatternSize / 2,
  45219. -symbolPatternSize / 2,
  45220. symbolPatternSize,
  45221. symbolPatternSize,
  45222. symbolMeta.color
  45223. );
  45224. path.attr({
  45225. culling: true
  45226. });
  45227. path.type !== 'image' && path.setStyle({
  45228. strokeNoScale: true
  45229. });
  45230. return path;
  45231. }
  45232. function createOrUpdateRepeatSymbols(bar, opt, symbolMeta, isUpdate) {
  45233. var bundle = bar.__pictorialBundle;
  45234. var symbolSize = symbolMeta.symbolSize;
  45235. var valueLineWidth = symbolMeta.valueLineWidth;
  45236. var pathPosition = symbolMeta.pathPosition;
  45237. var valueDim = opt.valueDim;
  45238. var repeatTimes = symbolMeta.repeatTimes || 0;
  45239. var index = 0;
  45240. var unit = symbolSize[opt.valueDim.index] + valueLineWidth + symbolMeta.symbolMargin * 2;
  45241. eachPath(bar, function (path) {
  45242. path.__pictorialAnimationIndex = index;
  45243. path.__pictorialRepeatTimes = repeatTimes;
  45244. if (index < repeatTimes) {
  45245. updateAttr(path, null, makeTarget(index), symbolMeta, isUpdate);
  45246. }
  45247. else {
  45248. updateAttr(path, null, {scale: [0, 0]}, symbolMeta, isUpdate, function () {
  45249. bundle.remove(path);
  45250. });
  45251. }
  45252. updateHoverAnimation(path, symbolMeta);
  45253. index++;
  45254. });
  45255. for (; index < repeatTimes; index++) {
  45256. var path = createPath(symbolMeta);
  45257. path.__pictorialAnimationIndex = index;
  45258. path.__pictorialRepeatTimes = repeatTimes;
  45259. bundle.add(path);
  45260. var target = makeTarget(index);
  45261. updateAttr(
  45262. path,
  45263. {
  45264. position: target.position,
  45265. scale: [0, 0]
  45266. },
  45267. {
  45268. scale: target.scale,
  45269. rotation: target.rotation
  45270. },
  45271. symbolMeta,
  45272. isUpdate
  45273. );
  45274. // FIXME
  45275. // If all emphasis/normal through action.
  45276. path
  45277. .on('mouseover', onMouseOver)
  45278. .on('mouseout', onMouseOut);
  45279. updateHoverAnimation(path, symbolMeta);
  45280. }
  45281. function makeTarget(index) {
  45282. var position = pathPosition.slice();
  45283. // (start && pxSign > 0) || (end && pxSign < 0): i = repeatTimes - index
  45284. // Otherwise: i = index;
  45285. var pxSign = symbolMeta.pxSign;
  45286. var i = index;
  45287. if (symbolMeta.symbolRepeatDirection === 'start' ? pxSign > 0 : pxSign < 0) {
  45288. i = repeatTimes - 1 - index;
  45289. }
  45290. position[valueDim.index] = unit * (i - repeatTimes / 2 + 0.5) + pathPosition[valueDim.index];
  45291. return {
  45292. position: position,
  45293. scale: symbolMeta.symbolScale.slice(),
  45294. rotation: symbolMeta.rotation
  45295. };
  45296. }
  45297. function onMouseOver() {
  45298. eachPath(bar, function (path) {
  45299. path.trigger('emphasis');
  45300. });
  45301. }
  45302. function onMouseOut() {
  45303. eachPath(bar, function (path) {
  45304. path.trigger('normal');
  45305. });
  45306. }
  45307. }
  45308. function createOrUpdateSingleSymbol(bar, opt, symbolMeta, isUpdate) {
  45309. var bundle = bar.__pictorialBundle;
  45310. var mainPath = bar.__pictorialMainPath;
  45311. if (!mainPath) {
  45312. mainPath = bar.__pictorialMainPath = createPath(symbolMeta);
  45313. bundle.add(mainPath);
  45314. updateAttr(
  45315. mainPath,
  45316. {
  45317. position: symbolMeta.pathPosition.slice(),
  45318. scale: [0, 0],
  45319. rotation: symbolMeta.rotation
  45320. },
  45321. {
  45322. scale: symbolMeta.symbolScale.slice()
  45323. },
  45324. symbolMeta,
  45325. isUpdate
  45326. );
  45327. mainPath
  45328. .on('mouseover', onMouseOver)
  45329. .on('mouseout', onMouseOut);
  45330. }
  45331. else {
  45332. updateAttr(
  45333. mainPath,
  45334. null,
  45335. {
  45336. position: symbolMeta.pathPosition.slice(),
  45337. scale: symbolMeta.symbolScale.slice(),
  45338. rotation: symbolMeta.rotation
  45339. },
  45340. symbolMeta,
  45341. isUpdate
  45342. );
  45343. }
  45344. updateHoverAnimation(mainPath, symbolMeta);
  45345. function onMouseOver() {
  45346. this.trigger('emphasis');
  45347. }
  45348. function onMouseOut() {
  45349. this.trigger('normal');
  45350. }
  45351. }
  45352. // bar rect is used for label.
  45353. function createOrUpdateBarRect(bar, symbolMeta, isUpdate) {
  45354. var rectShape = zrUtil.extend({}, symbolMeta.barRectShape);
  45355. var barRect = bar.__pictorialBarRect;
  45356. if (!barRect) {
  45357. barRect = bar.__pictorialBarRect = new graphic.Rect({
  45358. z2: 2,
  45359. shape: rectShape,
  45360. silent: true,
  45361. style: {
  45362. stroke: 'transparent',
  45363. fill: 'transparent',
  45364. lineWidth: 0
  45365. }
  45366. });
  45367. bar.add(barRect);
  45368. }
  45369. else {
  45370. updateAttr(barRect, null, {shape: rectShape}, symbolMeta, isUpdate);
  45371. }
  45372. }
  45373. function createOrUpdateClip(bar, opt, symbolMeta, isUpdate) {
  45374. // If not clip, symbol will be remove and rebuilt.
  45375. if (symbolMeta.symbolClip) {
  45376. var clipPath = bar.__pictorialClipPath;
  45377. var clipShape = zrUtil.extend({}, symbolMeta.clipShape);
  45378. var valueDim = opt.valueDim;
  45379. var animationModel = symbolMeta.animationModel;
  45380. var dataIndex = symbolMeta.dataIndex;
  45381. if (clipPath) {
  45382. graphic.updateProps(
  45383. clipPath, {shape: clipShape}, animationModel, dataIndex
  45384. );
  45385. }
  45386. else {
  45387. clipShape[valueDim.wh] = 0;
  45388. clipPath = new graphic.Rect({shape: clipShape});
  45389. bar.__pictorialBundle.setClipPath(clipPath);
  45390. bar.__pictorialClipPath = clipPath;
  45391. var target = {};
  45392. target[valueDim.wh] = symbolMeta.clipShape[valueDim.wh];
  45393. graphic[isUpdate ? 'updateProps' : 'initProps'](
  45394. clipPath, {shape: target}, animationModel, dataIndex
  45395. );
  45396. }
  45397. }
  45398. }
  45399. function getItemModel(data, dataIndex) {
  45400. var itemModel = data.getItemModel(dataIndex);
  45401. itemModel.getAnimationDelayParams = getAnimationDelayParams;
  45402. itemModel.isAnimationEnabled = isAnimationEnabled;
  45403. return itemModel;
  45404. }
  45405. function getAnimationDelayParams(path) {
  45406. // The order is the same as the z-order, see `symbolRepeatDiretion`.
  45407. return {
  45408. index: path.__pictorialAnimationIndex,
  45409. count: path.__pictorialRepeatTimes
  45410. };
  45411. }
  45412. function isAnimationEnabled() {
  45413. // `animation` prop can be set on itemModel in pictorial bar chart.
  45414. return this.parentModel.isAnimationEnabled() && !!this.getShallow('animation');
  45415. }
  45416. function updateHoverAnimation(path, symbolMeta) {
  45417. path.off('emphasis').off('normal');
  45418. var scale = symbolMeta.symbolScale.slice();
  45419. symbolMeta.hoverAnimation && path
  45420. .on('emphasis', function() {
  45421. this.animateTo({
  45422. scale: [scale[0] * 1.1, scale[1] * 1.1]
  45423. }, 400, 'elasticOut');
  45424. })
  45425. .on('normal', function() {
  45426. this.animateTo({
  45427. scale: scale.slice()
  45428. }, 400, 'elasticOut');
  45429. });
  45430. }
  45431. function createBar(data, opt, symbolMeta, isUpdate) {
  45432. // bar is the main element for each data.
  45433. var bar = new graphic.Group();
  45434. // bundle is used for location and clip.
  45435. var bundle = new graphic.Group();
  45436. bar.add(bundle);
  45437. bar.__pictorialBundle = bundle;
  45438. bundle.attr('position', symbolMeta.bundlePosition.slice());
  45439. if (symbolMeta.symbolRepeat) {
  45440. createOrUpdateRepeatSymbols(bar, opt, symbolMeta);
  45441. }
  45442. else {
  45443. createOrUpdateSingleSymbol(bar, opt, symbolMeta);
  45444. }
  45445. createOrUpdateBarRect(bar, symbolMeta, isUpdate);
  45446. createOrUpdateClip(bar, opt, symbolMeta, isUpdate);
  45447. bar.__pictorialShapeStr = getShapeStr(data, symbolMeta);
  45448. bar.__pictorialSymbolMeta = symbolMeta;
  45449. return bar;
  45450. }
  45451. function updateBar(bar, opt, symbolMeta) {
  45452. var animationModel = symbolMeta.animationModel;
  45453. var dataIndex = symbolMeta.dataIndex;
  45454. var bundle = bar.__pictorialBundle;
  45455. graphic.updateProps(
  45456. bundle, {position: symbolMeta.bundlePosition.slice()}, animationModel, dataIndex
  45457. );
  45458. if (symbolMeta.symbolRepeat) {
  45459. createOrUpdateRepeatSymbols(bar, opt, symbolMeta, true);
  45460. }
  45461. else {
  45462. createOrUpdateSingleSymbol(bar, opt, symbolMeta, true);
  45463. }
  45464. createOrUpdateBarRect(bar, symbolMeta, true);
  45465. createOrUpdateClip(bar, opt, symbolMeta, true);
  45466. }
  45467. function removeBar(data, dataIndex, animationModel, bar) {
  45468. // Not show text when animating
  45469. var labelRect = bar.__pictorialBarRect;
  45470. labelRect && (labelRect.style.text = null);
  45471. var pathes = [];
  45472. eachPath(bar, function (path) {
  45473. pathes.push(path);
  45474. });
  45475. bar.__pictorialMainPath && pathes.push(bar.__pictorialMainPath);
  45476. // I do not find proper remove animation for clip yet.
  45477. bar.__pictorialClipPath && (animationModel = null);
  45478. zrUtil.each(pathes, function (path) {
  45479. graphic.updateProps(
  45480. path, {scale: [0, 0]}, animationModel, dataIndex,
  45481. function () {
  45482. bar.parent && bar.parent.remove(bar);
  45483. }
  45484. );
  45485. });
  45486. data.setItemGraphicEl(dataIndex, null);
  45487. }
  45488. function getShapeStr(data, symbolMeta) {
  45489. return [
  45490. data.getItemVisual(symbolMeta.dataIndex, 'symbol') || 'none',
  45491. !!symbolMeta.symbolRepeat,
  45492. !!symbolMeta.symbolClip
  45493. ].join(':');
  45494. }
  45495. function eachPath(bar, cb, context) {
  45496. // Do not use Group#eachChild, because it do not support remove.
  45497. zrUtil.each(bar.__pictorialBundle.children(), function (el) {
  45498. el !== bar.__pictorialBarRect && cb.call(context, el);
  45499. });
  45500. }
  45501. function updateAttr(el, immediateAttrs, animationAttrs, symbolMeta, isUpdate, cb) {
  45502. immediateAttrs && el.attr(immediateAttrs);
  45503. // when symbolCip used, only clip path has init animation, otherwise it would be weird effect.
  45504. if (symbolMeta.symbolClip && !isUpdate) {
  45505. animationAttrs && el.attr(animationAttrs);
  45506. }
  45507. else {
  45508. animationAttrs && graphic[isUpdate ? 'updateProps' : 'initProps'](
  45509. el, animationAttrs, symbolMeta.animationModel, symbolMeta.dataIndex, cb
  45510. );
  45511. }
  45512. }
  45513. function updateCommon(bar, opt, symbolMeta) {
  45514. var color = symbolMeta.color;
  45515. var dataIndex = symbolMeta.dataIndex;
  45516. var itemModel = symbolMeta.itemModel;
  45517. // Color must be excluded.
  45518. // Because symbol provide setColor individually to set fill and stroke
  45519. var normalStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  45520. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  45521. var cursorStyle = itemModel.getShallow('cursor');
  45522. eachPath(bar, function (path) {
  45523. // PENDING setColor should be before setStyle!!!
  45524. path.setColor(color);
  45525. path.setStyle(zrUtil.defaults(
  45526. {
  45527. fill: color,
  45528. opacity: symbolMeta.opacity
  45529. },
  45530. normalStyle
  45531. ));
  45532. graphic.setHoverStyle(path, hoverStyle);
  45533. cursorStyle && (path.cursor = cursorStyle);
  45534. path.z2 = symbolMeta.z2;
  45535. });
  45536. var barRectHoverStyle = {};
  45537. var barPositionOutside = opt.valueDim.posDesc[+(symbolMeta.boundingLength > 0)];
  45538. var barRect = bar.__pictorialBarRect;
  45539. helper.setLabel(
  45540. barRect.style, barRectHoverStyle, itemModel,
  45541. color, opt.seriesModel, dataIndex, barPositionOutside
  45542. );
  45543. graphic.setHoverStyle(barRect, barRectHoverStyle);
  45544. }
  45545. function toIntTimes(times) {
  45546. var roundedTimes = Math.round(times);
  45547. // Escapse accurate error
  45548. return Math.abs(times - roundedTimes) < 1e-4
  45549. ? roundedTimes
  45550. : Math.ceil(times);
  45551. }
  45552. module.exports = BarView;
  45553. /***/ }),
  45554. /* 293 */
  45555. /***/ (function(module, exports, __webpack_require__) {
  45556. var echarts = __webpack_require__(1);
  45557. var zrUtil = __webpack_require__(4);
  45558. __webpack_require__(294);
  45559. __webpack_require__(311);
  45560. __webpack_require__(312);
  45561. echarts.registerLayout(__webpack_require__(314));
  45562. echarts.registerVisual(__webpack_require__(315));
  45563. echarts.registerProcessor(
  45564. zrUtil.curry(__webpack_require__(157), 'themeRiver')
  45565. );
  45566. /***/ }),
  45567. /* 294 */
  45568. /***/ (function(module, exports, __webpack_require__) {
  45569. __webpack_require__(295);
  45570. __webpack_require__(298);
  45571. __webpack_require__(300);
  45572. __webpack_require__(301);
  45573. __webpack_require__(310);
  45574. var echarts = __webpack_require__(1);
  45575. echarts.extendComponentView({
  45576. type: 'single'
  45577. });
  45578. /***/ }),
  45579. /* 295 */
  45580. /***/ (function(module, exports, __webpack_require__) {
  45581. /**
  45582. * Single coordinate system creator.
  45583. */
  45584. var Single = __webpack_require__(296);
  45585. /**
  45586. * Create single coordinate system and inject it into seriesModel.
  45587. *
  45588. * @param {module:echarts/model/Global} ecModel
  45589. * @param {module:echarts/ExtensionAPI} api
  45590. * @return {Array.<module:echarts/coord/single/Single>}
  45591. */
  45592. function create(ecModel, api) {
  45593. var singles = [];
  45594. ecModel.eachComponent('singleAxis', function(axisModel, idx) {
  45595. var single = new Single(axisModel, ecModel, api);
  45596. single.name = 'single_' + idx;
  45597. single.resize(axisModel, api);
  45598. axisModel.coordinateSystem = single;
  45599. singles.push(single);
  45600. });
  45601. ecModel.eachSeries(function (seriesModel) {
  45602. if (seriesModel.get('coordinateSystem') === 'singleAxis') {
  45603. var singleAxisModel = ecModel.queryComponents({
  45604. mainType: 'singleAxis',
  45605. index: seriesModel.get('singleAxisIndex'),
  45606. id: seriesModel.get('singleAxisId')
  45607. })[0];
  45608. seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
  45609. }
  45610. });
  45611. return singles;
  45612. }
  45613. __webpack_require__(79).register('single', {
  45614. create: create,
  45615. dimensions: Single.prototype.dimensions
  45616. });
  45617. /***/ }),
  45618. /* 296 */
  45619. /***/ (function(module, exports, __webpack_require__) {
  45620. /**
  45621. * Single coordinates system.
  45622. */
  45623. var SingleAxis = __webpack_require__(297);
  45624. var axisHelper = __webpack_require__(104);
  45625. var layout = __webpack_require__(74);
  45626. /**
  45627. * Create a single coordinates system.
  45628. *
  45629. * @param {module:echarts/coord/single/AxisModel} axisModel
  45630. * @param {module:echarts/model/Global} ecModel
  45631. * @param {module:echarts/ExtensionAPI} api
  45632. */
  45633. function Single(axisModel, ecModel, api) {
  45634. /**
  45635. * @type {string}
  45636. * @readOnly
  45637. */
  45638. this.dimension = 'single';
  45639. /**
  45640. * Add it just for draw tooltip.
  45641. *
  45642. * @type {Array.<string>}
  45643. * @readOnly
  45644. */
  45645. this.dimensions = ['single'];
  45646. /**
  45647. * @private
  45648. * @type {module:echarts/coord/single/SingleAxis}.
  45649. */
  45650. this._axis = null;
  45651. /**
  45652. * @private
  45653. * @type {module:zrender/core/BoundingRect}
  45654. */
  45655. this._rect;
  45656. this._init(axisModel, ecModel, api);
  45657. /**
  45658. * @type {module:echarts/coord/single/AxisModel}
  45659. */
  45660. this.model = axisModel;
  45661. }
  45662. Single.prototype = {
  45663. type: 'singleAxis',
  45664. axisPointerEnabled: true,
  45665. constructor: Single,
  45666. /**
  45667. * Initialize single coordinate system.
  45668. *
  45669. * @param {module:echarts/coord/single/AxisModel} axisModel
  45670. * @param {module:echarts/model/Global} ecModel
  45671. * @param {module:echarts/ExtensionAPI} api
  45672. * @private
  45673. */
  45674. _init: function (axisModel, ecModel, api) {
  45675. var dim = this.dimension;
  45676. var axis = new SingleAxis(
  45677. dim,
  45678. axisHelper.createScaleByModel(axisModel),
  45679. [0, 0],
  45680. axisModel.get('type'),
  45681. axisModel.get('position')
  45682. );
  45683. var isCategory = axis.type === 'category';
  45684. axis.onBand = isCategory && axisModel.get('boundaryGap');
  45685. axis.inverse = axisModel.get('inverse');
  45686. axis.orient = axisModel.get('orient');
  45687. axisModel.axis = axis;
  45688. axis.model = axisModel;
  45689. axis.coordinateSystem = this;
  45690. this._axis = axis;
  45691. },
  45692. /**
  45693. * Update axis scale after data processed
  45694. * @param {module:echarts/model/Global} ecModel
  45695. * @param {module:echarts/ExtensionAPI} api
  45696. */
  45697. update: function (ecModel, api) {
  45698. ecModel.eachSeries(function (seriesModel) {
  45699. if (seriesModel.coordinateSystem === this) {
  45700. var data = seriesModel.getData();
  45701. var dim = this.dimension;
  45702. this._axis.scale.unionExtentFromData(
  45703. data, seriesModel.coordDimToDataDim(dim)
  45704. );
  45705. axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
  45706. }
  45707. }, this);
  45708. },
  45709. /**
  45710. * Resize the single coordinate system.
  45711. *
  45712. * @param {module:echarts/coord/single/AxisModel} axisModel
  45713. * @param {module:echarts/ExtensionAPI} api
  45714. */
  45715. resize: function (axisModel, api) {
  45716. this._rect = layout.getLayoutRect(
  45717. {
  45718. left: axisModel.get('left'),
  45719. top: axisModel.get('top'),
  45720. right: axisModel.get('right'),
  45721. bottom: axisModel.get('bottom'),
  45722. width: axisModel.get('width'),
  45723. height: axisModel.get('height')
  45724. },
  45725. {
  45726. width: api.getWidth(),
  45727. height: api.getHeight()
  45728. }
  45729. );
  45730. this._adjustAxis();
  45731. },
  45732. /**
  45733. * @return {module:zrender/core/BoundingRect}
  45734. */
  45735. getRect: function () {
  45736. return this._rect;
  45737. },
  45738. /**
  45739. * @private
  45740. */
  45741. _adjustAxis: function () {
  45742. var rect = this._rect;
  45743. var axis = this._axis;
  45744. var isHorizontal = axis.isHorizontal();
  45745. var extent = isHorizontal ? [0, rect.width] : [0, rect.height];
  45746. var idx = axis.reverse ? 1 : 0;
  45747. axis.setExtent(extent[idx], extent[1 - idx]);
  45748. this._updateAxisTransform(axis, isHorizontal ? rect.x : rect.y);
  45749. },
  45750. /**
  45751. * @param {module:echarts/coord/single/SingleAxis} axis
  45752. * @param {number} coordBase
  45753. */
  45754. _updateAxisTransform: function (axis, coordBase) {
  45755. var axisExtent = axis.getExtent();
  45756. var extentSum = axisExtent[0] + axisExtent[1];
  45757. var isHorizontal = axis.isHorizontal();
  45758. axis.toGlobalCoord = isHorizontal
  45759. ? function (coord) {
  45760. return coord + coordBase;
  45761. }
  45762. : function (coord) {
  45763. return extentSum - coord + coordBase;
  45764. };
  45765. axis.toLocalCoord = isHorizontal
  45766. ? function (coord) {
  45767. return coord - coordBase;
  45768. }
  45769. : function (coord) {
  45770. return extentSum - coord + coordBase;
  45771. };
  45772. },
  45773. /**
  45774. * Get axis.
  45775. *
  45776. * @return {module:echarts/coord/single/SingleAxis}
  45777. */
  45778. getAxis: function () {
  45779. return this._axis;
  45780. },
  45781. /**
  45782. * Get axis, add it just for draw tooltip.
  45783. *
  45784. * @return {[type]} [description]
  45785. */
  45786. getBaseAxis: function () {
  45787. return this._axis;
  45788. },
  45789. /**
  45790. * @return {Array.<module:echarts/coord/Axis>}
  45791. */
  45792. getAxes: function () {
  45793. return [this._axis];
  45794. },
  45795. /**
  45796. * @return {Object} {baseAxes: [], otherAxes: []}
  45797. */
  45798. getTooltipAxes: function () {
  45799. return {baseAxes: [this.getAxis()]};
  45800. },
  45801. /**
  45802. * If contain point.
  45803. *
  45804. * @param {Array.<number>} point
  45805. * @return {boolean}
  45806. */
  45807. containPoint: function (point) {
  45808. var rect = this.getRect();
  45809. var axis = this.getAxis();
  45810. var orient = axis.orient;
  45811. if (orient === 'horizontal') {
  45812. return axis.contain(axis.toLocalCoord(point[0]))
  45813. && (point[1] >= rect.y && point[1] <= (rect.y + rect.height));
  45814. }
  45815. else {
  45816. return axis.contain(axis.toLocalCoord(point[1]))
  45817. && (point[0] >= rect.y && point[0] <= (rect.y + rect.height));
  45818. }
  45819. },
  45820. /**
  45821. * @param {Array.<number>} point
  45822. * @return {Array.<number>}
  45823. */
  45824. pointToData: function (point) {
  45825. var axis = this.getAxis();
  45826. return [axis.coordToData(axis.toLocalCoord(
  45827. point[axis.orient === 'horizontal' ? 0 : 1]
  45828. ))];
  45829. },
  45830. /**
  45831. * Convert the series data to concrete point.
  45832. *
  45833. * @param {number|Array.<number>} val
  45834. * @return {Array.<number>}
  45835. */
  45836. dataToPoint: function (val) {
  45837. var axis = this.getAxis();
  45838. var rect = this.getRect();
  45839. var pt = [];
  45840. var idx = axis.orient === 'horizontal' ? 0 : 1;
  45841. if (val instanceof Array) {
  45842. val = val[0];
  45843. }
  45844. pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
  45845. pt[1 - idx] = idx === 0 ? (rect.y + rect.height / 2) : (rect.x + rect.width / 2);
  45846. return pt;
  45847. }
  45848. };
  45849. module.exports = Single;
  45850. /***/ }),
  45851. /* 297 */
  45852. /***/ (function(module, exports, __webpack_require__) {
  45853. var zrUtil = __webpack_require__(4);
  45854. var Axis = __webpack_require__(103);
  45855. /**
  45856. * @constructor module:echarts/coord/single/SingleAxis
  45857. * @extends {module:echarts/coord/Axis}
  45858. * @param {string} dim
  45859. * @param {*} scale
  45860. * @param {Array.<number>} coordExtent
  45861. * @param {string} axisType
  45862. * @param {string} position
  45863. */
  45864. var SingleAxis = function (dim, scale, coordExtent, axisType, position) {
  45865. Axis.call(this, dim, scale, coordExtent);
  45866. /**
  45867. * Axis type
  45868. * - 'category'
  45869. * - 'value'
  45870. * - 'time'
  45871. * - 'log'
  45872. * @type {string}
  45873. */
  45874. this.type = axisType || 'value';
  45875. /**
  45876. * Axis position
  45877. * - 'top'
  45878. * - 'bottom'
  45879. * - 'left'
  45880. * - 'right'
  45881. * @type {string}
  45882. */
  45883. this.position = position || 'bottom';
  45884. /**
  45885. * Axis orient
  45886. * - 'horizontal'
  45887. * - 'vertical'
  45888. * @type {[type]}
  45889. */
  45890. this.orient = null;
  45891. /**
  45892. * @type {number}
  45893. */
  45894. this._labelInterval = null;
  45895. };
  45896. SingleAxis.prototype = {
  45897. constructor: SingleAxis,
  45898. /**
  45899. * Axis model
  45900. * @type {module:echarts/coord/single/AxisModel}
  45901. */
  45902. model: null,
  45903. /**
  45904. * Judge the orient of the axis.
  45905. * @return {boolean}
  45906. */
  45907. isHorizontal: function () {
  45908. var position = this.position;
  45909. return position === 'top' || position === 'bottom';
  45910. },
  45911. /**
  45912. * @override
  45913. */
  45914. pointToData: function (point, clamp) {
  45915. return this.coordinateSystem.pointToData(point, clamp)[0];
  45916. },
  45917. /**
  45918. * Convert the local coord(processed by dataToCoord())
  45919. * to global coord(concrete pixel coord).
  45920. * designated by module:echarts/coord/single/Single.
  45921. * @type {Function}
  45922. */
  45923. toGlobalCoord: null,
  45924. /**
  45925. * Convert the global coord to local coord.
  45926. * designated by module:echarts/coord/single/Single.
  45927. * @type {Function}
  45928. */
  45929. toLocalCoord: null
  45930. };
  45931. zrUtil.inherits(SingleAxis, Axis);
  45932. module.exports = SingleAxis;
  45933. /***/ }),
  45934. /* 298 */
  45935. /***/ (function(module, exports, __webpack_require__) {
  45936. var AxisBuilder = __webpack_require__(138);
  45937. var zrUtil = __webpack_require__(4);
  45938. var graphic = __webpack_require__(20);
  45939. var singleAxisHelper = __webpack_require__(299);
  45940. var getInterval = AxisBuilder.getInterval;
  45941. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  45942. var axisBuilderAttrs = [
  45943. 'axisLine', 'axisTickLabel', 'axisName'
  45944. ];
  45945. var selfBuilderAttr = 'splitLine';
  45946. var SingleAxisView = __webpack_require__(139).extend({
  45947. type: 'singleAxis',
  45948. axisPointerClass: 'SingleAxisPointer',
  45949. render: function (axisModel, ecModel, api, payload) {
  45950. var group = this.group;
  45951. group.removeAll();
  45952. var layout = singleAxisHelper.layout(axisModel);
  45953. var axisBuilder = new AxisBuilder(axisModel, layout);
  45954. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  45955. group.add(axisBuilder.getGroup());
  45956. if (axisModel.get(selfBuilderAttr + '.show')) {
  45957. this['_' + selfBuilderAttr](axisModel, layout.labelInterval);
  45958. }
  45959. SingleAxisView.superCall(this, 'render', axisModel, ecModel, api, payload);
  45960. },
  45961. _splitLine: function(axisModel, labelInterval) {
  45962. var axis = axisModel.axis;
  45963. if (axis.scale.isBlank()) {
  45964. return;
  45965. }
  45966. var splitLineModel = axisModel.getModel('splitLine');
  45967. var lineStyleModel = splitLineModel.getModel('lineStyle');
  45968. var lineWidth = lineStyleModel.get('width');
  45969. var lineColors = lineStyleModel.get('color');
  45970. var lineInterval = getInterval(splitLineModel, labelInterval);
  45971. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  45972. var gridRect = axisModel.coordinateSystem.getRect();
  45973. var isHorizontal = axis.isHorizontal();
  45974. var splitLines = [];
  45975. var lineCount = 0;
  45976. var ticksCoords = axis.getTicksCoords();
  45977. var p1 = [];
  45978. var p2 = [];
  45979. var showMinLabel = axisModel.get('axisLabel.showMinLabel');
  45980. var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
  45981. for (var i = 0; i < ticksCoords.length; ++i) {
  45982. if (ifIgnoreOnTick(
  45983. axis, i, lineInterval, ticksCoords.length,
  45984. showMinLabel, showMaxLabel
  45985. )) {
  45986. continue;
  45987. }
  45988. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  45989. if (isHorizontal) {
  45990. p1[0] = tickCoord;
  45991. p1[1] = gridRect.y;
  45992. p2[0] = tickCoord;
  45993. p2[1] = gridRect.y + gridRect.height;
  45994. }
  45995. else {
  45996. p1[0] = gridRect.x;
  45997. p1[1] = tickCoord;
  45998. p2[0] = gridRect.x + gridRect.width;
  45999. p2[1] = tickCoord;
  46000. }
  46001. var colorIndex = (lineCount++) % lineColors.length;
  46002. splitLines[colorIndex] = splitLines[colorIndex] || [];
  46003. splitLines[colorIndex].push(new graphic.Line(
  46004. graphic.subPixelOptimizeLine({
  46005. shape: {
  46006. x1: p1[0],
  46007. y1: p1[1],
  46008. x2: p2[0],
  46009. y2: p2[1]
  46010. },
  46011. style: {
  46012. lineWidth: lineWidth
  46013. },
  46014. silent: true
  46015. })));
  46016. }
  46017. for (var i = 0; i < splitLines.length; ++i) {
  46018. this.group.add(graphic.mergePath(splitLines[i], {
  46019. style: {
  46020. stroke: lineColors[i % lineColors.length],
  46021. lineDash: lineStyleModel.getLineDash(lineWidth),
  46022. lineWidth: lineWidth
  46023. },
  46024. silent: true
  46025. }));
  46026. }
  46027. }
  46028. });
  46029. module.exports = SingleAxisView;
  46030. /***/ }),
  46031. /* 299 */
  46032. /***/ (function(module, exports, __webpack_require__) {
  46033. var zrUtil = __webpack_require__(4);
  46034. var helper = {};
  46035. /**
  46036. * @param {Object} opt {labelInside}
  46037. * @return {Object} {
  46038. * position, rotation, labelDirection, labelOffset,
  46039. * tickDirection, labelRotate, labelInterval, z2
  46040. * }
  46041. */
  46042. helper.layout = function (axisModel, opt) {
  46043. opt = opt || {};
  46044. var single = axisModel.coordinateSystem;
  46045. var axis = axisModel.axis;
  46046. var layout = {};
  46047. var axisPosition = axis.position;
  46048. var orient = axis.orient;
  46049. var rect = single.getRect();
  46050. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  46051. var positionMap = {
  46052. horizontal: {top: rectBound[2], bottom: rectBound[3]},
  46053. vertical: {left: rectBound[0], right: rectBound[1]}
  46054. };
  46055. layout.position = [
  46056. orient === 'vertical'
  46057. ? positionMap.vertical[axisPosition]
  46058. : rectBound[0],
  46059. orient === 'horizontal'
  46060. ? positionMap.horizontal[axisPosition]
  46061. : rectBound[3]
  46062. ];
  46063. var r = {horizontal: 0, vertical: 1};
  46064. layout.rotation = Math.PI / 2 * r[orient];
  46065. var directionMap = {top: -1, bottom: 1, right: 1, left: -1};
  46066. layout.labelDirection = layout.tickDirection
  46067. = layout.nameDirection
  46068. = directionMap[axisPosition];
  46069. if (axisModel.get('axisTick.inside')) {
  46070. layout.tickDirection = -layout.tickDirection;
  46071. }
  46072. if (zrUtil.retrieve(opt.labelInside, axisModel.get('axisLabel.inside'))) {
  46073. layout.labelDirection = -layout.labelDirection;
  46074. }
  46075. var labelRotation = opt.rotate;
  46076. labelRotation == null && (labelRotation = axisModel.get('axisLabel.rotate'));
  46077. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  46078. layout.labelInterval = axis.getLabelInterval();
  46079. layout.z2 = 1;
  46080. return layout;
  46081. };
  46082. module.exports = helper;
  46083. /***/ }),
  46084. /* 300 */
  46085. /***/ (function(module, exports, __webpack_require__) {
  46086. var ComponentModel = __webpack_require__(72);
  46087. var axisModelCreator = __webpack_require__(134);
  46088. var zrUtil = __webpack_require__(4);
  46089. var AxisModel = ComponentModel.extend({
  46090. type: 'singleAxis',
  46091. layoutMode: 'box',
  46092. /**
  46093. * @type {module:echarts/coord/single/SingleAxis}
  46094. */
  46095. axis: null,
  46096. /**
  46097. * @type {module:echarts/coord/single/Single}
  46098. */
  46099. coordinateSystem: null,
  46100. /**
  46101. * @override
  46102. */
  46103. getCoordSysModel: function () {
  46104. return this;
  46105. }
  46106. });
  46107. var defaultOption = {
  46108. left: '5%',
  46109. top: '5%',
  46110. right: '5%',
  46111. bottom: '5%',
  46112. type: 'value',
  46113. position: 'bottom',
  46114. orient: 'horizontal',
  46115. axisLine: {
  46116. show: true,
  46117. lineStyle: {
  46118. width: 2,
  46119. type: 'solid'
  46120. }
  46121. },
  46122. // Single coordinate system and single axis is the,
  46123. // which is used as the parent tooltip model.
  46124. // same model, so we set default tooltip show as true.
  46125. tooltip: {
  46126. show: true
  46127. },
  46128. axisTick: {
  46129. show: true,
  46130. length: 6,
  46131. lineStyle: {
  46132. width: 2
  46133. }
  46134. },
  46135. axisLabel: {
  46136. show: true,
  46137. interval: 'auto'
  46138. },
  46139. splitLine: {
  46140. show: true,
  46141. lineStyle: {
  46142. type: 'dashed',
  46143. opacity: 0.2
  46144. }
  46145. }
  46146. };
  46147. function getAxisType(axisName, option) {
  46148. return option.type || (option.data ? 'category' : 'value');
  46149. }
  46150. zrUtil.merge(AxisModel.prototype, __webpack_require__(115));
  46151. axisModelCreator('single', AxisModel, getAxisType, defaultOption);
  46152. module.exports = AxisModel;
  46153. /***/ }),
  46154. /* 301 */
  46155. /***/ (function(module, exports, __webpack_require__) {
  46156. var echarts = __webpack_require__(1);
  46157. var axisPointerModelHelper = __webpack_require__(140);
  46158. var axisTrigger = __webpack_require__(302);
  46159. var zrUtil = __webpack_require__(4);
  46160. __webpack_require__(304);
  46161. __webpack_require__(305);
  46162. // CartesianAxisPointer is not supposed to be required here. But consider
  46163. // echarts.simple.js and online build tooltip, which only require gridSimple,
  46164. // CartesianAxisPointer should be able to required somewhere.
  46165. __webpack_require__(307);
  46166. echarts.registerPreprocessor(function (option) {
  46167. // Always has a global axisPointerModel for default setting.
  46168. if (option) {
  46169. (!option.axisPointer || option.axisPointer.length === 0)
  46170. && (option.axisPointer = {});
  46171. var link = option.axisPointer.link;
  46172. // Normalize to array to avoid object mergin. But if link
  46173. // is not set, remain null/undefined, otherwise it will
  46174. // override existent link setting.
  46175. if (link && !zrUtil.isArray(link)) {
  46176. option.axisPointer.link = [link];
  46177. }
  46178. }
  46179. });
  46180. // This process should proformed after coordinate systems created
  46181. // and series data processed. So put it on statistic processing stage.
  46182. echarts.registerProcessor(echarts.PRIORITY.PROCESSOR.STATISTIC, function (ecModel, api) {
  46183. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  46184. // allAxesInfo should be updated when setOption performed.
  46185. ecModel.getComponent('axisPointer').coordSysAxesInfo
  46186. = axisPointerModelHelper.collect(ecModel, api);
  46187. });
  46188. // Broadcast to all views.
  46189. echarts.registerAction({
  46190. type: 'updateAxisPointer',
  46191. event: 'updateAxisPointer',
  46192. update: ':updateAxisPointer'
  46193. }, axisTrigger);
  46194. /***/ }),
  46195. /* 302 */
  46196. /***/ (function(module, exports, __webpack_require__) {
  46197. var zrUtil = __webpack_require__(4);
  46198. var modelUtil = __webpack_require__(5);
  46199. var modelHelper = __webpack_require__(140);
  46200. var findPointFromSeries = __webpack_require__(303);
  46201. var each = zrUtil.each;
  46202. var curry = zrUtil.curry;
  46203. var get = modelUtil.makeGetter();
  46204. /**
  46205. * Basic logic: check all axis, if they do not demand show/highlight,
  46206. * then hide/downplay them.
  46207. *
  46208. * @param {Object} coordSysAxesInfo
  46209. * @param {Object} payload
  46210. * @param {string} [payload.currTrigger] 'click' | 'mousemove' | 'leave'
  46211. * @param {Array.<number>} [payload.x] x and y, which are mandatory, specify a point to
  46212. * trigger axisPointer and tooltip.
  46213. * @param {Array.<number>} [payload.y] x and y, which are mandatory, specify a point to
  46214. * trigger axisPointer and tooltip.
  46215. * @param {Object} [payload.seriesIndex] finder, optional, restrict target axes.
  46216. * @param {Object} [payload.dataIndex] finder, restrict target axes.
  46217. * @param {Object} [payload.axesInfo] finder, restrict target axes.
  46218. * [{
  46219. * axisDim: 'x'|'y'|'angle'|...,
  46220. * axisIndex: ...,
  46221. * value: ...
  46222. * }, ...]
  46223. * @param {Function} [payload.dispatchAction]
  46224. * @param {Object} [payload.tooltipOption]
  46225. * @param {Object|Array.<number>|Function} [payload.position] Tooltip position,
  46226. * which can be specified in dispatchAction
  46227. * @param {module:echarts/model/Global} ecModel
  46228. * @param {module:echarts/ExtensionAPI} api
  46229. * @return {Object} content of event obj for echarts.connect.
  46230. */
  46231. function axisTrigger(payload, ecModel, api) {
  46232. var currTrigger = payload.currTrigger;
  46233. var point = [payload.x, payload.y];
  46234. var finder = payload;
  46235. var dispatchAction = payload.dispatchAction || zrUtil.bind(api.dispatchAction, api);
  46236. var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo;
  46237. // Pending
  46238. // See #6121. But we are not able to reproduce it yet.
  46239. if (!coordSysAxesInfo) {
  46240. return;
  46241. }
  46242. if (illegalPoint(point)) {
  46243. // Used in the default behavior of `connection`: use the sample seriesIndex
  46244. // and dataIndex. And also used in the tooltipView trigger.
  46245. point = findPointFromSeries({
  46246. seriesIndex: finder.seriesIndex,
  46247. // Do not use dataIndexInside from other ec instance.
  46248. // FIXME: auto detect it?
  46249. dataIndex: finder.dataIndex
  46250. }, ecModel).point;
  46251. }
  46252. var isIllegalPoint = illegalPoint(point);
  46253. // Axis and value can be specified when calling dispatchAction({type: 'updateAxisPointer'}).
  46254. // Notice: In this case, it is difficult to get the `point` (which is necessary to show
  46255. // tooltip, so if point is not given, we just use the point found by sample seriesIndex
  46256. // and dataIndex.
  46257. var inputAxesInfo = finder.axesInfo;
  46258. var axesInfo = coordSysAxesInfo.axesInfo;
  46259. var shouldHide = currTrigger === 'leave' || illegalPoint(point);
  46260. var outputFinder = {};
  46261. var showValueMap = {};
  46262. var dataByCoordSys = {list: [], map: {}};
  46263. var updaters = {
  46264. showPointer: curry(showPointer, showValueMap),
  46265. showTooltip: curry(showTooltip, dataByCoordSys)
  46266. };
  46267. // Process for triggered axes.
  46268. each(coordSysAxesInfo.coordSysMap, function (coordSys, coordSysKey) {
  46269. // If a point given, it must be contained by the coordinate system.
  46270. var coordSysContainsPoint = isIllegalPoint || coordSys.containPoint(point);
  46271. each(coordSysAxesInfo.coordSysAxesInfo[coordSysKey], function (axisInfo, key) {
  46272. var axis = axisInfo.axis;
  46273. var inputAxisInfo = findInputAxisInfo(inputAxesInfo, axisInfo);
  46274. // If no inputAxesInfo, no axis is restricted.
  46275. if (!shouldHide && coordSysContainsPoint && (!inputAxesInfo || inputAxisInfo)) {
  46276. var val = inputAxisInfo && inputAxisInfo.value;
  46277. if (val == null && !isIllegalPoint) {
  46278. val = axis.pointToData(point);
  46279. }
  46280. val != null && processOnAxis(axisInfo, val, updaters, false, outputFinder);
  46281. }
  46282. });
  46283. });
  46284. // Process for linked axes.
  46285. var linkTriggers = {};
  46286. each(axesInfo, function (tarAxisInfo, tarKey) {
  46287. var linkGroup = tarAxisInfo.linkGroup;
  46288. // If axis has been triggered in the previous stage, it should not be triggered by link.
  46289. if (linkGroup && !showValueMap[tarKey]) {
  46290. each(linkGroup.axesInfo, function (srcAxisInfo, srcKey) {
  46291. var srcValItem = showValueMap[srcKey];
  46292. // If srcValItem exist, source axis is triggered, so link to target axis.
  46293. if (srcAxisInfo !== tarAxisInfo && srcValItem) {
  46294. var val = srcValItem.value;
  46295. linkGroup.mapper && (val = tarAxisInfo.axis.scale.parse(linkGroup.mapper(
  46296. val, makeMapperParam(srcAxisInfo), makeMapperParam(tarAxisInfo)
  46297. )));
  46298. linkTriggers[tarAxisInfo.key] = val;
  46299. }
  46300. });
  46301. }
  46302. });
  46303. each(linkTriggers, function (val, tarKey) {
  46304. processOnAxis(axesInfo[tarKey], val, updaters, true, outputFinder);
  46305. });
  46306. updateModelActually(showValueMap, axesInfo, outputFinder);
  46307. dispatchTooltipActually(dataByCoordSys, point, payload, dispatchAction);
  46308. dispatchHighDownActually(axesInfo, dispatchAction, api);
  46309. return outputFinder;
  46310. }
  46311. function processOnAxis(axisInfo, newValue, updaters, dontSnap, outputFinder) {
  46312. var axis = axisInfo.axis;
  46313. if (axis.scale.isBlank() || !axis.containData(newValue)) {
  46314. return;
  46315. }
  46316. if (!axisInfo.involveSeries) {
  46317. updaters.showPointer(axisInfo, newValue);
  46318. return;
  46319. }
  46320. // Heavy calculation. So put it after axis.containData checking.
  46321. var payloadInfo = buildPayloadsBySeries(newValue, axisInfo);
  46322. var payloadBatch = payloadInfo.payloadBatch;
  46323. var snapToValue = payloadInfo.snapToValue;
  46324. // Fill content of event obj for echarts.connect.
  46325. // By defualt use the first involved series data as a sample to connect.
  46326. if (payloadBatch[0] && outputFinder.seriesIndex == null) {
  46327. zrUtil.extend(outputFinder, payloadBatch[0]);
  46328. }
  46329. // If no linkSource input, this process is for collecting link
  46330. // target, where snap should not be accepted.
  46331. if (!dontSnap && axisInfo.snap) {
  46332. if (axis.containData(snapToValue) && snapToValue != null) {
  46333. newValue = snapToValue;
  46334. }
  46335. }
  46336. updaters.showPointer(axisInfo, newValue, payloadBatch, outputFinder);
  46337. // Tooltip should always be snapToValue, otherwise there will be
  46338. // incorrect "axis value ~ series value" mapping displayed in tooltip.
  46339. updaters.showTooltip(axisInfo, payloadInfo, snapToValue);
  46340. }
  46341. function buildPayloadsBySeries(value, axisInfo) {
  46342. var axis = axisInfo.axis;
  46343. var dim = axis.dim;
  46344. var snapToValue = value;
  46345. var payloadBatch = [];
  46346. var minDist = Number.MAX_VALUE;
  46347. var minDiff = -1;
  46348. each(axisInfo.seriesModels, function (series, idx) {
  46349. var dataDim = series.coordDimToDataDim(dim);
  46350. var seriesNestestValue;
  46351. var dataIndices;
  46352. if (series.getAxisTooltipData) {
  46353. var result = series.getAxisTooltipData(dataDim, value, axis);
  46354. dataIndices = result.dataIndices;
  46355. seriesNestestValue = result.nestestValue;
  46356. }
  46357. else {
  46358. dataIndices = series.getData().indicesOfNearest(
  46359. dataDim[0],
  46360. value,
  46361. // Add a threshold to avoid find the wrong dataIndex
  46362. // when data length is not same.
  46363. false, axis.type === 'category' ? 0.5 : null
  46364. );
  46365. if (!dataIndices.length) {
  46366. return;
  46367. }
  46368. seriesNestestValue = series.getData().get(dataDim[0], dataIndices[0]);
  46369. }
  46370. if (seriesNestestValue == null || !isFinite(seriesNestestValue)) {
  46371. return;
  46372. }
  46373. var diff = value - seriesNestestValue;
  46374. var dist = Math.abs(diff);
  46375. // Consider category case
  46376. if (dist <= minDist) {
  46377. if (dist < minDist || (diff >= 0 && minDiff < 0)) {
  46378. minDist = dist;
  46379. minDiff = diff;
  46380. snapToValue = seriesNestestValue;
  46381. payloadBatch.length = 0;
  46382. }
  46383. each(dataIndices, function (dataIndex) {
  46384. payloadBatch.push({
  46385. seriesIndex: series.seriesIndex,
  46386. dataIndexInside: dataIndex,
  46387. dataIndex: series.getData().getRawIndex(dataIndex)
  46388. });
  46389. });
  46390. }
  46391. });
  46392. return {
  46393. payloadBatch: payloadBatch,
  46394. snapToValue: snapToValue
  46395. };
  46396. }
  46397. function showPointer(showValueMap, axisInfo, value, payloadBatch) {
  46398. showValueMap[axisInfo.key] = {value: value, payloadBatch: payloadBatch};
  46399. }
  46400. function showTooltip(dataByCoordSys, axisInfo, payloadInfo, value) {
  46401. var payloadBatch = payloadInfo.payloadBatch;
  46402. var axis = axisInfo.axis;
  46403. var axisModel = axis.model;
  46404. var axisPointerModel = axisInfo.axisPointerModel;
  46405. // If no data, do not create anything in dataByCoordSys,
  46406. // whose length will be used to judge whether dispatch action.
  46407. if (!axisInfo.triggerTooltip || !payloadBatch.length) {
  46408. return;
  46409. }
  46410. var coordSysModel = axisInfo.coordSys.model;
  46411. var coordSysKey = modelHelper.makeKey(coordSysModel);
  46412. var coordSysItem = dataByCoordSys.map[coordSysKey];
  46413. if (!coordSysItem) {
  46414. coordSysItem = dataByCoordSys.map[coordSysKey] = {
  46415. coordSysId: coordSysModel.id,
  46416. coordSysIndex: coordSysModel.componentIndex,
  46417. coordSysType: coordSysModel.type,
  46418. coordSysMainType: coordSysModel.mainType,
  46419. dataByAxis: []
  46420. };
  46421. dataByCoordSys.list.push(coordSysItem);
  46422. }
  46423. coordSysItem.dataByAxis.push({
  46424. axisDim: axis.dim,
  46425. axisIndex: axisModel.componentIndex,
  46426. axisType: axisModel.type,
  46427. axisId: axisModel.id,
  46428. value: value,
  46429. // Caustion: viewHelper.getValueLabel is actually on "view stage", which
  46430. // depends that all models have been updated. So it should not be performed
  46431. // here. Considering axisPointerModel used here is volatile, which is hard
  46432. // to be retrieve in TooltipView, we prepare parameters here.
  46433. valueLabelOpt: {
  46434. precision: axisPointerModel.get('label.precision'),
  46435. formatter: axisPointerModel.get('label.formatter')
  46436. },
  46437. seriesDataIndices: payloadBatch.slice()
  46438. });
  46439. }
  46440. function updateModelActually(showValueMap, axesInfo, outputFinder) {
  46441. var outputAxesInfo = outputFinder.axesInfo = [];
  46442. // Basic logic: If no 'show' required, 'hide' this axisPointer.
  46443. each(axesInfo, function (axisInfo, key) {
  46444. var option = axisInfo.axisPointerModel.option;
  46445. var valItem = showValueMap[key];
  46446. if (valItem) {
  46447. !axisInfo.useHandle && (option.status = 'show');
  46448. option.value = valItem.value;
  46449. // For label formatter param and highlight.
  46450. option.seriesDataIndices = (valItem.payloadBatch || []).slice();
  46451. }
  46452. // When always show (e.g., handle used), remain
  46453. // original value and status.
  46454. else {
  46455. // If hide, value still need to be set, consider
  46456. // click legend to toggle axis blank.
  46457. !axisInfo.useHandle && (option.status = 'hide');
  46458. }
  46459. // If status is 'hide', should be no info in payload.
  46460. option.status === 'show' && outputAxesInfo.push({
  46461. axisDim: axisInfo.axis.dim,
  46462. axisIndex: axisInfo.axis.model.componentIndex,
  46463. value: option.value
  46464. });
  46465. });
  46466. }
  46467. function dispatchTooltipActually(dataByCoordSys, point, payload, dispatchAction) {
  46468. // Basic logic: If no showTip required, hideTip will be dispatched.
  46469. if (illegalPoint(point) || !dataByCoordSys.list.length) {
  46470. dispatchAction({type: 'hideTip'});
  46471. return;
  46472. }
  46473. // In most case only one axis (or event one series is used). It is
  46474. // convinient to fetch payload.seriesIndex and payload.dataIndex
  46475. // dirtectly. So put the first seriesIndex and dataIndex of the first
  46476. // axis on the payload.
  46477. var sampleItem = ((dataByCoordSys.list[0].dataByAxis[0] || {}).seriesDataIndices || [])[0] || {};
  46478. dispatchAction({
  46479. type: 'showTip',
  46480. escapeConnect: true,
  46481. x: point[0],
  46482. y: point[1],
  46483. tooltipOption: payload.tooltipOption,
  46484. position: payload.position,
  46485. dataIndexInside: sampleItem.dataIndexInside,
  46486. dataIndex: sampleItem.dataIndex,
  46487. seriesIndex: sampleItem.seriesIndex,
  46488. dataByCoordSys: dataByCoordSys.list
  46489. });
  46490. }
  46491. function dispatchHighDownActually(axesInfo, dispatchAction, api) {
  46492. // FIXME
  46493. // highlight status modification shoule be a stage of main process?
  46494. // (Consider confilct (e.g., legend and axisPointer) and setOption)
  46495. var zr = api.getZr();
  46496. var highDownKey = 'axisPointerLastHighlights';
  46497. var lastHighlights = get(zr)[highDownKey] || {};
  46498. var newHighlights = get(zr)[highDownKey] = {};
  46499. // Update highlight/downplay status according to axisPointer model.
  46500. // Build hash map and remove duplicate incidentally.
  46501. each(axesInfo, function (axisInfo, key) {
  46502. var option = axisInfo.axisPointerModel.option;
  46503. option.status === 'show' && each(option.seriesDataIndices, function (batchItem) {
  46504. var key = batchItem.seriesIndex + ' | ' + batchItem.dataIndex;
  46505. newHighlights[key] = batchItem;
  46506. });
  46507. });
  46508. // Diff.
  46509. var toHighlight = [];
  46510. var toDownplay = [];
  46511. zrUtil.each(lastHighlights, function (batchItem, key) {
  46512. !newHighlights[key] && toDownplay.push(batchItem);
  46513. });
  46514. zrUtil.each(newHighlights, function (batchItem, key) {
  46515. !lastHighlights[key] && toHighlight.push(batchItem);
  46516. });
  46517. toDownplay.length && api.dispatchAction({
  46518. type: 'downplay', escapeConnect: true, batch: toDownplay
  46519. });
  46520. toHighlight.length && api.dispatchAction({
  46521. type: 'highlight', escapeConnect: true, batch: toHighlight
  46522. });
  46523. }
  46524. function findInputAxisInfo(inputAxesInfo, axisInfo) {
  46525. for (var i = 0; i < (inputAxesInfo || []).length; i++) {
  46526. var inputAxisInfo = inputAxesInfo[i];
  46527. if (axisInfo.axis.dim === inputAxisInfo.axisDim
  46528. && axisInfo.axis.model.componentIndex === inputAxisInfo.axisIndex
  46529. ) {
  46530. return inputAxisInfo;
  46531. }
  46532. }
  46533. }
  46534. function makeMapperParam(axisInfo) {
  46535. var axisModel = axisInfo.axis.model;
  46536. var item = {};
  46537. var dim = item.axisDim = axisInfo.axis.dim;
  46538. item.axisIndex = item[dim + 'AxisIndex'] = axisModel.componentIndex;
  46539. item.axisName = item[dim + 'AxisName'] = axisModel.name;
  46540. item.axisId = item[dim + 'AxisId'] = axisModel.id;
  46541. return item;
  46542. }
  46543. function illegalPoint(point) {
  46544. return !point || point[0] == null || isNaN(point[0]) || point[1] == null || isNaN(point[1]);
  46545. }
  46546. module.exports = axisTrigger;
  46547. /***/ }),
  46548. /* 303 */
  46549. /***/ (function(module, exports, __webpack_require__) {
  46550. var zrUtil = __webpack_require__(4);
  46551. var modelUtil = __webpack_require__(5);
  46552. /**
  46553. * @param {Object} finder contains {seriesIndex, dataIndex, dataIndexInside}
  46554. * @param {module:echarts/model/Global} ecModel
  46555. * @return {Object} {point: [x, y], el: ...} point Will not be null.
  46556. */
  46557. module.exports = function (finder, ecModel) {
  46558. var point = [];
  46559. var seriesIndex = finder.seriesIndex;
  46560. var seriesModel;
  46561. if (seriesIndex == null || !(
  46562. seriesModel = ecModel.getSeriesByIndex(seriesIndex)
  46563. )) {
  46564. return {point: []};
  46565. }
  46566. var data = seriesModel.getData();
  46567. var dataIndex = modelUtil.queryDataIndex(data, finder);
  46568. if (dataIndex == null || zrUtil.isArray(dataIndex)) {
  46569. return {point: []};
  46570. }
  46571. var el = data.getItemGraphicEl(dataIndex);
  46572. var coordSys = seriesModel.coordinateSystem;
  46573. if (seriesModel.getTooltipPosition) {
  46574. point = seriesModel.getTooltipPosition(dataIndex) || [];
  46575. }
  46576. else if (coordSys && coordSys.dataToPoint) {
  46577. point = coordSys.dataToPoint(
  46578. data.getValues(
  46579. zrUtil.map(coordSys.dimensions, function (dim) {
  46580. return seriesModel.coordDimToDataDim(dim)[0];
  46581. }), dataIndex, true
  46582. )
  46583. ) || [];
  46584. }
  46585. else if (el) {
  46586. // Use graphic bounding rect
  46587. var rect = el.getBoundingRect().clone();
  46588. rect.applyTransform(el.transform);
  46589. point = [
  46590. rect.x + rect.width / 2,
  46591. rect.y + rect.height / 2
  46592. ];
  46593. }
  46594. return {point: point, el: el};
  46595. };
  46596. /***/ }),
  46597. /* 304 */
  46598. /***/ (function(module, exports, __webpack_require__) {
  46599. var echarts = __webpack_require__(1);
  46600. var AxisPointerModel = echarts.extendComponentModel({
  46601. type: 'axisPointer',
  46602. coordSysAxesInfo: null,
  46603. defaultOption: {
  46604. // 'auto' means that show when triggered by tooltip or handle.
  46605. show: 'auto',
  46606. // 'click' | 'mousemove' | 'none'
  46607. triggerOn: null, // set default in AxisPonterView.js
  46608. zlevel: 0,
  46609. z: 50,
  46610. type: 'line',
  46611. // axispointer triggered by tootip determine snap automatically,
  46612. // see `modelHelper`.
  46613. snap: false,
  46614. triggerTooltip: true,
  46615. value: null,
  46616. status: null, // Init value depends on whether handle is used.
  46617. // [group0, group1, ...]
  46618. // Each group can be: {
  46619. // mapper: function () {},
  46620. // singleTooltip: 'multiple', // 'multiple' or 'single'
  46621. // xAxisId: ...,
  46622. // yAxisName: ...,
  46623. // angleAxisIndex: ...
  46624. // }
  46625. // mapper: can be ignored.
  46626. // input: {axisInfo, value}
  46627. // output: {axisInfo, value}
  46628. link: [],
  46629. // Do not set 'auto' here, otherwise global animation: false
  46630. // will not effect at this axispointer.
  46631. animation: null,
  46632. animationDurationUpdate: 200,
  46633. lineStyle: {
  46634. color: '#aaa',
  46635. width: 1,
  46636. type: 'solid'
  46637. },
  46638. shadowStyle: {
  46639. color: 'rgba(150,150,150,0.3)'
  46640. },
  46641. label: {
  46642. show: true,
  46643. formatter: null, // string | Function
  46644. precision: 'auto', // Or a number like 0, 1, 2 ...
  46645. margin: 3,
  46646. color: '#fff',
  46647. padding: [5, 7, 5, 7],
  46648. backgroundColor: 'auto', // default: axis line color
  46649. borderColor: null,
  46650. borderWidth: 0,
  46651. shadowBlur: 3,
  46652. shadowColor: '#aaa'
  46653. // Considering applicability, common style should
  46654. // better not have shadowOffset.
  46655. // shadowOffsetX: 0,
  46656. // shadowOffsetY: 2
  46657. },
  46658. handle: {
  46659. show: false,
  46660. icon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z', // jshint ignore:line
  46661. size: 45,
  46662. // handle margin is from symbol center to axis, which is stable when circular move.
  46663. margin: 50,
  46664. // color: '#1b8bbd'
  46665. // color: '#2f4554'
  46666. color: '#333',
  46667. shadowBlur: 3,
  46668. shadowColor: '#aaa',
  46669. shadowOffsetX: 0,
  46670. shadowOffsetY: 2,
  46671. // For mobile performance
  46672. throttle: 40
  46673. }
  46674. }
  46675. });
  46676. module.exports = AxisPointerModel;
  46677. /***/ }),
  46678. /* 305 */
  46679. /***/ (function(module, exports, __webpack_require__) {
  46680. var globalListener = __webpack_require__(306);
  46681. var AxisPonterView = __webpack_require__(1).extendComponentView({
  46682. type: 'axisPointer',
  46683. render: function (globalAxisPointerModel, ecModel, api) {
  46684. var globalTooltipModel = ecModel.getComponent('tooltip');
  46685. var triggerOn = globalAxisPointerModel.get('triggerOn')
  46686. || (globalTooltipModel && globalTooltipModel.get('triggerOn') || 'mousemove|click');
  46687. // Register global listener in AxisPointerView to enable
  46688. // AxisPointerView to be independent to Tooltip.
  46689. globalListener.register(
  46690. 'axisPointer',
  46691. api,
  46692. function (currTrigger, e, dispatchAction) {
  46693. // If 'none', it is not controlled by mouse totally.
  46694. if (triggerOn !== 'none'
  46695. && (currTrigger === 'leave' || triggerOn.indexOf(currTrigger) >= 0)
  46696. ) {
  46697. dispatchAction({
  46698. type: 'updateAxisPointer',
  46699. currTrigger: currTrigger,
  46700. x: e && e.offsetX,
  46701. y: e && e.offsetY
  46702. });
  46703. }
  46704. }
  46705. );
  46706. },
  46707. /**
  46708. * @override
  46709. */
  46710. remove: function (ecModel, api) {
  46711. globalListener.disopse(api.getZr(), 'axisPointer');
  46712. AxisPonterView.superApply(this._model, 'remove', arguments);
  46713. },
  46714. /**
  46715. * @override
  46716. */
  46717. dispose: function (ecModel, api) {
  46718. globalListener.unregister('axisPointer', api);
  46719. AxisPonterView.superApply(this._model, 'dispose', arguments);
  46720. }
  46721. });
  46722. /***/ }),
  46723. /* 306 */
  46724. /***/ (function(module, exports, __webpack_require__) {
  46725. var env = __webpack_require__(2);
  46726. var zrUtil = __webpack_require__(4);
  46727. var get = __webpack_require__(5).makeGetter();
  46728. var each = zrUtil.each;
  46729. var globalListener = {};
  46730. /**
  46731. * @param {string} key
  46732. * @param {module:echarts/ExtensionAPI} api
  46733. * @param {Function} handler
  46734. * param: {string} currTrigger
  46735. * param: {Array.<number>} point
  46736. */
  46737. globalListener.register = function (key, api, handler) {
  46738. if (env.node) {
  46739. return;
  46740. }
  46741. var zr = api.getZr();
  46742. get(zr).records || (get(zr).records = {});
  46743. initGlobalListeners(zr, api);
  46744. var record = get(zr).records[key] || (get(zr).records[key] = {});
  46745. record.handler = handler;
  46746. };
  46747. function initGlobalListeners(zr, api) {
  46748. if (get(zr).initialized) {
  46749. return;
  46750. }
  46751. get(zr).initialized = true;
  46752. useHandler('click', zrUtil.curry(doEnter, 'click'));
  46753. useHandler('mousemove', zrUtil.curry(doEnter, 'mousemove'));
  46754. // useHandler('mouseout', onLeave);
  46755. useHandler('globalout', onLeave);
  46756. function useHandler(eventType, cb) {
  46757. zr.on(eventType, function (e) {
  46758. var dis = makeDispatchAction(api);
  46759. each(get(zr).records, function (record) {
  46760. record && cb(record, e, dis.dispatchAction);
  46761. });
  46762. dispatchTooltipFinally(dis.pendings, api);
  46763. });
  46764. }
  46765. }
  46766. function dispatchTooltipFinally(pendings, api) {
  46767. var showLen = pendings.showTip.length;
  46768. var hideLen = pendings.hideTip.length;
  46769. var actuallyPayload;
  46770. if (showLen) {
  46771. actuallyPayload = pendings.showTip[showLen - 1];
  46772. }
  46773. else if (hideLen) {
  46774. actuallyPayload = pendings.hideTip[hideLen - 1];
  46775. }
  46776. if (actuallyPayload) {
  46777. actuallyPayload.dispatchAction = null;
  46778. api.dispatchAction(actuallyPayload);
  46779. }
  46780. }
  46781. function onLeave(record, e, dispatchAction) {
  46782. record.handler('leave', null, dispatchAction);
  46783. }
  46784. function doEnter(currTrigger, record, e, dispatchAction) {
  46785. record.handler(currTrigger, e, dispatchAction);
  46786. }
  46787. function makeDispatchAction(api) {
  46788. var pendings = {
  46789. showTip: [],
  46790. hideTip: []
  46791. };
  46792. // FIXME
  46793. // better approach?
  46794. // 'showTip' and 'hideTip' can be triggered by axisPointer and tooltip,
  46795. // which may be conflict, (axisPointer call showTip but tooltip call hideTip);
  46796. // So we have to add "final stage" to merge those dispatched actions.
  46797. var dispatchAction = function (payload) {
  46798. var pendingList = pendings[payload.type];
  46799. if (pendingList) {
  46800. pendingList.push(payload);
  46801. }
  46802. else {
  46803. payload.dispatchAction = dispatchAction;
  46804. api.dispatchAction(payload);
  46805. }
  46806. };
  46807. return {
  46808. dispatchAction: dispatchAction,
  46809. pendings: pendings
  46810. };
  46811. }
  46812. /**
  46813. * @param {string} key
  46814. * @param {module:echarts/ExtensionAPI} api
  46815. */
  46816. globalListener.unregister = function (key, api) {
  46817. if (env.node) {
  46818. return;
  46819. }
  46820. var zr = api.getZr();
  46821. var record = (get(zr).records || {})[key];
  46822. if (record) {
  46823. get(zr).records[key] = null;
  46824. }
  46825. };
  46826. module.exports = globalListener;
  46827. /***/ }),
  46828. /* 307 */
  46829. /***/ (function(module, exports, __webpack_require__) {
  46830. 'use strict';
  46831. var graphic = __webpack_require__(20);
  46832. var BaseAxisPointer = __webpack_require__(308);
  46833. var viewHelper = __webpack_require__(309);
  46834. var cartesianAxisHelper = __webpack_require__(141);
  46835. var AxisView = __webpack_require__(139);
  46836. var CartesianAxisPointer = BaseAxisPointer.extend({
  46837. /**
  46838. * @override
  46839. */
  46840. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  46841. var axis = axisModel.axis;
  46842. var grid = axis.grid;
  46843. var axisPointerType = axisPointerModel.get('type');
  46844. var otherExtent = getCartesian(grid, axis).getOtherAxis(axis).getGlobalExtent();
  46845. var pixelValue = axis.toGlobalCoord(axis.dataToCoord(value, true));
  46846. if (axisPointerType && axisPointerType !== 'none') {
  46847. var elStyle = viewHelper.buildElStyle(axisPointerModel);
  46848. var pointerOption = pointerShapeBuilder[axisPointerType](
  46849. axis, pixelValue, otherExtent, elStyle
  46850. );
  46851. pointerOption.style = elStyle;
  46852. elOption.graphicKey = pointerOption.type;
  46853. elOption.pointer = pointerOption;
  46854. }
  46855. var layoutInfo = cartesianAxisHelper.layout(grid.model, axisModel);
  46856. viewHelper.buildCartesianSingleLabelElOption(
  46857. value, elOption, layoutInfo, axisModel, axisPointerModel, api
  46858. );
  46859. },
  46860. /**
  46861. * @override
  46862. */
  46863. getHandleTransform: function (value, axisModel, axisPointerModel) {
  46864. var layoutInfo = cartesianAxisHelper.layout(axisModel.axis.grid.model, axisModel, {
  46865. labelInside: false
  46866. });
  46867. layoutInfo.labelMargin = axisPointerModel.get('handle.margin');
  46868. return {
  46869. position: viewHelper.getTransformedPosition(axisModel.axis, value, layoutInfo),
  46870. rotation: layoutInfo.rotation + (layoutInfo.labelDirection < 0 ? Math.PI : 0)
  46871. };
  46872. },
  46873. /**
  46874. * @override
  46875. */
  46876. updateHandleTransform: function (transform, delta, axisModel, axisPointerModel) {
  46877. var axis = axisModel.axis;
  46878. var grid = axis.grid;
  46879. var axisExtent = axis.getGlobalExtent(true);
  46880. var otherExtent = getCartesian(grid, axis).getOtherAxis(axis).getGlobalExtent();
  46881. var dimIndex = axis.dim === 'x' ? 0 : 1;
  46882. var currPosition = transform.position;
  46883. currPosition[dimIndex] += delta[dimIndex];
  46884. currPosition[dimIndex] = Math.min(axisExtent[1], currPosition[dimIndex]);
  46885. currPosition[dimIndex] = Math.max(axisExtent[0], currPosition[dimIndex]);
  46886. var cursorOtherValue = (otherExtent[1] + otherExtent[0]) / 2;
  46887. var cursorPoint = [cursorOtherValue, cursorOtherValue];
  46888. cursorPoint[dimIndex] = currPosition[dimIndex];
  46889. // Make tooltip do not overlap axisPointer and in the middle of the grid.
  46890. var tooltipOptions = [{verticalAlign: 'middle'}, {align: 'center'}];
  46891. return {
  46892. position: currPosition,
  46893. rotation: transform.rotation,
  46894. cursorPoint: cursorPoint,
  46895. tooltipOption: tooltipOptions[dimIndex]
  46896. };
  46897. }
  46898. });
  46899. function getCartesian(grid, axis) {
  46900. var opt = {};
  46901. opt[axis.dim + 'AxisIndex'] = axis.index;
  46902. return grid.getCartesian(opt);
  46903. }
  46904. var pointerShapeBuilder = {
  46905. line: function (axis, pixelValue, otherExtent, elStyle) {
  46906. var targetShape = viewHelper.makeLineShape(
  46907. [pixelValue, otherExtent[0]],
  46908. [pixelValue, otherExtent[1]],
  46909. getAxisDimIndex(axis)
  46910. );
  46911. graphic.subPixelOptimizeLine({
  46912. shape: targetShape,
  46913. style: elStyle
  46914. });
  46915. return {
  46916. type: 'Line',
  46917. shape: targetShape
  46918. };
  46919. },
  46920. shadow: function (axis, pixelValue, otherExtent, elStyle) {
  46921. var bandWidth = axis.getBandWidth();
  46922. var span = otherExtent[1] - otherExtent[0];
  46923. return {
  46924. type: 'Rect',
  46925. shape: viewHelper.makeRectShape(
  46926. [pixelValue - bandWidth / 2, otherExtent[0]],
  46927. [bandWidth, span],
  46928. getAxisDimIndex(axis)
  46929. )
  46930. };
  46931. }
  46932. };
  46933. function getAxisDimIndex(axis) {
  46934. return axis.dim === 'x' ? 0 : 1;
  46935. }
  46936. AxisView.registerAxisPointerClass('CartesianAxisPointer', CartesianAxisPointer);
  46937. module.exports = CartesianAxisPointer;
  46938. /***/ }),
  46939. /* 308 */
  46940. /***/ (function(module, exports, __webpack_require__) {
  46941. 'use strict';
  46942. var zrUtil = __webpack_require__(4);
  46943. var clazzUtil = __webpack_require__(15);
  46944. var graphic = __webpack_require__(20);
  46945. var get = __webpack_require__(5).makeGetter();
  46946. var axisPointerModelHelper = __webpack_require__(140);
  46947. var eventTool = __webpack_require__(93);
  46948. var throttle = __webpack_require__(86);
  46949. var clone = zrUtil.clone;
  46950. var bind = zrUtil.bind;
  46951. /**
  46952. * Base axis pointer class in 2D.
  46953. * Implemenents {module:echarts/component/axis/IAxisPointer}.
  46954. */
  46955. function BaseAxisPointer () {
  46956. }
  46957. BaseAxisPointer.prototype = {
  46958. /**
  46959. * @private
  46960. */
  46961. _group: null,
  46962. /**
  46963. * @private
  46964. */
  46965. _lastGraphicKey: null,
  46966. /**
  46967. * @private
  46968. */
  46969. _handle: null,
  46970. /**
  46971. * @private
  46972. */
  46973. _dragging: false,
  46974. /**
  46975. * @private
  46976. */
  46977. _lastValue: null,
  46978. /**
  46979. * @private
  46980. */
  46981. _lastStatus: null,
  46982. /**
  46983. * @private
  46984. */
  46985. _payloadInfo: null,
  46986. /**
  46987. * In px, arbitrary value. Do not set too small,
  46988. * no animation is ok for most cases.
  46989. * @protected
  46990. */
  46991. animationThreshold: 15,
  46992. /**
  46993. * @implement
  46994. */
  46995. render: function (axisModel, axisPointerModel, api, forceRender) {
  46996. var value = axisPointerModel.get('value');
  46997. var status = axisPointerModel.get('status');
  46998. // Bind them to `this`, not in closure, otherwise they will not
  46999. // be replaced when user calling setOption in not merge mode.
  47000. this._axisModel = axisModel;
  47001. this._axisPointerModel = axisPointerModel;
  47002. this._api = api;
  47003. // Optimize: `render` will be called repeatly during mouse move.
  47004. // So it is power consuming if performing `render` each time,
  47005. // especially on mobile device.
  47006. if (!forceRender
  47007. && this._lastValue === value
  47008. && this._lastStatus === status
  47009. ) {
  47010. return;
  47011. }
  47012. this._lastValue = value;
  47013. this._lastStatus = status;
  47014. var group = this._group;
  47015. var handle = this._handle;
  47016. if (!status || status === 'hide') {
  47017. // Do not clear here, for animation better.
  47018. group && group.hide();
  47019. handle && handle.hide();
  47020. return;
  47021. }
  47022. group && group.show();
  47023. handle && handle.show();
  47024. // Otherwise status is 'show'
  47025. var elOption = {};
  47026. this.makeElOption(elOption, value, axisModel, axisPointerModel, api);
  47027. // Enable change axis pointer type.
  47028. var graphicKey = elOption.graphicKey;
  47029. if (graphicKey !== this._lastGraphicKey) {
  47030. this.clear(api);
  47031. }
  47032. this._lastGraphicKey = graphicKey;
  47033. var moveAnimation = this._moveAnimation =
  47034. this.determineAnimation(axisModel, axisPointerModel);
  47035. if (!group) {
  47036. group = this._group = new graphic.Group();
  47037. this.createPointerEl(group, elOption, axisModel, axisPointerModel);
  47038. this.createLabelEl(group, elOption, axisModel, axisPointerModel);
  47039. api.getZr().add(group);
  47040. }
  47041. else {
  47042. var doUpdateProps = zrUtil.curry(updateProps, axisPointerModel, moveAnimation);
  47043. this.updatePointerEl(group, elOption, doUpdateProps, axisPointerModel);
  47044. this.updateLabelEl(group, elOption, doUpdateProps, axisPointerModel);
  47045. }
  47046. updateMandatoryProps(group, axisPointerModel, true);
  47047. this._renderHandle(value);
  47048. },
  47049. /**
  47050. * @implement
  47051. */
  47052. remove: function (api) {
  47053. this.clear(api);
  47054. },
  47055. /**
  47056. * @implement
  47057. */
  47058. dispose: function (api) {
  47059. this.clear(api);
  47060. },
  47061. /**
  47062. * @protected
  47063. */
  47064. determineAnimation: function (axisModel, axisPointerModel) {
  47065. var animation = axisPointerModel.get('animation');
  47066. var axis = axisModel.axis;
  47067. var isCategoryAxis = axis.type === 'category';
  47068. var useSnap = axisPointerModel.get('snap');
  47069. // Value axis without snap always do not snap.
  47070. if (!useSnap && !isCategoryAxis) {
  47071. return false;
  47072. }
  47073. if (animation === 'auto' || animation == null) {
  47074. var animationThreshold = this.animationThreshold;
  47075. if (isCategoryAxis && axis.getBandWidth() > animationThreshold) {
  47076. return true;
  47077. }
  47078. // It is important to auto animation when snap used. Consider if there is
  47079. // a dataZoom, animation will be disabled when too many points exist, while
  47080. // it will be enabled for better visual effect when little points exist.
  47081. if (useSnap) {
  47082. var seriesDataCount = axisPointerModelHelper.getAxisInfo(axisModel).seriesDataCount;
  47083. var axisExtent = axis.getExtent();
  47084. // Approximate band width
  47085. return Math.abs(axisExtent[0] - axisExtent[1]) / seriesDataCount > animationThreshold;
  47086. }
  47087. return false;
  47088. }
  47089. return animation === true;
  47090. },
  47091. /**
  47092. * add {pointer, label, graphicKey} to elOption
  47093. * @protected
  47094. */
  47095. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  47096. // Shoule be implemenented by sub-class.
  47097. },
  47098. /**
  47099. * @protected
  47100. */
  47101. createPointerEl: function (group, elOption, axisModel, axisPointerModel) {
  47102. var pointerOption = elOption.pointer;
  47103. if (pointerOption) {
  47104. var pointerEl = get(group).pointerEl = new graphic[pointerOption.type](
  47105. clone(elOption.pointer)
  47106. );
  47107. group.add(pointerEl);
  47108. }
  47109. },
  47110. /**
  47111. * @protected
  47112. */
  47113. createLabelEl: function (group, elOption, axisModel, axisPointerModel) {
  47114. if (elOption.label) {
  47115. var labelEl = get(group).labelEl = new graphic.Rect(
  47116. clone(elOption.label)
  47117. );
  47118. group.add(labelEl);
  47119. updateLabelShowHide(labelEl, axisPointerModel);
  47120. }
  47121. },
  47122. /**
  47123. * @protected
  47124. */
  47125. updatePointerEl: function (group, elOption, updateProps) {
  47126. var pointerEl = get(group).pointerEl;
  47127. if (pointerEl) {
  47128. pointerEl.setStyle(elOption.pointer.style);
  47129. updateProps(pointerEl, {shape: elOption.pointer.shape});
  47130. }
  47131. },
  47132. /**
  47133. * @protected
  47134. */
  47135. updateLabelEl: function (group, elOption, updateProps, axisPointerModel) {
  47136. var labelEl = get(group).labelEl;
  47137. if (labelEl) {
  47138. labelEl.setStyle(elOption.label.style);
  47139. updateProps(labelEl, {
  47140. // Consider text length change in vertical axis, animation should
  47141. // be used on shape, otherwise the effect will be weird.
  47142. shape: elOption.label.shape,
  47143. position: elOption.label.position
  47144. });
  47145. updateLabelShowHide(labelEl, axisPointerModel);
  47146. }
  47147. },
  47148. /**
  47149. * @private
  47150. */
  47151. _renderHandle: function (value) {
  47152. if (this._dragging || !this.updateHandleTransform) {
  47153. return;
  47154. }
  47155. var axisPointerModel = this._axisPointerModel;
  47156. var zr = this._api.getZr();
  47157. var handle = this._handle;
  47158. var handleModel = axisPointerModel.getModel('handle');
  47159. var status = axisPointerModel.get('status');
  47160. if (!handleModel.get('show') || !status || status === 'hide') {
  47161. handle && zr.remove(handle);
  47162. this._handle = null;
  47163. return;
  47164. }
  47165. var isInit;
  47166. if (!this._handle) {
  47167. isInit = true;
  47168. handle = this._handle = graphic.createIcon(
  47169. handleModel.get('icon'),
  47170. {
  47171. cursor: 'move',
  47172. draggable: true,
  47173. onmousemove: function (e) {
  47174. // Fot mobile devicem, prevent screen slider on the button.
  47175. eventTool.stop(e.event);
  47176. },
  47177. onmousedown: bind(this._onHandleDragMove, this, 0, 0),
  47178. drift: bind(this._onHandleDragMove, this),
  47179. ondragend: bind(this._onHandleDragEnd, this)
  47180. }
  47181. );
  47182. zr.add(handle);
  47183. }
  47184. updateMandatoryProps(handle, axisPointerModel, false);
  47185. // update style
  47186. var includeStyles = [
  47187. 'color', 'borderColor', 'borderWidth', 'opacity',
  47188. 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY'
  47189. ];
  47190. handle.setStyle(handleModel.getItemStyle(null, includeStyles));
  47191. // update position
  47192. var handleSize = handleModel.get('size');
  47193. if (!zrUtil.isArray(handleSize)) {
  47194. handleSize = [handleSize, handleSize];
  47195. }
  47196. handle.attr('scale', [handleSize[0] / 2, handleSize[1] / 2]);
  47197. throttle.createOrUpdate(
  47198. this,
  47199. '_doDispatchAxisPointer',
  47200. handleModel.get('throttle') || 0,
  47201. 'fixRate'
  47202. );
  47203. this._moveHandleToValue(value, isInit);
  47204. },
  47205. /**
  47206. * @private
  47207. */
  47208. _moveHandleToValue: function (value, isInit) {
  47209. updateProps(
  47210. this._axisPointerModel,
  47211. !isInit && this._moveAnimation,
  47212. this._handle,
  47213. getHandleTransProps(this.getHandleTransform(
  47214. value, this._axisModel, this._axisPointerModel
  47215. ))
  47216. );
  47217. },
  47218. /**
  47219. * @private
  47220. */
  47221. _onHandleDragMove: function (dx, dy) {
  47222. var handle = this._handle;
  47223. if (!handle) {
  47224. return;
  47225. }
  47226. this._dragging = true;
  47227. // Persistent for throttle.
  47228. var trans = this.updateHandleTransform(
  47229. getHandleTransProps(handle),
  47230. [dx, dy],
  47231. this._axisModel,
  47232. this._axisPointerModel
  47233. );
  47234. this._payloadInfo = trans;
  47235. handle.stopAnimation();
  47236. handle.attr(getHandleTransProps(trans));
  47237. get(handle).lastProp = null;
  47238. this._doDispatchAxisPointer();
  47239. },
  47240. /**
  47241. * Throttled method.
  47242. * @private
  47243. */
  47244. _doDispatchAxisPointer: function () {
  47245. var handle = this._handle;
  47246. if (!handle) {
  47247. return;
  47248. }
  47249. var payloadInfo = this._payloadInfo;
  47250. var axisModel = this._axisModel;
  47251. this._api.dispatchAction({
  47252. type: 'updateAxisPointer',
  47253. x: payloadInfo.cursorPoint[0],
  47254. y: payloadInfo.cursorPoint[1],
  47255. tooltipOption: payloadInfo.tooltipOption,
  47256. axesInfo: [{
  47257. axisDim: axisModel.axis.dim,
  47258. axisIndex: axisModel.componentIndex
  47259. }]
  47260. });
  47261. },
  47262. /**
  47263. * @private
  47264. */
  47265. _onHandleDragEnd: function (moveAnimation) {
  47266. this._dragging = false;
  47267. var handle = this._handle;
  47268. if (!handle) {
  47269. return;
  47270. }
  47271. var value = this._axisPointerModel.get('value');
  47272. // Consider snap or categroy axis, handle may be not consistent with
  47273. // axisPointer. So move handle to align the exact value position when
  47274. // drag ended.
  47275. this._moveHandleToValue(value);
  47276. // For the effect: tooltip will be shown when finger holding on handle
  47277. // button, and will be hidden after finger left handle button.
  47278. this._api.dispatchAction({
  47279. type: 'hideTip'
  47280. });
  47281. },
  47282. /**
  47283. * Should be implemenented by sub-class if support `handle`.
  47284. * @protected
  47285. * @param {number} value
  47286. * @param {module:echarts/model/Model} axisModel
  47287. * @param {module:echarts/model/Model} axisPointerModel
  47288. * @return {Object} {position: [x, y], rotation: 0}
  47289. */
  47290. getHandleTransform: null,
  47291. /**
  47292. * * Should be implemenented by sub-class if support `handle`.
  47293. * @protected
  47294. * @param {Object} transform {position, rotation}
  47295. * @param {Array.<number>} delta [dx, dy]
  47296. * @param {module:echarts/model/Model} axisModel
  47297. * @param {module:echarts/model/Model} axisPointerModel
  47298. * @return {Object} {position: [x, y], rotation: 0, cursorPoint: [x, y]}
  47299. */
  47300. updateHandleTransform: null,
  47301. /**
  47302. * @private
  47303. */
  47304. clear: function (api) {
  47305. this._lastValue = null;
  47306. this._lastStatus = null;
  47307. var zr = api.getZr();
  47308. var group = this._group;
  47309. var handle = this._handle;
  47310. if (zr && group) {
  47311. this._lastGraphicKey = null;
  47312. group && zr.remove(group);
  47313. handle && zr.remove(handle);
  47314. this._group = null;
  47315. this._handle = null;
  47316. this._payloadInfo = null;
  47317. }
  47318. },
  47319. /**
  47320. * @protected
  47321. */
  47322. doClear: function () {
  47323. // Implemented by sub-class if necessary.
  47324. },
  47325. /**
  47326. * @protected
  47327. * @param {Array.<number>} xy
  47328. * @param {Array.<number>} wh
  47329. * @param {number} [xDimIndex=0] or 1
  47330. */
  47331. buildLabel: function (xy, wh, xDimIndex) {
  47332. xDimIndex = xDimIndex || 0;
  47333. return {
  47334. x: xy[xDimIndex],
  47335. y: xy[1 - xDimIndex],
  47336. width: wh[xDimIndex],
  47337. height: wh[1 - xDimIndex]
  47338. };
  47339. }
  47340. };
  47341. BaseAxisPointer.prototype.constructor = BaseAxisPointer;
  47342. function updateProps(animationModel, moveAnimation, el, props) {
  47343. // Animation optimize.
  47344. if (!propsEqual(get(el).lastProp, props)) {
  47345. get(el).lastProp = props;
  47346. moveAnimation
  47347. ? graphic.updateProps(el, props, animationModel)
  47348. : (el.stopAnimation(), el.attr(props));
  47349. }
  47350. }
  47351. function propsEqual(lastProps, newProps) {
  47352. if (zrUtil.isObject(lastProps) && zrUtil.isObject(newProps)) {
  47353. var equals = true;
  47354. zrUtil.each(newProps, function (item, key) {
  47355. equals = equals && propsEqual(lastProps[key], item);
  47356. });
  47357. return !!equals;
  47358. }
  47359. else {
  47360. return lastProps === newProps;
  47361. }
  47362. }
  47363. function updateLabelShowHide(labelEl, axisPointerModel) {
  47364. labelEl[axisPointerModel.get('label.show') ? 'show' : 'hide']();
  47365. }
  47366. function getHandleTransProps(trans) {
  47367. return {
  47368. position: trans.position.slice(),
  47369. rotation: trans.rotation || 0
  47370. };
  47371. }
  47372. function updateMandatoryProps(group, axisPointerModel, silent) {
  47373. var z = axisPointerModel.get('z');
  47374. var zlevel = axisPointerModel.get('zlevel');
  47375. group && group.traverse(function (el) {
  47376. if (el.type !== 'group') {
  47377. z != null && (el.z = z);
  47378. zlevel != null && (el.zlevel = zlevel);
  47379. el.silent = silent;
  47380. }
  47381. });
  47382. }
  47383. clazzUtil.enableClassExtend(BaseAxisPointer);
  47384. module.exports = BaseAxisPointer;
  47385. /***/ }),
  47386. /* 309 */
  47387. /***/ (function(module, exports, __webpack_require__) {
  47388. 'use strict';
  47389. var zrUtil = __webpack_require__(4);
  47390. var graphic = __webpack_require__(20);
  47391. var textContain = __webpack_require__(8);
  47392. var formatUtil = __webpack_require__(6);
  47393. var matrix = __webpack_require__(11);
  47394. var axisHelper = __webpack_require__(104);
  47395. var AxisBuilder = __webpack_require__(138);
  47396. var helper = {};
  47397. /**
  47398. * @param {module:echarts/model/Model} axisPointerModel
  47399. */
  47400. helper.buildElStyle = function (axisPointerModel) {
  47401. var axisPointerType = axisPointerModel.get('type');
  47402. var styleModel = axisPointerModel.getModel(axisPointerType + 'Style');
  47403. var style;
  47404. if (axisPointerType === 'line') {
  47405. style = styleModel.getLineStyle();
  47406. style.fill = null;
  47407. }
  47408. else if (axisPointerType === 'shadow') {
  47409. style = styleModel.getAreaStyle();
  47410. style.stroke = null;
  47411. }
  47412. return style;
  47413. };
  47414. /**
  47415. * @param {Function} labelPos {align, verticalAlign, position}
  47416. */
  47417. helper.buildLabelElOption = function (
  47418. elOption, axisModel, axisPointerModel, api, labelPos
  47419. ) {
  47420. var value = axisPointerModel.get('value');
  47421. var text = helper.getValueLabel(
  47422. value, axisModel.axis, axisModel.ecModel,
  47423. axisPointerModel.get('seriesDataIndices'),
  47424. {
  47425. precision: axisPointerModel.get('label.precision'),
  47426. formatter: axisPointerModel.get('label.formatter')
  47427. }
  47428. );
  47429. var labelModel = axisPointerModel.getModel('label');
  47430. var paddings = formatUtil.normalizeCssArray(labelModel.get('padding') || 0);
  47431. var font = labelModel.getFont();
  47432. var textRect = textContain.getBoundingRect(text, font);
  47433. var position = labelPos.position;
  47434. var width = textRect.width + paddings[1] + paddings[3];
  47435. var height = textRect.height + paddings[0] + paddings[2];
  47436. // Adjust by align.
  47437. var align = labelPos.align;
  47438. align === 'right' && (position[0] -= width);
  47439. align === 'center' && (position[0] -= width / 2);
  47440. var verticalAlign = labelPos.verticalAlign;
  47441. verticalAlign === 'bottom' && (position[1] -= height);
  47442. verticalAlign === 'middle' && (position[1] -= height / 2);
  47443. // Not overflow ec container
  47444. confineInContainer(position, width, height, api);
  47445. var bgColor = labelModel.get('backgroundColor');
  47446. if (!bgColor || bgColor === 'auto') {
  47447. bgColor = axisModel.get('axisLine.lineStyle.color');
  47448. }
  47449. elOption.label = {
  47450. shape: {x: 0, y: 0, width: width, height: height, r: labelModel.get('borderRadius')},
  47451. position: position.slice(),
  47452. // TODO: rich
  47453. style: {
  47454. text: text,
  47455. textFont: font,
  47456. textFill: labelModel.getTextColor(),
  47457. textPosition: 'inside',
  47458. fill: bgColor,
  47459. stroke: labelModel.get('borderColor') || 'transparent',
  47460. lineWidth: labelModel.get('borderWidth') || 0,
  47461. shadowBlur: labelModel.get('shadowBlur'),
  47462. shadowColor: labelModel.get('shadowColor'),
  47463. shadowOffsetX: labelModel.get('shadowOffsetX'),
  47464. shadowOffsetY: labelModel.get('shadowOffsetY')
  47465. },
  47466. // Lable should be over axisPointer.
  47467. z2: 10
  47468. };
  47469. };
  47470. // Do not overflow ec container
  47471. function confineInContainer(position, width, height, api) {
  47472. var viewWidth = api.getWidth();
  47473. var viewHeight = api.getHeight();
  47474. position[0] = Math.min(position[0] + width, viewWidth) - width;
  47475. position[1] = Math.min(position[1] + height, viewHeight) - height;
  47476. position[0] = Math.max(position[0], 0);
  47477. position[1] = Math.max(position[1], 0);
  47478. }
  47479. /**
  47480. * @param {number} value
  47481. * @param {module:echarts/coord/Axis} axis
  47482. * @param {module:echarts/model/Global} ecModel
  47483. * @param {Object} opt
  47484. * @param {Array.<Object>} seriesDataIndices
  47485. * @param {number|string} opt.precision 'auto' or a number
  47486. * @param {string|Function} opt.formatter label formatter
  47487. */
  47488. helper.getValueLabel = function (value, axis, ecModel, seriesDataIndices, opt) {
  47489. var text = axis.scale.getLabel(
  47490. // If `precision` is set, width can be fixed (like '12.00500'), which
  47491. // helps to debounce when when moving label.
  47492. value, {precision: opt.precision}
  47493. );
  47494. var formatter = opt.formatter;
  47495. if (formatter) {
  47496. var params = {
  47497. value: axisHelper.getAxisRawValue(axis, value),
  47498. seriesData: []
  47499. };
  47500. zrUtil.each(seriesDataIndices, function (idxItem) {
  47501. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
  47502. var dataIndex = idxItem.dataIndexInside;
  47503. var dataParams = series && series.getDataParams(dataIndex);
  47504. dataParams && params.seriesData.push(dataParams);
  47505. });
  47506. if (zrUtil.isString(formatter)) {
  47507. text = formatter.replace('{value}', text);
  47508. }
  47509. else if (zrUtil.isFunction(formatter)) {
  47510. text = formatter(params);
  47511. }
  47512. }
  47513. return text;
  47514. };
  47515. /**
  47516. * @param {module:echarts/coord/Axis} axis
  47517. * @param {number} value
  47518. * @param {Object} layoutInfo {
  47519. * rotation, position, labelOffset, labelDirection, labelMargin
  47520. * }
  47521. */
  47522. helper.getTransformedPosition = function (axis, value, layoutInfo) {
  47523. var transform = matrix.create();
  47524. matrix.rotate(transform, transform, layoutInfo.rotation);
  47525. matrix.translate(transform, transform, layoutInfo.position);
  47526. return graphic.applyTransform([
  47527. axis.dataToCoord(value),
  47528. (layoutInfo.labelOffset || 0)
  47529. + (layoutInfo.labelDirection || 1) * (layoutInfo.labelMargin || 0)
  47530. ], transform);
  47531. };
  47532. helper.buildCartesianSingleLabelElOption = function (
  47533. value, elOption, layoutInfo, axisModel, axisPointerModel, api
  47534. ) {
  47535. var textLayout = AxisBuilder.innerTextLayout(
  47536. layoutInfo.rotation, 0, layoutInfo.labelDirection
  47537. );
  47538. layoutInfo.labelMargin = axisPointerModel.get('label.margin');
  47539. helper.buildLabelElOption(elOption, axisModel, axisPointerModel, api, {
  47540. position: helper.getTransformedPosition(axisModel.axis, value, layoutInfo),
  47541. align: textLayout.textAlign,
  47542. verticalAlign: textLayout.textVerticalAlign
  47543. });
  47544. };
  47545. /**
  47546. * @param {Array.<number>} p1
  47547. * @param {Array.<number>} p2
  47548. * @param {number} [xDimIndex=0] or 1
  47549. */
  47550. helper.makeLineShape = function (p1, p2, xDimIndex) {
  47551. xDimIndex = xDimIndex || 0;
  47552. return {
  47553. x1: p1[xDimIndex],
  47554. y1: p1[1 - xDimIndex],
  47555. x2: p2[xDimIndex],
  47556. y2: p2[1 - xDimIndex]
  47557. };
  47558. };
  47559. /**
  47560. * @param {Array.<number>} xy
  47561. * @param {Array.<number>} wh
  47562. * @param {number} [xDimIndex=0] or 1
  47563. */
  47564. helper.makeRectShape = function (xy, wh, xDimIndex) {
  47565. xDimIndex = xDimIndex || 0;
  47566. return {
  47567. x: xy[xDimIndex],
  47568. y: xy[1 - xDimIndex],
  47569. width: wh[xDimIndex],
  47570. height: wh[1 - xDimIndex]
  47571. };
  47572. };
  47573. helper.makeSectorShape = function (cx, cy, r0, r, startAngle, endAngle) {
  47574. return {
  47575. cx: cx,
  47576. cy: cy,
  47577. r0: r0,
  47578. r: r,
  47579. startAngle: startAngle,
  47580. endAngle: endAngle,
  47581. clockwise: true
  47582. };
  47583. };
  47584. module.exports = helper;
  47585. /***/ }),
  47586. /* 310 */
  47587. /***/ (function(module, exports, __webpack_require__) {
  47588. 'use strict';
  47589. var graphic = __webpack_require__(20);
  47590. var BaseAxisPointer = __webpack_require__(308);
  47591. var viewHelper = __webpack_require__(309);
  47592. var singleAxisHelper = __webpack_require__(299);
  47593. var AxisView = __webpack_require__(139);
  47594. var XY = ['x', 'y'];
  47595. var WH = ['width', 'height'];
  47596. var SingleAxisPointer = BaseAxisPointer.extend({
  47597. /**
  47598. * @override
  47599. */
  47600. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  47601. var axis = axisModel.axis;
  47602. var coordSys = axis.coordinateSystem;
  47603. var otherExtent = getGlobalExtent(coordSys, 1 - getPointDimIndex(axis));
  47604. var pixelValue = coordSys.dataToPoint(value)[0];
  47605. var axisPointerType = axisPointerModel.get('type');
  47606. if (axisPointerType && axisPointerType !== 'none') {
  47607. var elStyle = viewHelper.buildElStyle(axisPointerModel);
  47608. var pointerOption = pointerShapeBuilder[axisPointerType](
  47609. axis, pixelValue, otherExtent, elStyle
  47610. );
  47611. pointerOption.style = elStyle;
  47612. elOption.graphicKey = pointerOption.type;
  47613. elOption.pointer = pointerOption;
  47614. }
  47615. var layoutInfo = singleAxisHelper.layout(axisModel);
  47616. viewHelper.buildCartesianSingleLabelElOption(
  47617. value, elOption, layoutInfo, axisModel, axisPointerModel, api
  47618. );
  47619. },
  47620. /**
  47621. * @override
  47622. */
  47623. getHandleTransform: function (value, axisModel, axisPointerModel) {
  47624. var layoutInfo = singleAxisHelper.layout(axisModel, {labelInside: false});
  47625. layoutInfo.labelMargin = axisPointerModel.get('handle.margin');
  47626. return {
  47627. position: viewHelper.getTransformedPosition(axisModel.axis, value, layoutInfo),
  47628. rotation: layoutInfo.rotation + (layoutInfo.labelDirection < 0 ? Math.PI : 0)
  47629. };
  47630. },
  47631. /**
  47632. * @override
  47633. */
  47634. updateHandleTransform: function (transform, delta, axisModel, axisPointerModel) {
  47635. var axis = axisModel.axis;
  47636. var coordSys = axis.coordinateSystem;
  47637. var dimIndex = getPointDimIndex(axis);
  47638. var axisExtent = getGlobalExtent(coordSys, dimIndex);
  47639. var currPosition = transform.position;
  47640. currPosition[dimIndex] += delta[dimIndex];
  47641. currPosition[dimIndex] = Math.min(axisExtent[1], currPosition[dimIndex]);
  47642. currPosition[dimIndex] = Math.max(axisExtent[0], currPosition[dimIndex]);
  47643. var otherExtent = getGlobalExtent(coordSys, 1 - dimIndex);
  47644. var cursorOtherValue = (otherExtent[1] + otherExtent[0]) / 2;
  47645. var cursorPoint = [cursorOtherValue, cursorOtherValue];
  47646. cursorPoint[dimIndex] = currPosition[dimIndex];
  47647. return {
  47648. position: currPosition,
  47649. rotation: transform.rotation,
  47650. cursorPoint: cursorPoint,
  47651. tooltipOption: {
  47652. verticalAlign: 'middle'
  47653. }
  47654. };
  47655. }
  47656. });
  47657. var pointerShapeBuilder = {
  47658. line: function (axis, pixelValue, otherExtent, elStyle) {
  47659. var targetShape = viewHelper.makeLineShape(
  47660. [pixelValue, otherExtent[0]],
  47661. [pixelValue, otherExtent[1]],
  47662. getPointDimIndex(axis)
  47663. );
  47664. graphic.subPixelOptimizeLine({
  47665. shape: targetShape,
  47666. style: elStyle
  47667. });
  47668. return {
  47669. type: 'Line',
  47670. shape: targetShape
  47671. };
  47672. },
  47673. shadow: function (axis, pixelValue, otherExtent, elStyle) {
  47674. var bandWidth = axis.getBandWidth();
  47675. var span = otherExtent[1] - otherExtent[0];
  47676. return {
  47677. type: 'Rect',
  47678. shape: viewHelper.makeRectShape(
  47679. [pixelValue - bandWidth / 2, otherExtent[0]],
  47680. [bandWidth, span],
  47681. getPointDimIndex(axis)
  47682. )
  47683. };
  47684. }
  47685. };
  47686. function getPointDimIndex(axis) {
  47687. return axis.isHorizontal() ? 0 : 1;
  47688. }
  47689. function getGlobalExtent(coordSys, dimIndex) {
  47690. var rect = coordSys.getRect();
  47691. return [rect[XY[dimIndex]], rect[XY[dimIndex]] + rect[WH[dimIndex]]];
  47692. }
  47693. AxisView.registerAxisPointerClass('SingleAxisPointer', SingleAxisPointer);
  47694. module.exports = SingleAxisPointer;
  47695. /***/ }),
  47696. /* 311 */
  47697. /***/ (function(module, exports, __webpack_require__) {
  47698. 'use strict';
  47699. /**
  47700. * @file Define the themeRiver view's series model
  47701. * @author Deqing Li(annong035@gmail.com)
  47702. */
  47703. var completeDimensions = __webpack_require__(113);
  47704. var SeriesModel = __webpack_require__(83);
  47705. var List = __webpack_require__(101);
  47706. var zrUtil = __webpack_require__(4);
  47707. var formatUtil = __webpack_require__(6);
  47708. var encodeHTML = formatUtil.encodeHTML;
  47709. var nest = __webpack_require__(258);
  47710. var DATA_NAME_INDEX = 2;
  47711. var ThemeRiverSeries = SeriesModel.extend({
  47712. type: 'series.themeRiver',
  47713. dependencies: ['singleAxis'],
  47714. /**
  47715. * @readOnly
  47716. * @type {module:zrender/core/util#HashMap}
  47717. */
  47718. nameMap: null,
  47719. /**
  47720. * @override
  47721. */
  47722. init: function (option) {
  47723. ThemeRiverSeries.superApply(this, 'init', arguments);
  47724. // Put this function here is for the sake of consistency of code
  47725. // Enable legend selection for each data item
  47726. // Use a function instead of direct access because data reference may changed
  47727. this.legendDataProvider = function () {
  47728. return this.getRawData();
  47729. };
  47730. },
  47731. /**
  47732. * If there is no value of a certain point in the time for some event,set it value to 0.
  47733. *
  47734. * @param {Array} data initial data in the option
  47735. * @return {Array}
  47736. */
  47737. fixData: function (data) {
  47738. var rawDataLength = data.length;
  47739. // grouped data by name
  47740. var dataByName = nest()
  47741. .key(function (dataItem) {
  47742. return dataItem[2];
  47743. })
  47744. .entries(data);
  47745. // data group in each layer
  47746. var layData = zrUtil.map(dataByName, function (d) {
  47747. return {
  47748. name: d.key,
  47749. dataList: d.values
  47750. };
  47751. });
  47752. var layerNum = layData.length;
  47753. var largestLayer = -1;
  47754. var index = -1;
  47755. for (var i = 0; i < layerNum; ++i) {
  47756. var len = layData[i].dataList.length;
  47757. if (len > largestLayer) {
  47758. largestLayer = len;
  47759. index = i;
  47760. }
  47761. }
  47762. for (var k = 0; k < layerNum; ++k) {
  47763. if (k === index) {
  47764. continue;
  47765. }
  47766. var name = layData[k].name;
  47767. for (var j = 0; j < largestLayer; ++j) {
  47768. var timeValue = layData[index].dataList[j][0];
  47769. var length = layData[k].dataList.length;
  47770. var keyIndex = -1;
  47771. for (var l = 0; l < length; ++l) {
  47772. var value = layData[k].dataList[l][0];
  47773. if (value === timeValue) {
  47774. keyIndex = l;
  47775. break;
  47776. }
  47777. }
  47778. if (keyIndex === -1) {
  47779. data[rawDataLength] = [];
  47780. data[rawDataLength][0] = timeValue;
  47781. data[rawDataLength][1] = 0;
  47782. data[rawDataLength][2] = name;
  47783. rawDataLength++;
  47784. }
  47785. }
  47786. }
  47787. return data;
  47788. },
  47789. /**
  47790. * @override
  47791. * @param {Object} option the initial option that user gived
  47792. * @param {module:echarts/model/Model} ecModel the model object for themeRiver option
  47793. * @return {module:echarts/data/List}
  47794. */
  47795. getInitialData: function (option, ecModel) {
  47796. var dimensions = [];
  47797. var singleAxisModel = ecModel.queryComponents({
  47798. mainType: 'singleAxis',
  47799. index: this.get('singleAxisIndex'),
  47800. id: this.get('singleAxisId')
  47801. })[0];
  47802. var axisType = singleAxisModel.get('type');
  47803. dimensions = [
  47804. {
  47805. name: 'time',
  47806. // FIXME common?
  47807. type: axisType === 'category'
  47808. ? 'ordinal'
  47809. : axisType === 'time'
  47810. ? 'time'
  47811. : 'float'
  47812. },
  47813. {
  47814. name: 'value',
  47815. type: 'float'
  47816. },
  47817. {
  47818. name: 'name',
  47819. type: 'ordinal'
  47820. }
  47821. ];
  47822. // filter the data item with the value of label is undefined
  47823. var filterData = zrUtil.filter(option.data, function (dataItem) {
  47824. return dataItem[2] !== undefined;
  47825. });
  47826. var data = this.fixData(filterData || []);
  47827. var nameList = [];
  47828. var nameMap = this.nameMap = zrUtil.createHashMap();
  47829. var count = 0;
  47830. for (var i = 0; i < data.length; ++i) {
  47831. nameList.push(data[i][DATA_NAME_INDEX]);
  47832. if (!nameMap.get(data[i][DATA_NAME_INDEX])) {
  47833. nameMap.set(data[i][DATA_NAME_INDEX], count);
  47834. count++;
  47835. }
  47836. }
  47837. dimensions = completeDimensions(dimensions, data);
  47838. var list = new List(dimensions, this);
  47839. list.initData(data, nameList);
  47840. return list;
  47841. },
  47842. /**
  47843. * Used by single coordinate
  47844. *
  47845. * @param {string} axisDim the dimension for single coordinate
  47846. * @return {Array.<string> } specified dimensions on the axis.
  47847. */
  47848. coordDimToDataDim: function (axisDim) {
  47849. return ['time'];
  47850. },
  47851. /**
  47852. * The raw data is divided into multiple layers and each layer
  47853. * has same name.
  47854. *
  47855. * @return {Array.<Array.<number>>}
  47856. */
  47857. getLayerSeries: function () {
  47858. var data = this.getData();
  47859. var lenCount = data.count();
  47860. var indexArr = [];
  47861. for (var i = 0; i < lenCount; ++i) {
  47862. indexArr[i] = i;
  47863. }
  47864. // data group by name
  47865. var dataByName = nest()
  47866. .key(function (index) {
  47867. return data.get('name', index);
  47868. })
  47869. .entries(indexArr);
  47870. var layerSeries = zrUtil.map(dataByName, function (d) {
  47871. return {
  47872. name: d.key,
  47873. indices: d.values
  47874. };
  47875. });
  47876. for (var j = 0; j < layerSeries.length; ++j) {
  47877. layerSeries[j].indices.sort(comparer);
  47878. }
  47879. function comparer(index1, index2) {
  47880. return data.get('time', index1) - data.get('time', index2);
  47881. }
  47882. return layerSeries;
  47883. },
  47884. /**
  47885. * Get data indices for show tooltip content
  47886. *
  47887. * @param {Array.<string>|string} dim single coordinate dimension
  47888. * @param {number} value axis value
  47889. * @param {module:echarts/coord/single/SingleAxis} baseAxis single Axis used
  47890. * the themeRiver.
  47891. * @return {Object} {dataIndices, nestestValue}
  47892. */
  47893. getAxisTooltipData: function (dim, value, baseAxis) {
  47894. if (!zrUtil.isArray(dim)) {
  47895. dim = dim ? [dim] : [];
  47896. }
  47897. var data = this.getData();
  47898. var layerSeries = this.getLayerSeries();
  47899. var indices = [];
  47900. var layerNum = layerSeries.length;
  47901. var nestestValue;
  47902. for (var i = 0; i < layerNum; ++i) {
  47903. var minDist = Number.MAX_VALUE;
  47904. var nearestIdx = -1;
  47905. var pointNum = layerSeries[i].indices.length;
  47906. for (var j = 0; j < pointNum; ++j) {
  47907. var theValue = data.get(dim[0], layerSeries[i].indices[j]);
  47908. var dist = Math.abs(theValue - value);
  47909. if (dist <= minDist) {
  47910. nestestValue = theValue;
  47911. minDist = dist;
  47912. nearestIdx = layerSeries[i].indices[j];
  47913. }
  47914. }
  47915. indices.push(nearestIdx);
  47916. }
  47917. return {dataIndices: indices, nestestValue: nestestValue};
  47918. },
  47919. /**
  47920. * @override
  47921. * @param {number} dataIndex index of data
  47922. */
  47923. formatTooltip: function (dataIndex) {
  47924. var data = this.getData();
  47925. var htmlName = data.get('name', dataIndex);
  47926. var htmlValue = data.get('value', dataIndex);
  47927. if (isNaN(htmlValue) || htmlValue == null) {
  47928. htmlValue = '-';
  47929. }
  47930. return encodeHTML(htmlName + ' : ' + htmlValue);
  47931. },
  47932. defaultOption: {
  47933. zlevel: 0,
  47934. z: 2,
  47935. coordinateSystem: 'singleAxis',
  47936. // gap in axis's orthogonal orientation
  47937. boundaryGap: ['10%', '10%'],
  47938. // legendHoverLink: true,
  47939. singleAxisIndex: 0,
  47940. animationEasing: 'linear',
  47941. label: {
  47942. normal: {
  47943. margin: 4,
  47944. textAlign: 'right',
  47945. show: true,
  47946. position: 'left',
  47947. color: '#000',
  47948. fontSize: 11
  47949. },
  47950. emphasis: {
  47951. show: true
  47952. }
  47953. }
  47954. }
  47955. });
  47956. module.exports = ThemeRiverSeries;
  47957. /***/ }),
  47958. /* 312 */
  47959. /***/ (function(module, exports, __webpack_require__) {
  47960. /* WEBPACK VAR INJECTION */(function(process) {/**
  47961. * @file The file used to draw themeRiver view
  47962. * @author Deqing Li(annong035@gmail.com)
  47963. */
  47964. var poly = __webpack_require__(123);
  47965. var graphic = __webpack_require__(20);
  47966. var zrUtil = __webpack_require__(4);
  47967. var DataDiffer = __webpack_require__(102);
  47968. module.exports = __webpack_require__(1).extendChartView({
  47969. type: 'themeRiver',
  47970. init: function () {
  47971. this._layers = [];
  47972. },
  47973. render: function (seriesModel, ecModel, api) {
  47974. var data = seriesModel.getData();
  47975. var rawData = seriesModel.getRawData();
  47976. if (!data.count()) {
  47977. return;
  47978. }
  47979. var group = this.group;
  47980. var layerSeries = seriesModel.getLayerSeries();
  47981. var layoutInfo = data.getLayout('layoutInfo');
  47982. var rect = layoutInfo.rect;
  47983. var boundaryGap = layoutInfo.boundaryGap;
  47984. group.attr('position', [0, rect.y + boundaryGap[0]]);
  47985. function keyGetter(item) {
  47986. return item.name;
  47987. }
  47988. var dataDiffer = new DataDiffer(
  47989. this._layersSeries || [], layerSeries,
  47990. keyGetter, keyGetter
  47991. );
  47992. var newLayersGroups = {};
  47993. dataDiffer.add(zrUtil.bind(zrUtil.curry(process, 'add'), this))
  47994. .update(zrUtil.bind(zrUtil.curry(process, 'update'), this))
  47995. .remove(zrUtil.bind(zrUtil.curry(process, 'remove'), this))
  47996. .execute();
  47997. function process(status, idx, oldIdx) {
  47998. var oldLayersGroups = this._layers;
  47999. if (status === 'remove') {
  48000. group.remove(oldLayersGroups[idx]);
  48001. return;
  48002. }
  48003. var points0 = [];
  48004. var points1 = [];
  48005. var color;
  48006. var indices = layerSeries[idx].indices;
  48007. for (var j = 0; j < indices.length; j++) {
  48008. var layout = data.getItemLayout(indices[j]);
  48009. var x = layout.x;
  48010. var y0 = layout.y0;
  48011. var y = layout.y;
  48012. points0.push([x, y0]);
  48013. points1.push([x, y0 + y]);
  48014. color = rawData.getItemVisual(indices[j], 'color');
  48015. }
  48016. var polygon;
  48017. var text;
  48018. var textLayout = data.getItemLayout(indices[0]);
  48019. var itemModel = data.getItemModel(indices[j - 1]);
  48020. var labelModel = itemModel.getModel('label.normal');
  48021. var margin = labelModel.get('margin');
  48022. if (status === 'add') {
  48023. var layerGroup = newLayersGroups[idx] = new graphic.Group();
  48024. polygon = new poly.Polygon({
  48025. shape: {
  48026. points: points0,
  48027. stackedOnPoints: points1,
  48028. smooth: 0.4,
  48029. stackedOnSmooth: 0.4,
  48030. smoothConstraint: false
  48031. },
  48032. z2: 0
  48033. });
  48034. text = new graphic.Text({
  48035. style: {
  48036. x: textLayout.x - margin,
  48037. y: textLayout.y0 + textLayout.y / 2
  48038. }
  48039. });
  48040. layerGroup.add(polygon);
  48041. layerGroup.add(text);
  48042. group.add(layerGroup);
  48043. polygon.setClipPath(createGridClipShape(polygon.getBoundingRect(), seriesModel, function () {
  48044. polygon.removeClipPath();
  48045. }));
  48046. }
  48047. else {
  48048. var layerGroup = oldLayersGroups[oldIdx];
  48049. polygon = layerGroup.childAt(0);
  48050. text = layerGroup.childAt(1);
  48051. group.add(layerGroup);
  48052. newLayersGroups[idx] = layerGroup;
  48053. graphic.updateProps(polygon, {
  48054. shape: {
  48055. points: points0,
  48056. stackedOnPoints: points1
  48057. }
  48058. }, seriesModel);
  48059. graphic.updateProps(text, {
  48060. style: {
  48061. x: textLayout.x - margin,
  48062. y: textLayout.y0 + textLayout.y / 2
  48063. }
  48064. }, seriesModel);
  48065. }
  48066. var hoverItemStyleModel = itemModel.getModel('itemStyle.emphasis');
  48067. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  48068. graphic.setTextStyle(text.style, labelModel, {
  48069. text: labelModel.get('show')
  48070. ? seriesModel.getFormattedLabel(indices[j - 1], 'normal')
  48071. || data.getName(indices[j - 1])
  48072. : null,
  48073. textVerticalAlign: 'middle'
  48074. });
  48075. polygon.setStyle(zrUtil.extend({
  48076. fill: color
  48077. }, itemStyleModel.getItemStyle(['color'])));
  48078. graphic.setHoverStyle(polygon, hoverItemStyleModel.getItemStyle());
  48079. }
  48080. this._layersSeries = layerSeries;
  48081. this._layers = newLayersGroups;
  48082. },
  48083. dispose: function () {}
  48084. });
  48085. // add animation to the view
  48086. function createGridClipShape(rect, seriesModel, cb) {
  48087. var rectEl = new graphic.Rect({
  48088. shape: {
  48089. x: rect.x - 10,
  48090. y: rect.y - 10,
  48091. width: 0,
  48092. height: rect.height + 20
  48093. }
  48094. });
  48095. graphic.initProps(rectEl, {
  48096. shape: {
  48097. width: rect.width + 20,
  48098. height: rect.height + 20
  48099. }
  48100. }, seriesModel, cb);
  48101. return rectEl;
  48102. }
  48103. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(313)))
  48104. /***/ }),
  48105. /* 313 */
  48106. /***/ (function(module, exports) {
  48107. // shim for using process in browser
  48108. var process = module.exports = {};
  48109. // cached from whatever global is present so that test runners that stub it
  48110. // don't break things. But we need to wrap it in a try catch in case it is
  48111. // wrapped in strict mode code which doesn't define any globals. It's inside a
  48112. // function because try/catches deoptimize in certain engines.
  48113. var cachedSetTimeout;
  48114. var cachedClearTimeout;
  48115. function defaultSetTimout() {
  48116. throw new Error('setTimeout has not been defined');
  48117. }
  48118. function defaultClearTimeout () {
  48119. throw new Error('clearTimeout has not been defined');
  48120. }
  48121. (function () {
  48122. try {
  48123. if (typeof setTimeout === 'function') {
  48124. cachedSetTimeout = setTimeout;
  48125. } else {
  48126. cachedSetTimeout = defaultSetTimout;
  48127. }
  48128. } catch (e) {
  48129. cachedSetTimeout = defaultSetTimout;
  48130. }
  48131. try {
  48132. if (typeof clearTimeout === 'function') {
  48133. cachedClearTimeout = clearTimeout;
  48134. } else {
  48135. cachedClearTimeout = defaultClearTimeout;
  48136. }
  48137. } catch (e) {
  48138. cachedClearTimeout = defaultClearTimeout;
  48139. }
  48140. } ())
  48141. function runTimeout(fun) {
  48142. if (cachedSetTimeout === setTimeout) {
  48143. //normal enviroments in sane situations
  48144. return setTimeout(fun, 0);
  48145. }
  48146. // if setTimeout wasn't available but was latter defined
  48147. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  48148. cachedSetTimeout = setTimeout;
  48149. return setTimeout(fun, 0);
  48150. }
  48151. try {
  48152. // when when somebody has screwed with setTimeout but no I.E. maddness
  48153. return cachedSetTimeout(fun, 0);
  48154. } catch(e){
  48155. try {
  48156. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  48157. return cachedSetTimeout.call(null, fun, 0);
  48158. } catch(e){
  48159. // 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
  48160. return cachedSetTimeout.call(this, fun, 0);
  48161. }
  48162. }
  48163. }
  48164. function runClearTimeout(marker) {
  48165. if (cachedClearTimeout === clearTimeout) {
  48166. //normal enviroments in sane situations
  48167. return clearTimeout(marker);
  48168. }
  48169. // if clearTimeout wasn't available but was latter defined
  48170. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  48171. cachedClearTimeout = clearTimeout;
  48172. return clearTimeout(marker);
  48173. }
  48174. try {
  48175. // when when somebody has screwed with setTimeout but no I.E. maddness
  48176. return cachedClearTimeout(marker);
  48177. } catch (e){
  48178. try {
  48179. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  48180. return cachedClearTimeout.call(null, marker);
  48181. } catch (e){
  48182. // 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.
  48183. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  48184. return cachedClearTimeout.call(this, marker);
  48185. }
  48186. }
  48187. }
  48188. var queue = [];
  48189. var draining = false;
  48190. var currentQueue;
  48191. var queueIndex = -1;
  48192. function cleanUpNextTick() {
  48193. if (!draining || !currentQueue) {
  48194. return;
  48195. }
  48196. draining = false;
  48197. if (currentQueue.length) {
  48198. queue = currentQueue.concat(queue);
  48199. } else {
  48200. queueIndex = -1;
  48201. }
  48202. if (queue.length) {
  48203. drainQueue();
  48204. }
  48205. }
  48206. function drainQueue() {
  48207. if (draining) {
  48208. return;
  48209. }
  48210. var timeout = runTimeout(cleanUpNextTick);
  48211. draining = true;
  48212. var len = queue.length;
  48213. while(len) {
  48214. currentQueue = queue;
  48215. queue = [];
  48216. while (++queueIndex < len) {
  48217. if (currentQueue) {
  48218. currentQueue[queueIndex].run();
  48219. }
  48220. }
  48221. queueIndex = -1;
  48222. len = queue.length;
  48223. }
  48224. currentQueue = null;
  48225. draining = false;
  48226. runClearTimeout(timeout);
  48227. }
  48228. process.nextTick = function (fun) {
  48229. var args = new Array(arguments.length - 1);
  48230. if (arguments.length > 1) {
  48231. for (var i = 1; i < arguments.length; i++) {
  48232. args[i - 1] = arguments[i];
  48233. }
  48234. }
  48235. queue.push(new Item(fun, args));
  48236. if (queue.length === 1 && !draining) {
  48237. runTimeout(drainQueue);
  48238. }
  48239. };
  48240. // v8 likes predictible objects
  48241. function Item(fun, array) {
  48242. this.fun = fun;
  48243. this.array = array;
  48244. }
  48245. Item.prototype.run = function () {
  48246. this.fun.apply(null, this.array);
  48247. };
  48248. process.title = 'browser';
  48249. process.browser = true;
  48250. process.env = {};
  48251. process.argv = [];
  48252. process.version = ''; // empty string to avoid regexp issues
  48253. process.versions = {};
  48254. function noop() {}
  48255. process.on = noop;
  48256. process.addListener = noop;
  48257. process.once = noop;
  48258. process.off = noop;
  48259. process.removeListener = noop;
  48260. process.removeAllListeners = noop;
  48261. process.emit = noop;
  48262. process.prependListener = noop;
  48263. process.prependOnceListener = noop;
  48264. process.listeners = function (name) { return [] }
  48265. process.binding = function (name) {
  48266. throw new Error('process.binding is not supported');
  48267. };
  48268. process.cwd = function () { return '/' };
  48269. process.chdir = function (dir) {
  48270. throw new Error('process.chdir is not supported');
  48271. };
  48272. process.umask = function() { return 0; };
  48273. /***/ }),
  48274. /* 314 */
  48275. /***/ (function(module, exports, __webpack_require__) {
  48276. /**
  48277. * @file Using layout algorithm transform the raw data to layout information.
  48278. * @author Deqing Li(annong035@gmail.com)
  48279. */
  48280. var zrUtil = __webpack_require__(4);
  48281. var numberUtil = __webpack_require__(7);
  48282. module.exports = function (ecModel, api) {
  48283. ecModel.eachSeriesByType('themeRiver', function (seriesModel) {
  48284. var data = seriesModel.getData();
  48285. var single = seriesModel.coordinateSystem;
  48286. var layoutInfo = {};
  48287. // use the axis boundingRect for view
  48288. var rect = single.getRect();
  48289. layoutInfo.rect = rect;
  48290. var boundaryGap = seriesModel.get('boundaryGap');
  48291. var axis = single.getAxis();
  48292. layoutInfo.boundaryGap = boundaryGap;
  48293. if (axis.orient === 'horizontal') {
  48294. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], rect.height);
  48295. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], rect.height);
  48296. var height = rect.height - boundaryGap[0] - boundaryGap[1];
  48297. themeRiverLayout(data, seriesModel, height);
  48298. }
  48299. else {
  48300. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], rect.width);
  48301. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], rect.width);
  48302. var width = rect.width - boundaryGap[0] - boundaryGap[1];
  48303. themeRiverLayout(data, seriesModel, width);
  48304. }
  48305. data.setLayout('layoutInfo', layoutInfo);
  48306. });
  48307. };
  48308. /**
  48309. * The layout information about themeriver
  48310. *
  48311. * @param {module:echarts/data/List} data data in the series
  48312. * @param {module:echarts/model/Series} seriesModel the model object of themeRiver series
  48313. * @param {number} height value used to compute every series height
  48314. */
  48315. function themeRiverLayout(data, seriesModel, height) {
  48316. if (!data.count()) {
  48317. return;
  48318. }
  48319. var coordSys = seriesModel.coordinateSystem;
  48320. // the data in each layer are organized into a series.
  48321. var layerSeries = seriesModel.getLayerSeries();
  48322. // the points in each layer.
  48323. var layerPoints = zrUtil.map(layerSeries, function (singleLayer) {
  48324. return zrUtil.map(singleLayer.indices, function (idx) {
  48325. var pt = coordSys.dataToPoint(data.get('time', idx));
  48326. pt[1] = data.get('value', idx);
  48327. return pt;
  48328. });
  48329. });
  48330. var base = computeBaseline(layerPoints);
  48331. var baseLine = base.y0;
  48332. var ky = height / base.max;
  48333. // set layout information for each item.
  48334. var n = layerSeries.length;
  48335. var m = layerSeries[0].indices.length;
  48336. var baseY0;
  48337. for (var j = 0; j < m; ++j) {
  48338. baseY0 = baseLine[j] * ky;
  48339. data.setItemLayout(layerSeries[0].indices[j], {
  48340. layerIndex: 0,
  48341. x: layerPoints[0][j][0],
  48342. y0: baseY0,
  48343. y: layerPoints[0][j][1] * ky
  48344. });
  48345. for (var i = 1; i < n; ++i) {
  48346. baseY0 += layerPoints[i - 1][j][1] * ky;
  48347. data.setItemLayout(layerSeries[i].indices[j], {
  48348. layerIndex: i,
  48349. x: layerPoints[i][j][0],
  48350. y0: baseY0,
  48351. y: layerPoints[i][j][1] * ky
  48352. });
  48353. }
  48354. }
  48355. }
  48356. /**
  48357. * Compute the baseLine of the rawdata
  48358. * Inspired by Lee Byron's paper Stacked Graphs - Geometry & Aesthetics
  48359. *
  48360. * @param {Array.<Array>} data the points in each layer
  48361. * @return {Object}
  48362. */
  48363. function computeBaseline(data) {
  48364. var layerNum = data.length;
  48365. var pointNum = data[0].length;
  48366. var sums = [];
  48367. var y0 = [];
  48368. var max = 0;
  48369. var temp;
  48370. var base = {};
  48371. for (var i = 0; i < pointNum; ++i) {
  48372. for (var j = 0, temp = 0; j < layerNum; ++j) {
  48373. temp += data[j][i][1];
  48374. }
  48375. if (temp > max) {
  48376. max = temp;
  48377. }
  48378. sums.push(temp);
  48379. }
  48380. for (var k = 0; k < pointNum; ++k) {
  48381. y0[k] = (max - sums[k]) / 2;
  48382. }
  48383. max = 0;
  48384. for (var l = 0; l < pointNum; ++l) {
  48385. var sum = sums[l] + y0[l];
  48386. if (sum > max) {
  48387. max = sum;
  48388. }
  48389. }
  48390. base.y0 = y0;
  48391. base.max = max;
  48392. return base;
  48393. }
  48394. /***/ }),
  48395. /* 315 */
  48396. /***/ (function(module, exports) {
  48397. /**
  48398. * @file Visual encoding for themeRiver view
  48399. * @author Deqing Li(annong035@gmail.com)
  48400. */
  48401. module.exports = function (ecModel) {
  48402. ecModel.eachSeriesByType('themeRiver', function (seriesModel) {
  48403. var data = seriesModel.getData();
  48404. var rawData = seriesModel.getRawData();
  48405. var colorList = seriesModel.get('color');
  48406. data.each(function (index) {
  48407. var name = data.getName(index);
  48408. var color = colorList[(seriesModel.nameMap.get(name) - 1) % colorList.length];
  48409. rawData.setItemVisual(index, 'color', color);
  48410. });
  48411. });
  48412. };
  48413. /***/ }),
  48414. /* 316 */
  48415. /***/ (function(module, exports, __webpack_require__) {
  48416. var echarts = __webpack_require__(1);
  48417. var zrUtil = __webpack_require__(4);
  48418. var graphicUtil = __webpack_require__(20);
  48419. var labelHelper = __webpack_require__(121);
  48420. var createListFromArray = __webpack_require__(112);
  48421. var barGrid = __webpack_require__(148);
  48422. var DataDiffer = __webpack_require__(102);
  48423. var ITEM_STYLE_NORMAL_PATH = ['itemStyle', 'normal'];
  48424. var ITEM_STYLE_EMPHASIS_PATH = ['itemStyle', 'emphasis'];
  48425. var LABEL_NORMAL = ['label', 'normal'];
  48426. var LABEL_EMPHASIS = ['label', 'emphasis'];
  48427. // Use prefix to avoid index to be the same as el.name,
  48428. // which will cause weird udpate animation.
  48429. var GROUP_DIFF_PREFIX = 'e\0\0';
  48430. /**
  48431. * To reduce total package size of each coordinate systems, the modules `prepareCustom`
  48432. * of each coordinate systems are not required by each coordinate systems directly, but
  48433. * required by the module `custom`.
  48434. *
  48435. * prepareInfoForCustomSeries {Function}: optional
  48436. * @return {Object} {coordSys: {...}, api: {
  48437. * coord: function (data, clamp) {}, // return point in global.
  48438. * size: function (dataSize, dataItem) {} // return size of each axis in coordSys.
  48439. * }}
  48440. */
  48441. var prepareCustoms = {
  48442. cartesian2d: __webpack_require__(317),
  48443. geo: __webpack_require__(318),
  48444. singleAxis: __webpack_require__(319),
  48445. polar: __webpack_require__(320),
  48446. calendar: __webpack_require__(321)
  48447. };
  48448. // ------
  48449. // Model
  48450. // ------
  48451. echarts.extendSeriesModel({
  48452. type: 'series.custom',
  48453. dependencies: ['grid', 'polar', 'geo', 'singleAxis', 'calendar'],
  48454. defaultOption: {
  48455. coordinateSystem: 'cartesian2d', // Can be set as 'none'
  48456. zlevel: 0,
  48457. z: 2,
  48458. legendHoverLink: true
  48459. // Cartesian coordinate system
  48460. // xAxisIndex: 0,
  48461. // yAxisIndex: 0,
  48462. // Polar coordinate system
  48463. // polarIndex: 0,
  48464. // Geo coordinate system
  48465. // geoIndex: 0,
  48466. // label: {}
  48467. // itemStyle: {}
  48468. },
  48469. getInitialData: function (option, ecModel) {
  48470. return createListFromArray(option.data, this, ecModel);
  48471. }
  48472. });
  48473. // -----
  48474. // View
  48475. // -----
  48476. echarts.extendChartView({
  48477. type: 'custom',
  48478. /**
  48479. * @private
  48480. * @type {module:echarts/data/List}
  48481. */
  48482. _data: null,
  48483. /**
  48484. * @override
  48485. */
  48486. render: function (customSeries, ecModel, api) {
  48487. var oldData = this._data;
  48488. var data = customSeries.getData();
  48489. var group = this.group;
  48490. var renderItem = makeRenderItem(customSeries, data, ecModel, api);
  48491. data.diff(oldData)
  48492. .add(function (newIdx) {
  48493. data.hasValue(newIdx) && createOrUpdate(
  48494. null, newIdx, renderItem(newIdx), customSeries, group, data
  48495. );
  48496. })
  48497. .update(function (newIdx, oldIdx) {
  48498. var el = oldData.getItemGraphicEl(oldIdx);
  48499. data.hasValue(newIdx)
  48500. ? createOrUpdate(
  48501. el, newIdx, renderItem(newIdx), customSeries, group, data
  48502. )
  48503. : (el && group.remove(el));
  48504. })
  48505. .remove(function (oldIdx) {
  48506. var el = oldData.getItemGraphicEl(oldIdx);
  48507. el && group.remove(el);
  48508. })
  48509. .execute();
  48510. this._data = data;
  48511. },
  48512. /**
  48513. * @override
  48514. */
  48515. dispose: zrUtil.noop
  48516. });
  48517. function createEl(elOption) {
  48518. var graphicType = elOption.type;
  48519. var el;
  48520. if (graphicType === 'path') {
  48521. var shape = elOption.shape;
  48522. el = graphicUtil.makePath(
  48523. shape.pathData,
  48524. null,
  48525. {
  48526. x: shape.x || 0,
  48527. y: shape.y || 0,
  48528. width: shape.width || 0,
  48529. height: shape.height || 0
  48530. },
  48531. 'center'
  48532. );
  48533. el.__customPathData = elOption.pathData;
  48534. }
  48535. else if (graphicType === 'image') {
  48536. el = new graphicUtil.Image({
  48537. });
  48538. el.__customImagePath = elOption.style.image;
  48539. }
  48540. else if (graphicType === 'text') {
  48541. el = new graphicUtil.Text({
  48542. });
  48543. el.__customText = elOption.style.text;
  48544. }
  48545. else {
  48546. var Clz = graphicUtil[graphicType.charAt(0).toUpperCase() + graphicType.slice(1)];
  48547. if (true) {
  48548. zrUtil.assert(Clz, 'graphic type "' + graphicType + '" can not be found.');
  48549. }
  48550. el = new Clz();
  48551. }
  48552. el.__customGraphicType = graphicType;
  48553. el.name = elOption.name;
  48554. return el;
  48555. }
  48556. function updateEl(el, dataIndex, elOption, animatableModel, data, isInit) {
  48557. var targetProps = {};
  48558. var elOptionStyle = elOption.style || {};
  48559. elOption.shape && (targetProps.shape = zrUtil.clone(elOption.shape));
  48560. elOption.position && (targetProps.position = elOption.position.slice());
  48561. elOption.scale && (targetProps.scale = elOption.scale.slice());
  48562. elOption.origin && (targetProps.origin = elOption.origin.slice());
  48563. elOption.rotation && (targetProps.rotation = elOption.rotation);
  48564. if (el.type === 'image' && elOption.style) {
  48565. var targetStyle = targetProps.style = {};
  48566. zrUtil.each(['x', 'y', 'width', 'height'], function (prop) {
  48567. prepareStyleTransition(prop, targetStyle, elOptionStyle, el.style, isInit);
  48568. });
  48569. }
  48570. if (el.type === 'text' && elOption.style) {
  48571. var targetStyle = targetProps.style = {};
  48572. zrUtil.each(['x', 'y'], function (prop) {
  48573. prepareStyleTransition(prop, targetStyle, elOptionStyle, el.style, isInit);
  48574. });
  48575. // Compatible with previous: both support
  48576. // textFill and fill, textStroke and stroke in 'text' element.
  48577. !elOptionStyle.hasOwnProperty('textFill') && elOptionStyle.fill && (
  48578. elOptionStyle.textFill = elOptionStyle.fill
  48579. );
  48580. !elOptionStyle.hasOwnProperty('textStroke') && elOptionStyle.stroke && (
  48581. elOptionStyle.textStroke = elOptionStyle.stroke
  48582. );
  48583. }
  48584. if (el.type !== 'group') {
  48585. el.useStyle(elOptionStyle);
  48586. // Init animation.
  48587. if (isInit) {
  48588. el.style.opacity = 0;
  48589. var targetOpacity = elOptionStyle.opacity;
  48590. targetOpacity == null && (targetOpacity = 1);
  48591. graphicUtil.initProps(el, {style: {opacity: targetOpacity}}, animatableModel, dataIndex);
  48592. }
  48593. }
  48594. if (isInit) {
  48595. el.attr(targetProps);
  48596. }
  48597. else {
  48598. graphicUtil.updateProps(el, targetProps, animatableModel, dataIndex);
  48599. }
  48600. // z2 must not be null/undefined, otherwise sort error may occur.
  48601. el.attr({z2: elOption.z2 || 0, silent: elOption.silent});
  48602. elOption.styleEmphasis !== false && graphicUtil.setHoverStyle(el, elOption.styleEmphasis);
  48603. }
  48604. function prepareStyleTransition(prop, targetStyle, elOptionStyle, oldElStyle, isInit) {
  48605. if (elOptionStyle[prop] != null && !isInit) {
  48606. targetStyle[prop] = elOptionStyle[prop];
  48607. elOptionStyle[prop] = oldElStyle[prop];
  48608. }
  48609. }
  48610. function makeRenderItem(customSeries, data, ecModel, api) {
  48611. var renderItem = customSeries.get('renderItem');
  48612. var coordSys = customSeries.coordinateSystem;
  48613. var prepareResult = {};
  48614. if (coordSys) {
  48615. if (true) {
  48616. zrUtil.assert(renderItem, 'series.render is required.');
  48617. zrUtil.assert(
  48618. coordSys.prepareCustoms || prepareCustoms[coordSys.type],
  48619. 'This coordSys does not support custom series.'
  48620. );
  48621. }
  48622. prepareResult = coordSys.prepareCustoms
  48623. ? coordSys.prepareCustoms()
  48624. : prepareCustoms[coordSys.type](coordSys);
  48625. }
  48626. var userAPI = zrUtil.defaults({
  48627. getWidth: api.getWidth,
  48628. getHeight: api.getHeight,
  48629. getZr: api.getZr,
  48630. getDevicePixelRatio: api.getDevicePixelRatio,
  48631. value: value,
  48632. style: style,
  48633. styleEmphasis: styleEmphasis,
  48634. visual: visual,
  48635. barLayout: barLayout,
  48636. currentSeriesIndices: currentSeriesIndices,
  48637. font: font
  48638. }, prepareResult.api || {});
  48639. var userParams = {
  48640. context: {},
  48641. seriesId: customSeries.id,
  48642. seriesName: customSeries.name,
  48643. seriesIndex: customSeries.seriesIndex,
  48644. coordSys: prepareResult.coordSys,
  48645. dataInsideLength: data.count(),
  48646. encode: wrapEncodeDef(customSeries.getData())
  48647. };
  48648. // Do not support call `api` asynchronously without dataIndexInside input.
  48649. var currDataIndexInside;
  48650. var currDirty = true;
  48651. var currItemModel;
  48652. var currLabelNormalModel;
  48653. var currLabelEmphasisModel;
  48654. var currLabelValueDim;
  48655. var currVisualColor;
  48656. return function (dataIndexInside) {
  48657. currDataIndexInside = dataIndexInside;
  48658. currDirty = true;
  48659. return renderItem && renderItem(
  48660. zrUtil.defaults({
  48661. dataIndexInside: dataIndexInside,
  48662. dataIndex: data.getRawIndex(dataIndexInside)
  48663. }, userParams),
  48664. userAPI
  48665. ) || {};
  48666. };
  48667. // Do not update cache until api called.
  48668. function updateCache(dataIndexInside) {
  48669. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  48670. if (currDirty) {
  48671. currItemModel = data.getItemModel(dataIndexInside);
  48672. currLabelNormalModel = currItemModel.getModel(LABEL_NORMAL);
  48673. currLabelEmphasisModel = currItemModel.getModel(LABEL_EMPHASIS);
  48674. currLabelValueDim = labelHelper.findLabelValueDim(data);
  48675. currVisualColor = data.getItemVisual(dataIndexInside, 'color');
  48676. currDirty = false;
  48677. }
  48678. }
  48679. /**
  48680. * @public
  48681. * @param {number|string} dim
  48682. * @param {number} [dataIndexInside=currDataIndexInside]
  48683. * @return {number|string} value
  48684. */
  48685. function value(dim, dataIndexInside) {
  48686. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  48687. return data.get(data.getDimension(dim || 0), dataIndexInside);
  48688. }
  48689. /**
  48690. * By default, `visual` is applied to style (to support visualMap).
  48691. * `visual.color` is applied at `fill`. If user want apply visual.color on `stroke`,
  48692. * it can be implemented as:
  48693. * `api.style({stroke: api.visual('color'), fill: null})`;
  48694. * @public
  48695. * @param {Object} [extra]
  48696. * @param {number} [dataIndexInside=currDataIndexInside]
  48697. */
  48698. function style(extra, dataIndexInside) {
  48699. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  48700. updateCache(dataIndexInside);
  48701. var itemStyle = currItemModel.getModel(ITEM_STYLE_NORMAL_PATH).getItemStyle();
  48702. currVisualColor != null && (itemStyle.fill = currVisualColor);
  48703. var opacity = data.getItemVisual(dataIndexInside, 'opacity');
  48704. opacity != null && (itemStyle.opacity = opacity);
  48705. if (currLabelValueDim != null) {
  48706. graphicUtil.setTextStyle(itemStyle, currLabelNormalModel, null, {
  48707. autoColor: currVisualColor,
  48708. isRectText: true
  48709. });
  48710. itemStyle.text = currLabelNormalModel.getShallow('show')
  48711. ? zrUtil.retrieve2(
  48712. customSeries.getFormattedLabel(dataIndexInside, 'normal'),
  48713. data.get(currLabelValueDim, dataIndexInside)
  48714. )
  48715. : null;
  48716. }
  48717. extra && zrUtil.extend(itemStyle, extra);
  48718. return itemStyle;
  48719. }
  48720. /**
  48721. * @public
  48722. * @param {Object} [extra]
  48723. * @param {number} [dataIndexInside=currDataIndexInside]
  48724. */
  48725. function styleEmphasis(extra, dataIndexInside) {
  48726. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  48727. updateCache(dataIndexInside);
  48728. var itemStyle = currItemModel.getModel(ITEM_STYLE_EMPHASIS_PATH).getItemStyle();
  48729. if (currLabelValueDim != null) {
  48730. graphicUtil.setTextStyle(itemStyle, currLabelEmphasisModel, null, {
  48731. isRectText: true
  48732. }, true);
  48733. itemStyle.text = currLabelEmphasisModel.getShallow('show')
  48734. ? zrUtil.retrieve3(
  48735. customSeries.getFormattedLabel(dataIndexInside, 'emphasis'),
  48736. customSeries.getFormattedLabel(dataIndexInside, 'normal'),
  48737. data.get(currLabelValueDim, dataIndexInside)
  48738. )
  48739. : null;
  48740. }
  48741. extra && zrUtil.extend(itemStyle, extra);
  48742. return itemStyle;
  48743. }
  48744. /**
  48745. * @public
  48746. * @param {string} visualType
  48747. * @param {number} [dataIndexInside=currDataIndexInside]
  48748. */
  48749. function visual(visualType, dataIndexInside) {
  48750. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  48751. return data.getItemVisual(dataIndexInside, visualType);
  48752. }
  48753. /**
  48754. * @public
  48755. * @param {number} opt.count Positive interger.
  48756. * @param {number} [opt.barWidth]
  48757. * @param {number} [opt.barMaxWidth]
  48758. * @param {number} [opt.barGap]
  48759. * @param {number} [opt.barCategoryGap]
  48760. * @return {Object} {width, offset, offsetCenter} is not support, return undefined.
  48761. */
  48762. function barLayout(opt) {
  48763. if (coordSys.getBaseAxis) {
  48764. var baseAxis = coordSys.getBaseAxis();
  48765. return barGrid.getLayoutOnAxis(zrUtil.defaults({axis: baseAxis}, opt), api);
  48766. }
  48767. }
  48768. /**
  48769. * @public
  48770. * @return {Array.<number>}
  48771. */
  48772. function currentSeriesIndices() {
  48773. return ecModel.getCurrentSeriesIndices();
  48774. }
  48775. /**
  48776. * @public
  48777. * @param {Object} opt
  48778. * @param {string} [opt.fontStyle]
  48779. * @param {number} [opt.fontWeight]
  48780. * @param {number} [opt.fontSize]
  48781. * @param {string} [opt.fontFamily]
  48782. * @return {string} font string
  48783. */
  48784. function font(opt) {
  48785. return graphicUtil.getFont(opt, ecModel);
  48786. }
  48787. }
  48788. function wrapEncodeDef(data) {
  48789. var encodeDef = {};
  48790. zrUtil.each(data.dimensions, function (dimName, dataDimIndex) {
  48791. var dimInfo = data.getDimensionInfo(dimName);
  48792. if (!dimInfo.isExtraCoord) {
  48793. var coordDim = dimInfo.coordDim;
  48794. var dataDims = encodeDef[coordDim] = encodeDef[coordDim] || [];
  48795. dataDims[dimInfo.coordDimIndex] = dataDimIndex;
  48796. }
  48797. });
  48798. return encodeDef;
  48799. }
  48800. function createOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
  48801. el = doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data);
  48802. el && data.setItemGraphicEl(dataIndex, el);
  48803. }
  48804. function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
  48805. var elOptionType = elOption.type;
  48806. if (el
  48807. && elOptionType !== el.__customGraphicType
  48808. && (elOptionType !== 'path' || elOption.pathData !== el.__customPathData)
  48809. && (elOptionType !== 'image' || elOption.style.image !== el.__customImagePath)
  48810. && (elOptionType !== 'text' || elOption.style.text !== el.__customText)
  48811. ) {
  48812. group.remove(el);
  48813. el = null;
  48814. }
  48815. // `elOption.type` is undefined when `renderItem` returns nothing.
  48816. if (elOptionType == null) {
  48817. return;
  48818. }
  48819. var isInit = !el;
  48820. !el && (el = createEl(elOption));
  48821. updateEl(el, dataIndex, elOption, animatableModel, data, isInit);
  48822. if (elOptionType === 'group') {
  48823. var oldChildren = el.children() || [];
  48824. var newChildren = elOption.children || [];
  48825. if (elOption.diffChildrenByName) {
  48826. // lower performance.
  48827. diffGroupChildren({
  48828. oldChildren: oldChildren,
  48829. newChildren: newChildren,
  48830. dataIndex: dataIndex,
  48831. animatableModel: animatableModel,
  48832. group: el,
  48833. data: data
  48834. });
  48835. }
  48836. else {
  48837. // better performance.
  48838. var index = 0;
  48839. for (; index < newChildren.length; index++) {
  48840. doCreateOrUpdate(
  48841. el.childAt(index),
  48842. dataIndex,
  48843. newChildren[index],
  48844. animatableModel,
  48845. el,
  48846. data
  48847. );
  48848. }
  48849. for (; index < oldChildren.length; index++) {
  48850. oldChildren[index] && el.remove(oldChildren[index]);
  48851. }
  48852. }
  48853. }
  48854. group.add(el);
  48855. return el;
  48856. }
  48857. function diffGroupChildren(context) {
  48858. (new DataDiffer(
  48859. context.oldChildren,
  48860. context.newChildren,
  48861. getKey,
  48862. getKey,
  48863. context
  48864. ))
  48865. .add(processAddUpdate)
  48866. .update(processAddUpdate)
  48867. .remove(processRemove)
  48868. .execute();
  48869. }
  48870. function getKey(item, idx) {
  48871. var name = item && item.name;
  48872. return name != null ? name : GROUP_DIFF_PREFIX + idx;
  48873. }
  48874. function processAddUpdate(newIndex, oldIndex) {
  48875. var context = this.context;
  48876. var childOption = newIndex != null ? context.newChildren[newIndex] : null;
  48877. var child = oldIndex != null ? context.oldChildren[oldIndex] : null;
  48878. doCreateOrUpdate(
  48879. child,
  48880. context.dataIndex,
  48881. childOption,
  48882. context.animatableModel,
  48883. context.group,
  48884. context.data
  48885. );
  48886. }
  48887. function processRemove(oldIndex) {
  48888. var context = this.context;
  48889. var child = context.oldChildren[oldIndex];
  48890. child && context.group.remove(child);
  48891. }
  48892. /***/ }),
  48893. /* 317 */
  48894. /***/ (function(module, exports, __webpack_require__) {
  48895. var zrUtil = __webpack_require__(4);
  48896. function dataToCoordSize(dataSize, dataItem) {
  48897. // dataItem is necessary in log axis.
  48898. dataItem = dataItem || [0, 0];
  48899. return zrUtil.map(['x', 'y'], function (dim, dimIdx) {
  48900. var axis = this.getAxis(dim);
  48901. var val = dataItem[dimIdx];
  48902. var halfSize = dataSize[dimIdx] / 2;
  48903. return axis.type === 'category'
  48904. ? axis.getBandWidth()
  48905. : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
  48906. }, this);
  48907. }
  48908. function prepareCustom(coordSys) {
  48909. var rect = coordSys.grid.getRect();
  48910. return {
  48911. coordSys: {
  48912. // The name exposed to user is always 'cartesian2d' but not 'grid'.
  48913. type: 'cartesian2d',
  48914. x: rect.x,
  48915. y: rect.y,
  48916. width: rect.width,
  48917. height: rect.height
  48918. },
  48919. api: {
  48920. coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
  48921. size: zrUtil.bind(dataToCoordSize, coordSys)
  48922. }
  48923. };
  48924. }
  48925. module.exports = prepareCustom;
  48926. /***/ }),
  48927. /* 318 */
  48928. /***/ (function(module, exports, __webpack_require__) {
  48929. var zrUtil = __webpack_require__(4);
  48930. function dataToCoordSize(dataSize, dataItem) {
  48931. dataItem = dataItem || [0, 0];
  48932. return zrUtil.map([0, 1], function (dimIdx) {
  48933. var val = dataItem[dimIdx];
  48934. var halfSize = dataSize[dimIdx] / 2;
  48935. var p1 = [];
  48936. var p2 = [];
  48937. p1[dimIdx] = val - halfSize;
  48938. p2[dimIdx] = val + halfSize;
  48939. p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
  48940. return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
  48941. }, this);
  48942. }
  48943. function prepareCustom(coordSys) {
  48944. var rect = coordSys.getBoundingRect();
  48945. return {
  48946. coordSys: {
  48947. type: 'geo',
  48948. x: rect.x,
  48949. y: rect.y,
  48950. width: rect.width,
  48951. height: rect.height
  48952. },
  48953. api: {
  48954. coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
  48955. size: zrUtil.bind(dataToCoordSize, coordSys)
  48956. }
  48957. };
  48958. }
  48959. module.exports = prepareCustom;
  48960. /***/ }),
  48961. /* 319 */
  48962. /***/ (function(module, exports, __webpack_require__) {
  48963. var zrUtil = __webpack_require__(4);
  48964. function dataToCoordSize(dataSize, dataItem) {
  48965. // dataItem is necessary in log axis.
  48966. var axis = this.getAxis();
  48967. var val = dataItem instanceof Array ? dataItem[0] : dataItem;
  48968. var halfSize = (dataSize instanceof Array ? dataSize[0] : dataSize) / 2;
  48969. return axis.type === 'category'
  48970. ? axis.getBandWidth()
  48971. : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
  48972. }
  48973. function prepareCustom(coordSys) {
  48974. var rect = coordSys.getRect();
  48975. return {
  48976. coordSys: {
  48977. type: 'singleAxis',
  48978. x: rect.x,
  48979. y: rect.y,
  48980. width: rect.width,
  48981. height: rect.height
  48982. },
  48983. api: {
  48984. coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
  48985. size: zrUtil.bind(dataToCoordSize, coordSys)
  48986. }
  48987. };
  48988. }
  48989. module.exports = prepareCustom;
  48990. /***/ }),
  48991. /* 320 */
  48992. /***/ (function(module, exports, __webpack_require__) {
  48993. var zrUtil = __webpack_require__(4);
  48994. function dataToCoordSize(dataSize, dataItem) {
  48995. // dataItem is necessary in log axis.
  48996. return zrUtil.map(['Radius', 'Angle'], function (dim, dimIdx) {
  48997. var axis = this['get' + dim + 'Axis']();
  48998. var val = dataItem[dimIdx];
  48999. var halfSize = dataSize[dimIdx] / 2;
  49000. var method = 'dataTo' + dim;
  49001. var result = axis.type === 'category'
  49002. ? axis.getBandWidth()
  49003. : Math.abs(axis[method](val - halfSize) - axis[method](val + halfSize));
  49004. if (dim === 'Angle') {
  49005. result = result * Math.PI / 180;
  49006. }
  49007. return result;
  49008. }, this);
  49009. }
  49010. function prepareCustom(coordSys) {
  49011. var radiusAxis = coordSys.getRadiusAxis();
  49012. var angleAxis = coordSys.getAngleAxis();
  49013. var radius = radiusAxis.getExtent();
  49014. radius[0] > radius[1] && radius.reverse();
  49015. return {
  49016. coordSys: {
  49017. type: 'polar',
  49018. cx: coordSys.cx,
  49019. cy: coordSys.cy,
  49020. r: radius[1],
  49021. r0: radius[0]
  49022. },
  49023. api: {
  49024. coord: zrUtil.bind(function (data) {
  49025. var radius = radiusAxis.dataToRadius(data[0]);
  49026. var angle = angleAxis.dataToAngle(data[1]);
  49027. var coord = coordSys.coordToPoint([radius, angle]);
  49028. coord.push(radius, angle * Math.PI / 180);
  49029. return coord;
  49030. }),
  49031. size: zrUtil.bind(dataToCoordSize, coordSys)
  49032. }
  49033. };
  49034. }
  49035. module.exports = prepareCustom;
  49036. /***/ }),
  49037. /* 321 */
  49038. /***/ (function(module, exports, __webpack_require__) {
  49039. var zrUtil = __webpack_require__(4);
  49040. function prepareCustom(coordSys) {
  49041. var rect = coordSys.getRect();
  49042. var rangeInfo = coordSys.getRangeInfo();
  49043. return {
  49044. coordSys: {
  49045. type: 'calendar',
  49046. x: rect.x,
  49047. y: rect.y,
  49048. width: rect.width,
  49049. height: rect.height,
  49050. cellWidth: coordSys.getCellWidth(),
  49051. cellHeight: coordSys.getCellHeight(),
  49052. rangeInfo: {
  49053. start: rangeInfo.start,
  49054. end: rangeInfo.end,
  49055. weeks: rangeInfo.weeks,
  49056. dayCount: rangeInfo.allDay
  49057. }
  49058. },
  49059. api: {
  49060. coord: zrUtil.bind(coordSys.dataToPoint, coordSys)
  49061. }
  49062. };
  49063. }
  49064. module.exports = prepareCustom;
  49065. /***/ }),
  49066. /* 322 */
  49067. /***/ (function(module, exports, __webpack_require__) {
  49068. var echarts = __webpack_require__(1);
  49069. var zrUtil = __webpack_require__(4);
  49070. var modelUtil = __webpack_require__(5);
  49071. var graphicUtil = __webpack_require__(20);
  49072. var layoutUtil = __webpack_require__(74);
  49073. // -------------
  49074. // Preprocessor
  49075. // -------------
  49076. echarts.registerPreprocessor(function (option) {
  49077. var graphicOption = option.graphic;
  49078. // Convert
  49079. // {graphic: [{left: 10, type: 'circle'}, ...]}
  49080. // or
  49081. // {graphic: {left: 10, type: 'circle'}}
  49082. // to
  49083. // {graphic: [{elements: [{left: 10, type: 'circle'}, ...]}]}
  49084. if (zrUtil.isArray(graphicOption)) {
  49085. if (!graphicOption[0] || !graphicOption[0].elements) {
  49086. option.graphic = [{elements: graphicOption}];
  49087. }
  49088. else {
  49089. // Only one graphic instance can be instantiated. (We dont
  49090. // want that too many views are created in echarts._viewMap)
  49091. option.graphic = [option.graphic[0]];
  49092. }
  49093. }
  49094. else if (graphicOption && !graphicOption.elements) {
  49095. option.graphic = [{elements: [graphicOption]}];
  49096. }
  49097. });
  49098. // ------
  49099. // Model
  49100. // ------
  49101. var GraphicModel = echarts.extendComponentModel({
  49102. type: 'graphic',
  49103. defaultOption: {
  49104. // Extra properties for each elements:
  49105. //
  49106. // left/right/top/bottom: (like 12, '22%', 'center', default undefined)
  49107. // If left/rigth is set, shape.x/shape.cx/position will not be used.
  49108. // If top/bottom is set, shape.y/shape.cy/position will not be used.
  49109. // This mechanism is useful when you want to position a group/element
  49110. // against the right side or the center of this container.
  49111. //
  49112. // width/height: (can only be pixel value, default 0)
  49113. // Only be used to specify contianer(group) size, if needed. And
  49114. // can not be percentage value (like '33%'). See the reason in the
  49115. // layout algorithm below.
  49116. //
  49117. // bounding: (enum: 'all' (default) | 'raw')
  49118. // Specify how to calculate boundingRect when locating.
  49119. // 'all': Get uioned and transformed boundingRect
  49120. // from both itself and its descendants.
  49121. // This mode simplies confining a group of elements in the bounding
  49122. // of their ancester container (e.g., using 'right: 0').
  49123. // 'raw': Only use the boundingRect of itself and before transformed.
  49124. // This mode is similar to css behavior, which is useful when you
  49125. // want an element to be able to overflow its container. (Consider
  49126. // a rotated circle needs to be located in a corner.)
  49127. // Note: elements is always behind its ancestors in this elements array.
  49128. elements: [],
  49129. parentId: null
  49130. },
  49131. /**
  49132. * Save el options for the sake of the performance (only update modified graphics).
  49133. * The order is the same as those in option. (ancesters -> descendants)
  49134. *
  49135. * @private
  49136. * @type {Array.<Object>}
  49137. */
  49138. _elOptionsToUpdate: null,
  49139. /**
  49140. * @override
  49141. */
  49142. mergeOption: function (option) {
  49143. // Prevent default merge to elements
  49144. var elements = this.option.elements;
  49145. this.option.elements = null;
  49146. GraphicModel.superApply(this, 'mergeOption', arguments);
  49147. this.option.elements = elements;
  49148. },
  49149. /**
  49150. * @override
  49151. */
  49152. optionUpdated: function (newOption, isInit) {
  49153. var thisOption = this.option;
  49154. var newList = (isInit ? thisOption : newOption).elements;
  49155. var existList = thisOption.elements = isInit ? [] : thisOption.elements;
  49156. var flattenedList = [];
  49157. this._flatten(newList, flattenedList);
  49158. var mappingResult = modelUtil.mappingToExists(existList, flattenedList);
  49159. modelUtil.makeIdAndName(mappingResult);
  49160. // Clear elOptionsToUpdate
  49161. var elOptionsToUpdate = this._elOptionsToUpdate = [];
  49162. zrUtil.each(mappingResult, function (resultItem, index) {
  49163. var newElOption = resultItem.option;
  49164. if (true) {
  49165. zrUtil.assert(
  49166. zrUtil.isObject(newElOption) || resultItem.exist,
  49167. 'Empty graphic option definition'
  49168. );
  49169. }
  49170. if (!newElOption) {
  49171. return;
  49172. }
  49173. elOptionsToUpdate.push(newElOption);
  49174. setKeyInfoToNewElOption(resultItem, newElOption);
  49175. mergeNewElOptionToExist(existList, index, newElOption);
  49176. setLayoutInfoToExist(existList[index], newElOption);
  49177. }, this);
  49178. // Clean
  49179. for (var i = existList.length - 1; i >= 0; i--) {
  49180. if (existList[i] == null) {
  49181. existList.splice(i, 1);
  49182. }
  49183. else {
  49184. // $action should be volatile, otherwise option gotten from
  49185. // `getOption` will contain unexpected $action.
  49186. delete existList[i].$action;
  49187. }
  49188. }
  49189. },
  49190. /**
  49191. * Convert
  49192. * [{
  49193. * type: 'group',
  49194. * id: 'xx',
  49195. * children: [{type: 'circle'}, {type: 'polygon'}]
  49196. * }]
  49197. * to
  49198. * [
  49199. * {type: 'group', id: 'xx'},
  49200. * {type: 'circle', parentId: 'xx'},
  49201. * {type: 'polygon', parentId: 'xx'}
  49202. * ]
  49203. *
  49204. * @private
  49205. * @param {Array.<Object>} optionList option list
  49206. * @param {Array.<Object>} result result of flatten
  49207. * @param {Object} parentOption parent option
  49208. */
  49209. _flatten: function (optionList, result, parentOption) {
  49210. zrUtil.each(optionList, function (option) {
  49211. if (!option) {
  49212. return;
  49213. }
  49214. if (parentOption) {
  49215. option.parentOption = parentOption;
  49216. }
  49217. result.push(option);
  49218. var children = option.children;
  49219. if (option.type === 'group' && children) {
  49220. this._flatten(children, result, option);
  49221. }
  49222. // Deleting for JSON output, and for not affecting group creation.
  49223. delete option.children;
  49224. }, this);
  49225. },
  49226. // FIXME
  49227. // Pass to view using payload? setOption has a payload?
  49228. useElOptionsToUpdate: function () {
  49229. var els = this._elOptionsToUpdate;
  49230. // Clear to avoid render duplicately when zooming.
  49231. this._elOptionsToUpdate = null;
  49232. return els;
  49233. }
  49234. });
  49235. // -----
  49236. // View
  49237. // -----
  49238. echarts.extendComponentView({
  49239. type: 'graphic',
  49240. /**
  49241. * @override
  49242. */
  49243. init: function (ecModel, api) {
  49244. /**
  49245. * @private
  49246. * @type {module:zrender/core/util.HashMap}
  49247. */
  49248. this._elMap = zrUtil.createHashMap();
  49249. /**
  49250. * @private
  49251. * @type {module:echarts/graphic/GraphicModel}
  49252. */
  49253. this._lastGraphicModel;
  49254. },
  49255. /**
  49256. * @override
  49257. */
  49258. render: function (graphicModel, ecModel, api) {
  49259. // Having leveraged between use cases and algorithm complexity, a very
  49260. // simple layout mechanism is used:
  49261. // The size(width/height) can be determined by itself or its parent (not
  49262. // implemented yet), but can not by its children. (Top-down travel)
  49263. // The location(x/y) can be determined by the bounding rect of itself
  49264. // (can including its descendants or not) and the size of its parent.
  49265. // (Bottom-up travel)
  49266. // When `chart.clear()` or `chart.setOption({...}, true)` with the same id,
  49267. // view will be reused.
  49268. if (graphicModel !== this._lastGraphicModel) {
  49269. this._clear();
  49270. }
  49271. this._lastGraphicModel = graphicModel;
  49272. this._updateElements(graphicModel, api);
  49273. this._relocate(graphicModel, api);
  49274. },
  49275. /**
  49276. * Update graphic elements.
  49277. *
  49278. * @private
  49279. * @param {Object} graphicModel graphic model
  49280. * @param {module:echarts/ExtensionAPI} api extension API
  49281. */
  49282. _updateElements: function (graphicModel, api) {
  49283. var elOptionsToUpdate = graphicModel.useElOptionsToUpdate();
  49284. if (!elOptionsToUpdate) {
  49285. return;
  49286. }
  49287. var elMap = this._elMap;
  49288. var rootGroup = this.group;
  49289. // Top-down tranverse to assign graphic settings to each elements.
  49290. zrUtil.each(elOptionsToUpdate, function (elOption) {
  49291. var $action = elOption.$action;
  49292. var id = elOption.id;
  49293. var existEl = elMap.get(id);
  49294. var parentId = elOption.parentId;
  49295. var targetElParent = parentId != null ? elMap.get(parentId) : rootGroup;
  49296. if (elOption.type === 'text') {
  49297. var elOptionStyle = elOption.style;
  49298. // In top/bottom mode, textVerticalAlign should not be used, which cause
  49299. // inaccurately locating.
  49300. if (elOption.hv && elOption.hv[1]) {
  49301. elOptionStyle.textVerticalAlign = elOptionStyle.textBaseline = null;
  49302. }
  49303. // Compatible with previous setting: both support fill and textFill,
  49304. // stroke and textStroke.
  49305. !elOptionStyle.hasOwnProperty('textFill') && elOptionStyle.fill && (
  49306. elOptionStyle.textFill = elOptionStyle.fill
  49307. );
  49308. !elOptionStyle.hasOwnProperty('textStroke') && elOptionStyle.stroke && (
  49309. elOptionStyle.textStroke = elOptionStyle.stroke
  49310. );
  49311. }
  49312. // Remove unnecessary props to avoid potential problems.
  49313. var elOptionCleaned = getCleanedElOption(elOption);
  49314. // For simple, do not support parent change, otherwise reorder is needed.
  49315. if (true) {
  49316. existEl && zrUtil.assert(
  49317. targetElParent === existEl.parent,
  49318. 'Changing parent is not supported.'
  49319. );
  49320. }
  49321. if (!$action || $action === 'merge') {
  49322. existEl
  49323. ? existEl.attr(elOptionCleaned)
  49324. : createEl(id, targetElParent, elOptionCleaned, elMap);
  49325. }
  49326. else if ($action === 'replace') {
  49327. removeEl(existEl, elMap);
  49328. createEl(id, targetElParent, elOptionCleaned, elMap);
  49329. }
  49330. else if ($action === 'remove') {
  49331. removeEl(existEl, elMap);
  49332. }
  49333. var el = elMap.get(id);
  49334. if (el) {
  49335. el.__ecGraphicWidth = elOption.width;
  49336. el.__ecGraphicHeight = elOption.height;
  49337. }
  49338. });
  49339. },
  49340. /**
  49341. * Locate graphic elements.
  49342. *
  49343. * @private
  49344. * @param {Object} graphicModel graphic model
  49345. * @param {module:echarts/ExtensionAPI} api extension API
  49346. */
  49347. _relocate: function (graphicModel, api) {
  49348. var elOptions = graphicModel.option.elements;
  49349. var rootGroup = this.group;
  49350. var elMap = this._elMap;
  49351. // Bottom-up tranvese all elements (consider ec resize) to locate elements.
  49352. for (var i = elOptions.length - 1; i >= 0; i--) {
  49353. var elOption = elOptions[i];
  49354. var el = elMap.get(elOption.id);
  49355. if (!el) {
  49356. continue;
  49357. }
  49358. var parentEl = el.parent;
  49359. var containerInfo = parentEl === rootGroup
  49360. ? {
  49361. width: api.getWidth(),
  49362. height: api.getHeight()
  49363. }
  49364. : { // Like 'position:absolut' in css, default 0.
  49365. width: parentEl.__ecGraphicWidth || 0,
  49366. height: parentEl.__ecGraphicHeight || 0
  49367. };
  49368. layoutUtil.positionElement(
  49369. el, elOption, containerInfo, null,
  49370. {hv: elOption.hv, boundingMode: elOption.bounding}
  49371. );
  49372. }
  49373. },
  49374. /**
  49375. * Clear all elements.
  49376. *
  49377. * @private
  49378. */
  49379. _clear: function () {
  49380. var elMap = this._elMap;
  49381. elMap.each(function (el) {
  49382. removeEl(el, elMap);
  49383. });
  49384. this._elMap = zrUtil.createHashMap();
  49385. },
  49386. /**
  49387. * @override
  49388. */
  49389. dispose: function () {
  49390. this._clear();
  49391. }
  49392. });
  49393. function createEl(id, targetElParent, elOption, elMap) {
  49394. var graphicType = elOption.type;
  49395. if (true) {
  49396. zrUtil.assert(graphicType, 'graphic type MUST be set');
  49397. }
  49398. var Clz = graphicUtil[graphicType.charAt(0).toUpperCase() + graphicType.slice(1)];
  49399. if (true) {
  49400. zrUtil.assert(Clz, 'graphic type can not be found');
  49401. }
  49402. var el = new Clz(elOption);
  49403. targetElParent.add(el);
  49404. elMap.set(id, el);
  49405. el.__ecGraphicId = id;
  49406. }
  49407. function removeEl(existEl, elMap) {
  49408. var existElParent = existEl && existEl.parent;
  49409. if (existElParent) {
  49410. existEl.type === 'group' && existEl.traverse(function (el) {
  49411. removeEl(el, elMap);
  49412. });
  49413. elMap.removeKey(existEl.__ecGraphicId);
  49414. existElParent.remove(existEl);
  49415. }
  49416. }
  49417. // Remove unnecessary props to avoid potential problems.
  49418. function getCleanedElOption(elOption) {
  49419. elOption = zrUtil.extend({}, elOption);
  49420. zrUtil.each(
  49421. ['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
  49422. function (name) {
  49423. delete elOption[name];
  49424. }
  49425. );
  49426. return elOption;
  49427. }
  49428. function isSetLoc(obj, props) {
  49429. var isSet;
  49430. zrUtil.each(props, function (prop) {
  49431. obj[prop] != null && obj[prop] !== 'auto' && (isSet = true);
  49432. });
  49433. return isSet;
  49434. }
  49435. function setKeyInfoToNewElOption(resultItem, newElOption) {
  49436. var existElOption = resultItem.exist;
  49437. // Set id and type after id assigned.
  49438. newElOption.id = resultItem.keyInfo.id;
  49439. !newElOption.type && existElOption && (newElOption.type = existElOption.type);
  49440. // Set parent id if not specified
  49441. if (newElOption.parentId == null) {
  49442. var newElParentOption = newElOption.parentOption;
  49443. if (newElParentOption) {
  49444. newElOption.parentId = newElParentOption.id;
  49445. }
  49446. else if (existElOption) {
  49447. newElOption.parentId = existElOption.parentId;
  49448. }
  49449. }
  49450. // Clear
  49451. newElOption.parentOption = null;
  49452. }
  49453. function mergeNewElOptionToExist(existList, index, newElOption) {
  49454. // Update existing options, for `getOption` feature.
  49455. var newElOptCopy = zrUtil.extend({}, newElOption);
  49456. var existElOption = existList[index];
  49457. var $action = newElOption.$action || 'merge';
  49458. if ($action === 'merge') {
  49459. if (existElOption) {
  49460. if (true) {
  49461. var newType = newElOption.type;
  49462. zrUtil.assert(
  49463. !newType || existElOption.type === newType,
  49464. 'Please set $action: "replace" to change `type`'
  49465. );
  49466. }
  49467. // We can ensure that newElOptCopy and existElOption are not
  49468. // the same object, so `merge` will not change newElOptCopy.
  49469. zrUtil.merge(existElOption, newElOptCopy, true);
  49470. // Rigid body, use ignoreSize.
  49471. layoutUtil.mergeLayoutParam(existElOption, newElOptCopy, {ignoreSize: true});
  49472. // Will be used in render.
  49473. layoutUtil.copyLayoutParams(newElOption, existElOption);
  49474. }
  49475. else {
  49476. existList[index] = newElOptCopy;
  49477. }
  49478. }
  49479. else if ($action === 'replace') {
  49480. existList[index] = newElOptCopy;
  49481. }
  49482. else if ($action === 'remove') {
  49483. // null will be cleaned later.
  49484. existElOption && (existList[index] = null);
  49485. }
  49486. }
  49487. function setLayoutInfoToExist(existItem, newElOption) {
  49488. if (!existItem) {
  49489. return;
  49490. }
  49491. existItem.hv = newElOption.hv = [
  49492. // Rigid body, dont care `width`.
  49493. isSetLoc(newElOption, ['left', 'right']),
  49494. // Rigid body, dont care `height`.
  49495. isSetLoc(newElOption, ['top', 'bottom'])
  49496. ];
  49497. // Give default group size. Otherwise layout error may occur.
  49498. if (existItem.type === 'group') {
  49499. existItem.width == null && (existItem.width = newElOption.width = 0);
  49500. existItem.height == null && (existItem.height = newElOption.height = 0);
  49501. }
  49502. }
  49503. /***/ }),
  49504. /* 323 */
  49505. /***/ (function(module, exports, __webpack_require__) {
  49506. __webpack_require__(127);
  49507. __webpack_require__(307);
  49508. __webpack_require__(301);
  49509. /***/ }),
  49510. /* 324 */
  49511. /***/ (function(module, exports, __webpack_require__) {
  49512. /**
  49513. * Legend component entry file8
  49514. */
  49515. __webpack_require__(325);
  49516. __webpack_require__(331);
  49517. __webpack_require__(332);
  49518. __webpack_require__(333);
  49519. /***/ }),
  49520. /* 325 */
  49521. /***/ (function(module, exports, __webpack_require__) {
  49522. // Do not contain scrollable legend, for sake of file size.
  49523. __webpack_require__(326);
  49524. __webpack_require__(327);
  49525. __webpack_require__(328);
  49526. var echarts = __webpack_require__(1);
  49527. // Series Filter
  49528. echarts.registerProcessor(__webpack_require__(330));
  49529. __webpack_require__(72).registerSubTypeDefaulter('legend', function () {
  49530. // Default 'plain' when no type specified.
  49531. return 'plain';
  49532. });
  49533. /***/ }),
  49534. /* 326 */
  49535. /***/ (function(module, exports, __webpack_require__) {
  49536. 'use strict';
  49537. var zrUtil = __webpack_require__(4);
  49538. var Model = __webpack_require__(14);
  49539. var LegendModel = __webpack_require__(1).extendComponentModel({
  49540. type: 'legend.plain',
  49541. dependencies: ['series'],
  49542. layoutMode: {
  49543. type: 'box',
  49544. // legend.width/height are maxWidth/maxHeight actually,
  49545. // whereas realy width/height is calculated by its content.
  49546. // (Setting {left: 10, right: 10} does not make sense).
  49547. // So consider the case:
  49548. // `setOption({legend: {left: 10});`
  49549. // then `setOption({legend: {right: 10});`
  49550. // The previous `left` should be cleared by setting `ignoreSize`.
  49551. ignoreSize: true
  49552. },
  49553. init: function (option, parentModel, ecModel) {
  49554. this.mergeDefaultAndTheme(option, ecModel);
  49555. option.selected = option.selected || {};
  49556. },
  49557. mergeOption: function (option) {
  49558. LegendModel.superCall(this, 'mergeOption', option);
  49559. },
  49560. optionUpdated: function () {
  49561. this._updateData(this.ecModel);
  49562. var legendData = this._data;
  49563. // If selectedMode is single, try to select one
  49564. if (legendData[0] && this.get('selectedMode') === 'single') {
  49565. var hasSelected = false;
  49566. // If has any selected in option.selected
  49567. for (var i = 0; i < legendData.length; i++) {
  49568. var name = legendData[i].get('name');
  49569. if (this.isSelected(name)) {
  49570. // Force to unselect others
  49571. this.select(name);
  49572. hasSelected = true;
  49573. break;
  49574. }
  49575. }
  49576. // Try select the first if selectedMode is single
  49577. !hasSelected && this.select(legendData[0].get('name'));
  49578. }
  49579. },
  49580. _updateData: function (ecModel) {
  49581. var legendData = zrUtil.map(this.get('data') || [], function (dataItem) {
  49582. // Can be string or number
  49583. if (typeof dataItem === 'string' || typeof dataItem === 'number') {
  49584. dataItem = {
  49585. name: dataItem
  49586. };
  49587. }
  49588. return new Model(dataItem, this, this.ecModel);
  49589. }, this);
  49590. this._data = legendData;
  49591. var availableNames = zrUtil.map(ecModel.getSeries(), function (series) {
  49592. return series.name;
  49593. });
  49594. ecModel.eachSeries(function (seriesModel) {
  49595. if (seriesModel.legendDataProvider) {
  49596. var data = seriesModel.legendDataProvider();
  49597. availableNames = availableNames.concat(data.mapArray(data.getName));
  49598. }
  49599. });
  49600. /**
  49601. * @type {Array.<string>}
  49602. * @private
  49603. */
  49604. this._availableNames = availableNames;
  49605. },
  49606. /**
  49607. * @return {Array.<module:echarts/model/Model>}
  49608. */
  49609. getData: function () {
  49610. return this._data;
  49611. },
  49612. /**
  49613. * @param {string} name
  49614. */
  49615. select: function (name) {
  49616. var selected = this.option.selected;
  49617. var selectedMode = this.get('selectedMode');
  49618. if (selectedMode === 'single') {
  49619. var data = this._data;
  49620. zrUtil.each(data, function (dataItem) {
  49621. selected[dataItem.get('name')] = false;
  49622. });
  49623. }
  49624. selected[name] = true;
  49625. },
  49626. /**
  49627. * @param {string} name
  49628. */
  49629. unSelect: function (name) {
  49630. if (this.get('selectedMode') !== 'single') {
  49631. this.option.selected[name] = false;
  49632. }
  49633. },
  49634. /**
  49635. * @param {string} name
  49636. */
  49637. toggleSelected: function (name) {
  49638. var selected = this.option.selected;
  49639. // Default is true
  49640. if (!selected.hasOwnProperty(name)) {
  49641. selected[name] = true;
  49642. }
  49643. this[selected[name] ? 'unSelect' : 'select'](name);
  49644. },
  49645. /**
  49646. * @param {string} name
  49647. */
  49648. isSelected: function (name) {
  49649. var selected = this.option.selected;
  49650. return !(selected.hasOwnProperty(name) && !selected[name])
  49651. && zrUtil.indexOf(this._availableNames, name) >= 0;
  49652. },
  49653. defaultOption: {
  49654. // 一级层叠
  49655. zlevel: 0,
  49656. // 二级层叠
  49657. z: 4,
  49658. show: true,
  49659. // 布局方式,默认为水平布局,可选为:
  49660. // 'horizontal' | 'vertical'
  49661. orient: 'horizontal',
  49662. left: 'center',
  49663. // right: 'center',
  49664. top: 0,
  49665. // bottom: null,
  49666. // 水平对齐
  49667. // 'auto' | 'left' | 'right'
  49668. // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐
  49669. align: 'auto',
  49670. backgroundColor: 'rgba(0,0,0,0)',
  49671. // 图例边框颜色
  49672. borderColor: '#ccc',
  49673. borderRadius: 0,
  49674. // 图例边框线宽,单位px,默认为0(无边框)
  49675. borderWidth: 0,
  49676. // 图例内边距,单位px,默认各方向内边距为5,
  49677. // 接受数组分别设定上右下左边距,同css
  49678. padding: 5,
  49679. // 各个item之间的间隔,单位px,默认为10,
  49680. // 横向布局时为水平间隔,纵向布局时为纵向间隔
  49681. itemGap: 10,
  49682. // 图例图形宽度
  49683. itemWidth: 25,
  49684. // 图例图形高度
  49685. itemHeight: 14,
  49686. // 图例关闭时候的颜色
  49687. inactiveColor: '#ccc',
  49688. textStyle: {
  49689. // 图例文字颜色
  49690. color: '#333'
  49691. },
  49692. // formatter: '',
  49693. // 选择模式,默认开启图例开关
  49694. selectedMode: true,
  49695. // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入
  49696. // selected: null,
  49697. // 图例内容(详见legend.data,数组中每一项代表一个item
  49698. // data: [],
  49699. // Tooltip 相关配置
  49700. tooltip: {
  49701. show: false
  49702. }
  49703. }
  49704. });
  49705. module.exports = LegendModel;
  49706. /***/ }),
  49707. /* 327 */
  49708. /***/ (function(module, exports, __webpack_require__) {
  49709. /**
  49710. * @file Legend action
  49711. */
  49712. var echarts = __webpack_require__(1);
  49713. var zrUtil = __webpack_require__(4);
  49714. function legendSelectActionHandler(methodName, payload, ecModel) {
  49715. var selectedMap = {};
  49716. var isToggleSelect = methodName === 'toggleSelected';
  49717. var isSelected;
  49718. // Update all legend components
  49719. ecModel.eachComponent('legend', function (legendModel) {
  49720. if (isToggleSelect && isSelected != null) {
  49721. // Force other legend has same selected status
  49722. // Or the first is toggled to true and other are toggled to false
  49723. // In the case one legend has some item unSelected in option. And if other legend
  49724. // doesn't has the item, they will assume it is selected.
  49725. legendModel[isSelected ? 'select' : 'unSelect'](payload.name);
  49726. }
  49727. else {
  49728. legendModel[methodName](payload.name);
  49729. isSelected = legendModel.isSelected(payload.name);
  49730. }
  49731. var legendData = legendModel.getData();
  49732. zrUtil.each(legendData, function (model) {
  49733. var name = model.get('name');
  49734. // Wrap element
  49735. if (name === '\n' || name === '') {
  49736. return;
  49737. }
  49738. var isItemSelected = legendModel.isSelected(name);
  49739. if (selectedMap.hasOwnProperty(name)) {
  49740. // Unselected if any legend is unselected
  49741. selectedMap[name] = selectedMap[name] && isItemSelected;
  49742. }
  49743. else {
  49744. selectedMap[name] = isItemSelected;
  49745. }
  49746. });
  49747. });
  49748. // Return the event explicitly
  49749. return {
  49750. name: payload.name,
  49751. selected: selectedMap
  49752. };
  49753. }
  49754. /**
  49755. * @event legendToggleSelect
  49756. * @type {Object}
  49757. * @property {string} type 'legendToggleSelect'
  49758. * @property {string} [from]
  49759. * @property {string} name Series name or data item name
  49760. */
  49761. echarts.registerAction(
  49762. 'legendToggleSelect', 'legendselectchanged',
  49763. zrUtil.curry(legendSelectActionHandler, 'toggleSelected')
  49764. );
  49765. /**
  49766. * @event legendSelect
  49767. * @type {Object}
  49768. * @property {string} type 'legendSelect'
  49769. * @property {string} name Series name or data item name
  49770. */
  49771. echarts.registerAction(
  49772. 'legendSelect', 'legendselected',
  49773. zrUtil.curry(legendSelectActionHandler, 'select')
  49774. );
  49775. /**
  49776. * @event legendUnSelect
  49777. * @type {Object}
  49778. * @property {string} type 'legendUnSelect'
  49779. * @property {string} name Series name or data item name
  49780. */
  49781. echarts.registerAction(
  49782. 'legendUnSelect', 'legendunselected',
  49783. zrUtil.curry(legendSelectActionHandler, 'unSelect')
  49784. );
  49785. /***/ }),
  49786. /* 328 */
  49787. /***/ (function(module, exports, __webpack_require__) {
  49788. var zrUtil = __webpack_require__(4);
  49789. var symbolCreator = __webpack_require__(114);
  49790. var graphic = __webpack_require__(20);
  49791. var listComponentHelper = __webpack_require__(329);
  49792. var layoutUtil = __webpack_require__(74);
  49793. var curry = zrUtil.curry;
  49794. var each = zrUtil.each;
  49795. var Group = graphic.Group;
  49796. module.exports = __webpack_require__(1).extendComponentView({
  49797. type: 'legend.plain',
  49798. newlineDisabled: false,
  49799. /**
  49800. * @override
  49801. */
  49802. init: function () {
  49803. /**
  49804. * @private
  49805. * @type {module:zrender/container/Group}
  49806. */
  49807. this.group.add(this._contentGroup = new Group());
  49808. /**
  49809. * @private
  49810. * @type {module:zrender/Element}
  49811. */
  49812. this._backgroundEl;
  49813. },
  49814. /**
  49815. * @protected
  49816. */
  49817. getContentGroup: function () {
  49818. return this._contentGroup;
  49819. },
  49820. /**
  49821. * @override
  49822. */
  49823. render: function (legendModel, ecModel, api) {
  49824. this.resetInner();
  49825. if (!legendModel.get('show', true)) {
  49826. return;
  49827. }
  49828. var itemAlign = legendModel.get('align');
  49829. if (!itemAlign || itemAlign === 'auto') {
  49830. itemAlign = (
  49831. legendModel.get('left') === 'right'
  49832. && legendModel.get('orient') === 'vertical'
  49833. ) ? 'right' : 'left';
  49834. }
  49835. this.renderInner(itemAlign, legendModel, ecModel, api);
  49836. // Perform layout.
  49837. var positionInfo = legendModel.getBoxLayoutParams();
  49838. var viewportSize = {width: api.getWidth(), height: api.getHeight()};
  49839. var padding = legendModel.get('padding');
  49840. var maxSize = layoutUtil.getLayoutRect(positionInfo, viewportSize, padding);
  49841. var mainRect = this.layoutInner(legendModel, itemAlign, maxSize);
  49842. // Place mainGroup, based on the calculated `mainRect`.
  49843. var layoutRect = layoutUtil.getLayoutRect(
  49844. zrUtil.defaults({width: mainRect.width, height: mainRect.height}, positionInfo),
  49845. viewportSize,
  49846. padding
  49847. );
  49848. this.group.attr('position', [layoutRect.x - mainRect.x, layoutRect.y - mainRect.y]);
  49849. // Render background after group is layout.
  49850. this.group.add(
  49851. this._backgroundEl = listComponentHelper.makeBackground(mainRect, legendModel)
  49852. );
  49853. },
  49854. /**
  49855. * @protected
  49856. */
  49857. resetInner: function () {
  49858. this.getContentGroup().removeAll();
  49859. this._backgroundEl && this.group.remove(this._backgroundEl);
  49860. },
  49861. /**
  49862. * @protected
  49863. */
  49864. renderInner: function (itemAlign, legendModel, ecModel, api) {
  49865. var contentGroup = this.getContentGroup();
  49866. var legendDrawnMap = zrUtil.createHashMap();
  49867. var selectMode = legendModel.get('selectedMode');
  49868. each(legendModel.getData(), function (itemModel, dataIndex) {
  49869. var name = itemModel.get('name');
  49870. // Use empty string or \n as a newline string
  49871. if (!this.newlineDisabled && (name === '' || name === '\n')) {
  49872. contentGroup.add(new Group({
  49873. newline: true
  49874. }));
  49875. return;
  49876. }
  49877. var seriesModel = ecModel.getSeriesByName(name)[0];
  49878. if (legendDrawnMap.get(name)) {
  49879. // Have been drawed
  49880. return;
  49881. }
  49882. // Series legend
  49883. if (seriesModel) {
  49884. var data = seriesModel.getData();
  49885. var color = data.getVisual('color');
  49886. // If color is a callback function
  49887. if (typeof color === 'function') {
  49888. // Use the first data
  49889. color = color(seriesModel.getDataParams(0));
  49890. }
  49891. // Using rect symbol defaultly
  49892. var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect';
  49893. var symbolType = data.getVisual('symbol');
  49894. var itemGroup = this._createItem(
  49895. name, dataIndex, itemModel, legendModel,
  49896. legendSymbolType, symbolType,
  49897. itemAlign, color,
  49898. selectMode
  49899. );
  49900. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  49901. .on('mouseover', curry(dispatchHighlightAction, seriesModel, null, api))
  49902. .on('mouseout', curry(dispatchDownplayAction, seriesModel, null, api));
  49903. legendDrawnMap.set(name, true);
  49904. }
  49905. else {
  49906. // Data legend of pie, funnel
  49907. ecModel.eachRawSeries(function (seriesModel) {
  49908. // In case multiple series has same data name
  49909. if (legendDrawnMap.get(name)) {
  49910. return;
  49911. }
  49912. if (seriesModel.legendDataProvider) {
  49913. var data = seriesModel.legendDataProvider();
  49914. var idx = data.indexOfName(name);
  49915. if (idx < 0) {
  49916. return;
  49917. }
  49918. var color = data.getItemVisual(idx, 'color');
  49919. var legendSymbolType = 'roundRect';
  49920. var itemGroup = this._createItem(
  49921. name, dataIndex, itemModel, legendModel,
  49922. legendSymbolType, null,
  49923. itemAlign, color,
  49924. selectMode
  49925. );
  49926. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  49927. // FIXME Should not specify the series name
  49928. .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api))
  49929. .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api));
  49930. legendDrawnMap.set(name, true);
  49931. }
  49932. }, this);
  49933. }
  49934. if (true) {
  49935. if (!legendDrawnMap.get(name)) {
  49936. console.warn(name + ' series not exists. Legend data should be same with series name or data name.');
  49937. }
  49938. }
  49939. }, this);
  49940. },
  49941. _createItem: function (
  49942. name, dataIndex, itemModel, legendModel,
  49943. legendSymbolType, symbolType,
  49944. itemAlign, color, selectMode
  49945. ) {
  49946. var itemWidth = legendModel.get('itemWidth');
  49947. var itemHeight = legendModel.get('itemHeight');
  49948. var inactiveColor = legendModel.get('inactiveColor');
  49949. var isSelected = legendModel.isSelected(name);
  49950. var itemGroup = new Group();
  49951. var textStyleModel = itemModel.getModel('textStyle');
  49952. var itemIcon = itemModel.get('icon');
  49953. var tooltipModel = itemModel.getModel('tooltip');
  49954. var legendGlobalTooltipModel = tooltipModel.parentModel;
  49955. // Use user given icon first
  49956. legendSymbolType = itemIcon || legendSymbolType;
  49957. itemGroup.add(symbolCreator.createSymbol(
  49958. legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : inactiveColor
  49959. ));
  49960. // Compose symbols
  49961. // PENDING
  49962. if (!itemIcon && symbolType
  49963. // At least show one symbol, can't be all none
  49964. && ((symbolType !== legendSymbolType) || symbolType == 'none')
  49965. ) {
  49966. var size = itemHeight * 0.8;
  49967. if (symbolType === 'none') {
  49968. symbolType = 'circle';
  49969. }
  49970. // Put symbol in the center
  49971. itemGroup.add(symbolCreator.createSymbol(
  49972. symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size,
  49973. isSelected ? color : inactiveColor
  49974. ));
  49975. }
  49976. var textX = itemAlign === 'left' ? itemWidth + 5 : -5;
  49977. var textAlign = itemAlign;
  49978. var formatter = legendModel.get('formatter');
  49979. var content = name;
  49980. if (typeof formatter === 'string' && formatter) {
  49981. content = formatter.replace('{name}', name != null ? name : '');
  49982. }
  49983. else if (typeof formatter === 'function') {
  49984. content = formatter(name);
  49985. }
  49986. itemGroup.add(new graphic.Text({
  49987. style: graphic.setTextStyle({}, textStyleModel, {
  49988. text: content,
  49989. x: textX,
  49990. y: itemHeight / 2,
  49991. textFill: isSelected ? textStyleModel.getTextColor() : inactiveColor,
  49992. textAlign: textAlign,
  49993. textVerticalAlign: 'middle'
  49994. })
  49995. }));
  49996. // Add a invisible rect to increase the area of mouse hover
  49997. var hitRect = new graphic.Rect({
  49998. shape: itemGroup.getBoundingRect(),
  49999. invisible: true,
  50000. tooltip: tooltipModel.get('show') ? zrUtil.extend({
  50001. content: name,
  50002. // Defaul formatter
  50003. formatter: legendGlobalTooltipModel.get('formatter', true) || function () {
  50004. return name;
  50005. },
  50006. formatterParams: {
  50007. componentType: 'legend',
  50008. legendIndex: legendModel.componentIndex,
  50009. name: name,
  50010. $vars: ['name']
  50011. }
  50012. }, tooltipModel.option) : null
  50013. });
  50014. itemGroup.add(hitRect);
  50015. itemGroup.eachChild(function (child) {
  50016. child.silent = true;
  50017. });
  50018. hitRect.silent = !selectMode;
  50019. this.getContentGroup().add(itemGroup);
  50020. graphic.setHoverStyle(itemGroup);
  50021. itemGroup.__legendDataIndex = dataIndex;
  50022. return itemGroup;
  50023. },
  50024. /**
  50025. * @protected
  50026. */
  50027. layoutInner: function (legendModel, itemAlign, maxSize) {
  50028. var contentGroup = this.getContentGroup();
  50029. // Place items in contentGroup.
  50030. layoutUtil.box(
  50031. legendModel.get('orient'),
  50032. contentGroup,
  50033. legendModel.get('itemGap'),
  50034. maxSize.width,
  50035. maxSize.height
  50036. );
  50037. var contentRect = contentGroup.getBoundingRect();
  50038. contentGroup.attr('position', [-contentRect.x, -contentRect.y]);
  50039. return this.group.getBoundingRect();
  50040. }
  50041. });
  50042. function dispatchSelectAction(name, api) {
  50043. api.dispatchAction({
  50044. type: 'legendToggleSelect',
  50045. name: name
  50046. });
  50047. }
  50048. function dispatchHighlightAction(seriesModel, dataName, api) {
  50049. // If element hover will move to a hoverLayer.
  50050. var el = api.getZr().storage.getDisplayList()[0];
  50051. if (!(el && el.useHoverLayer)) {
  50052. seriesModel.get('legendHoverLink') && api.dispatchAction({
  50053. type: 'highlight',
  50054. seriesName: seriesModel.name,
  50055. name: dataName
  50056. });
  50057. }
  50058. }
  50059. function dispatchDownplayAction(seriesModel, dataName, api) {
  50060. // If element hover will move to a hoverLayer.
  50061. var el = api.getZr().storage.getDisplayList()[0];
  50062. if (!(el && el.useHoverLayer)) {
  50063. seriesModel.get('legendHoverLink') && api.dispatchAction({
  50064. type: 'downplay',
  50065. seriesName: seriesModel.name,
  50066. name: dataName
  50067. });
  50068. }
  50069. }
  50070. /***/ }),
  50071. /* 329 */
  50072. /***/ (function(module, exports, __webpack_require__) {
  50073. // List layout
  50074. var layout = __webpack_require__(74);
  50075. var formatUtil = __webpack_require__(6);
  50076. var graphic = __webpack_require__(20);
  50077. module.exports = {
  50078. /**
  50079. * Layout list like component.
  50080. * It will box layout each items in group of component and then position the whole group in the viewport
  50081. * @param {module:zrender/group/Group} group
  50082. * @param {module:echarts/model/Component} componentModel
  50083. * @param {module:echarts/ExtensionAPI}
  50084. */
  50085. layout: function (group, componentModel, api) {
  50086. var boxLayoutParams = componentModel.getBoxLayoutParams();
  50087. var padding = componentModel.get('padding');
  50088. var viewportSize = {width: api.getWidth(), height: api.getHeight()};
  50089. var rect = layout.getLayoutRect(
  50090. boxLayoutParams,
  50091. viewportSize,
  50092. padding
  50093. );
  50094. layout.box(
  50095. componentModel.get('orient'),
  50096. group,
  50097. componentModel.get('itemGap'),
  50098. rect.width,
  50099. rect.height
  50100. );
  50101. layout.positionElement(
  50102. group,
  50103. boxLayoutParams,
  50104. viewportSize,
  50105. padding
  50106. );
  50107. },
  50108. makeBackground: function (rect, componentModel) {
  50109. var padding = formatUtil.normalizeCssArray(
  50110. componentModel.get('padding')
  50111. );
  50112. var style = componentModel.getItemStyle(['color', 'opacity']);
  50113. style.fill = componentModel.get('backgroundColor');
  50114. var rect = new graphic.Rect({
  50115. shape: {
  50116. x: rect.x - padding[3],
  50117. y: rect.y - padding[0],
  50118. width: rect.width + padding[1] + padding[3],
  50119. height: rect.height + padding[0] + padding[2],
  50120. r: componentModel.get('borderRadius')
  50121. },
  50122. style: style,
  50123. silent: true,
  50124. z2: -1
  50125. });
  50126. // FIXME
  50127. // `subPixelOptimizeRect` may bring some gap between edge of viewpart
  50128. // and background rect when setting like `left: 0`, `top: 0`.
  50129. // graphic.subPixelOptimizeRect(rect);
  50130. return rect;
  50131. }
  50132. };
  50133. /***/ }),
  50134. /* 330 */
  50135. /***/ (function(module, exports) {
  50136. module.exports = function (ecModel) {
  50137. var legendModels = ecModel.findComponents({
  50138. mainType: 'legend'
  50139. });
  50140. if (legendModels && legendModels.length) {
  50141. ecModel.filterSeries(function (series) {
  50142. // If in any legend component the status is not selected.
  50143. // Because in legend series is assumed selected when it is not in the legend data.
  50144. for (var i = 0; i < legendModels.length; i++) {
  50145. if (!legendModels[i].isSelected(series.name)) {
  50146. return false;
  50147. }
  50148. }
  50149. return true;
  50150. });
  50151. }
  50152. };
  50153. /***/ }),
  50154. /* 331 */
  50155. /***/ (function(module, exports, __webpack_require__) {
  50156. var LegendModel = __webpack_require__(326);
  50157. var layout = __webpack_require__(74);
  50158. var ScrollableLegendModel = LegendModel.extend({
  50159. type: 'legend.scroll',
  50160. /**
  50161. * @param {number} scrollDataIndex
  50162. */
  50163. setScrollDataIndex: function (scrollDataIndex) {
  50164. this.option.scrollDataIndex = scrollDataIndex;
  50165. },
  50166. defaultOption: {
  50167. scrollDataIndex: 0,
  50168. pageButtonItemGap: 5,
  50169. pageButtonGap: null,
  50170. pageButtonPosition: 'end', // 'start' or 'end'
  50171. pageFormatter: '{current}/{total}', // If null/undefined, do not show page.
  50172. pageIcons: {
  50173. horizontal: ['M0,0L12,-10L12,10z', 'M0,0L-12,-10L-12,10z'],
  50174. vertical: ['M0,0L20,0L10,-20z', 'M0,0L20,0L10,20z']
  50175. },
  50176. pageIconColor: '#2f4554',
  50177. pageIconInactiveColor: '#aaa',
  50178. pageIconSize: 15, // Can be [10, 3], which represents [width, height]
  50179. pageTextStyle: {
  50180. color: '#333'
  50181. },
  50182. animationDurationUpdate: 800
  50183. },
  50184. /**
  50185. * @override
  50186. */
  50187. init: function (option, parentModel, ecModel, extraOpt) {
  50188. var inputPositionParams = layout.getLayoutParams(option);
  50189. ScrollableLegendModel.superCall(this, 'init', option, parentModel, ecModel, extraOpt);
  50190. mergeAndNormalizeLayoutParams(this, option, inputPositionParams);
  50191. },
  50192. /**
  50193. * @override
  50194. */
  50195. mergeOption: function (option, extraOpt) {
  50196. ScrollableLegendModel.superCall(this, 'mergeOption', option, extraOpt);
  50197. mergeAndNormalizeLayoutParams(this, this.option, option);
  50198. },
  50199. getOrient: function () {
  50200. return this.get('orient') === 'vertical'
  50201. ? {index: 1, name: 'vertical'}
  50202. : {index: 0, name: 'horizontal'};
  50203. }
  50204. });
  50205. // Do not `ignoreSize` to enable setting {left: 10, right: 10}.
  50206. function mergeAndNormalizeLayoutParams(legendModel, target, raw) {
  50207. var orient = legendModel.getOrient();
  50208. var ignoreSize = [1, 1];
  50209. ignoreSize[orient.index] = 0;
  50210. layout.mergeLayoutParam(target, raw, {
  50211. type: 'box', ignoreSize: ignoreSize
  50212. });
  50213. }
  50214. module.exports = ScrollableLegendModel;
  50215. /***/ }),
  50216. /* 332 */
  50217. /***/ (function(module, exports, __webpack_require__) {
  50218. /**
  50219. * Separate legend and scrollable legend to reduce package size.
  50220. */
  50221. var zrUtil = __webpack_require__(4);
  50222. var graphic = __webpack_require__(20);
  50223. var layoutUtil = __webpack_require__(74);
  50224. var LegendView = __webpack_require__(328);
  50225. var Group = graphic.Group;
  50226. var WH = ['width', 'height'];
  50227. var XY = ['x', 'y'];
  50228. var ScrollableLegendView = LegendView.extend({
  50229. type: 'legend.scroll',
  50230. newlineDisabled: true,
  50231. init: function () {
  50232. ScrollableLegendView.superCall(this, 'init');
  50233. /**
  50234. * @private
  50235. * @type {number} For `scroll`.
  50236. */
  50237. this._currentIndex = 0;
  50238. /**
  50239. * @private
  50240. * @type {module:zrender/container/Group}
  50241. */
  50242. this.group.add(this._containerGroup = new Group());
  50243. this._containerGroup.add(this.getContentGroup());
  50244. /**
  50245. * @private
  50246. * @type {module:zrender/container/Group}
  50247. */
  50248. this.group.add(this._controllerGroup = new Group());
  50249. },
  50250. /**
  50251. * @override
  50252. */
  50253. resetInner: function () {
  50254. ScrollableLegendView.superCall(this, 'resetInner');
  50255. this._controllerGroup.removeAll();
  50256. this._containerGroup.removeClipPath();
  50257. this._containerGroup.__rectSize = null;
  50258. },
  50259. /**
  50260. * @override
  50261. */
  50262. renderInner: function (itemAlign, legendModel, ecModel, api) {
  50263. var me = this;
  50264. // Render content items.
  50265. ScrollableLegendView.superCall(this, 'renderInner', itemAlign, legendModel, ecModel, api);
  50266. var controllerGroup = this._controllerGroup;
  50267. var pageIconSize = legendModel.get('pageIconSize', true);
  50268. if (!zrUtil.isArray(pageIconSize)) {
  50269. pageIconSize = [pageIconSize, pageIconSize];
  50270. }
  50271. createPageButton('pagePrev', 0);
  50272. var pageTextStyleModel = legendModel.getModel('pageTextStyle');
  50273. controllerGroup.add(new graphic.Text({
  50274. name: 'pageText',
  50275. style: {
  50276. textFill: pageTextStyleModel.getTextColor(),
  50277. font: pageTextStyleModel.getFont(),
  50278. textVerticalAlign: 'middle',
  50279. textAlign: 'center'
  50280. },
  50281. silent: true
  50282. }));
  50283. createPageButton('pageNext', 1);
  50284. function createPageButton(name, iconIdx) {
  50285. var pageDataIndexName = name + 'DataIndex';
  50286. var icon = graphic.createIcon(
  50287. legendModel.get('pageIcons', true)[legendModel.getOrient().name][iconIdx],
  50288. {
  50289. // Buttons will be created in each render, so we do not need
  50290. // to worry about avoiding using legendModel kept in scope.
  50291. onclick: zrUtil.bind(
  50292. me._pageGo, me, pageDataIndexName, legendModel, api
  50293. )
  50294. },
  50295. {
  50296. x: -pageIconSize[0] / 2,
  50297. y: -pageIconSize[1] / 2,
  50298. width: pageIconSize[0],
  50299. height: pageIconSize[1]
  50300. }
  50301. );
  50302. icon.name = name;
  50303. controllerGroup.add(icon);
  50304. }
  50305. },
  50306. /**
  50307. * @override
  50308. */
  50309. layoutInner: function (legendModel, itemAlign, maxSize) {
  50310. var contentGroup = this.getContentGroup();
  50311. var containerGroup = this._containerGroup;
  50312. var controllerGroup = this._controllerGroup;
  50313. var orientIdx = legendModel.getOrient().index;
  50314. var wh = WH[orientIdx];
  50315. var hw = WH[1 - orientIdx];
  50316. var yx = XY[1 - orientIdx];
  50317. // Place items in contentGroup.
  50318. layoutUtil.box(
  50319. legendModel.get('orient'),
  50320. contentGroup,
  50321. legendModel.get('itemGap'),
  50322. !orientIdx ? null : maxSize.width,
  50323. orientIdx ? null : maxSize.height
  50324. );
  50325. layoutUtil.box(
  50326. // Buttons in controller are layout always horizontally.
  50327. 'horizontal',
  50328. controllerGroup,
  50329. legendModel.get('pageButtonItemGap', true)
  50330. );
  50331. var contentRect = contentGroup.getBoundingRect();
  50332. var controllerRect = controllerGroup.getBoundingRect();
  50333. var showController = contentRect[wh] > maxSize[wh];
  50334. var contentPos = [-contentRect.x, -contentRect.y];
  50335. // Remain contentPos when scroll animation perfroming.
  50336. contentPos[orientIdx] = contentGroup.position[orientIdx];
  50337. // Layout container group based on 0.
  50338. var containerPos = [0, 0];
  50339. var controllerPos = [-controllerRect.x, -controllerRect.y];
  50340. var pageButtonGap = zrUtil.retrieve2(
  50341. legendModel.get('pageButtonGap', true), legendModel.get('itemGap', true)
  50342. );
  50343. // Place containerGroup and controllerGroup and contentGroup.
  50344. if (showController) {
  50345. var pageButtonPosition = legendModel.get('pageButtonPosition', true);
  50346. // controller is on the right / bottom.
  50347. if (pageButtonPosition === 'end') {
  50348. controllerPos[orientIdx] += maxSize[wh] - controllerRect[wh];
  50349. }
  50350. // controller is on the left / top.
  50351. else {
  50352. containerPos[orientIdx] += controllerRect[wh] + pageButtonGap;
  50353. }
  50354. }
  50355. // Always align controller to content as 'middle'.
  50356. controllerPos[1 - orientIdx] += contentRect[hw] / 2 - controllerRect[hw] / 2;
  50357. contentGroup.attr('position', contentPos);
  50358. containerGroup.attr('position', containerPos);
  50359. controllerGroup.attr('position', controllerPos);
  50360. // Calculate `mainRect` and set `clipPath`.
  50361. // mainRect should not be calculated by `this.group.getBoundingRect()`
  50362. // for sake of the overflow.
  50363. var mainRect = this.group.getBoundingRect();
  50364. var mainRect = {x: 0, y: 0};
  50365. // Consider content may be overflow (should be clipped).
  50366. mainRect[wh] = showController ? maxSize[wh] : contentRect[wh];
  50367. mainRect[hw] = Math.max(contentRect[hw], controllerRect[hw]);
  50368. // `containerRect[yx] + containerPos[1 - orientIdx]` is 0.
  50369. mainRect[yx] = Math.min(0, controllerRect[yx] + controllerPos[1 - orientIdx]);
  50370. containerGroup.__rectSize = maxSize[wh];
  50371. if (showController) {
  50372. var clipShape = {x: 0, y: 0};
  50373. clipShape[wh] = Math.max(maxSize[wh] - controllerRect[wh] - pageButtonGap, 0);
  50374. clipShape[hw] = mainRect[hw];
  50375. containerGroup.setClipPath(new graphic.Rect({shape: clipShape}));
  50376. // Consider content may be larger than container, container rect
  50377. // can not be obtained from `containerGroup.getBoundingRect()`.
  50378. containerGroup.__rectSize = clipShape[wh];
  50379. }
  50380. else {
  50381. // Do not remove or ignore controller. Keep them set as place holders.
  50382. controllerGroup.eachChild(function (child) {
  50383. child.attr({invisible: true, silent: true});
  50384. });
  50385. }
  50386. // Content translate animation.
  50387. var pageInfo = this._getPageInfo(legendModel);
  50388. pageInfo.pageIndex != null && graphic.updateProps(
  50389. contentGroup, {position: pageInfo.contentPosition}, legendModel
  50390. );
  50391. this._updatePageInfoView(legendModel, pageInfo);
  50392. return mainRect;
  50393. },
  50394. _pageGo: function (to, legendModel, api) {
  50395. var scrollDataIndex = this._getPageInfo(legendModel)[to];
  50396. scrollDataIndex != null && api.dispatchAction({
  50397. type: 'legendScroll',
  50398. scrollDataIndex: scrollDataIndex,
  50399. legendId: legendModel.id
  50400. });
  50401. },
  50402. _updatePageInfoView: function (legendModel, pageInfo) {
  50403. var controllerGroup = this._controllerGroup;
  50404. zrUtil.each(['pagePrev', 'pageNext'], function (name) {
  50405. var canJump = pageInfo[name + 'DataIndex'] != null;
  50406. var icon = controllerGroup.childOfName(name);
  50407. if (icon) {
  50408. icon.setStyle(
  50409. 'fill',
  50410. canJump
  50411. ? legendModel.get('pageIconColor', true)
  50412. : legendModel.get('pageIconInactiveColor', true)
  50413. );
  50414. icon.cursor = canJump ? 'pointer' : 'default';
  50415. }
  50416. });
  50417. var pageText = controllerGroup.childOfName('pageText');
  50418. var pageFormatter = legendModel.get('pageFormatter');
  50419. var pageIndex = pageInfo.pageIndex;
  50420. var current = pageIndex != null ? pageIndex + 1 : 0;
  50421. var total = pageInfo.pageCount;
  50422. pageText && pageFormatter && pageText.setStyle(
  50423. 'text',
  50424. zrUtil.isString(pageFormatter)
  50425. ? pageFormatter.replace('{current}', current).replace('{total}', total)
  50426. : pageFormatter({current: current, total: total})
  50427. );
  50428. },
  50429. /**
  50430. * @param {module:echarts/model/Model} legendModel
  50431. * @return {Object} {
  50432. * contentPosition: Array.<number>, null when data item not found.
  50433. * pageIndex: number, null when data item not found.
  50434. * pageCount: number, always be a number, can be 0.
  50435. * pagePrevDataIndex: number, null when no next page.
  50436. * pageNextDataIndex: number, null when no previous page.
  50437. * }
  50438. */
  50439. _getPageInfo: function (legendModel) {
  50440. // Align left or top by the current dataIndex.
  50441. var currDataIndex = legendModel.get('scrollDataIndex', true);
  50442. var contentGroup = this.getContentGroup();
  50443. var contentRect = contentGroup.getBoundingRect();
  50444. var containerRectSize = this._containerGroup.__rectSize;
  50445. var orientIdx = legendModel.getOrient().index;
  50446. var wh = WH[orientIdx];
  50447. var hw = WH[1 - orientIdx];
  50448. var xy = XY[orientIdx];
  50449. var contentPos = contentGroup.position.slice();
  50450. var pageIndex;
  50451. var pagePrevDataIndex;
  50452. var pageNextDataIndex;
  50453. var targetItemGroup;
  50454. contentGroup.eachChild(function (child) {
  50455. if (child.__legendDataIndex === currDataIndex) {
  50456. targetItemGroup = child;
  50457. }
  50458. });
  50459. var pageCount = containerRectSize ? Math.ceil(contentRect[wh] / containerRectSize) : 0;
  50460. if (targetItemGroup) {
  50461. var itemRect = targetItemGroup.getBoundingRect();
  50462. var itemLoc = targetItemGroup.position[orientIdx] + itemRect[xy];
  50463. contentPos[orientIdx] = -itemLoc - contentRect[xy];
  50464. pageIndex = Math.floor(
  50465. pageCount * (itemLoc + itemRect[xy] + containerRectSize / 2) / contentRect[wh]
  50466. );
  50467. pageIndex = (contentRect[wh] && pageCount)
  50468. ? Math.max(0, Math.min(pageCount - 1, pageIndex))
  50469. : -1;
  50470. var winRect = {x: 0, y: 0};
  50471. winRect[wh] = containerRectSize;
  50472. winRect[hw] = contentRect[hw];
  50473. winRect[xy] = -contentPos[orientIdx] - contentRect[xy];
  50474. var startIdx;
  50475. var children = contentGroup.children();
  50476. contentGroup.eachChild(function (child, index) {
  50477. var itemRect = getItemRect(child);
  50478. if (itemRect.intersect(winRect)) {
  50479. startIdx == null && (startIdx = index);
  50480. // It is user-friendly that the last item shown in the
  50481. // current window is shown at the begining of next window.
  50482. pageNextDataIndex = child.__legendDataIndex;
  50483. }
  50484. // If the last item is shown entirely, no next page.
  50485. if (index === children.length - 1
  50486. && itemRect[xy] + itemRect[wh] <= winRect[xy] + winRect[wh]
  50487. ) {
  50488. pageNextDataIndex = null;
  50489. }
  50490. });
  50491. // Always align based on the left/top most item, so the left/top most
  50492. // item in the previous window is needed to be found here.
  50493. if (startIdx != null) {
  50494. var startItem = children[startIdx];
  50495. var startRect = getItemRect(startItem);
  50496. winRect[xy] = startRect[xy] + startRect[wh] - winRect[wh];
  50497. // If the first item is shown entirely, no previous page.
  50498. if (startIdx <= 0 && startRect[xy] >= winRect[xy]) {
  50499. pagePrevDataIndex = null;
  50500. }
  50501. else {
  50502. while (startIdx > 0 && getItemRect(children[startIdx - 1]).intersect(winRect)) {
  50503. startIdx--;
  50504. }
  50505. pagePrevDataIndex = children[startIdx].__legendDataIndex;
  50506. }
  50507. }
  50508. }
  50509. return {
  50510. contentPosition: contentPos,
  50511. pageIndex: pageIndex,
  50512. pageCount: pageCount,
  50513. pagePrevDataIndex: pagePrevDataIndex,
  50514. pageNextDataIndex: pageNextDataIndex
  50515. };
  50516. function getItemRect(el) {
  50517. var itemRect = el.getBoundingRect().clone();
  50518. itemRect[xy] += el.position[orientIdx];
  50519. return itemRect;
  50520. }
  50521. }
  50522. });
  50523. module.exports = ScrollableLegendView;
  50524. /***/ }),
  50525. /* 333 */
  50526. /***/ (function(module, exports, __webpack_require__) {
  50527. /**
  50528. * @file Legend action
  50529. */
  50530. /**
  50531. * @event legendScroll
  50532. * @type {Object}
  50533. * @property {string} type 'legendScroll'
  50534. * @property {string} scrollDataIndex
  50535. */
  50536. __webpack_require__(1).registerAction(
  50537. 'legendScroll', 'legendscroll',
  50538. function (payload, ecModel) {
  50539. var scrollDataIndex = payload.scrollDataIndex;
  50540. scrollDataIndex != null && ecModel.eachComponent(
  50541. {mainType: 'legend', subType: 'scroll', query: payload},
  50542. function (legendModel) {
  50543. legendModel.setScrollDataIndex(scrollDataIndex);
  50544. }
  50545. );
  50546. }
  50547. );
  50548. /***/ }),
  50549. /* 334 */
  50550. /***/ (function(module, exports, __webpack_require__) {
  50551. // FIXME Better way to pack data in graphic element
  50552. __webpack_require__(301);
  50553. __webpack_require__(335);
  50554. __webpack_require__(336);
  50555. // Show tip action
  50556. /**
  50557. * @action
  50558. * @property {string} type
  50559. * @property {number} seriesIndex
  50560. * @property {number} dataIndex
  50561. * @property {number} [x]
  50562. * @property {number} [y]
  50563. */
  50564. __webpack_require__(1).registerAction(
  50565. {
  50566. type: 'showTip',
  50567. event: 'showTip',
  50568. update: 'tooltip:manuallyShowTip'
  50569. },
  50570. // noop
  50571. function () {}
  50572. );
  50573. // Hide tip action
  50574. __webpack_require__(1).registerAction(
  50575. {
  50576. type: 'hideTip',
  50577. event: 'hideTip',
  50578. update: 'tooltip:manuallyHideTip'
  50579. },
  50580. // noop
  50581. function () {}
  50582. );
  50583. /***/ }),
  50584. /* 335 */
  50585. /***/ (function(module, exports, __webpack_require__) {
  50586. __webpack_require__(1).extendComponentModel({
  50587. type: 'tooltip',
  50588. dependencies: ['axisPointer'],
  50589. defaultOption: {
  50590. zlevel: 0,
  50591. z: 8,
  50592. show: true,
  50593. // tooltip主体内容
  50594. showContent: true,
  50595. // 'trigger' only works on coordinate system.
  50596. // 'item' | 'axis' | 'none'
  50597. trigger: 'item',
  50598. // 'click' | 'mousemove' | 'none'
  50599. triggerOn: 'mousemove|click',
  50600. alwaysShowContent: false,
  50601. displayMode: 'single', // 'single' | 'multipleByCoordSys'
  50602. // 位置 {Array} | {Function}
  50603. // position: null
  50604. // Consider triggered from axisPointer handle, verticalAlign should be 'middle'
  50605. // align: null,
  50606. // verticalAlign: null,
  50607. // 是否约束 content 在 viewRect 中。默认 false 是为了兼容以前版本。
  50608. confine: false,
  50609. // 内容格式器:{string}(Template) ¦ {Function}
  50610. // formatter: null
  50611. showDelay: 0,
  50612. // 隐藏延迟,单位ms
  50613. hideDelay: 100,
  50614. // 动画变换时间,单位s
  50615. transitionDuration: 0.4,
  50616. enterable: false,
  50617. // 提示背景颜色,默认为透明度为0.7的黑色
  50618. backgroundColor: 'rgba(50,50,50,0.7)',
  50619. // 提示边框颜色
  50620. borderColor: '#333',
  50621. // 提示边框圆角,单位px,默认为4
  50622. borderRadius: 4,
  50623. // 提示边框线宽,单位px,默认为0(无边框)
  50624. borderWidth: 0,
  50625. // 提示内边距,单位px,默认各方向内边距为5,
  50626. // 接受数组分别设定上右下左边距,同css
  50627. padding: 5,
  50628. // Extra css text
  50629. extraCssText: '',
  50630. // 坐标轴指示器,坐标轴触发有效
  50631. axisPointer: {
  50632. // 默认为直线
  50633. // 可选为:'line' | 'shadow' | 'cross'
  50634. type: 'line',
  50635. // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选
  50636. // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto'
  50637. // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴
  50638. // 极坐标系会默认选择 angle 轴
  50639. axis: 'auto',
  50640. animation: 'auto',
  50641. animationDurationUpdate: 200,
  50642. animationEasingUpdate: 'exponentialOut',
  50643. crossStyle: {
  50644. color: '#999',
  50645. width: 1,
  50646. type: 'dashed',
  50647. // TODO formatter
  50648. textStyle: {}
  50649. }
  50650. // lineStyle and shadowStyle should not be specified here,
  50651. // otherwise it will always override those styles on option.axisPointer.
  50652. },
  50653. textStyle: {
  50654. color: '#fff',
  50655. fontSize: 14
  50656. }
  50657. }
  50658. });
  50659. /***/ }),
  50660. /* 336 */
  50661. /***/ (function(module, exports, __webpack_require__) {
  50662. var TooltipContent = __webpack_require__(337);
  50663. var zrUtil = __webpack_require__(4);
  50664. var formatUtil = __webpack_require__(6);
  50665. var numberUtil = __webpack_require__(7);
  50666. var graphic = __webpack_require__(20);
  50667. var findPointFromSeries = __webpack_require__(303);
  50668. var layoutUtil = __webpack_require__(74);
  50669. var env = __webpack_require__(2);
  50670. var Model = __webpack_require__(14);
  50671. var globalListener = __webpack_require__(306);
  50672. var axisHelper = __webpack_require__(104);
  50673. var axisPointerViewHelper = __webpack_require__(309);
  50674. var bind = zrUtil.bind;
  50675. var each = zrUtil.each;
  50676. var parsePercent = numberUtil.parsePercent;
  50677. var proxyRect = new graphic.Rect({
  50678. shape: {x: -1, y: -1, width: 2, height: 2}
  50679. });
  50680. __webpack_require__(1).extendComponentView({
  50681. type: 'tooltip',
  50682. init: function (ecModel, api) {
  50683. if (env.node) {
  50684. return;
  50685. }
  50686. var tooltipContent = new TooltipContent(api.getDom(), api);
  50687. this._tooltipContent = tooltipContent;
  50688. },
  50689. render: function (tooltipModel, ecModel, api) {
  50690. if (env.node) {
  50691. return;
  50692. }
  50693. // Reset
  50694. this.group.removeAll();
  50695. /**
  50696. * @private
  50697. * @type {module:echarts/component/tooltip/TooltipModel}
  50698. */
  50699. this._tooltipModel = tooltipModel;
  50700. /**
  50701. * @private
  50702. * @type {module:echarts/model/Global}
  50703. */
  50704. this._ecModel = ecModel;
  50705. /**
  50706. * @private
  50707. * @type {module:echarts/ExtensionAPI}
  50708. */
  50709. this._api = api;
  50710. /**
  50711. * Should be cleaned when render.
  50712. * @private
  50713. * @type {Array.<Array.<Object>>}
  50714. */
  50715. this._lastDataByCoordSys = null;
  50716. /**
  50717. * @private
  50718. * @type {boolean}
  50719. */
  50720. this._alwaysShowContent = tooltipModel.get('alwaysShowContent');
  50721. var tooltipContent = this._tooltipContent;
  50722. tooltipContent.update();
  50723. tooltipContent.setEnterable(tooltipModel.get('enterable'));
  50724. this._initGlobalListener();
  50725. this._keepShow();
  50726. },
  50727. _initGlobalListener: function () {
  50728. var tooltipModel = this._tooltipModel;
  50729. var triggerOn = tooltipModel.get('triggerOn');
  50730. globalListener.register(
  50731. 'itemTooltip',
  50732. this._api,
  50733. bind(function (currTrigger, e, dispatchAction) {
  50734. // If 'none', it is not controlled by mouse totally.
  50735. if (triggerOn !== 'none') {
  50736. if (triggerOn.indexOf(currTrigger) >= 0) {
  50737. this._tryShow(e, dispatchAction);
  50738. }
  50739. else if (currTrigger === 'leave') {
  50740. this._hide(dispatchAction);
  50741. }
  50742. }
  50743. }, this)
  50744. );
  50745. },
  50746. _keepShow: function () {
  50747. var tooltipModel = this._tooltipModel;
  50748. var ecModel = this._ecModel;
  50749. var api = this._api;
  50750. // Try to keep the tooltip show when refreshing
  50751. if (this._lastX != null
  50752. && this._lastY != null
  50753. // When user is willing to control tooltip totally using API,
  50754. // self.manuallyShowTip({x, y}) might cause tooltip hide,
  50755. // which is not expected.
  50756. && tooltipModel.get('triggerOn') !== 'none'
  50757. ) {
  50758. var self = this;
  50759. clearTimeout(this._refreshUpdateTimeout);
  50760. this._refreshUpdateTimeout = setTimeout(function () {
  50761. // Show tip next tick after other charts are rendered
  50762. // In case highlight action has wrong result
  50763. // FIXME
  50764. self.manuallyShowTip(tooltipModel, ecModel, api, {
  50765. x: self._lastX,
  50766. y: self._lastY
  50767. });
  50768. });
  50769. }
  50770. },
  50771. /**
  50772. * Show tip manually by
  50773. * dispatchAction({
  50774. * type: 'showTip',
  50775. * x: 10,
  50776. * y: 10
  50777. * });
  50778. * Or
  50779. * dispatchAction({
  50780. * type: 'showTip',
  50781. * seriesIndex: 0,
  50782. * dataIndex or dataIndexInside or name
  50783. * });
  50784. *
  50785. * TODO Batch
  50786. */
  50787. manuallyShowTip: function (tooltipModel, ecModel, api, payload) {
  50788. if (payload.from === this.uid || env.node) {
  50789. return;
  50790. }
  50791. var dispatchAction = makeDispatchAction(payload, api);
  50792. // Reset ticket
  50793. this._ticket = '';
  50794. // When triggered from axisPointer.
  50795. var dataByCoordSys = payload.dataByCoordSys;
  50796. if (payload.tooltip && payload.x != null && payload.y != null) {
  50797. var el = proxyRect;
  50798. el.position = [payload.x, payload.y];
  50799. el.update();
  50800. el.tooltip = payload.tooltip;
  50801. // Manually show tooltip while view is not using zrender elements.
  50802. this._tryShow({
  50803. offsetX: payload.x,
  50804. offsetY: payload.y,
  50805. target: el
  50806. }, dispatchAction);
  50807. }
  50808. else if (dataByCoordSys) {
  50809. this._tryShow({
  50810. offsetX: payload.x,
  50811. offsetY: payload.y,
  50812. position: payload.position,
  50813. event: {},
  50814. dataByCoordSys: payload.dataByCoordSys,
  50815. tooltipOption: payload.tooltipOption
  50816. }, dispatchAction);
  50817. }
  50818. else if (payload.seriesIndex != null) {
  50819. if (this._manuallyAxisShowTip(tooltipModel, ecModel, api, payload)) {
  50820. return;
  50821. }
  50822. var pointInfo = findPointFromSeries(payload, ecModel);
  50823. var cx = pointInfo.point[0];
  50824. var cy = pointInfo.point[1];
  50825. if (cx != null && cy != null) {
  50826. this._tryShow({
  50827. offsetX: cx,
  50828. offsetY: cy,
  50829. position: payload.position,
  50830. target: pointInfo.el,
  50831. event: {}
  50832. }, dispatchAction);
  50833. }
  50834. }
  50835. else if (payload.x != null && payload.y != null) {
  50836. // FIXME
  50837. // should wrap dispatchAction like `axisPointer/globalListener` ?
  50838. api.dispatchAction({
  50839. type: 'updateAxisPointer',
  50840. x: payload.x,
  50841. y: payload.y
  50842. });
  50843. this._tryShow({
  50844. offsetX: payload.x,
  50845. offsetY: payload.y,
  50846. position: payload.position,
  50847. target: api.getZr().findHover(payload.x, payload.y).target,
  50848. event: {}
  50849. }, dispatchAction);
  50850. }
  50851. },
  50852. manuallyHideTip: function (tooltipModel, ecModel, api, payload) {
  50853. var tooltipContent = this._tooltipContent;
  50854. if (!this._alwaysShowContent) {
  50855. tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
  50856. }
  50857. this._lastX = this._lastY = null;
  50858. if (payload.from !== this.uid) {
  50859. this._hide(makeDispatchAction(payload, api));
  50860. }
  50861. },
  50862. // Be compatible with previous design, that is, when tooltip.type is 'axis' and
  50863. // dispatchAction 'showTip' with seriesIndex and dataIndex will trigger axis pointer
  50864. // and tooltip.
  50865. _manuallyAxisShowTip: function (tooltipModel, ecModel, api, payload) {
  50866. var seriesIndex = payload.seriesIndex;
  50867. var dataIndex = payload.dataIndex;
  50868. var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo;
  50869. if (seriesIndex == null || dataIndex == null || coordSysAxesInfo == null) {
  50870. return;
  50871. }
  50872. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  50873. if (!seriesModel) {
  50874. return;
  50875. }
  50876. var data = seriesModel.getData();
  50877. var tooltipModel = buildTooltipModel([
  50878. data.getItemModel(dataIndex),
  50879. seriesModel,
  50880. (seriesModel.coordinateSystem || {}).model,
  50881. tooltipModel
  50882. ]);
  50883. if (tooltipModel.get('trigger') !== 'axis') {
  50884. return;
  50885. }
  50886. api.dispatchAction({
  50887. type: 'updateAxisPointer',
  50888. seriesIndex: seriesIndex,
  50889. dataIndex: dataIndex,
  50890. position: payload.position
  50891. });
  50892. return true;
  50893. },
  50894. _tryShow: function (e, dispatchAction) {
  50895. var el = e.target;
  50896. var tooltipModel = this._tooltipModel;
  50897. if (!tooltipModel) {
  50898. return;
  50899. }
  50900. // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed
  50901. this._lastX = e.offsetX;
  50902. this._lastY = e.offsetY;
  50903. var dataByCoordSys = e.dataByCoordSys;
  50904. if (dataByCoordSys && dataByCoordSys.length) {
  50905. this._showAxisTooltip(dataByCoordSys, e);
  50906. }
  50907. // Always show item tooltip if mouse is on the element with dataIndex
  50908. else if (el && el.dataIndex != null) {
  50909. this._lastDataByCoordSys = null;
  50910. this._showSeriesItemTooltip(e, el, dispatchAction);
  50911. }
  50912. // Tooltip provided directly. Like legend.
  50913. else if (el && el.tooltip) {
  50914. this._lastDataByCoordSys = null;
  50915. this._showComponentItemTooltip(e, el, dispatchAction);
  50916. }
  50917. else {
  50918. this._lastDataByCoordSys = null;
  50919. this._hide(dispatchAction);
  50920. }
  50921. },
  50922. _showOrMove: function (tooltipModel, cb) {
  50923. // showDelay is used in this case: tooltip.enterable is set
  50924. // as true. User intent to move mouse into tooltip and click
  50925. // something. `showDelay` makes it easyer to enter the content
  50926. // but tooltip do not move immediately.
  50927. var delay = tooltipModel.get('showDelay');
  50928. cb = zrUtil.bind(cb, this);
  50929. clearTimeout(this._showTimout);
  50930. delay > 0
  50931. ? (this._showTimout = setTimeout(cb, delay))
  50932. : cb();
  50933. },
  50934. _showAxisTooltip: function (dataByCoordSys, e) {
  50935. var ecModel = this._ecModel;
  50936. var globalTooltipModel = this._tooltipModel;
  50937. var point = [e.offsetX, e.offsetY];
  50938. var singleDefaultHTML = [];
  50939. var singleParamsList = [];
  50940. var singleTooltipModel = buildTooltipModel([
  50941. e.tooltipOption,
  50942. globalTooltipModel
  50943. ]);
  50944. each(dataByCoordSys, function (itemCoordSys) {
  50945. // var coordParamList = [];
  50946. // var coordDefaultHTML = [];
  50947. // var coordTooltipModel = buildTooltipModel([
  50948. // e.tooltipOption,
  50949. // itemCoordSys.tooltipOption,
  50950. // ecModel.getComponent(itemCoordSys.coordSysMainType, itemCoordSys.coordSysIndex),
  50951. // globalTooltipModel
  50952. // ]);
  50953. // var displayMode = coordTooltipModel.get('displayMode');
  50954. // var paramsList = displayMode === 'single' ? singleParamsList : [];
  50955. each(itemCoordSys.dataByAxis, function (item) {
  50956. var axisModel = ecModel.getComponent(item.axisDim + 'Axis', item.axisIndex);
  50957. var axisValue = item.value;
  50958. var seriesDefaultHTML = [];
  50959. if (!axisModel || axisValue == null) {
  50960. return;
  50961. }
  50962. var valueLabel = axisPointerViewHelper.getValueLabel(
  50963. axisValue, axisModel.axis, ecModel,
  50964. item.seriesDataIndices,
  50965. item.valueLabelOpt
  50966. );
  50967. zrUtil.each(item.seriesDataIndices, function (idxItem) {
  50968. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
  50969. var dataIndex = idxItem.dataIndexInside;
  50970. var dataParams = series && series.getDataParams(dataIndex);
  50971. dataParams.axisDim = item.axisDim;
  50972. dataParams.axisIndex = item.axisIndex;
  50973. dataParams.axisType = item.axisType;
  50974. dataParams.axisId = item.axisId;
  50975. dataParams.axisValue = axisHelper.getAxisRawValue(axisModel.axis, axisValue);
  50976. dataParams.axisValueLabel = valueLabel;
  50977. if (dataParams) {
  50978. singleParamsList.push(dataParams);
  50979. seriesDefaultHTML.push(series.formatTooltip(dataIndex, true));
  50980. }
  50981. });
  50982. // Default tooltip content
  50983. // FIXME
  50984. // (1) shold be the first data which has name?
  50985. // (2) themeRiver, firstDataIndex is array, and first line is unnecessary.
  50986. var firstLine = valueLabel;
  50987. singleDefaultHTML.push(
  50988. (firstLine ? formatUtil.encodeHTML(firstLine) + '<br />' : '')
  50989. + seriesDefaultHTML.join('<br />')
  50990. );
  50991. });
  50992. }, this);
  50993. // In most case, the second axis is shown upper than the first one.
  50994. singleDefaultHTML.reverse();
  50995. singleDefaultHTML = singleDefaultHTML.join('<br /><br />');
  50996. var positionExpr = e.position;
  50997. this._showOrMove(singleTooltipModel, function () {
  50998. if (this._updateContentNotChangedOnAxis(dataByCoordSys)) {
  50999. this._updatePosition(
  51000. singleTooltipModel,
  51001. positionExpr,
  51002. point[0], point[1],
  51003. this._tooltipContent,
  51004. singleParamsList
  51005. );
  51006. }
  51007. else {
  51008. this._showTooltipContent(
  51009. singleTooltipModel, singleDefaultHTML, singleParamsList, Math.random(),
  51010. point[0], point[1], positionExpr
  51011. );
  51012. }
  51013. });
  51014. // Do not trigger events here, because this branch only be entered
  51015. // from dispatchAction.
  51016. },
  51017. _showSeriesItemTooltip: function (e, el, dispatchAction) {
  51018. var ecModel = this._ecModel;
  51019. // Use dataModel in element if possible
  51020. // Used when mouseover on a element like markPoint or edge
  51021. // In which case, the data is not main data in series.
  51022. var seriesIndex = el.seriesIndex;
  51023. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  51024. // For example, graph link.
  51025. var dataModel = el.dataModel || seriesModel;
  51026. var dataIndex = el.dataIndex;
  51027. var dataType = el.dataType;
  51028. var data = dataModel.getData();
  51029. var tooltipModel = buildTooltipModel([
  51030. data.getItemModel(dataIndex),
  51031. dataModel,
  51032. seriesModel && (seriesModel.coordinateSystem || {}).model,
  51033. this._tooltipModel
  51034. ]);
  51035. var tooltipTrigger = tooltipModel.get('trigger');
  51036. if (tooltipTrigger != null && tooltipTrigger !== 'item') {
  51037. return;
  51038. }
  51039. var params = dataModel.getDataParams(dataIndex, dataType);
  51040. var defaultHtml = dataModel.formatTooltip(dataIndex, false, dataType);
  51041. var asyncTicket = 'item_' + dataModel.name + '_' + dataIndex;
  51042. this._showOrMove(tooltipModel, function () {
  51043. this._showTooltipContent(
  51044. tooltipModel, defaultHtml, params, asyncTicket,
  51045. e.offsetX, e.offsetY, e.position, e.target
  51046. );
  51047. });
  51048. // FIXME
  51049. // duplicated showtip if manuallyShowTip is called from dispatchAction.
  51050. dispatchAction({
  51051. type: 'showTip',
  51052. dataIndexInside: dataIndex,
  51053. dataIndex: data.getRawIndex(dataIndex),
  51054. seriesIndex: seriesIndex,
  51055. from: this.uid
  51056. });
  51057. },
  51058. _showComponentItemTooltip: function (e, el, dispatchAction) {
  51059. var tooltipOpt = el.tooltip;
  51060. if (typeof tooltipOpt === 'string') {
  51061. var content = tooltipOpt;
  51062. tooltipOpt = {
  51063. content: content,
  51064. // Fixed formatter
  51065. formatter: content
  51066. };
  51067. }
  51068. var subTooltipModel = new Model(tooltipOpt, this._tooltipModel, this._ecModel);
  51069. var defaultHtml = subTooltipModel.get('content');
  51070. var asyncTicket = Math.random();
  51071. // Do not check whether `trigger` is 'none' here, because `trigger`
  51072. // only works on cooridinate system. In fact, we have not found case
  51073. // that requires setting `trigger` nothing on component yet.
  51074. this._showOrMove(subTooltipModel, function () {
  51075. this._showTooltipContent(
  51076. subTooltipModel, defaultHtml, subTooltipModel.get('formatterParams') || {},
  51077. asyncTicket, e.offsetX, e.offsetY, e.position, el
  51078. );
  51079. });
  51080. // If not dispatch showTip, tip may be hide triggered by axis.
  51081. dispatchAction({
  51082. type: 'showTip',
  51083. from: this.uid
  51084. });
  51085. },
  51086. _showTooltipContent: function (
  51087. tooltipModel, defaultHtml, params, asyncTicket, x, y, positionExpr, el
  51088. ) {
  51089. // Reset ticket
  51090. this._ticket = '';
  51091. if (!tooltipModel.get('showContent') || !tooltipModel.get('show')) {
  51092. return;
  51093. }
  51094. var tooltipContent = this._tooltipContent;
  51095. var formatter = tooltipModel.get('formatter');
  51096. positionExpr = positionExpr || tooltipModel.get('position');
  51097. var html = defaultHtml;
  51098. if (formatter && typeof formatter === 'string') {
  51099. html = formatUtil.formatTpl(formatter, params, true);
  51100. }
  51101. else if (typeof formatter === 'function') {
  51102. var callback = bind(function (cbTicket, html) {
  51103. if (cbTicket === this._ticket) {
  51104. tooltipContent.setContent(html);
  51105. this._updatePosition(
  51106. tooltipModel, positionExpr, x, y, tooltipContent, params, el
  51107. );
  51108. }
  51109. }, this);
  51110. this._ticket = asyncTicket;
  51111. html = formatter(params, asyncTicket, callback);
  51112. }
  51113. tooltipContent.setContent(html);
  51114. tooltipContent.show(tooltipModel);
  51115. this._updatePosition(
  51116. tooltipModel, positionExpr, x, y, tooltipContent, params, el
  51117. );
  51118. },
  51119. /**
  51120. * @param {string|Function|Array.<number>|Object} positionExpr
  51121. * @param {number} x Mouse x
  51122. * @param {number} y Mouse y
  51123. * @param {boolean} confine Whether confine tooltip content in view rect.
  51124. * @param {Object|<Array.<Object>} params
  51125. * @param {module:zrender/Element} el target element
  51126. * @param {module:echarts/ExtensionAPI} api
  51127. * @return {Array.<number>}
  51128. */
  51129. _updatePosition: function (tooltipModel, positionExpr, x, y, content, params, el) {
  51130. var viewWidth = this._api.getWidth();
  51131. var viewHeight = this._api.getHeight();
  51132. positionExpr = positionExpr || tooltipModel.get('position');
  51133. var contentSize = content.getSize();
  51134. var align = tooltipModel.get('align');
  51135. var vAlign = tooltipModel.get('verticalAlign');
  51136. var rect = el && el.getBoundingRect().clone();
  51137. el && rect.applyTransform(el.transform);
  51138. if (typeof positionExpr === 'function') {
  51139. // Callback of position can be an array or a string specify the position
  51140. positionExpr = positionExpr([x, y], params, content.el, rect, {
  51141. viewSize: [viewWidth, viewHeight],
  51142. contentSize: contentSize.slice()
  51143. });
  51144. }
  51145. if (zrUtil.isArray(positionExpr)) {
  51146. x = parsePercent(positionExpr[0], viewWidth);
  51147. y = parsePercent(positionExpr[1], viewHeight);
  51148. }
  51149. else if (zrUtil.isObject(positionExpr)) {
  51150. positionExpr.width = contentSize[0];
  51151. positionExpr.height = contentSize[1];
  51152. var layoutRect = layoutUtil.getLayoutRect(
  51153. positionExpr, {width: viewWidth, height: viewHeight}
  51154. );
  51155. x = layoutRect.x;
  51156. y = layoutRect.y;
  51157. align = null;
  51158. // When positionExpr is left/top/right/bottom,
  51159. // align and verticalAlign will not work.
  51160. vAlign = null;
  51161. }
  51162. // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
  51163. else if (typeof positionExpr === 'string' && el) {
  51164. var pos = calcTooltipPosition(
  51165. positionExpr, rect, contentSize
  51166. );
  51167. x = pos[0];
  51168. y = pos[1];
  51169. }
  51170. else {
  51171. var pos = refixTooltipPosition(
  51172. x, y, content.el, viewWidth, viewHeight, align ? null : 20, vAlign ? null : 20
  51173. );
  51174. x = pos[0];
  51175. y = pos[1];
  51176. }
  51177. align && (x -= isCenterAlign(align) ? contentSize[0] / 2 : align === 'right' ? contentSize[0] : 0);
  51178. vAlign && (y -= isCenterAlign(vAlign) ? contentSize[1] / 2 : vAlign === 'bottom' ? contentSize[1] : 0);
  51179. if (tooltipModel.get('confine')) {
  51180. var pos = confineTooltipPosition(
  51181. x, y, content.el, viewWidth, viewHeight
  51182. );
  51183. x = pos[0];
  51184. y = pos[1];
  51185. }
  51186. content.moveTo(x, y);
  51187. },
  51188. // FIXME
  51189. // Should we remove this but leave this to user?
  51190. _updateContentNotChangedOnAxis: function (dataByCoordSys) {
  51191. var lastCoordSys = this._lastDataByCoordSys;
  51192. var contentNotChanged = !!lastCoordSys
  51193. && lastCoordSys.length === dataByCoordSys.length;
  51194. contentNotChanged && each(lastCoordSys, function (lastItemCoordSys, indexCoordSys) {
  51195. var lastDataByAxis = lastItemCoordSys.dataByAxis || {};
  51196. var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {};
  51197. var thisDataByAxis = thisItemCoordSys.dataByAxis || [];
  51198. contentNotChanged &= lastDataByAxis.length === thisDataByAxis.length;
  51199. contentNotChanged && each(lastDataByAxis, function (lastItem, indexAxis) {
  51200. var thisItem = thisDataByAxis[indexAxis] || {};
  51201. var lastIndices = lastItem.seriesDataIndices || [];
  51202. var newIndices = thisItem.seriesDataIndices || [];
  51203. contentNotChanged &=
  51204. lastItem.value === thisItem.value
  51205. && lastItem.axisType === thisItem.axisType
  51206. && lastItem.axisId === thisItem.axisId
  51207. && lastIndices.length === newIndices.length;
  51208. contentNotChanged && each(lastIndices, function (lastIdxItem, j) {
  51209. var newIdxItem = newIndices[j];
  51210. contentNotChanged &=
  51211. lastIdxItem.seriesIndex === newIdxItem.seriesIndex
  51212. && lastIdxItem.dataIndex === newIdxItem.dataIndex;
  51213. });
  51214. });
  51215. });
  51216. this._lastDataByCoordSys = dataByCoordSys;
  51217. return !!contentNotChanged;
  51218. },
  51219. _hide: function (dispatchAction) {
  51220. // Do not directly hideLater here, because this behavior may be prevented
  51221. // in dispatchAction when showTip is dispatched.
  51222. // FIXME
  51223. // duplicated hideTip if manuallyHideTip is called from dispatchAction.
  51224. this._lastDataByCoordSys = null;
  51225. dispatchAction({
  51226. type: 'hideTip',
  51227. from: this.uid
  51228. });
  51229. },
  51230. dispose: function (ecModel, api) {
  51231. if (env.node) {
  51232. return;
  51233. }
  51234. this._tooltipContent.hide();
  51235. globalListener.unregister('itemTooltip', api);
  51236. }
  51237. });
  51238. /**
  51239. * @param {Array.<Object|module:echarts/model/Model>} modelCascade
  51240. * From top to bottom. (the last one should be globalTooltipModel);
  51241. */
  51242. function buildTooltipModel(modelCascade) {
  51243. var resultModel = modelCascade.pop();
  51244. while (modelCascade.length) {
  51245. var tooltipOpt = modelCascade.pop();
  51246. if (tooltipOpt) {
  51247. if (tooltipOpt instanceof Model) {
  51248. tooltipOpt = tooltipOpt.get('tooltip', true);
  51249. }
  51250. // In each data item tooltip can be simply write:
  51251. // {
  51252. // value: 10,
  51253. // tooltip: 'Something you need to know'
  51254. // }
  51255. if (typeof tooltipOpt === 'string') {
  51256. tooltipOpt = {formatter: tooltipOpt};
  51257. }
  51258. resultModel = new Model(tooltipOpt, resultModel, resultModel.ecModel);
  51259. }
  51260. }
  51261. return resultModel;
  51262. }
  51263. function makeDispatchAction(payload, api) {
  51264. return payload.dispatchAction || zrUtil.bind(api.dispatchAction, api);
  51265. }
  51266. function refixTooltipPosition(x, y, el, viewWidth, viewHeight, gapH, gapV) {
  51267. var size = getOuterSize(el);
  51268. var width = size.width;
  51269. var height = size.height;
  51270. if (gapH != null) {
  51271. if (x + width + gapH > viewWidth) {
  51272. x -= width + gapH;
  51273. }
  51274. else {
  51275. x += gapH;
  51276. }
  51277. }
  51278. if (gapV != null) {
  51279. if (y + height + gapV > viewHeight) {
  51280. y -= height + gapV;
  51281. }
  51282. else {
  51283. y += gapV;
  51284. }
  51285. }
  51286. return [x, y];
  51287. }
  51288. function confineTooltipPosition(x, y, el, viewWidth, viewHeight) {
  51289. var size = getOuterSize(el);
  51290. var width = size.width;
  51291. var height = size.height;
  51292. x = Math.min(x + width, viewWidth) - width;
  51293. y = Math.min(y + height, viewHeight) - height;
  51294. x = Math.max(x, 0);
  51295. y = Math.max(y, 0);
  51296. return [x, y];
  51297. }
  51298. function getOuterSize(el) {
  51299. var width = el.clientWidth;
  51300. var height = el.clientHeight;
  51301. // Consider browser compatibility.
  51302. // IE8 does not support getComputedStyle.
  51303. if (document.defaultView && document.defaultView.getComputedStyle) {
  51304. var stl = document.defaultView.getComputedStyle(el);
  51305. if (stl) {
  51306. width += parseInt(stl.paddingLeft, 10) + parseInt(stl.paddingRight, 10)
  51307. + parseInt(stl.borderLeftWidth, 10) + parseInt(stl.borderRightWidth, 10);
  51308. height += parseInt(stl.paddingTop, 10) + parseInt(stl.paddingBottom, 10)
  51309. + parseInt(stl.borderTopWidth, 10) + parseInt(stl.borderBottomWidth, 10);
  51310. }
  51311. }
  51312. return {width: width, height: height};
  51313. }
  51314. function calcTooltipPosition(position, rect, contentSize) {
  51315. var domWidth = contentSize[0];
  51316. var domHeight = contentSize[1];
  51317. var gap = 5;
  51318. var x = 0;
  51319. var y = 0;
  51320. var rectWidth = rect.width;
  51321. var rectHeight = rect.height;
  51322. switch (position) {
  51323. case 'inside':
  51324. x = rect.x + rectWidth / 2 - domWidth / 2;
  51325. y = rect.y + rectHeight / 2 - domHeight / 2;
  51326. break;
  51327. case 'top':
  51328. x = rect.x + rectWidth / 2 - domWidth / 2;
  51329. y = rect.y - domHeight - gap;
  51330. break;
  51331. case 'bottom':
  51332. x = rect.x + rectWidth / 2 - domWidth / 2;
  51333. y = rect.y + rectHeight + gap;
  51334. break;
  51335. case 'left':
  51336. x = rect.x - domWidth - gap;
  51337. y = rect.y + rectHeight / 2 - domHeight / 2;
  51338. break;
  51339. case 'right':
  51340. x = rect.x + rectWidth + gap;
  51341. y = rect.y + rectHeight / 2 - domHeight / 2;
  51342. }
  51343. return [x, y];
  51344. }
  51345. function isCenterAlign(align) {
  51346. return align === 'center' || align === 'middle';
  51347. }
  51348. /***/ }),
  51349. /* 337 */
  51350. /***/ (function(module, exports, __webpack_require__) {
  51351. /**
  51352. * @module echarts/component/tooltip/TooltipContent
  51353. */
  51354. var zrUtil = __webpack_require__(4);
  51355. var zrColor = __webpack_require__(33);
  51356. var eventUtil = __webpack_require__(93);
  51357. var formatUtil = __webpack_require__(6);
  51358. var each = zrUtil.each;
  51359. var toCamelCase = formatUtil.toCamelCase;
  51360. var env = __webpack_require__(2);
  51361. var vendors = ['', '-webkit-', '-moz-', '-o-'];
  51362. var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;z-index:9999999;';
  51363. /**
  51364. * @param {number} duration
  51365. * @return {string}
  51366. * @inner
  51367. */
  51368. function assembleTransition(duration) {
  51369. var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)';
  51370. var transitionText = 'left ' + duration + 's ' + transitionCurve + ','
  51371. + 'top ' + duration + 's ' + transitionCurve;
  51372. return zrUtil.map(vendors, function (vendorPrefix) {
  51373. return vendorPrefix + 'transition:' + transitionText;
  51374. }).join(';');
  51375. }
  51376. /**
  51377. * @param {Object} textStyle
  51378. * @return {string}
  51379. * @inner
  51380. */
  51381. function assembleFont(textStyleModel) {
  51382. var cssText = [];
  51383. var fontSize = textStyleModel.get('fontSize');
  51384. var color = textStyleModel.getTextColor();
  51385. color && cssText.push('color:' + color);
  51386. cssText.push('font:' + textStyleModel.getFont());
  51387. fontSize &&
  51388. cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px');
  51389. each(['decoration', 'align'], function (name) {
  51390. var val = textStyleModel.get(name);
  51391. val && cssText.push('text-' + name + ':' + val);
  51392. });
  51393. return cssText.join(';');
  51394. }
  51395. /**
  51396. * @param {Object} tooltipModel
  51397. * @return {string}
  51398. * @inner
  51399. */
  51400. function assembleCssText(tooltipModel) {
  51401. var cssText = [];
  51402. var transitionDuration = tooltipModel.get('transitionDuration');
  51403. var backgroundColor = tooltipModel.get('backgroundColor');
  51404. var textStyleModel = tooltipModel.getModel('textStyle');
  51405. var padding = tooltipModel.get('padding');
  51406. // Animation transition. Do not animate when transitionDuration is 0.
  51407. transitionDuration &&
  51408. cssText.push(assembleTransition(transitionDuration));
  51409. if (backgroundColor) {
  51410. if (env.canvasSupported) {
  51411. cssText.push('background-Color:' + backgroundColor);
  51412. }
  51413. else {
  51414. // for ie
  51415. cssText.push(
  51416. 'background-Color:#' + zrColor.toHex(backgroundColor)
  51417. );
  51418. cssText.push('filter:alpha(opacity=70)');
  51419. }
  51420. }
  51421. // Border style
  51422. each(['width', 'color', 'radius'], function (name) {
  51423. var borderName = 'border-' + name;
  51424. var camelCase = toCamelCase(borderName);
  51425. var val = tooltipModel.get(camelCase);
  51426. val != null &&
  51427. cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px'));
  51428. });
  51429. // Text style
  51430. cssText.push(assembleFont(textStyleModel));
  51431. // Padding
  51432. if (padding != null) {
  51433. cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px');
  51434. }
  51435. return cssText.join(';') + ';';
  51436. }
  51437. /**
  51438. * @alias module:echarts/component/tooltip/TooltipContent
  51439. * @constructor
  51440. */
  51441. function TooltipContent(container, api) {
  51442. var el = document.createElement('div');
  51443. var zr = this._zr = api.getZr();
  51444. this.el = el;
  51445. this._x = api.getWidth() / 2;
  51446. this._y = api.getHeight() / 2;
  51447. container.appendChild(el);
  51448. this._container = container;
  51449. this._show = false;
  51450. /**
  51451. * @private
  51452. */
  51453. this._hideTimeout;
  51454. var self = this;
  51455. el.onmouseenter = function () {
  51456. // clear the timeout in hideLater and keep showing tooltip
  51457. if (self._enterable) {
  51458. clearTimeout(self._hideTimeout);
  51459. self._show = true;
  51460. }
  51461. self._inContent = true;
  51462. };
  51463. el.onmousemove = function (e) {
  51464. e = e || window.event;
  51465. if (!self._enterable) {
  51466. // Try trigger zrender event to avoid mouse
  51467. // in and out shape too frequently
  51468. var handler = zr.handler;
  51469. eventUtil.normalizeEvent(container, e, true);
  51470. handler.dispatch('mousemove', e);
  51471. }
  51472. };
  51473. el.onmouseleave = function () {
  51474. if (self._enterable) {
  51475. if (self._show) {
  51476. self.hideLater(self._hideDelay);
  51477. }
  51478. }
  51479. self._inContent = false;
  51480. };
  51481. }
  51482. TooltipContent.prototype = {
  51483. constructor: TooltipContent,
  51484. /**
  51485. * @private
  51486. * @type {boolean}
  51487. */
  51488. _enterable: true,
  51489. /**
  51490. * Update when tooltip is rendered
  51491. */
  51492. update: function () {
  51493. // FIXME
  51494. // Move this logic to ec main?
  51495. var container = this._container;
  51496. var stl = container.currentStyle
  51497. || document.defaultView.getComputedStyle(container);
  51498. var domStyle = container.style;
  51499. if (domStyle.position !== 'absolute' && stl.position !== 'absolute') {
  51500. domStyle.position = 'relative';
  51501. }
  51502. // Hide the tooltip
  51503. // PENDING
  51504. // this.hide();
  51505. },
  51506. show: function (tooltipModel) {
  51507. clearTimeout(this._hideTimeout);
  51508. var el = this.el;
  51509. el.style.cssText = gCssText + assembleCssText(tooltipModel)
  51510. // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
  51511. + ';left:' + this._x + 'px;top:' + this._y + 'px;'
  51512. + (tooltipModel.get('extraCssText') || '');
  51513. el.style.display = el.innerHTML ? 'block' : 'none';
  51514. this._show = true;
  51515. },
  51516. setContent: function (content) {
  51517. this.el.innerHTML = content == null ? '' : content;
  51518. },
  51519. setEnterable: function (enterable) {
  51520. this._enterable = enterable;
  51521. },
  51522. getSize: function () {
  51523. var el = this.el;
  51524. return [el.clientWidth, el.clientHeight];
  51525. },
  51526. moveTo: function (x, y) {
  51527. // xy should be based on canvas root. But tooltipContent is
  51528. // the sibling of canvas root. So padding of ec container
  51529. // should be considered here.
  51530. var zr = this._zr;
  51531. var viewportRootOffset;
  51532. if (zr && zr.painter && (viewportRootOffset = zr.painter.getViewportRootOffset())) {
  51533. x += viewportRootOffset.offsetLeft;
  51534. y += viewportRootOffset.offsetTop;
  51535. }
  51536. var style = this.el.style;
  51537. style.left = x + 'px';
  51538. style.top = y + 'px';
  51539. this._x = x;
  51540. this._y = y;
  51541. },
  51542. hide: function () {
  51543. this.el.style.display = 'none';
  51544. this._show = false;
  51545. },
  51546. hideLater: function (time) {
  51547. if (this._show && !(this._inContent && this._enterable)) {
  51548. if (time) {
  51549. this._hideDelay = time;
  51550. // Set show false to avoid invoke hideLater mutiple times
  51551. this._show = false;
  51552. this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time);
  51553. }
  51554. else {
  51555. this.hide();
  51556. }
  51557. }
  51558. },
  51559. isShow: function () {
  51560. return this._show;
  51561. }
  51562. };
  51563. module.exports = TooltipContent;
  51564. /***/ }),
  51565. /* 338 */
  51566. /***/ (function(module, exports, __webpack_require__) {
  51567. 'use strict';
  51568. var zrUtil = __webpack_require__(4);
  51569. __webpack_require__(339);
  51570. __webpack_require__(345);
  51571. __webpack_require__(347);
  51572. __webpack_require__(301);
  51573. __webpack_require__(349);
  51574. // For reducing size of echarts.min, barLayoutPolar is required by polar.
  51575. __webpack_require__(1).registerLayout(zrUtil.curry(__webpack_require__(350), 'bar'));
  51576. // Polar view
  51577. __webpack_require__(1).extendComponentView({
  51578. type: 'polar'
  51579. });
  51580. /***/ }),
  51581. /* 339 */
  51582. /***/ (function(module, exports, __webpack_require__) {
  51583. // TODO Axis scale
  51584. var Polar = __webpack_require__(340);
  51585. var numberUtil = __webpack_require__(7);
  51586. var zrUtil = __webpack_require__(4);
  51587. var axisHelper = __webpack_require__(104);
  51588. var niceScaleExtent = axisHelper.niceScaleExtent;
  51589. // 依赖 PolarModel 做预处理
  51590. __webpack_require__(343);
  51591. /**
  51592. * Resize method bound to the polar
  51593. * @param {module:echarts/coord/polar/PolarModel} polarModel
  51594. * @param {module:echarts/ExtensionAPI} api
  51595. */
  51596. function resizePolar(polarModel, api) {
  51597. var center = polarModel.get('center');
  51598. var radius = polarModel.get('radius');
  51599. var width = api.getWidth();
  51600. var height = api.getHeight();
  51601. var parsePercent = numberUtil.parsePercent;
  51602. this.cx = parsePercent(center[0], width);
  51603. this.cy = parsePercent(center[1], height);
  51604. var radiusAxis = this.getRadiusAxis();
  51605. var size = Math.min(width, height) / 2;
  51606. // var idx = radiusAxis.inverse ? 1 : 0;
  51607. radiusAxis.setExtent(0, parsePercent(radius, size));
  51608. }
  51609. /**
  51610. * Update polar
  51611. */
  51612. function updatePolarScale(ecModel, api) {
  51613. var polar = this;
  51614. var angleAxis = polar.getAngleAxis();
  51615. var radiusAxis = polar.getRadiusAxis();
  51616. // Reset scale
  51617. angleAxis.scale.setExtent(Infinity, -Infinity);
  51618. radiusAxis.scale.setExtent(Infinity, -Infinity);
  51619. ecModel.eachSeries(function (seriesModel) {
  51620. if (seriesModel.coordinateSystem === polar) {
  51621. var data = seriesModel.getData();
  51622. radiusAxis.scale.unionExtentFromData(data, 'radius');
  51623. angleAxis.scale.unionExtentFromData(data, 'angle');
  51624. }
  51625. });
  51626. niceScaleExtent(angleAxis.scale, angleAxis.model);
  51627. niceScaleExtent(radiusAxis.scale, radiusAxis.model);
  51628. // Fix extent of category angle axis
  51629. if (angleAxis.type === 'category' && !angleAxis.onBand) {
  51630. var extent = angleAxis.getExtent();
  51631. var diff = 360 / angleAxis.scale.count();
  51632. angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
  51633. angleAxis.setExtent(extent[0], extent[1]);
  51634. }
  51635. }
  51636. /**
  51637. * Set common axis properties
  51638. * @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  51639. * @param {module:echarts/coord/polar/AxisModel}
  51640. * @inner
  51641. */
  51642. function setAxis(axis, axisModel) {
  51643. axis.type = axisModel.get('type');
  51644. axis.scale = axisHelper.createScaleByModel(axisModel);
  51645. axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
  51646. // FIXME Radius axis not support inverse axis
  51647. if (axisModel.mainType === 'angleAxis') {
  51648. var startAngle = axisModel.get('startAngle');
  51649. axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise');
  51650. axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
  51651. }
  51652. // Inject axis instance
  51653. axisModel.axis = axis;
  51654. axis.model = axisModel;
  51655. }
  51656. var polarCreator = {
  51657. dimensions: Polar.prototype.dimensions,
  51658. create: function (ecModel, api) {
  51659. var polarList = [];
  51660. ecModel.eachComponent('polar', function (polarModel, idx) {
  51661. var polar = new Polar(idx);
  51662. // Inject resize and update method
  51663. polar.resize = resizePolar;
  51664. polar.update = updatePolarScale;
  51665. var radiusAxis = polar.getRadiusAxis();
  51666. var angleAxis = polar.getAngleAxis();
  51667. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  51668. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  51669. setAxis(radiusAxis, radiusAxisModel);
  51670. setAxis(angleAxis, angleAxisModel);
  51671. polar.resize(polarModel, api);
  51672. polarList.push(polar);
  51673. polarModel.coordinateSystem = polar;
  51674. polar.model = polarModel;
  51675. });
  51676. // Inject coordinateSystem to series
  51677. ecModel.eachSeries(function (seriesModel) {
  51678. if (seriesModel.get('coordinateSystem') === 'polar') {
  51679. var polarModel = ecModel.queryComponents({
  51680. mainType: 'polar',
  51681. index: seriesModel.get('polarIndex'),
  51682. id: seriesModel.get('polarId')
  51683. })[0];
  51684. if (true) {
  51685. if (!polarModel) {
  51686. throw new Error(
  51687. 'Polar "' + zrUtil.retrieve(
  51688. seriesModel.get('polarIndex'),
  51689. seriesModel.get('polarId'),
  51690. 0
  51691. ) + '" not found'
  51692. );
  51693. }
  51694. }
  51695. seriesModel.coordinateSystem = polarModel.coordinateSystem;
  51696. }
  51697. });
  51698. return polarList;
  51699. }
  51700. };
  51701. __webpack_require__(79).register('polar', polarCreator);
  51702. /***/ }),
  51703. /* 340 */
  51704. /***/ (function(module, exports, __webpack_require__) {
  51705. 'use strict';
  51706. /**
  51707. * @module echarts/coord/polar/Polar
  51708. */
  51709. var RadiusAxis = __webpack_require__(341);
  51710. var AngleAxis = __webpack_require__(342);
  51711. /**
  51712. * @alias {module:echarts/coord/polar/Polar}
  51713. * @constructor
  51714. * @param {string} name
  51715. */
  51716. var Polar = function (name) {
  51717. /**
  51718. * @type {string}
  51719. */
  51720. this.name = name || '';
  51721. /**
  51722. * x of polar center
  51723. * @type {number}
  51724. */
  51725. this.cx = 0;
  51726. /**
  51727. * y of polar center
  51728. * @type {number}
  51729. */
  51730. this.cy = 0;
  51731. /**
  51732. * @type {module:echarts/coord/polar/RadiusAxis}
  51733. * @private
  51734. */
  51735. this._radiusAxis = new RadiusAxis();
  51736. /**
  51737. * @type {module:echarts/coord/polar/AngleAxis}
  51738. * @private
  51739. */
  51740. this._angleAxis = new AngleAxis();
  51741. this._radiusAxis.polar = this._angleAxis.polar = this;
  51742. };
  51743. Polar.prototype = {
  51744. type: 'polar',
  51745. axisPointerEnabled: true,
  51746. constructor: Polar,
  51747. /**
  51748. * @param {Array.<string>}
  51749. * @readOnly
  51750. */
  51751. dimensions: ['radius', 'angle'],
  51752. /**
  51753. * @type {module:echarts/coord/PolarModel}
  51754. */
  51755. model: null,
  51756. /**
  51757. * If contain coord
  51758. * @param {Array.<number>} point
  51759. * @return {boolean}
  51760. */
  51761. containPoint: function (point) {
  51762. var coord = this.pointToCoord(point);
  51763. return this._radiusAxis.contain(coord[0])
  51764. && this._angleAxis.contain(coord[1]);
  51765. },
  51766. /**
  51767. * If contain data
  51768. * @param {Array.<number>} data
  51769. * @return {boolean}
  51770. */
  51771. containData: function (data) {
  51772. return this._radiusAxis.containData(data[0])
  51773. && this._angleAxis.containData(data[1]);
  51774. },
  51775. /**
  51776. * @param {string} dim
  51777. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  51778. */
  51779. getAxis: function (dim) {
  51780. return this['_' + dim + 'Axis'];
  51781. },
  51782. /**
  51783. * @return {Array.<module:echarts/coord/Axis>}
  51784. */
  51785. getAxes: function () {
  51786. return [this._radiusAxis, this._angleAxis];
  51787. },
  51788. /**
  51789. * Get axes by type of scale
  51790. * @param {string} scaleType
  51791. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  51792. */
  51793. getAxesByScale: function (scaleType) {
  51794. var axes = [];
  51795. var angleAxis = this._angleAxis;
  51796. var radiusAxis = this._radiusAxis;
  51797. angleAxis.scale.type === scaleType && axes.push(angleAxis);
  51798. radiusAxis.scale.type === scaleType && axes.push(radiusAxis);
  51799. return axes;
  51800. },
  51801. /**
  51802. * @return {module:echarts/coord/polar/AngleAxis}
  51803. */
  51804. getAngleAxis: function () {
  51805. return this._angleAxis;
  51806. },
  51807. /**
  51808. * @return {module:echarts/coord/polar/RadiusAxis}
  51809. */
  51810. getRadiusAxis: function () {
  51811. return this._radiusAxis;
  51812. },
  51813. /**
  51814. * @param {module:echarts/coord/polar/Axis}
  51815. * @return {module:echarts/coord/polar/Axis}
  51816. */
  51817. getOtherAxis: function (axis) {
  51818. var angleAxis = this._angleAxis;
  51819. return axis === angleAxis ? this._radiusAxis : angleAxis;
  51820. },
  51821. /**
  51822. * Base axis will be used on stacking.
  51823. *
  51824. * @return {module:echarts/coord/polar/Axis}
  51825. */
  51826. getBaseAxis: function () {
  51827. return this.getAxesByScale('ordinal')[0]
  51828. || this.getAxesByScale('time')[0]
  51829. || this.getAngleAxis();
  51830. },
  51831. /**
  51832. * @param {string} [dim] 'radius' or 'angle' or 'auto' or null/undefined
  51833. * @return {Object} {baseAxes: [], otherAxes: []}
  51834. */
  51835. getTooltipAxes: function (dim) {
  51836. var baseAxis = (dim != null && dim !== 'auto')
  51837. ? this.getAxis(dim) : this.getBaseAxis();
  51838. return {
  51839. baseAxes: [baseAxis],
  51840. otherAxes: [this.getOtherAxis(baseAxis)]
  51841. };
  51842. },
  51843. /**
  51844. * Convert a single data item to (x, y) point.
  51845. * Parameter data is an array which the first element is radius and the second is angle
  51846. * @param {Array.<number>} data
  51847. * @param {boolean} [clamp=false]
  51848. * @return {Array.<number>}
  51849. */
  51850. dataToPoint: function (data, clamp) {
  51851. return this.coordToPoint([
  51852. this._radiusAxis.dataToRadius(data[0], clamp),
  51853. this._angleAxis.dataToAngle(data[1], clamp)
  51854. ]);
  51855. },
  51856. /**
  51857. * Convert a (x, y) point to data
  51858. * @param {Array.<number>} point
  51859. * @param {boolean} [clamp=false]
  51860. * @return {Array.<number>}
  51861. */
  51862. pointToData: function (point, clamp) {
  51863. var coord = this.pointToCoord(point);
  51864. return [
  51865. this._radiusAxis.radiusToData(coord[0], clamp),
  51866. this._angleAxis.angleToData(coord[1], clamp)
  51867. ];
  51868. },
  51869. /**
  51870. * Convert a (x, y) point to (radius, angle) coord
  51871. * @param {Array.<number>} point
  51872. * @return {Array.<number>}
  51873. */
  51874. pointToCoord: function (point) {
  51875. var dx = point[0] - this.cx;
  51876. var dy = point[1] - this.cy;
  51877. var angleAxis = this.getAngleAxis();
  51878. var extent = angleAxis.getExtent();
  51879. var minAngle = Math.min(extent[0], extent[1]);
  51880. var maxAngle = Math.max(extent[0], extent[1]);
  51881. // Fix fixed extent in polarCreator
  51882. // FIXME
  51883. angleAxis.inverse
  51884. ? (minAngle = maxAngle - 360)
  51885. : (maxAngle = minAngle + 360);
  51886. var radius = Math.sqrt(dx * dx + dy * dy);
  51887. dx /= radius;
  51888. dy /= radius;
  51889. var radian = Math.atan2(-dy, dx) / Math.PI * 180;
  51890. // move to angleExtent
  51891. var dir = radian < minAngle ? 1 : -1;
  51892. while (radian < minAngle || radian > maxAngle) {
  51893. radian += dir * 360;
  51894. }
  51895. return [radius, radian];
  51896. },
  51897. /**
  51898. * Convert a (radius, angle) coord to (x, y) point
  51899. * @param {Array.<number>} coord
  51900. * @return {Array.<number>}
  51901. */
  51902. coordToPoint: function (coord) {
  51903. var radius = coord[0];
  51904. var radian = coord[1] / 180 * Math.PI;
  51905. var x = Math.cos(radian) * radius + this.cx;
  51906. // Inverse the y
  51907. var y = -Math.sin(radian) * radius + this.cy;
  51908. return [x, y];
  51909. }
  51910. };
  51911. module.exports = Polar;
  51912. /***/ }),
  51913. /* 341 */
  51914. /***/ (function(module, exports, __webpack_require__) {
  51915. 'use strict';
  51916. var zrUtil = __webpack_require__(4);
  51917. var Axis = __webpack_require__(103);
  51918. function RadiusAxis(scale, radiusExtent) {
  51919. Axis.call(this, 'radius', scale, radiusExtent);
  51920. /**
  51921. * Axis type
  51922. * - 'category'
  51923. * - 'value'
  51924. * - 'time'
  51925. * - 'log'
  51926. * @type {string}
  51927. */
  51928. this.type = 'category';
  51929. }
  51930. RadiusAxis.prototype = {
  51931. constructor: RadiusAxis,
  51932. /**
  51933. * @override
  51934. */
  51935. pointToData: function (point, clamp) {
  51936. return this.polar.pointToData(point, clamp)[this.dim === 'radius' ? 0 : 1];
  51937. },
  51938. dataToRadius: Axis.prototype.dataToCoord,
  51939. radiusToData: Axis.prototype.coordToData
  51940. };
  51941. zrUtil.inherits(RadiusAxis, Axis);
  51942. module.exports = RadiusAxis;
  51943. /***/ }),
  51944. /* 342 */
  51945. /***/ (function(module, exports, __webpack_require__) {
  51946. 'use strict';
  51947. var zrUtil = __webpack_require__(4);
  51948. var Axis = __webpack_require__(103);
  51949. function AngleAxis(scale, angleExtent) {
  51950. angleExtent = angleExtent || [0, 360];
  51951. Axis.call(this, 'angle', scale, angleExtent);
  51952. /**
  51953. * Axis type
  51954. * - 'category'
  51955. * - 'value'
  51956. * - 'time'
  51957. * - 'log'
  51958. * @type {string}
  51959. */
  51960. this.type = 'category';
  51961. }
  51962. AngleAxis.prototype = {
  51963. constructor: AngleAxis,
  51964. /**
  51965. * @override
  51966. */
  51967. pointToData: function (point, clamp) {
  51968. return this.polar.pointToData(point, clamp)[this.dim === 'radius' ? 0 : 1];
  51969. },
  51970. dataToAngle: Axis.prototype.dataToCoord,
  51971. angleToData: Axis.prototype.coordToData
  51972. };
  51973. zrUtil.inherits(AngleAxis, Axis);
  51974. module.exports = AngleAxis;
  51975. /***/ }),
  51976. /* 343 */
  51977. /***/ (function(module, exports, __webpack_require__) {
  51978. 'use strict';
  51979. __webpack_require__(344);
  51980. __webpack_require__(1).extendComponentModel({
  51981. type: 'polar',
  51982. dependencies: ['polarAxis', 'angleAxis'],
  51983. /**
  51984. * @type {module:echarts/coord/polar/Polar}
  51985. */
  51986. coordinateSystem: null,
  51987. /**
  51988. * @param {string} axisType
  51989. * @return {module:echarts/coord/polar/AxisModel}
  51990. */
  51991. findAxisModel: function (axisType) {
  51992. var foundAxisModel;
  51993. var ecModel = this.ecModel;
  51994. ecModel.eachComponent(axisType, function (axisModel) {
  51995. if (axisModel.getCoordSysModel() === this) {
  51996. foundAxisModel = axisModel;
  51997. }
  51998. }, this);
  51999. return foundAxisModel;
  52000. },
  52001. defaultOption: {
  52002. zlevel: 0,
  52003. z: 0,
  52004. center: ['50%', '50%'],
  52005. radius: '80%'
  52006. }
  52007. });
  52008. /***/ }),
  52009. /* 344 */
  52010. /***/ (function(module, exports, __webpack_require__) {
  52011. 'use strict';
  52012. var zrUtil = __webpack_require__(4);
  52013. var ComponentModel = __webpack_require__(72);
  52014. var axisModelCreator = __webpack_require__(134);
  52015. var PolarAxisModel = ComponentModel.extend({
  52016. type: 'polarAxis',
  52017. /**
  52018. * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  52019. */
  52020. axis: null,
  52021. /**
  52022. * @override
  52023. */
  52024. getCoordSysModel: function () {
  52025. return this.ecModel.queryComponents({
  52026. mainType: 'polar',
  52027. index: this.option.polarIndex,
  52028. id: this.option.polarId
  52029. })[0];
  52030. }
  52031. });
  52032. zrUtil.merge(PolarAxisModel.prototype, __webpack_require__(115));
  52033. var polarAxisDefaultExtendedOption = {
  52034. angle: {
  52035. // polarIndex: 0,
  52036. // polarId: '',
  52037. startAngle: 90,
  52038. clockwise: true,
  52039. splitNumber: 12,
  52040. axisLabel: {
  52041. rotate: false
  52042. }
  52043. },
  52044. radius: {
  52045. // polarIndex: 0,
  52046. // polarId: '',
  52047. splitNumber: 5
  52048. }
  52049. };
  52050. function getAxisType(axisDim, option) {
  52051. // Default axis with data is category axis
  52052. return option.type || (option.data ? 'category' : 'value');
  52053. }
  52054. axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle);
  52055. axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius);
  52056. /***/ }),
  52057. /* 345 */
  52058. /***/ (function(module, exports, __webpack_require__) {
  52059. 'use strict';
  52060. __webpack_require__(339);
  52061. __webpack_require__(346);
  52062. /***/ }),
  52063. /* 346 */
  52064. /***/ (function(module, exports, __webpack_require__) {
  52065. 'use strict';
  52066. var zrUtil = __webpack_require__(4);
  52067. var graphic = __webpack_require__(20);
  52068. var Model = __webpack_require__(14);
  52069. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea'];
  52070. function getAxisLineShape(polar, r0, r, angle) {
  52071. var start = polar.coordToPoint([r0, angle]);
  52072. var end = polar.coordToPoint([r, angle]);
  52073. return {
  52074. x1: start[0],
  52075. y1: start[1],
  52076. x2: end[0],
  52077. y2: end[1]
  52078. };
  52079. }
  52080. __webpack_require__(139).extend({
  52081. type: 'angleAxis',
  52082. axisPointerClass: 'PolarAxisPointer',
  52083. render: function (angleAxisModel, ecModel) {
  52084. this.group.removeAll();
  52085. if (!angleAxisModel.get('show')) {
  52086. return;
  52087. }
  52088. var angleAxis = angleAxisModel.axis;
  52089. var polar = angleAxis.polar;
  52090. var radiusExtent = polar.getRadiusAxis().getExtent();
  52091. var ticksAngles = angleAxis.getTicksCoords();
  52092. if (angleAxis.type !== 'category') {
  52093. // Remove the last tick which will overlap the first tick
  52094. ticksAngles.pop();
  52095. }
  52096. zrUtil.each(elementList, function (name) {
  52097. if (angleAxisModel.get(name +'.show')
  52098. && (!angleAxis.scale.isBlank() || name === 'axisLine')
  52099. ) {
  52100. this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent);
  52101. }
  52102. }, this);
  52103. },
  52104. /**
  52105. * @private
  52106. */
  52107. _axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  52108. var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle');
  52109. var circle = new graphic.Circle({
  52110. shape: {
  52111. cx: polar.cx,
  52112. cy: polar.cy,
  52113. r: radiusExtent[1]
  52114. },
  52115. style: lineStyleModel.getLineStyle(),
  52116. z2: 1,
  52117. silent: true
  52118. });
  52119. circle.style.fill = null;
  52120. this.group.add(circle);
  52121. },
  52122. /**
  52123. * @private
  52124. */
  52125. _axisTick: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  52126. var tickModel = angleAxisModel.getModel('axisTick');
  52127. var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
  52128. var lines = zrUtil.map(ticksAngles, function (tickAngle) {
  52129. return new graphic.Line({
  52130. shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle)
  52131. });
  52132. });
  52133. this.group.add(graphic.mergePath(
  52134. lines, {
  52135. style: zrUtil.defaults(
  52136. tickModel.getModel('lineStyle').getLineStyle(),
  52137. {
  52138. stroke: angleAxisModel.get('axisLine.lineStyle.color')
  52139. }
  52140. )
  52141. }
  52142. ));
  52143. },
  52144. /**
  52145. * @private
  52146. */
  52147. _axisLabel: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  52148. var axis = angleAxisModel.axis;
  52149. var categoryData = angleAxisModel.get('data');
  52150. var labelModel = angleAxisModel.getModel('axisLabel');
  52151. var labels = angleAxisModel.getFormattedLabels();
  52152. var labelMargin = labelModel.get('margin');
  52153. var labelsAngles = axis.getLabelsCoords();
  52154. // Use length of ticksAngles because it may remove the last tick to avoid overlapping
  52155. for (var i = 0; i < ticksAngles.length; i++) {
  52156. var r = radiusExtent[1];
  52157. var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]);
  52158. var cx = polar.cx;
  52159. var cy = polar.cy;
  52160. var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3
  52161. ? 'center' : (p[0] > cx ? 'left' : 'right');
  52162. var labelTextVerticalAlign = Math.abs(p[1] - cy) / r < 0.3
  52163. ? 'middle' : (p[1] > cy ? 'top' : 'bottom');
  52164. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  52165. labelModel = new Model(categoryData[i].textStyle, labelModel, labelModel.ecModel);
  52166. }
  52167. var textEl = new graphic.Text({silent: true});
  52168. this.group.add(textEl);
  52169. graphic.setTextStyle(textEl.style, labelModel, {
  52170. x: p[0],
  52171. y: p[1],
  52172. textFill: labelModel.getTextColor() || angleAxisModel.get('axisLine.lineStyle.color'),
  52173. text: labels[i],
  52174. textAlign: labelTextAlign,
  52175. textVerticalAlign: labelTextVerticalAlign
  52176. });
  52177. }
  52178. },
  52179. /**
  52180. * @private
  52181. */
  52182. _splitLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  52183. var splitLineModel = angleAxisModel.getModel('splitLine');
  52184. var lineStyleModel = splitLineModel.getModel('lineStyle');
  52185. var lineColors = lineStyleModel.get('color');
  52186. var lineCount = 0;
  52187. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  52188. var splitLines = [];
  52189. for (var i = 0; i < ticksAngles.length; i++) {
  52190. var colorIndex = (lineCount++) % lineColors.length;
  52191. splitLines[colorIndex] = splitLines[colorIndex] || [];
  52192. splitLines[colorIndex].push(new graphic.Line({
  52193. shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i])
  52194. }));
  52195. }
  52196. // Simple optimization
  52197. // Batching the lines if color are the same
  52198. for (var i = 0; i < splitLines.length; i++) {
  52199. this.group.add(graphic.mergePath(splitLines[i], {
  52200. style: zrUtil.defaults({
  52201. stroke: lineColors[i % lineColors.length]
  52202. }, lineStyleModel.getLineStyle()),
  52203. silent: true,
  52204. z: angleAxisModel.get('z')
  52205. }));
  52206. }
  52207. },
  52208. /**
  52209. * @private
  52210. */
  52211. _splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  52212. var splitAreaModel = angleAxisModel.getModel('splitArea');
  52213. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  52214. var areaColors = areaStyleModel.get('color');
  52215. var lineCount = 0;
  52216. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  52217. var splitAreas = [];
  52218. var RADIAN = Math.PI / 180;
  52219. var prevAngle = -ticksAngles[0] * RADIAN;
  52220. var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
  52221. var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
  52222. var clockwise = angleAxisModel.get('clockwise');
  52223. for (var i = 1; i < ticksAngles.length; i++) {
  52224. var colorIndex = (lineCount++) % areaColors.length;
  52225. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  52226. splitAreas[colorIndex].push(new graphic.Sector({
  52227. shape: {
  52228. cx: polar.cx,
  52229. cy: polar.cy,
  52230. r0: r0,
  52231. r: r1,
  52232. startAngle: prevAngle,
  52233. endAngle: -ticksAngles[i] * RADIAN,
  52234. clockwise: clockwise
  52235. },
  52236. silent: true
  52237. }));
  52238. prevAngle = -ticksAngles[i] * RADIAN;
  52239. }
  52240. // Simple optimization
  52241. // Batching the lines if color are the same
  52242. for (var i = 0; i < splitAreas.length; i++) {
  52243. this.group.add(graphic.mergePath(splitAreas[i], {
  52244. style: zrUtil.defaults({
  52245. fill: areaColors[i % areaColors.length]
  52246. }, areaStyleModel.getAreaStyle()),
  52247. silent: true
  52248. }));
  52249. }
  52250. }
  52251. });
  52252. /***/ }),
  52253. /* 347 */
  52254. /***/ (function(module, exports, __webpack_require__) {
  52255. __webpack_require__(339);
  52256. __webpack_require__(348);
  52257. /***/ }),
  52258. /* 348 */
  52259. /***/ (function(module, exports, __webpack_require__) {
  52260. 'use strict';
  52261. var zrUtil = __webpack_require__(4);
  52262. var graphic = __webpack_require__(20);
  52263. var AxisBuilder = __webpack_require__(138);
  52264. var axisBuilderAttrs = [
  52265. 'axisLine', 'axisTickLabel', 'axisName'
  52266. ];
  52267. var selfBuilderAttrs = [
  52268. 'splitLine', 'splitArea'
  52269. ];
  52270. __webpack_require__(139).extend({
  52271. type: 'radiusAxis',
  52272. axisPointerClass: 'PolarAxisPointer',
  52273. render: function (radiusAxisModel, ecModel) {
  52274. this.group.removeAll();
  52275. if (!radiusAxisModel.get('show')) {
  52276. return;
  52277. }
  52278. var radiusAxis = radiusAxisModel.axis;
  52279. var polar = radiusAxis.polar;
  52280. var angleAxis = polar.getAngleAxis();
  52281. var ticksCoords = radiusAxis.getTicksCoords();
  52282. var axisAngle = angleAxis.getExtent()[0];
  52283. var radiusExtent = radiusAxis.getExtent();
  52284. var layout = layoutAxis(polar, radiusAxisModel, axisAngle);
  52285. var axisBuilder = new AxisBuilder(radiusAxisModel, layout);
  52286. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  52287. this.group.add(axisBuilder.getGroup());
  52288. zrUtil.each(selfBuilderAttrs, function (name) {
  52289. if (radiusAxisModel.get(name +'.show') && !radiusAxis.scale.isBlank()) {
  52290. this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords);
  52291. }
  52292. }, this);
  52293. },
  52294. /**
  52295. * @private
  52296. */
  52297. _splitLine: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  52298. var splitLineModel = radiusAxisModel.getModel('splitLine');
  52299. var lineStyleModel = splitLineModel.getModel('lineStyle');
  52300. var lineColors = lineStyleModel.get('color');
  52301. var lineCount = 0;
  52302. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  52303. var splitLines = [];
  52304. for (var i = 0; i < ticksCoords.length; i++) {
  52305. var colorIndex = (lineCount++) % lineColors.length;
  52306. splitLines[colorIndex] = splitLines[colorIndex] || [];
  52307. splitLines[colorIndex].push(new graphic.Circle({
  52308. shape: {
  52309. cx: polar.cx,
  52310. cy: polar.cy,
  52311. r: ticksCoords[i]
  52312. },
  52313. silent: true
  52314. }));
  52315. }
  52316. // Simple optimization
  52317. // Batching the lines if color are the same
  52318. for (var i = 0; i < splitLines.length; i++) {
  52319. this.group.add(graphic.mergePath(splitLines[i], {
  52320. style: zrUtil.defaults({
  52321. stroke: lineColors[i % lineColors.length],
  52322. fill: null
  52323. }, lineStyleModel.getLineStyle()),
  52324. silent: true
  52325. }));
  52326. }
  52327. },
  52328. /**
  52329. * @private
  52330. */
  52331. _splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  52332. var splitAreaModel = radiusAxisModel.getModel('splitArea');
  52333. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  52334. var areaColors = areaStyleModel.get('color');
  52335. var lineCount = 0;
  52336. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  52337. var splitAreas = [];
  52338. var prevRadius = ticksCoords[0];
  52339. for (var i = 1; i < ticksCoords.length; i++) {
  52340. var colorIndex = (lineCount++) % areaColors.length;
  52341. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  52342. splitAreas[colorIndex].push(new graphic.Sector({
  52343. shape: {
  52344. cx: polar.cx,
  52345. cy: polar.cy,
  52346. r0: prevRadius,
  52347. r: ticksCoords[i],
  52348. startAngle: 0,
  52349. endAngle: Math.PI * 2
  52350. },
  52351. silent: true
  52352. }));
  52353. prevRadius = ticksCoords[i];
  52354. }
  52355. // Simple optimization
  52356. // Batching the lines if color are the same
  52357. for (var i = 0; i < splitAreas.length; i++) {
  52358. this.group.add(graphic.mergePath(splitAreas[i], {
  52359. style: zrUtil.defaults({
  52360. fill: areaColors[i % areaColors.length]
  52361. }, areaStyleModel.getAreaStyle()),
  52362. silent: true
  52363. }));
  52364. }
  52365. }
  52366. });
  52367. /**
  52368. * @inner
  52369. */
  52370. function layoutAxis(polar, radiusAxisModel, axisAngle) {
  52371. return {
  52372. position: [polar.cx, polar.cy],
  52373. rotation: axisAngle / 180 * Math.PI,
  52374. labelDirection: -1,
  52375. tickDirection: -1,
  52376. nameDirection: 1,
  52377. labelRotate: radiusAxisModel.getModel('axisLabel').get('rotate'),
  52378. // Over splitLine and splitArea
  52379. z2: 1
  52380. };
  52381. }
  52382. /***/ }),
  52383. /* 349 */
  52384. /***/ (function(module, exports, __webpack_require__) {
  52385. 'use strict';
  52386. var formatUtil = __webpack_require__(6);
  52387. var BaseAxisPointer = __webpack_require__(308);
  52388. var graphic = __webpack_require__(20);
  52389. var viewHelper = __webpack_require__(309);
  52390. var matrix = __webpack_require__(11);
  52391. var AxisBuilder = __webpack_require__(138);
  52392. var AxisView = __webpack_require__(139);
  52393. var PolarAxisPointer = BaseAxisPointer.extend({
  52394. /**
  52395. * @override
  52396. */
  52397. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  52398. var axis = axisModel.axis;
  52399. if (axis.dim === 'angle') {
  52400. this.animationThreshold = Math.PI / 18;
  52401. }
  52402. var polar = axis.polar;
  52403. var otherAxis = polar.getOtherAxis(axis);
  52404. var otherExtent = otherAxis.getExtent();
  52405. var coordValue;
  52406. coordValue = axis['dataTo' + formatUtil.capitalFirst(axis.dim)](value);
  52407. var axisPointerType = axisPointerModel.get('type');
  52408. if (axisPointerType && axisPointerType !== 'none') {
  52409. var elStyle = viewHelper.buildElStyle(axisPointerModel);
  52410. var pointerOption = pointerShapeBuilder[axisPointerType](
  52411. axis, polar, coordValue, otherExtent, elStyle
  52412. );
  52413. pointerOption.style = elStyle;
  52414. elOption.graphicKey = pointerOption.type;
  52415. elOption.pointer = pointerOption;
  52416. }
  52417. var labelMargin = axisPointerModel.get('label.margin');
  52418. var labelPos = getLabelPosition(value, axisModel, axisPointerModel, polar, labelMargin);
  52419. viewHelper.buildLabelElOption(elOption, axisModel, axisPointerModel, api, labelPos);
  52420. }
  52421. // Do not support handle, utill any user requires it.
  52422. });
  52423. function getLabelPosition(value, axisModel, axisPointerModel, polar, labelMargin) {
  52424. var axis = axisModel.axis;
  52425. var coord = axis.dataToCoord(value);
  52426. var axisAngle = polar.getAngleAxis().getExtent()[0];
  52427. axisAngle = axisAngle / 180 * Math.PI;
  52428. var radiusExtent = polar.getRadiusAxis().getExtent();
  52429. var position;
  52430. var align;
  52431. var verticalAlign;
  52432. if (axis.dim === 'radius') {
  52433. var transform = matrix.create();
  52434. matrix.rotate(transform, transform, axisAngle);
  52435. matrix.translate(transform, transform, [polar.cx, polar.cy]);
  52436. position = graphic.applyTransform([coord, -labelMargin], transform);
  52437. var labelRotation = axisModel.getModel('axisLabel').get('rotate') || 0;
  52438. var labelLayout = AxisBuilder.innerTextLayout(
  52439. axisAngle, labelRotation * Math.PI / 180, -1
  52440. );
  52441. align = labelLayout.textAlign;
  52442. verticalAlign = labelLayout.textVerticalAlign;
  52443. }
  52444. else { // angle axis
  52445. var r = radiusExtent[1];
  52446. position = polar.coordToPoint([r + labelMargin, coord]);
  52447. var cx = polar.cx;
  52448. var cy = polar.cy;
  52449. align = Math.abs(position[0] - cx) / r < 0.3
  52450. ? 'center' : (position[0] > cx ? 'left' : 'right');
  52451. verticalAlign = Math.abs(position[1] - cy) / r < 0.3
  52452. ? 'middle' : (position[1] > cy ? 'top' : 'bottom');
  52453. }
  52454. return {
  52455. position: position,
  52456. align: align,
  52457. verticalAlign: verticalAlign
  52458. };
  52459. }
  52460. var pointerShapeBuilder = {
  52461. line: function (axis, polar, coordValue, otherExtent, elStyle) {
  52462. return axis.dim === 'angle'
  52463. ? {
  52464. type: 'Line',
  52465. shape: viewHelper.makeLineShape(
  52466. polar.coordToPoint([otherExtent[0], coordValue]),
  52467. polar.coordToPoint([otherExtent[1], coordValue])
  52468. )
  52469. }
  52470. : {
  52471. type: 'Circle',
  52472. shape: {
  52473. cx: polar.cx,
  52474. cy: polar.cy,
  52475. r: coordValue
  52476. }
  52477. };
  52478. },
  52479. shadow: function (axis, polar, coordValue, otherExtent, elStyle) {
  52480. var bandWidth = axis.getBandWidth();
  52481. var radian = Math.PI / 180;
  52482. return axis.dim === 'angle'
  52483. ? {
  52484. type: 'Sector',
  52485. shape: viewHelper.makeSectorShape(
  52486. polar.cx, polar.cy,
  52487. otherExtent[0], otherExtent[1],
  52488. // In ECharts y is negative if angle is positive
  52489. (-coordValue - bandWidth / 2) * radian,
  52490. (-coordValue + bandWidth / 2) * radian
  52491. )
  52492. }
  52493. : {
  52494. type: 'Sector',
  52495. shape: viewHelper.makeSectorShape(
  52496. polar.cx, polar.cy,
  52497. coordValue - bandWidth / 2,
  52498. coordValue + bandWidth / 2,
  52499. 0, Math.PI * 2
  52500. )
  52501. };
  52502. }
  52503. };
  52504. AxisView.registerAxisPointerClass('PolarAxisPointer', PolarAxisPointer);
  52505. module.exports = PolarAxisPointer;
  52506. /***/ }),
  52507. /* 350 */
  52508. /***/ (function(module, exports, __webpack_require__) {
  52509. 'use strict';
  52510. var zrUtil = __webpack_require__(4);
  52511. var parsePercent = __webpack_require__(7).parsePercent;
  52512. function getSeriesStackId(seriesModel) {
  52513. return seriesModel.get('stack')
  52514. || '__ec_stack_' + seriesModel.seriesIndex;
  52515. }
  52516. function getAxisKey(axis) {
  52517. return axis.dim;
  52518. }
  52519. /**
  52520. * @param {string} seriesType
  52521. * @param {module:echarts/model/Global} ecModel
  52522. * @param {module:echarts/ExtensionAPI} api
  52523. */
  52524. function barLayoutPolar(seriesType, ecModel, api) {
  52525. var width = api.getWidth();
  52526. var height = api.getHeight();
  52527. var lastStackCoords = {};
  52528. var lastStackCoordsOrigin = {};
  52529. var barWidthAndOffset = calRadialBar(
  52530. zrUtil.filter(
  52531. ecModel.getSeriesByType(seriesType),
  52532. function (seriesModel) {
  52533. return !ecModel.isSeriesFiltered(seriesModel)
  52534. && seriesModel.coordinateSystem
  52535. && seriesModel.coordinateSystem.type === 'polar';
  52536. }
  52537. )
  52538. );
  52539. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  52540. // Check series coordinate, do layout for polar only
  52541. if (seriesModel.coordinateSystem.type !== 'polar') {
  52542. return;
  52543. }
  52544. var data = seriesModel.getData();
  52545. var polar = seriesModel.coordinateSystem;
  52546. var angleAxis = polar.getAngleAxis();
  52547. var baseAxis = polar.getBaseAxis();
  52548. var stackId = getSeriesStackId(seriesModel);
  52549. var columnLayoutInfo
  52550. = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
  52551. var columnOffset = columnLayoutInfo.offset;
  52552. var columnWidth = columnLayoutInfo.width;
  52553. var valueAxis = polar.getOtherAxis(baseAxis);
  52554. var center = seriesModel.get('center') || ['50%', '50%'];
  52555. var cx = parsePercent(center[0], width);
  52556. var cy = parsePercent(center[1], height);
  52557. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  52558. var barMinAngle = seriesModel.get('barMinAngle') || 0;
  52559. var valueAxisStart = valueAxis.getExtent()[0];
  52560. var valueMax = valueAxis.model.get('max');
  52561. var valueMin = valueAxis.model.get('min');
  52562. var coordDims = [
  52563. seriesModel.coordDimToDataDim('radius')[0],
  52564. seriesModel.coordDimToDataDim('angle')[0]
  52565. ];
  52566. var coords = data.mapArray(coordDims, function (radius, angle) {
  52567. return polar.dataToPoint([radius, angle]);
  52568. }, true);
  52569. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  52570. lastStackCoordsOrigin[stackId] = lastStackCoordsOrigin[stackId] || []; // Fix #4243
  52571. data.each(seriesModel.coordDimToDataDim(valueAxis.dim)[0], function (value, idx) {
  52572. if (isNaN(value)) {
  52573. return;
  52574. }
  52575. if (!lastStackCoords[stackId][idx]) {
  52576. lastStackCoords[stackId][idx] = {
  52577. p: valueAxisStart, // Positive stack
  52578. n: valueAxisStart // Negative stack
  52579. };
  52580. lastStackCoordsOrigin[stackId][idx] = {
  52581. p: valueAxisStart, // Positive stack
  52582. n: valueAxisStart // Negative stack
  52583. };
  52584. }
  52585. var sign = value >= 0 ? 'p' : 'n';
  52586. var coord = polar.pointToCoord(coords[idx]);
  52587. var lastCoordOrigin = lastStackCoordsOrigin[stackId][idx][sign];
  52588. var r0;
  52589. var r;
  52590. var startAngle;
  52591. var endAngle;
  52592. if (valueAxis.dim === 'radius') {
  52593. // radial sector
  52594. r0 = lastCoordOrigin;
  52595. r = coord[0];
  52596. startAngle = (-coord[1] + columnOffset) * Math.PI / 180;
  52597. endAngle = startAngle + columnWidth * Math.PI / 180;
  52598. if (Math.abs(r) < barMinHeight) {
  52599. r = r0 + (r < 0 ? -1 : 1) * barMinHeight;
  52600. }
  52601. lastStackCoordsOrigin[stackId][idx][sign] = r;
  52602. }
  52603. else {
  52604. // tangential sector
  52605. r0 = coord[0] + columnOffset;
  52606. r = r0 + columnWidth;
  52607. // clamp data if min or max is defined for valueAxis
  52608. if (valueMax != null) {
  52609. value = Math.min(value, valueMax);
  52610. }
  52611. if (valueMin != null) {
  52612. value = Math.max(value, valueMin);
  52613. }
  52614. var angle = angleAxis.dataToAngle(value);
  52615. if (Math.abs(angle - lastCoordOrigin) < barMinAngle) {
  52616. angle = lastCoordOrigin - (value < 0 ? -1 : 1)
  52617. * barMinAngle;
  52618. }
  52619. startAngle = -lastCoordOrigin * Math.PI / 180;
  52620. endAngle = -angle * Math.PI / 180;
  52621. // if the previous stack is at the end of the ring,
  52622. // add a round to differentiate it from origin
  52623. var extent = angleAxis.getExtent();
  52624. var stackCoord = angle;
  52625. if (stackCoord === extent[0] && value > 0) {
  52626. stackCoord = extent[1];
  52627. }
  52628. else if (stackCoord === extent[1] && value < 0) {
  52629. stackCoord = extent[0];
  52630. }
  52631. lastStackCoordsOrigin[stackId][idx][sign] = stackCoord;
  52632. }
  52633. data.setItemLayout(idx, {
  52634. cx: cx,
  52635. cy: cy,
  52636. r0: r0,
  52637. r: r,
  52638. startAngle: startAngle,
  52639. endAngle: endAngle
  52640. });
  52641. }, true);
  52642. }, this);
  52643. }
  52644. /**
  52645. * Calculate bar width and offset for radial bar charts
  52646. */
  52647. function calRadialBar(barSeries, api) {
  52648. // Columns info on each category axis. Key is polar name
  52649. var columnsMap = {};
  52650. zrUtil.each(barSeries, function (seriesModel, idx) {
  52651. var data = seriesModel.getData();
  52652. var polar = seriesModel.coordinateSystem;
  52653. var baseAxis = polar.getBaseAxis();
  52654. var axisExtent = baseAxis.getExtent();
  52655. var bandWidth = baseAxis.type === 'category'
  52656. ? baseAxis.getBandWidth()
  52657. : (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
  52658. var columnsOnAxis = columnsMap[getAxisKey(baseAxis)] || {
  52659. bandWidth: bandWidth,
  52660. remainedWidth: bandWidth,
  52661. autoWidthCount: 0,
  52662. categoryGap: '20%',
  52663. gap: '30%',
  52664. stacks: {}
  52665. };
  52666. var stacks = columnsOnAxis.stacks;
  52667. columnsMap[getAxisKey(baseAxis)] = columnsOnAxis;
  52668. var stackId = getSeriesStackId(seriesModel);
  52669. if (!stacks[stackId]) {
  52670. columnsOnAxis.autoWidthCount++;
  52671. }
  52672. stacks[stackId] = stacks[stackId] || {
  52673. width: 0,
  52674. maxWidth: 0
  52675. };
  52676. var barWidth = parsePercent(
  52677. seriesModel.get('barWidth'),
  52678. bandWidth
  52679. );
  52680. var barMaxWidth = parsePercent(
  52681. seriesModel.get('barMaxWidth'),
  52682. bandWidth
  52683. );
  52684. var barGap = seriesModel.get('barGap');
  52685. var barCategoryGap = seriesModel.get('barCategoryGap');
  52686. if (barWidth && !stacks[stackId].width) {
  52687. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  52688. stacks[stackId].width = barWidth;
  52689. columnsOnAxis.remainedWidth -= barWidth;
  52690. }
  52691. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  52692. (barGap != null) && (columnsOnAxis.gap = barGap);
  52693. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  52694. });
  52695. var result = {};
  52696. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  52697. result[coordSysName] = {};
  52698. var stacks = columnsOnAxis.stacks;
  52699. var bandWidth = columnsOnAxis.bandWidth;
  52700. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  52701. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  52702. var remainedWidth = columnsOnAxis.remainedWidth;
  52703. var autoWidthCount = columnsOnAxis.autoWidthCount;
  52704. var autoWidth = (remainedWidth - categoryGap)
  52705. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  52706. autoWidth = Math.max(autoWidth, 0);
  52707. // Find if any auto calculated bar exceeded maxBarWidth
  52708. zrUtil.each(stacks, function (column, stack) {
  52709. var maxWidth = column.maxWidth;
  52710. if (maxWidth && maxWidth < autoWidth) {
  52711. maxWidth = Math.min(maxWidth, remainedWidth);
  52712. if (column.width) {
  52713. maxWidth = Math.min(maxWidth, column.width);
  52714. }
  52715. remainedWidth -= maxWidth;
  52716. column.width = maxWidth;
  52717. autoWidthCount--;
  52718. }
  52719. });
  52720. // Recalculate width again
  52721. autoWidth = (remainedWidth - categoryGap)
  52722. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  52723. autoWidth = Math.max(autoWidth, 0);
  52724. var widthSum = 0;
  52725. var lastColumn;
  52726. zrUtil.each(stacks, function (column, idx) {
  52727. if (!column.width) {
  52728. column.width = autoWidth;
  52729. }
  52730. lastColumn = column;
  52731. widthSum += column.width * (1 + barGapPercent);
  52732. });
  52733. if (lastColumn) {
  52734. widthSum -= lastColumn.width * barGapPercent;
  52735. }
  52736. var offset = -widthSum / 2;
  52737. zrUtil.each(stacks, function (column, stackId) {
  52738. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  52739. offset: offset,
  52740. width: column.width
  52741. };
  52742. offset += column.width * (1 + barGapPercent);
  52743. });
  52744. });
  52745. return result;
  52746. }
  52747. module.exports = barLayoutPolar;
  52748. /***/ }),
  52749. /* 351 */
  52750. /***/ (function(module, exports, __webpack_require__) {
  52751. __webpack_require__(352);
  52752. __webpack_require__(174);
  52753. __webpack_require__(353);
  52754. __webpack_require__(190);
  52755. var echarts = __webpack_require__(1);
  52756. var zrUtil = __webpack_require__(4);
  52757. function makeAction(method, actionInfo) {
  52758. actionInfo.update = 'updateView';
  52759. echarts.registerAction(actionInfo, function (payload, ecModel) {
  52760. var selected = {};
  52761. ecModel.eachComponent(
  52762. { mainType: 'geo', query: payload},
  52763. function (geoModel) {
  52764. geoModel[method](payload.name);
  52765. var geo = geoModel.coordinateSystem;
  52766. zrUtil.each(geo.regions, function (region) {
  52767. selected[region.name] = geoModel.isSelected(region.name) || false;
  52768. });
  52769. }
  52770. );
  52771. return {
  52772. selected: selected,
  52773. name: payload.name
  52774. };
  52775. });
  52776. }
  52777. makeAction('toggleSelected', {
  52778. type: 'geoToggleSelect',
  52779. event: 'geoselectchanged'
  52780. });
  52781. makeAction('select', {
  52782. type: 'geoSelect',
  52783. event: 'geoselected'
  52784. });
  52785. makeAction('unSelect', {
  52786. type: 'geoUnSelect',
  52787. event: 'geounselected'
  52788. });
  52789. /***/ }),
  52790. /* 352 */
  52791. /***/ (function(module, exports, __webpack_require__) {
  52792. 'use strict';
  52793. var modelUtil = __webpack_require__(5);
  52794. var ComponentModel = __webpack_require__(72);
  52795. var Model = __webpack_require__(14);
  52796. var zrUtil = __webpack_require__(4);
  52797. var selectableMixin = __webpack_require__(151);
  52798. var geoCreator = __webpack_require__(174);
  52799. var GeoModel = ComponentModel.extend({
  52800. type: 'geo',
  52801. /**
  52802. * @type {module:echarts/coord/geo/Geo}
  52803. */
  52804. coordinateSystem: null,
  52805. layoutMode: 'box',
  52806. init: function (option) {
  52807. ComponentModel.prototype.init.apply(this, arguments);
  52808. // Default label emphasis `show`
  52809. modelUtil.defaultEmphasis(option.label, ['show']);
  52810. },
  52811. optionUpdated: function () {
  52812. var option = this.option;
  52813. var self = this;
  52814. option.regions = geoCreator.getFilledRegions(option.regions, option.map, option.nameMap);
  52815. this._optionModelMap = zrUtil.reduce(option.regions || [], function (optionModelMap, regionOpt) {
  52816. if (regionOpt.name) {
  52817. optionModelMap.set(regionOpt.name, new Model(regionOpt, self));
  52818. }
  52819. return optionModelMap;
  52820. }, zrUtil.createHashMap());
  52821. this.updateSelectedMap(option.regions);
  52822. },
  52823. defaultOption: {
  52824. zlevel: 0,
  52825. z: 0,
  52826. show: true,
  52827. left: 'center',
  52828. top: 'center',
  52829. // width:,
  52830. // height:,
  52831. // right
  52832. // bottom
  52833. // Aspect is width / height. Inited to be geoJson bbox aspect
  52834. // This parameter is used for scale this aspect
  52835. aspectScale: 0.75,
  52836. ///// Layout with center and size
  52837. // If you wan't to put map in a fixed size box with right aspect ratio
  52838. // This two properties may more conveninet
  52839. // layoutCenter: [50%, 50%]
  52840. // layoutSize: 100
  52841. silent: false,
  52842. // Map type
  52843. map: '',
  52844. // Define left-top, right-bottom coords to control view
  52845. // For example, [ [180, 90], [-180, -90] ]
  52846. boundingCoords: null,
  52847. // Default on center of map
  52848. center: null,
  52849. zoom: 1,
  52850. scaleLimit: null,
  52851. // selectedMode: false
  52852. label: {
  52853. normal: {
  52854. show: false,
  52855. color: '#000'
  52856. },
  52857. emphasis: {
  52858. show: true,
  52859. color: 'rgb(100,0,0)'
  52860. }
  52861. },
  52862. itemStyle: {
  52863. normal: {
  52864. // color: 各异,
  52865. borderWidth: 0.5,
  52866. borderColor: '#444',
  52867. color: '#eee'
  52868. },
  52869. emphasis: { // 也是选中样式
  52870. color: 'rgba(255,215,0,0.8)'
  52871. }
  52872. },
  52873. regions: []
  52874. },
  52875. /**
  52876. * Get model of region
  52877. * @param {string} name
  52878. * @return {module:echarts/model/Model}
  52879. */
  52880. getRegionModel: function (name) {
  52881. return this._optionModelMap.get(name) || new Model(null, this, this.ecModel);
  52882. },
  52883. /**
  52884. * Format label
  52885. * @param {string} name Region name
  52886. * @param {string} [status='normal'] 'normal' or 'emphasis'
  52887. * @return {string}
  52888. */
  52889. getFormattedLabel: function (name, status) {
  52890. var regionModel = this.getRegionModel(name);
  52891. var formatter = regionModel.get('label.' + status + '.formatter');
  52892. var params = {
  52893. name: name
  52894. };
  52895. if (typeof formatter === 'function') {
  52896. params.status = status;
  52897. return formatter(params);
  52898. }
  52899. else if (typeof formatter === 'string') {
  52900. return formatter.replace('{a}', name != null ? name : '');
  52901. }
  52902. },
  52903. setZoom: function (zoom) {
  52904. this.option.zoom = zoom;
  52905. },
  52906. setCenter: function (center) {
  52907. this.option.center = center;
  52908. }
  52909. });
  52910. zrUtil.mixin(GeoModel, selectableMixin);
  52911. module.exports = GeoModel;
  52912. /***/ }),
  52913. /* 353 */
  52914. /***/ (function(module, exports, __webpack_require__) {
  52915. 'use strict';
  52916. var MapDraw = __webpack_require__(185);
  52917. module.exports = __webpack_require__(1).extendComponentView({
  52918. type: 'geo',
  52919. init: function (ecModel, api) {
  52920. var mapDraw = new MapDraw(api, true);
  52921. this._mapDraw = mapDraw;
  52922. this.group.add(mapDraw.group);
  52923. },
  52924. render: function (geoModel, ecModel, api, payload) {
  52925. // Not render if it is an toggleSelect action from self
  52926. if (payload && payload.type === 'geoToggleSelect'
  52927. && payload.from === this.uid
  52928. ) {
  52929. return;
  52930. }
  52931. var mapDraw = this._mapDraw;
  52932. if (geoModel.get('show')) {
  52933. mapDraw.draw(geoModel, ecModel, api, this, payload);
  52934. }
  52935. else {
  52936. this._mapDraw.group.removeAll();
  52937. }
  52938. this.group.silent = geoModel.get('silent');
  52939. },
  52940. dispose: function () {
  52941. this._mapDraw && this._mapDraw.remove();
  52942. }
  52943. });
  52944. /***/ }),
  52945. /* 354 */
  52946. /***/ (function(module, exports, __webpack_require__) {
  52947. /**
  52948. * Brush component entry
  52949. */
  52950. __webpack_require__(1).registerPreprocessor(
  52951. __webpack_require__(355)
  52952. );
  52953. __webpack_require__(356);
  52954. __webpack_require__(360);
  52955. __webpack_require__(361);
  52956. __webpack_require__(362);
  52957. __webpack_require__(363);
  52958. /***/ }),
  52959. /* 355 */
  52960. /***/ (function(module, exports, __webpack_require__) {
  52961. /**
  52962. * @file brush preprocessor
  52963. */
  52964. var zrUtil = __webpack_require__(4);
  52965. var DEFAULT_TOOLBOX_BTNS = ['rect', 'polygon', 'keep', 'clear'];
  52966. module.exports = function (option, isNew) {
  52967. var brushComponents = option && option.brush;
  52968. if (!zrUtil.isArray(brushComponents)) {
  52969. brushComponents = brushComponents ? [brushComponents] : [];
  52970. }
  52971. if (!brushComponents.length) {
  52972. return;
  52973. }
  52974. var brushComponentSpecifiedBtns = [];
  52975. zrUtil.each(brushComponents, function (brushOpt) {
  52976. var tbs = brushOpt.hasOwnProperty('toolbox')
  52977. ? brushOpt.toolbox : [];
  52978. if (tbs instanceof Array) {
  52979. brushComponentSpecifiedBtns = brushComponentSpecifiedBtns.concat(tbs);
  52980. }
  52981. });
  52982. var toolbox = option && option.toolbox;
  52983. if (zrUtil.isArray(toolbox)) {
  52984. toolbox = toolbox[0];
  52985. }
  52986. if (!toolbox) {
  52987. toolbox = {feature: {}};
  52988. option.toolbox = [toolbox];
  52989. }
  52990. var toolboxFeature = (toolbox.feature || (toolbox.feature = {}));
  52991. var toolboxBrush = toolboxFeature.brush || (toolboxFeature.brush = {});
  52992. var brushTypes = toolboxBrush.type || (toolboxBrush.type = []);
  52993. brushTypes.push.apply(brushTypes, brushComponentSpecifiedBtns);
  52994. removeDuplicate(brushTypes);
  52995. if (isNew && !brushTypes.length) {
  52996. brushTypes.push.apply(brushTypes, DEFAULT_TOOLBOX_BTNS);
  52997. }
  52998. };
  52999. function removeDuplicate(arr) {
  53000. var map = {};
  53001. zrUtil.each(arr, function (val) {
  53002. map[val] = 1;
  53003. });
  53004. arr.length = 0;
  53005. zrUtil.each(map, function (flag, val) {
  53006. arr.push(val);
  53007. });
  53008. }
  53009. /***/ }),
  53010. /* 356 */
  53011. /***/ (function(module, exports, __webpack_require__) {
  53012. /**
  53013. * @file Brush visual coding.
  53014. */
  53015. var echarts = __webpack_require__(1);
  53016. var visualSolution = __webpack_require__(357);
  53017. var zrUtil = __webpack_require__(4);
  53018. var BoundingRect = __webpack_require__(9);
  53019. var selector = __webpack_require__(358);
  53020. var throttle = __webpack_require__(86);
  53021. var BrushTargetManager = __webpack_require__(359);
  53022. var STATE_LIST = ['inBrush', 'outOfBrush'];
  53023. var DISPATCH_METHOD = '__ecBrushSelect';
  53024. var DISPATCH_FLAG = '__ecInBrushSelectEvent';
  53025. var PRIORITY_BRUSH = echarts.PRIORITY.VISUAL.BRUSH;
  53026. /**
  53027. * Layout for visual, the priority higher than other layout, and before brush visual.
  53028. */
  53029. echarts.registerLayout(PRIORITY_BRUSH, function (ecModel, api, payload) {
  53030. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  53031. payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(
  53032. payload.key === 'brush' ? payload.brushOption : {brushType: false}
  53033. );
  53034. var brushTargetManager = brushModel.brushTargetManager = new BrushTargetManager(brushModel.option, ecModel);
  53035. brushTargetManager.setInputRanges(brushModel.areas, ecModel);
  53036. });
  53037. });
  53038. /**
  53039. * Register the visual encoding if this modules required.
  53040. */
  53041. echarts.registerVisual(PRIORITY_BRUSH, function (ecModel, api, payload) {
  53042. var brushSelected = [];
  53043. var throttleType;
  53044. var throttleDelay;
  53045. ecModel.eachComponent({mainType: 'brush'}, function (brushModel, brushIndex) {
  53046. var thisBrushSelected = {
  53047. brushId: brushModel.id,
  53048. brushIndex: brushIndex,
  53049. brushName: brushModel.name,
  53050. areas: zrUtil.clone(brushModel.areas),
  53051. selected: []
  53052. };
  53053. // Every brush component exists in event params, convenient
  53054. // for user to find by index.
  53055. brushSelected.push(thisBrushSelected);
  53056. var brushOption = brushModel.option;
  53057. var brushLink = brushOption.brushLink;
  53058. var linkedSeriesMap = [];
  53059. var selectedDataIndexForLink = [];
  53060. var rangeInfoBySeries = [];
  53061. var hasBrushExists = 0;
  53062. if (!brushIndex) { // Only the first throttle setting works.
  53063. throttleType = brushOption.throttleType;
  53064. throttleDelay = brushOption.throttleDelay;
  53065. }
  53066. // Add boundingRect and selectors to range.
  53067. var areas = zrUtil.map(brushModel.areas, function (area) {
  53068. return bindSelector(
  53069. zrUtil.defaults(
  53070. {boundingRect: boundingRectBuilders[area.brushType](area)},
  53071. area
  53072. )
  53073. );
  53074. });
  53075. var visualMappings = visualSolution.createVisualMappings(
  53076. brushModel.option, STATE_LIST, function (mappingOption) {
  53077. mappingOption.mappingMethod = 'fixed';
  53078. }
  53079. );
  53080. zrUtil.isArray(brushLink) && zrUtil.each(brushLink, function (seriesIndex) {
  53081. linkedSeriesMap[seriesIndex] = 1;
  53082. });
  53083. function linkOthers(seriesIndex) {
  53084. return brushLink === 'all' || linkedSeriesMap[seriesIndex];
  53085. }
  53086. // If no supported brush or no brush on the series,
  53087. // all visuals should be in original state.
  53088. function brushed(rangeInfoList) {
  53089. return !!rangeInfoList.length;
  53090. }
  53091. /**
  53092. * Logic for each series: (If the logic has to be modified one day, do it carefully!)
  53093. *
  53094. * ( brushed ┬ && ┬hasBrushExist ┬ && linkOthers ) => StepA: ┬record, ┬ StepB: ┬visualByRecord.
  53095. * !brushed┘ ├hasBrushExist ┤ └nothing,┘ ├visualByRecord.
  53096. * └!hasBrushExist┘ └nothing.
  53097. * ( !brushed && ┬hasBrushExist ┬ && linkOthers ) => StepA: nothing, StepB: ┬visualByRecord.
  53098. * └!hasBrushExist┘ └nothing.
  53099. * ( brushed ┬ && !linkOthers ) => StepA: nothing, StepB: ┬visualByCheck.
  53100. * !brushed┘ └nothing.
  53101. * ( !brushed && !linkOthers ) => StepA: nothing, StepB: nothing.
  53102. */
  53103. // Step A
  53104. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  53105. var rangeInfoList = rangeInfoBySeries[seriesIndex] = [];
  53106. seriesModel.subType === 'parallel'
  53107. ? stepAParallel(seriesModel, seriesIndex, rangeInfoList)
  53108. : stepAOthers(seriesModel, seriesIndex, rangeInfoList);
  53109. });
  53110. function stepAParallel(seriesModel, seriesIndex) {
  53111. var coordSys = seriesModel.coordinateSystem;
  53112. hasBrushExists |= coordSys.hasAxisBrushed();
  53113. linkOthers(seriesIndex) && coordSys.eachActiveState(
  53114. seriesModel.getData(),
  53115. function (activeState, dataIndex) {
  53116. activeState === 'active' && (selectedDataIndexForLink[dataIndex] = 1);
  53117. }
  53118. );
  53119. }
  53120. function stepAOthers(seriesModel, seriesIndex, rangeInfoList) {
  53121. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  53122. if (!selectorsByBrushType || brushModelNotControll(brushModel, seriesIndex)) {
  53123. return;
  53124. }
  53125. zrUtil.each(areas, function (area) {
  53126. selectorsByBrushType[area.brushType]
  53127. && brushModel.brushTargetManager.controlSeries(area, seriesModel, ecModel)
  53128. && rangeInfoList.push(area);
  53129. hasBrushExists |= brushed(rangeInfoList);
  53130. });
  53131. if (linkOthers(seriesIndex) && brushed(rangeInfoList)) {
  53132. var data = seriesModel.getData();
  53133. data.each(function (dataIndex) {
  53134. if (checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)) {
  53135. selectedDataIndexForLink[dataIndex] = 1;
  53136. }
  53137. });
  53138. }
  53139. }
  53140. // Step B
  53141. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  53142. var seriesBrushSelected = {
  53143. seriesId: seriesModel.id,
  53144. seriesIndex: seriesIndex,
  53145. seriesName: seriesModel.name,
  53146. dataIndex: []
  53147. };
  53148. // Every series exists in event params, convenient
  53149. // for user to find series by seriesIndex.
  53150. thisBrushSelected.selected.push(seriesBrushSelected);
  53151. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  53152. var rangeInfoList = rangeInfoBySeries[seriesIndex];
  53153. var data = seriesModel.getData();
  53154. var getValueState = linkOthers(seriesIndex)
  53155. ? function (dataIndex) {
  53156. return selectedDataIndexForLink[dataIndex]
  53157. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  53158. : 'outOfBrush';
  53159. }
  53160. : function (dataIndex) {
  53161. return checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)
  53162. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  53163. : 'outOfBrush';
  53164. };
  53165. // If no supported brush or no brush, all visuals are in original state.
  53166. (linkOthers(seriesIndex) ? hasBrushExists : brushed(rangeInfoList))
  53167. && visualSolution.applyVisual(
  53168. STATE_LIST, visualMappings, data, getValueState
  53169. );
  53170. });
  53171. });
  53172. dispatchAction(api, throttleType, throttleDelay, brushSelected, payload);
  53173. });
  53174. function dispatchAction(api, throttleType, throttleDelay, brushSelected, payload) {
  53175. // This event will not be triggered when `setOpion`, otherwise dead lock may
  53176. // triggered when do `setOption` in event listener, which we do not find
  53177. // satisfactory way to solve yet. Some considered resolutions:
  53178. // (a) Diff with prevoius selected data ant only trigger event when changed.
  53179. // But store previous data and diff precisely (i.e., not only by dataIndex, but
  53180. // also detect value changes in selected data) might bring complexity or fragility.
  53181. // (b) Use spectial param like `silent` to suppress event triggering.
  53182. // But such kind of volatile param may be weird in `setOption`.
  53183. if (!payload) {
  53184. return;
  53185. }
  53186. var zr = api.getZr();
  53187. if (zr[DISPATCH_FLAG]) {
  53188. return;
  53189. }
  53190. if (!zr[DISPATCH_METHOD]) {
  53191. zr[DISPATCH_METHOD] = doDispatch;
  53192. }
  53193. var fn = throttle.createOrUpdate(zr, DISPATCH_METHOD, throttleDelay, throttleType);
  53194. fn(api, brushSelected);
  53195. }
  53196. function doDispatch(api, brushSelected) {
  53197. if (!api.isDisposed()) {
  53198. var zr = api.getZr();
  53199. zr[DISPATCH_FLAG] = true;
  53200. api.dispatchAction({
  53201. type: 'brushSelect',
  53202. batch: brushSelected
  53203. });
  53204. zr[DISPATCH_FLAG] = false;
  53205. }
  53206. }
  53207. function checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex) {
  53208. for (var i = 0, len = rangeInfoList.length; i < len; i++) {
  53209. var area = rangeInfoList[i];
  53210. if (selectorsByBrushType[area.brushType](
  53211. dataIndex, data, area.selectors, area
  53212. )) {
  53213. return true;
  53214. }
  53215. }
  53216. }
  53217. function getSelectorsByBrushType(seriesModel) {
  53218. var brushSelector = seriesModel.brushSelector;
  53219. if (zrUtil.isString(brushSelector)) {
  53220. var sels = [];
  53221. zrUtil.each(selector, function (selectorsByElementType, brushType) {
  53222. sels[brushType] = function (dataIndex, data, selectors, area) {
  53223. var itemLayout = data.getItemLayout(dataIndex);
  53224. return selectorsByElementType[brushSelector](itemLayout, selectors, area);
  53225. };
  53226. });
  53227. return sels;
  53228. }
  53229. else if (zrUtil.isFunction(brushSelector)) {
  53230. var bSelector = {};
  53231. zrUtil.each(selector, function (sel, brushType) {
  53232. bSelector[brushType] = brushSelector;
  53233. });
  53234. return bSelector;
  53235. }
  53236. return brushSelector;
  53237. }
  53238. function brushModelNotControll(brushModel, seriesIndex) {
  53239. var seriesIndices = brushModel.option.seriesIndex;
  53240. return seriesIndices != null
  53241. && seriesIndices !== 'all'
  53242. && (
  53243. zrUtil.isArray(seriesIndices)
  53244. ? zrUtil.indexOf(seriesIndices, seriesIndex) < 0
  53245. : seriesIndex !== seriesIndices
  53246. );
  53247. }
  53248. function bindSelector(area) {
  53249. var selectors = area.selectors = {};
  53250. zrUtil.each(selector[area.brushType], function (selFn, elType) {
  53251. // Do not use function binding or curry for performance.
  53252. selectors[elType] = function (itemLayout) {
  53253. return selFn(itemLayout, selectors, area);
  53254. };
  53255. });
  53256. return area;
  53257. }
  53258. var boundingRectBuilders = {
  53259. lineX: zrUtil.noop,
  53260. lineY: zrUtil.noop,
  53261. rect: function (area) {
  53262. return getBoundingRectFromMinMax(area.range);
  53263. },
  53264. polygon: function (area) {
  53265. var minMax;
  53266. var range = area.range;
  53267. for (var i = 0, len = range.length; i < len; i++) {
  53268. minMax = minMax || [[Infinity, -Infinity], [Infinity, -Infinity]];
  53269. var rg = range[i];
  53270. rg[0] < minMax[0][0] && (minMax[0][0] = rg[0]);
  53271. rg[0] > minMax[0][1] && (minMax[0][1] = rg[0]);
  53272. rg[1] < minMax[1][0] && (minMax[1][0] = rg[1]);
  53273. rg[1] > minMax[1][1] && (minMax[1][1] = rg[1]);
  53274. }
  53275. return minMax && getBoundingRectFromMinMax(minMax);
  53276. }
  53277. };
  53278. function getBoundingRectFromMinMax(minMax) {
  53279. return new BoundingRect(
  53280. minMax[0][0],
  53281. minMax[1][0],
  53282. minMax[0][1] - minMax[0][0],
  53283. minMax[1][1] - minMax[1][0]
  53284. );
  53285. }
  53286. /***/ }),
  53287. /* 357 */
  53288. /***/ (function(module, exports, __webpack_require__) {
  53289. /**
  53290. * @file Visual solution, for consistent option specification.
  53291. */
  53292. var zrUtil = __webpack_require__(4);
  53293. var VisualMapping = __webpack_require__(206);
  53294. var each = zrUtil.each;
  53295. function hasKeys(obj) {
  53296. if (obj) {
  53297. for (var name in obj){
  53298. if (obj.hasOwnProperty(name)) {
  53299. return true;
  53300. }
  53301. }
  53302. }
  53303. }
  53304. var visualSolution = {
  53305. /**
  53306. * @param {Object} option
  53307. * @param {Array.<string>} stateList
  53308. * @param {Function} [supplementVisualOption]
  53309. * @return {Object} visualMappings <state, <visualType, module:echarts/visual/VisualMapping>>
  53310. */
  53311. createVisualMappings: function (option, stateList, supplementVisualOption) {
  53312. var visualMappings = {};
  53313. each(stateList, function (state) {
  53314. var mappings = visualMappings[state] = createMappings();
  53315. each(option[state], function (visualData, visualType) {
  53316. if (!VisualMapping.isValidType(visualType)) {
  53317. return;
  53318. }
  53319. var mappingOption = {
  53320. type: visualType,
  53321. visual: visualData
  53322. };
  53323. supplementVisualOption && supplementVisualOption(mappingOption, state);
  53324. mappings[visualType] = new VisualMapping(mappingOption);
  53325. // Prepare a alpha for opacity, for some case that opacity
  53326. // is not supported, such as rendering using gradient color.
  53327. if (visualType === 'opacity') {
  53328. mappingOption = zrUtil.clone(mappingOption);
  53329. mappingOption.type = 'colorAlpha';
  53330. mappings.__hidden.__alphaForOpacity = new VisualMapping(mappingOption);
  53331. }
  53332. });
  53333. });
  53334. return visualMappings;
  53335. function createMappings() {
  53336. var Creater = function () {};
  53337. // Make sure hidden fields will not be visited by
  53338. // object iteration (with hasOwnProperty checking).
  53339. Creater.prototype.__hidden = Creater.prototype;
  53340. var obj = new Creater();
  53341. return obj;
  53342. }
  53343. },
  53344. /**
  53345. * @param {Object} thisOption
  53346. * @param {Object} newOption
  53347. * @param {Array.<string>} keys
  53348. */
  53349. replaceVisualOption: function (thisOption, newOption, keys) {
  53350. // Visual attributes merge is not supported, otherwise it
  53351. // brings overcomplicated merge logic. See #2853. So if
  53352. // newOption has anyone of these keys, all of these keys
  53353. // will be reset. Otherwise, all keys remain.
  53354. var has;
  53355. zrUtil.each(keys, function (key) {
  53356. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  53357. has = true;
  53358. }
  53359. });
  53360. has && zrUtil.each(keys, function (key) {
  53361. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  53362. thisOption[key] = zrUtil.clone(newOption[key]);
  53363. }
  53364. else {
  53365. delete thisOption[key];
  53366. }
  53367. });
  53368. },
  53369. /**
  53370. * @param {Array.<string>} stateList
  53371. * @param {Object} visualMappings <state, Object.<visualType, module:echarts/visual/VisualMapping>>
  53372. * @param {module:echarts/data/List} list
  53373. * @param {Function} getValueState param: valueOrIndex, return: state.
  53374. * @param {object} [scope] Scope for getValueState
  53375. * @param {string} [dimension] Concrete dimension, if used.
  53376. */
  53377. applyVisual: function (stateList, visualMappings, data, getValueState, scope, dimension) {
  53378. var visualTypesMap = {};
  53379. zrUtil.each(stateList, function (state) {
  53380. var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
  53381. visualTypesMap[state] = visualTypes;
  53382. });
  53383. var dataIndex;
  53384. function getVisual(key) {
  53385. return data.getItemVisual(dataIndex, key);
  53386. }
  53387. function setVisual(key, value) {
  53388. data.setItemVisual(dataIndex, key, value);
  53389. }
  53390. if (dimension == null) {
  53391. data.each(eachItem, true);
  53392. }
  53393. else {
  53394. data.each([dimension], eachItem, true);
  53395. }
  53396. function eachItem(valueOrIndex, index) {
  53397. dataIndex = dimension == null ? valueOrIndex : index;
  53398. var rawDataItem = data.getRawDataItem(dataIndex);
  53399. // Consider performance
  53400. if (rawDataItem && rawDataItem.visualMap === false) {
  53401. return;
  53402. }
  53403. var valueState = getValueState.call(scope, valueOrIndex);
  53404. var mappings = visualMappings[valueState];
  53405. var visualTypes = visualTypesMap[valueState];
  53406. for (var i = 0, len = visualTypes.length; i < len; i++) {
  53407. var type = visualTypes[i];
  53408. mappings[type] && mappings[type].applyVisual(
  53409. valueOrIndex, getVisual, setVisual
  53410. );
  53411. }
  53412. }
  53413. }
  53414. };
  53415. module.exports = visualSolution;
  53416. /***/ }),
  53417. /* 358 */
  53418. /***/ (function(module, exports, __webpack_require__) {
  53419. var polygonContain = __webpack_require__(178).contain;
  53420. var BoundingRect = __webpack_require__(9);
  53421. // Key of the first level is brushType: `line`, `rect`, `polygon`.
  53422. // Key of the second level is chart element type: `point`, `rect`.
  53423. // See moudule:echarts/component/helper/BrushController
  53424. // function param:
  53425. // {Object} itemLayout fetch from data.getItemLayout(dataIndex)
  53426. // {Object} selectors {point: selector, rect: selector, ...}
  53427. // {Object} area {range: [[], [], ..], boudingRect}
  53428. // function return:
  53429. // {boolean} Whether in the given brush.
  53430. var selector = {
  53431. lineX: getLineSelectors(0),
  53432. lineY: getLineSelectors(1),
  53433. rect: {
  53434. point: function (itemLayout, selectors, area) {
  53435. return area.boundingRect.contain(itemLayout[0], itemLayout[1]);
  53436. },
  53437. rect: function (itemLayout, selectors, area) {
  53438. return area.boundingRect.intersect(itemLayout);
  53439. }
  53440. },
  53441. polygon: {
  53442. point: function (itemLayout, selectors, area) {
  53443. return area.boundingRect.contain(itemLayout[0], itemLayout[1])
  53444. && polygonContain(area.range, itemLayout[0], itemLayout[1]);
  53445. },
  53446. rect: function (itemLayout, selectors, area) {
  53447. var points = area.range;
  53448. if (points.length <= 1) {
  53449. return false;
  53450. }
  53451. var x = itemLayout.x;
  53452. var y = itemLayout.y;
  53453. var width = itemLayout.width;
  53454. var height = itemLayout.height;
  53455. var p = points[0];
  53456. if (polygonContain(points, x, y)
  53457. || polygonContain(points, x + width, y)
  53458. || polygonContain(points, x, y + height)
  53459. || polygonContain(points, x + width, y + height)
  53460. || BoundingRect.create(itemLayout).contain(p[0], p[1])
  53461. || lineIntersectPolygon(x, y, x + width, y, points)
  53462. || lineIntersectPolygon(x, y, x, y + height, points)
  53463. || lineIntersectPolygon(x + width, y, x + width, y + height, points)
  53464. || lineIntersectPolygon(x, y + height, x + width, y + height, points)
  53465. ) {
  53466. return true;
  53467. }
  53468. }
  53469. }
  53470. };
  53471. function getLineSelectors(xyIndex) {
  53472. var xy = ['x', 'y'];
  53473. var wh = ['width', 'height'];
  53474. return {
  53475. point: function (itemLayout, selectors, area) {
  53476. var range = area.range;
  53477. var p = itemLayout[xyIndex];
  53478. return inLineRange(p, range);
  53479. },
  53480. rect: function (itemLayout, selectors, area) {
  53481. var range = area.range;
  53482. var layoutRange = [
  53483. itemLayout[xy[xyIndex]],
  53484. itemLayout[xy[xyIndex]] + itemLayout[wh[xyIndex]]
  53485. ];
  53486. layoutRange[1] < layoutRange[0] && layoutRange.reverse();
  53487. return inLineRange(layoutRange[0], range)
  53488. || inLineRange(layoutRange[1], range)
  53489. || inLineRange(range[0], layoutRange)
  53490. || inLineRange(range[1], layoutRange);
  53491. }
  53492. };
  53493. }
  53494. function inLineRange(p, range) {
  53495. return range[0] <= p && p <= range[1];
  53496. }
  53497. function lineIntersectPolygon(lx, ly, l2x, l2y, points) {
  53498. for (var i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
  53499. var p = points[i];
  53500. if (lineIntersect(lx, ly, l2x, l2y, p[0], p[1], p2[0], p2[1])) {
  53501. return true;
  53502. }
  53503. p2 = p;
  53504. }
  53505. }
  53506. // Code from <http://blog.csdn.net/rickliuxiao/article/details/6259322> with some fix.
  53507. // See <https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection>
  53508. function lineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
  53509. var delta = determinant(a2x - a1x, b1x - b2x, a2y - a1y, b1y - b2y);
  53510. if (nearZero(delta)) { // parallel
  53511. return false;
  53512. }
  53513. var namenda = determinant(b1x - a1x, b1x - b2x, b1y - a1y, b1y - b2y) / delta;
  53514. if (namenda < 0 || namenda > 1) {
  53515. return false;
  53516. }
  53517. var miu = determinant(a2x - a1x, b1x - a1x, a2y - a1y, b1y - a1y) / delta;
  53518. if (miu < 0 || miu > 1) {
  53519. return false;
  53520. }
  53521. return true;
  53522. }
  53523. function nearZero(val) {
  53524. return val <= (1e-6) && val >= -(1e-6);
  53525. }
  53526. function determinant(v1, v2, v3, v4) {
  53527. return v1 * v4 - v2 * v3;
  53528. }
  53529. module.exports = selector;
  53530. /***/ }),
  53531. /* 359 */
  53532. /***/ (function(module, exports, __webpack_require__) {
  53533. var zrUtil = __webpack_require__(4);
  53534. var graphic = __webpack_require__(20);
  53535. var modelUtil = __webpack_require__(5);
  53536. var brushHelper = __webpack_require__(249);
  53537. var each = zrUtil.each;
  53538. var indexOf = zrUtil.indexOf;
  53539. var curry = zrUtil.curry;
  53540. var COORD_CONVERTS = ['dataToPoint', 'pointToData'];
  53541. // FIXME
  53542. // how to genarialize to more coordinate systems.
  53543. var INCLUDE_FINDER_MAIN_TYPES = [
  53544. 'grid', 'xAxis', 'yAxis', 'geo', 'graph',
  53545. 'polar', 'radiusAxis', 'angleAxis', 'bmap'
  53546. ];
  53547. /**
  53548. * [option in constructor]:
  53549. * {
  53550. * Index/Id/Name of geo, xAxis, yAxis, grid: See util/model#parseFinder.
  53551. * }
  53552. *
  53553. *
  53554. * [targetInfo]:
  53555. *
  53556. * There can be multiple axes in a single targetInfo. Consider the case
  53557. * of `grid` component, a targetInfo represents a grid which contains one or more
  53558. * cartesian and one or more axes. And consider the case of parallel system,
  53559. * which has multiple axes in a coordinate system.
  53560. * Can be {
  53561. * panelId: ...,
  53562. * coordSys: <a representitive cartesian in grid (first cartesian by default)>,
  53563. * coordSyses: all cartesians.
  53564. * gridModel: <grid component>
  53565. * xAxes: correspond to coordSyses on index
  53566. * yAxes: correspond to coordSyses on index
  53567. * }
  53568. * or {
  53569. * panelId: ...,
  53570. * coordSys: <geo coord sys>
  53571. * coordSyses: [<geo coord sys>]
  53572. * geoModel: <geo component>
  53573. * }
  53574. *
  53575. *
  53576. * [panelOpt]:
  53577. *
  53578. * Make from targetInfo. Input to BrushController.
  53579. * {
  53580. * panelId: ...,
  53581. * rect: ...
  53582. * }
  53583. *
  53584. *
  53585. * [area]:
  53586. *
  53587. * Generated by BrushController or user input.
  53588. * {
  53589. * panelId: Used to locate coordInfo directly. If user inpput, no panelId.
  53590. * brushType: determine how to convert to/from coord('rect' or 'polygon' or 'lineX/Y').
  53591. * Index/Id/Name of geo, xAxis, yAxis, grid: See util/model#parseFinder.
  53592. * range: pixel range.
  53593. * coordRange: representitive coord range (the first one of coordRanges).
  53594. * coordRanges: <Array> coord ranges, used in multiple cartesian in one grid.
  53595. * }
  53596. */
  53597. /**
  53598. * @param {Object} option contains Index/Id/Name of xAxis/yAxis/geo/grid
  53599. * Each can be {number|Array.<number>}. like: {xAxisIndex: [3, 4]}
  53600. * @param {module:echarts/model/Global} ecModel
  53601. * @param {Object} [opt]
  53602. * @param {Array.<string>} [opt.include] include coordinate system types.
  53603. */
  53604. function BrushTargetManager(option, ecModel, opt) {
  53605. /**
  53606. * @private
  53607. * @type {Array.<Object>}
  53608. */
  53609. var targetInfoList = this._targetInfoList = [];
  53610. var info = {};
  53611. var foundCpts = parseFinder(ecModel, option);
  53612. each(targetInfoBuilders, function (builder, type) {
  53613. if (!opt || !opt.include || indexOf(opt.include, type) >= 0) {
  53614. builder(foundCpts, targetInfoList, info);
  53615. }
  53616. });
  53617. }
  53618. var proto = BrushTargetManager.prototype;
  53619. proto.setOutputRanges = function (areas, ecModel) {
  53620. this.matchOutputRanges(areas, ecModel, function (area, coordRange, coordSys) {
  53621. (area.coordRanges || (area.coordRanges = [])).push(coordRange);
  53622. // area.coordRange is the first of area.coordRanges
  53623. if (!area.coordRange) {
  53624. area.coordRange = coordRange;
  53625. // In 'category' axis, coord to pixel is not reversible, so we can not
  53626. // rebuild range by coordRange accrately, which may bring trouble when
  53627. // brushing only one item. So we use __rangeOffset to rebuilding range
  53628. // by coordRange. And this it only used in brush component so it is no
  53629. // need to be adapted to coordRanges.
  53630. var result = coordConvert[area.brushType](0, coordSys, coordRange);
  53631. area.__rangeOffset = {
  53632. offset: diffProcessor[area.brushType](result.values, area.range, [1, 1]),
  53633. xyMinMax: result.xyMinMax
  53634. };
  53635. }
  53636. });
  53637. };
  53638. proto.matchOutputRanges = function (areas, ecModel, cb) {
  53639. each(areas, function (area) {
  53640. var targetInfo = this.findTargetInfo(area, ecModel);
  53641. if (targetInfo && targetInfo !== true) {
  53642. zrUtil.each(
  53643. targetInfo.coordSyses,
  53644. function (coordSys) {
  53645. var result = coordConvert[area.brushType](1, coordSys, area.range);
  53646. cb(area, result.values, coordSys, ecModel);
  53647. }
  53648. );
  53649. }
  53650. }, this);
  53651. };
  53652. proto.setInputRanges = function (areas, ecModel) {
  53653. each(areas, function (area) {
  53654. var targetInfo = this.findTargetInfo(area, ecModel);
  53655. if (true) {
  53656. zrUtil.assert(
  53657. !targetInfo || targetInfo === true || area.coordRange,
  53658. 'coordRange must be specified when coord index specified.'
  53659. );
  53660. zrUtil.assert(
  53661. !targetInfo || targetInfo !== true || area.range,
  53662. 'range must be specified in global brush.'
  53663. );
  53664. }
  53665. area.range = area.range || [];
  53666. // convert coordRange to global range and set panelId.
  53667. if (targetInfo && targetInfo !== true) {
  53668. area.panelId = targetInfo.panelId;
  53669. // (1) area.range shoule always be calculate from coordRange but does
  53670. // not keep its original value, for the sake of the dataZoom scenario,
  53671. // where area.coordRange remains unchanged but area.range may be changed.
  53672. // (2) Only support converting one coordRange to pixel range in brush
  53673. // component. So do not consider `coordRanges`.
  53674. // (3) About __rangeOffset, see comment above.
  53675. var result = coordConvert[area.brushType](0, targetInfo.coordSys, area.coordRange);
  53676. var rangeOffset = area.__rangeOffset;
  53677. area.range = rangeOffset
  53678. ? diffProcessor[area.brushType](
  53679. result.values,
  53680. rangeOffset.offset,
  53681. getScales(result.xyMinMax, rangeOffset.xyMinMax)
  53682. )
  53683. : result.values;
  53684. }
  53685. }, this);
  53686. };
  53687. proto.makePanelOpts = function (api, getDefaultBrushType) {
  53688. return zrUtil.map(this._targetInfoList, function (targetInfo) {
  53689. var rect = targetInfo.getPanelRect();
  53690. return {
  53691. panelId: targetInfo.panelId,
  53692. defaultBrushType: getDefaultBrushType && getDefaultBrushType(targetInfo),
  53693. clipPath: brushHelper.makeRectPanelClipPath(rect),
  53694. isTargetByCursor: brushHelper.makeRectIsTargetByCursor(
  53695. rect, api, targetInfo.coordSysModel
  53696. ),
  53697. getLinearBrushOtherExtent: brushHelper.makeLinearBrushOtherExtent(rect)
  53698. };
  53699. });
  53700. };
  53701. proto.controlSeries = function (area, seriesModel, ecModel) {
  53702. // Check whether area is bound in coord, and series do not belong to that coord.
  53703. // If do not do this check, some brush (like lineX) will controll all axes.
  53704. var targetInfo = this.findTargetInfo(area, ecModel);
  53705. return targetInfo === true || (
  53706. targetInfo && indexOf(targetInfo.coordSyses, seriesModel.coordinateSystem) >= 0
  53707. );
  53708. };
  53709. /**
  53710. * If return Object, a coord found.
  53711. * If reutrn true, global found.
  53712. * Otherwise nothing found.
  53713. *
  53714. * @param {Object} area
  53715. * @param {Array} targetInfoList
  53716. * @return {Object|boolean}
  53717. */
  53718. proto.findTargetInfo = function (area, ecModel) {
  53719. var targetInfoList = this._targetInfoList;
  53720. var foundCpts = parseFinder(ecModel, area);
  53721. for (var i = 0; i < targetInfoList.length; i++) {
  53722. var targetInfo = targetInfoList[i];
  53723. var areaPanelId = area.panelId;
  53724. if (areaPanelId) {
  53725. if (targetInfo.panelId === areaPanelId) {
  53726. return targetInfo;
  53727. }
  53728. }
  53729. else {
  53730. for (var i = 0; i < targetInfoMatchers.length; i++) {
  53731. if (targetInfoMatchers[i](foundCpts, targetInfo)) {
  53732. return targetInfo;
  53733. }
  53734. }
  53735. }
  53736. }
  53737. return true;
  53738. };
  53739. function formatMinMax(minMax) {
  53740. minMax[0] > minMax[1] && minMax.reverse();
  53741. return minMax;
  53742. }
  53743. function parseFinder(ecModel, option) {
  53744. return modelUtil.parseFinder(
  53745. ecModel, option, {includeMainTypes: INCLUDE_FINDER_MAIN_TYPES}
  53746. );
  53747. }
  53748. var targetInfoBuilders = {
  53749. grid: function (foundCpts, targetInfoList) {
  53750. var xAxisModels = foundCpts.xAxisModels;
  53751. var yAxisModels = foundCpts.yAxisModels;
  53752. var gridModels = foundCpts.gridModels;
  53753. // Remove duplicated.
  53754. var gridModelMap = zrUtil.createHashMap();
  53755. var xAxesHas = {};
  53756. var yAxesHas = {};
  53757. if (!xAxisModels && !yAxisModels && !gridModels) {
  53758. return;
  53759. }
  53760. each(xAxisModels, function (axisModel) {
  53761. var gridModel = axisModel.axis.grid.model;
  53762. gridModelMap.set(gridModel.id, gridModel);
  53763. xAxesHas[gridModel.id] = true;
  53764. });
  53765. each(yAxisModels, function (axisModel) {
  53766. var gridModel = axisModel.axis.grid.model;
  53767. gridModelMap.set(gridModel.id, gridModel);
  53768. yAxesHas[gridModel.id] = true;
  53769. });
  53770. each(gridModels, function (gridModel) {
  53771. gridModelMap.set(gridModel.id, gridModel);
  53772. xAxesHas[gridModel.id] = true;
  53773. yAxesHas[gridModel.id] = true;
  53774. });
  53775. gridModelMap.each(function (gridModel) {
  53776. var grid = gridModel.coordinateSystem;
  53777. var cartesians = [];
  53778. each(grid.getCartesians(), function (cartesian, index) {
  53779. if (indexOf(xAxisModels, cartesian.getAxis('x').model) >= 0
  53780. || indexOf(yAxisModels, cartesian.getAxis('y').model) >= 0
  53781. ) {
  53782. cartesians.push(cartesian);
  53783. }
  53784. });
  53785. targetInfoList.push({
  53786. panelId: 'grid--' + gridModel.id,
  53787. gridModel: gridModel,
  53788. coordSysModel: gridModel,
  53789. // Use the first one as the representitive coordSys.
  53790. coordSys: cartesians[0],
  53791. coordSyses: cartesians,
  53792. getPanelRect: panelRectBuilder.grid,
  53793. xAxisDeclared: xAxesHas[gridModel.id],
  53794. yAxisDeclared: yAxesHas[gridModel.id]
  53795. });
  53796. });
  53797. },
  53798. geo: function (foundCpts, targetInfoList) {
  53799. each(foundCpts.geoModels, function (geoModel) {
  53800. var coordSys = geoModel.coordinateSystem;
  53801. targetInfoList.push({
  53802. panelId: 'geo--' + geoModel.id,
  53803. geoModel: geoModel,
  53804. coordSysModel: geoModel,
  53805. coordSys: coordSys,
  53806. coordSyses: [coordSys],
  53807. getPanelRect: panelRectBuilder.geo
  53808. });
  53809. });
  53810. }
  53811. };
  53812. var targetInfoMatchers = [
  53813. // grid
  53814. function (foundCpts, targetInfo) {
  53815. var xAxisModel = foundCpts.xAxisModel;
  53816. var yAxisModel = foundCpts.yAxisModel;
  53817. var gridModel = foundCpts.gridModel;
  53818. !gridModel && xAxisModel && (gridModel = xAxisModel.axis.grid.model);
  53819. !gridModel && yAxisModel && (gridModel = yAxisModel.axis.grid.model);
  53820. return gridModel && gridModel === targetInfo.gridModel;
  53821. },
  53822. // geo
  53823. function (foundCpts, targetInfo) {
  53824. var geoModel = foundCpts.geoModel;
  53825. return geoModel && geoModel === targetInfo.geoModel;
  53826. }
  53827. ];
  53828. var panelRectBuilder = {
  53829. grid: function () {
  53830. // grid is not Transformable.
  53831. return this.coordSys.grid.getRect().clone();
  53832. },
  53833. geo: function () {
  53834. var coordSys = this.coordSys;
  53835. var rect = coordSys.getBoundingRect().clone();
  53836. // geo roam and zoom transform
  53837. rect.applyTransform(graphic.getTransform(coordSys));
  53838. return rect;
  53839. }
  53840. };
  53841. var coordConvert = {
  53842. lineX: curry(axisConvert, 0),
  53843. lineY: curry(axisConvert, 1),
  53844. rect: function (to, coordSys, rangeOrCoordRange) {
  53845. var xminymin = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]]);
  53846. var xmaxymax = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]]);
  53847. var values = [
  53848. formatMinMax([xminymin[0], xmaxymax[0]]),
  53849. formatMinMax([xminymin[1], xmaxymax[1]])
  53850. ];
  53851. return {values: values, xyMinMax: values};
  53852. },
  53853. polygon: function (to, coordSys, rangeOrCoordRange) {
  53854. var xyMinMax = [[Infinity, -Infinity], [Infinity, -Infinity]];
  53855. var values = zrUtil.map(rangeOrCoordRange, function (item) {
  53856. var p = coordSys[COORD_CONVERTS[to]](item);
  53857. xyMinMax[0][0] = Math.min(xyMinMax[0][0], p[0]);
  53858. xyMinMax[1][0] = Math.min(xyMinMax[1][0], p[1]);
  53859. xyMinMax[0][1] = Math.max(xyMinMax[0][1], p[0]);
  53860. xyMinMax[1][1] = Math.max(xyMinMax[1][1], p[1]);
  53861. return p;
  53862. });
  53863. return {values: values, xyMinMax: xyMinMax};
  53864. }
  53865. };
  53866. function axisConvert(axisNameIndex, to, coordSys, rangeOrCoordRange) {
  53867. if (true) {
  53868. zrUtil.assert(
  53869. coordSys.type === 'cartesian2d',
  53870. 'lineX/lineY brush is available only in cartesian2d.'
  53871. );
  53872. }
  53873. var axis = coordSys.getAxis(['x', 'y'][axisNameIndex]);
  53874. var values = formatMinMax(zrUtil.map([0, 1], function (i) {
  53875. return to
  53876. ? axis.coordToData(axis.toLocalCoord(rangeOrCoordRange[i]))
  53877. : axis.toGlobalCoord(axis.dataToCoord(rangeOrCoordRange[i]));
  53878. }));
  53879. var xyMinMax = [];
  53880. xyMinMax[axisNameIndex] = values;
  53881. xyMinMax[1 - axisNameIndex] = [NaN, NaN];
  53882. return {values: values, xyMinMax: xyMinMax};
  53883. }
  53884. var diffProcessor = {
  53885. lineX: curry(axisDiffProcessor, 0),
  53886. lineY: curry(axisDiffProcessor, 1),
  53887. rect: function (values, refer, scales) {
  53888. return [
  53889. [values[0][0] - scales[0] * refer[0][0], values[0][1] - scales[0] * refer[0][1]],
  53890. [values[1][0] - scales[1] * refer[1][0], values[1][1] - scales[1] * refer[1][1]]
  53891. ];
  53892. },
  53893. polygon: function (values, refer, scales) {
  53894. return zrUtil.map(values, function (item, idx) {
  53895. return [item[0] - scales[0] * refer[idx][0], item[1] - scales[1] * refer[idx][1]];
  53896. });
  53897. }
  53898. };
  53899. function axisDiffProcessor(axisNameIndex, values, refer, scales) {
  53900. return [
  53901. values[0] - scales[axisNameIndex] * refer[0],
  53902. values[1] - scales[axisNameIndex] * refer[1]
  53903. ];
  53904. }
  53905. // We have to process scale caused by dataZoom manually,
  53906. // although it might be not accurate.
  53907. function getScales(xyMinMaxCurr, xyMinMaxOrigin) {
  53908. var sizeCurr = getSize(xyMinMaxCurr);
  53909. var sizeOrigin = getSize(xyMinMaxOrigin);
  53910. var scales = [sizeCurr[0] / sizeOrigin[0], sizeCurr[1] / sizeOrigin[1]];
  53911. isNaN(scales[0]) && (scales[0] = 1);
  53912. isNaN(scales[1]) && (scales[1] = 1);
  53913. return scales;
  53914. }
  53915. function getSize(xyMinMax) {
  53916. return xyMinMax
  53917. ? [xyMinMax[0][1] - xyMinMax[0][0], xyMinMax[1][1] - xyMinMax[1][0]]
  53918. : [NaN, NaN];
  53919. }
  53920. module.exports = BrushTargetManager;
  53921. /***/ }),
  53922. /* 360 */
  53923. /***/ (function(module, exports, __webpack_require__) {
  53924. /**
  53925. * @file Brush model
  53926. */
  53927. var echarts = __webpack_require__(1);
  53928. var zrUtil = __webpack_require__(4);
  53929. var visualSolution = __webpack_require__(357);
  53930. var Model = __webpack_require__(14);
  53931. var DEFAULT_OUT_OF_BRUSH_COLOR = ['#ddd'];
  53932. var BrushModel = echarts.extendComponentModel({
  53933. type: 'brush',
  53934. dependencies: ['geo', 'grid', 'xAxis', 'yAxis', 'parallel', 'series'],
  53935. /**
  53936. * @protected
  53937. */
  53938. defaultOption: {
  53939. // inBrush: null,
  53940. // outOfBrush: null,
  53941. toolbox: null, // Default value see preprocessor.
  53942. brushLink: null, // Series indices array, broadcast using dataIndex.
  53943. // or 'all', which means all series. 'none' or null means no series.
  53944. seriesIndex: 'all', // seriesIndex array, specify series controlled by this brush component.
  53945. geoIndex: null, //
  53946. xAxisIndex: null,
  53947. yAxisIndex: null,
  53948. brushType: 'rect', // Default brushType, see BrushController.
  53949. brushMode: 'single', // Default brushMode, 'single' or 'multiple'
  53950. transformable: true, // Default transformable.
  53951. brushStyle: { // Default brushStyle
  53952. borderWidth: 1,
  53953. color: 'rgba(120,140,180,0.3)',
  53954. borderColor: 'rgba(120,140,180,0.8)'
  53955. },
  53956. throttleType: 'fixRate',// Throttle in brushSelected event. 'fixRate' or 'debounce'.
  53957. // If null, no throttle. Valid only in the first brush component
  53958. throttleDelay: 0, // Unit: ms, 0 means every event will be triggered.
  53959. // FIXME
  53960. // 试验效果
  53961. removeOnClick: true,
  53962. z: 10000
  53963. },
  53964. /**
  53965. * @readOnly
  53966. * @type {Array.<Object>}
  53967. */
  53968. areas: [],
  53969. /**
  53970. * Current activated brush type.
  53971. * If null, brush is inactived.
  53972. * see module:echarts/component/helper/BrushController
  53973. * @readOnly
  53974. * @type {string}
  53975. */
  53976. brushType: null,
  53977. /**
  53978. * Current brush opt.
  53979. * see module:echarts/component/helper/BrushController
  53980. * @readOnly
  53981. * @type {Object}
  53982. */
  53983. brushOption: {},
  53984. /**
  53985. * @readOnly
  53986. * @type {Array.<Object>}
  53987. */
  53988. coordInfoList: [],
  53989. optionUpdated: function (newOption, isInit) {
  53990. var thisOption = this.option;
  53991. !isInit && visualSolution.replaceVisualOption(
  53992. thisOption, newOption, ['inBrush', 'outOfBrush']
  53993. );
  53994. thisOption.inBrush = thisOption.inBrush || {};
  53995. // Always give default visual, consider setOption at the second time.
  53996. thisOption.outOfBrush = thisOption.outOfBrush || {color: DEFAULT_OUT_OF_BRUSH_COLOR};
  53997. },
  53998. /**
  53999. * If ranges is null/undefined, range state remain.
  54000. *
  54001. * @param {Array.<Object>} [ranges]
  54002. */
  54003. setAreas: function (areas) {
  54004. if (true) {
  54005. zrUtil.assert(zrUtil.isArray(areas));
  54006. zrUtil.each(areas, function (area) {
  54007. zrUtil.assert(area.brushType, 'Illegal areas');
  54008. });
  54009. }
  54010. // If ranges is null/undefined, range state remain.
  54011. // This helps user to dispatchAction({type: 'brush'}) with no areas
  54012. // set but just want to get the current brush select info from a `brush` event.
  54013. if (!areas) {
  54014. return;
  54015. }
  54016. this.areas = zrUtil.map(areas, function (area) {
  54017. return generateBrushOption(this.option, area);
  54018. }, this);
  54019. },
  54020. /**
  54021. * see module:echarts/component/helper/BrushController
  54022. * @param {Object} brushOption
  54023. */
  54024. setBrushOption: function (brushOption) {
  54025. this.brushOption = generateBrushOption(this.option, brushOption);
  54026. this.brushType = this.brushOption.brushType;
  54027. }
  54028. });
  54029. function generateBrushOption(option, brushOption) {
  54030. return zrUtil.merge(
  54031. {
  54032. brushType: option.brushType,
  54033. brushMode: option.brushMode,
  54034. transformable: option.transformable,
  54035. brushStyle: new Model(option.brushStyle).getItemStyle(),
  54036. removeOnClick: option.removeOnClick,
  54037. z: option.z
  54038. },
  54039. brushOption,
  54040. true
  54041. );
  54042. }
  54043. module.exports = BrushModel;
  54044. /***/ }),
  54045. /* 361 */
  54046. /***/ (function(module, exports, __webpack_require__) {
  54047. var zrUtil = __webpack_require__(4);
  54048. var BrushController = __webpack_require__(248);
  54049. var echarts = __webpack_require__(1);
  54050. module.exports = echarts.extendComponentView({
  54051. type: 'brush',
  54052. init: function (ecModel, api) {
  54053. /**
  54054. * @readOnly
  54055. * @type {module:echarts/model/Global}
  54056. */
  54057. this.ecModel = ecModel;
  54058. /**
  54059. * @readOnly
  54060. * @type {module:echarts/ExtensionAPI}
  54061. */
  54062. this.api = api;
  54063. /**
  54064. * @readOnly
  54065. * @type {module:echarts/component/brush/BrushModel}
  54066. */
  54067. this.model;
  54068. /**
  54069. * @private
  54070. * @type {module:echarts/component/helper/BrushController}
  54071. */
  54072. (this._brushController = new BrushController(api.getZr()))
  54073. .on('brush', zrUtil.bind(this._onBrush, this))
  54074. .mount();
  54075. },
  54076. /**
  54077. * @override
  54078. */
  54079. render: function (brushModel) {
  54080. this.model = brushModel;
  54081. return updateController.apply(this, arguments);
  54082. },
  54083. /**
  54084. * @override
  54085. */
  54086. updateView: updateController,
  54087. /**
  54088. * @override
  54089. */
  54090. updateLayout: updateController,
  54091. /**
  54092. * @override
  54093. */
  54094. updateVisual: updateController,
  54095. /**
  54096. * @override
  54097. */
  54098. dispose: function () {
  54099. this._brushController.dispose();
  54100. },
  54101. /**
  54102. * @private
  54103. */
  54104. _onBrush: function (areas, opt) {
  54105. var modelId = this.model.id;
  54106. this.model.brushTargetManager.setOutputRanges(areas, this.ecModel);
  54107. // Action is not dispatched on drag end, because the drag end
  54108. // emits the same params with the last drag move event, and
  54109. // may have some delay when using touch pad, which makes
  54110. // animation not smooth (when using debounce).
  54111. (!opt.isEnd || opt.removeOnClick) && this.api.dispatchAction({
  54112. type: 'brush',
  54113. brushId: modelId,
  54114. areas: zrUtil.clone(areas),
  54115. $from: modelId
  54116. });
  54117. }
  54118. });
  54119. function updateController(brushModel, ecModel, api, payload) {
  54120. // Do not update controller when drawing.
  54121. (!payload || payload.$from !== brushModel.id) && this._brushController
  54122. .setPanels(brushModel.brushTargetManager.makePanelOpts(api))
  54123. .enableBrush(brushModel.brushOption)
  54124. .updateCovers(brushModel.areas.slice());
  54125. }
  54126. /***/ }),
  54127. /* 362 */
  54128. /***/ (function(module, exports, __webpack_require__) {
  54129. /**
  54130. * @file Brush action
  54131. */
  54132. var echarts = __webpack_require__(1);
  54133. /**
  54134. * payload: {
  54135. * brushIndex: number, or,
  54136. * brushId: string, or,
  54137. * brushName: string,
  54138. * globalRanges: Array
  54139. * }
  54140. */
  54141. echarts.registerAction(
  54142. {type: 'brush', event: 'brush', update: 'updateView'},
  54143. function (payload, ecModel) {
  54144. ecModel.eachComponent({mainType: 'brush', query: payload}, function (brushModel) {
  54145. brushModel.setAreas(payload.areas);
  54146. });
  54147. }
  54148. );
  54149. /**
  54150. * payload: {
  54151. * brushComponents: [
  54152. * {
  54153. * brushId,
  54154. * brushIndex,
  54155. * brushName,
  54156. * series: [
  54157. * {
  54158. * seriesId,
  54159. * seriesIndex,
  54160. * seriesName,
  54161. * rawIndices: [21, 34, ...]
  54162. * },
  54163. * ...
  54164. * ]
  54165. * },
  54166. * ...
  54167. * ]
  54168. * }
  54169. */
  54170. echarts.registerAction(
  54171. {type: 'brushSelect', event: 'brushSelected', update: 'none'},
  54172. function () {}
  54173. );
  54174. /***/ }),
  54175. /* 363 */
  54176. /***/ (function(module, exports, __webpack_require__) {
  54177. 'use strict';
  54178. var featureManager = __webpack_require__(364);
  54179. var zrUtil = __webpack_require__(4);
  54180. var lang = __webpack_require__(365).toolbox.brush;
  54181. function Brush(model, ecModel, api) {
  54182. this.model = model;
  54183. this.ecModel = ecModel;
  54184. this.api = api;
  54185. /**
  54186. * @private
  54187. * @type {string}
  54188. */
  54189. this._brushType;
  54190. /**
  54191. * @private
  54192. * @type {string}
  54193. */
  54194. this._brushMode;
  54195. }
  54196. Brush.defaultOption = {
  54197. show: true,
  54198. type: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear'],
  54199. icon: {
  54200. 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
  54201. 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
  54202. 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
  54203. 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
  54204. 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
  54205. 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
  54206. },
  54207. // `rect`, `polygon`, `lineX`, `lineY`, `keep`, `clear`
  54208. title: zrUtil.clone(lang.title)
  54209. };
  54210. var proto = Brush.prototype;
  54211. proto.render =
  54212. proto.updateView =
  54213. proto.updateLayout = function (featureModel, ecModel, api) {
  54214. var brushType;
  54215. var brushMode;
  54216. var isBrushed;
  54217. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  54218. brushType = brushModel.brushType;
  54219. brushMode = brushModel.brushOption.brushMode || 'single';
  54220. isBrushed |= brushModel.areas.length;
  54221. });
  54222. this._brushType = brushType;
  54223. this._brushMode = brushMode;
  54224. zrUtil.each(featureModel.get('type', true), function (type) {
  54225. featureModel.setIconStatus(
  54226. type,
  54227. (
  54228. type === 'keep'
  54229. ? brushMode === 'multiple'
  54230. : type === 'clear'
  54231. ? isBrushed
  54232. : type === brushType
  54233. ) ? 'emphasis' : 'normal'
  54234. );
  54235. });
  54236. };
  54237. proto.getIcons = function () {
  54238. var model = this.model;
  54239. var availableIcons = model.get('icon', true);
  54240. var icons = {};
  54241. zrUtil.each(model.get('type', true), function (type) {
  54242. if (availableIcons[type]) {
  54243. icons[type] = availableIcons[type];
  54244. }
  54245. });
  54246. return icons;
  54247. };
  54248. proto.onclick = function (ecModel, api, type) {
  54249. var api = this.api;
  54250. var brushType = this._brushType;
  54251. var brushMode = this._brushMode;
  54252. if (type === 'clear') {
  54253. // Trigger parallel action firstly
  54254. api.dispatchAction({
  54255. type: 'axisAreaSelect',
  54256. intervals: []
  54257. });
  54258. api.dispatchAction({
  54259. type: 'brush',
  54260. command: 'clear',
  54261. // Clear all areas of all brush components.
  54262. areas: []
  54263. });
  54264. }
  54265. else {
  54266. api.dispatchAction({
  54267. type: 'takeGlobalCursor',
  54268. key: 'brush',
  54269. brushOption: {
  54270. brushType: type === 'keep'
  54271. ? brushType
  54272. : (brushType === type ? false : type),
  54273. brushMode: type === 'keep'
  54274. ? (brushMode === 'multiple' ? 'single' : 'multiple')
  54275. : brushMode
  54276. }
  54277. });
  54278. }
  54279. };
  54280. featureManager.register('brush', Brush);
  54281. module.exports = Brush;
  54282. /***/ }),
  54283. /* 364 */
  54284. /***/ (function(module, exports) {
  54285. 'use strict';
  54286. var features = {};
  54287. module.exports = {
  54288. register: function (name, ctor) {
  54289. features[name] = ctor;
  54290. },
  54291. get: function (name) {
  54292. return features[name];
  54293. }
  54294. };
  54295. /***/ }),
  54296. /* 365 */
  54297. /***/ (function(module, exports) {
  54298. module.exports = {
  54299. toolbox: {
  54300. brush: {
  54301. title: {
  54302. rect: '矩形选择',
  54303. polygon: '圈选',
  54304. lineX: '横向选择',
  54305. lineY: '纵向选择',
  54306. keep: '保持选择',
  54307. clear: '清除选择'
  54308. }
  54309. },
  54310. dataView: {
  54311. title: '数据视图',
  54312. lang: ['数据视图', '关闭', '刷新']
  54313. },
  54314. dataZoom: {
  54315. title: {
  54316. zoom: '区域缩放',
  54317. back: '区域缩放还原'
  54318. }
  54319. },
  54320. magicType: {
  54321. title: {
  54322. line: '切换为折线图',
  54323. bar: '切换为柱状图',
  54324. stack: '切换为堆叠',
  54325. tiled: '切换为平铺'
  54326. }
  54327. },
  54328. restore: {
  54329. title: '还原'
  54330. },
  54331. saveAsImage: {
  54332. title: '保存为图片',
  54333. lang: ['右键另存为图片']
  54334. }
  54335. }
  54336. };
  54337. /***/ }),
  54338. /* 366 */
  54339. /***/ (function(module, exports, __webpack_require__) {
  54340. 'use strict';
  54341. /**
  54342. * @file calendar.js
  54343. * @author dxh
  54344. */
  54345. __webpack_require__(367);
  54346. __webpack_require__(368);
  54347. __webpack_require__(369);
  54348. /***/ }),
  54349. /* 367 */
  54350. /***/ (function(module, exports, __webpack_require__) {
  54351. 'use strict';
  54352. var layout = __webpack_require__(74);
  54353. var numberUtil = __webpack_require__(7);
  54354. var zrUtil = __webpack_require__(4);
  54355. // (24*60*60*1000)
  54356. var PROXIMATE_ONE_DAY = 86400000;
  54357. /**
  54358. * Calendar
  54359. *
  54360. * @constructor
  54361. *
  54362. * @param {Object} calendarModel calendarModel
  54363. * @param {Object} ecModel ecModel
  54364. * @param {Object} api api
  54365. */
  54366. function Calendar(calendarModel, ecModel, api) {
  54367. this._model = calendarModel;
  54368. }
  54369. Calendar.prototype = {
  54370. constructor: Calendar,
  54371. type: 'calendar',
  54372. dimensions: ['time', 'value'],
  54373. // Required in createListFromData
  54374. getDimensionsInfo: function () {
  54375. return [{name: 'time', type: 'time'}];
  54376. },
  54377. getRangeInfo: function () {
  54378. return this._rangeInfo;
  54379. },
  54380. getModel: function () {
  54381. return this._model;
  54382. },
  54383. getRect: function () {
  54384. return this._rect;
  54385. },
  54386. getCellWidth: function () {
  54387. return this._sw;
  54388. },
  54389. getCellHeight: function () {
  54390. return this._sh;
  54391. },
  54392. getOrient: function () {
  54393. return this._orient;
  54394. },
  54395. /**
  54396. * getFirstDayOfWeek
  54397. *
  54398. * @example
  54399. * 0 : start at Sunday
  54400. * 1 : start at Monday
  54401. *
  54402. * @return {number}
  54403. */
  54404. getFirstDayOfWeek: function () {
  54405. return this._firstDayOfWeek;
  54406. },
  54407. /**
  54408. * get date info
  54409. *
  54410. * @param {string|number} date date
  54411. * @return {Object}
  54412. * {
  54413. * y: string, local full year, eg., '1940',
  54414. * m: string, local month, from '01' ot '12',
  54415. * d: string, local date, from '01' to '31' (if exists),
  54416. * day: It is not date.getDay(). It is the location of the cell in a week, from 0 to 6,
  54417. * time: timestamp,
  54418. * formatedDate: string, yyyy-MM-dd,
  54419. * date: original date object.
  54420. * }
  54421. */
  54422. getDateInfo: function (date) {
  54423. date = numberUtil.parseDate(date);
  54424. var y = date.getFullYear();
  54425. var m = date.getMonth() + 1;
  54426. m = m < 10 ? '0' + m : m;
  54427. var d = date.getDate();
  54428. d = d < 10 ? '0' + d : d;
  54429. var day = date.getDay();
  54430. day = Math.abs((day + 7 - this.getFirstDayOfWeek()) % 7);
  54431. return {
  54432. y: y,
  54433. m: m,
  54434. d: d,
  54435. day: day,
  54436. time: date.getTime(),
  54437. formatedDate: y + '-' + m + '-' + d,
  54438. date: date
  54439. };
  54440. },
  54441. getNextNDay: function (date, n) {
  54442. n = n || 0;
  54443. if (n === 0) {
  54444. return this.getDateInfo(date);
  54445. }
  54446. date = new Date(this.getDateInfo(date).time);
  54447. date.setDate(date.getDate() + n);
  54448. return this.getDateInfo(date);
  54449. },
  54450. update: function (ecModel, api) {
  54451. this._firstDayOfWeek = this._model.getModel('dayLabel').get('firstDay');
  54452. this._orient = this._model.get('orient');
  54453. this._lineWidth = this._model.getModel('itemStyle.normal').getItemStyle().lineWidth || 0;
  54454. this._rangeInfo = this._getRangeInfo(this._initRangeOption());
  54455. var weeks = this._rangeInfo.weeks || 1;
  54456. var whNames = ['width', 'height'];
  54457. var cellSize = this._model.get('cellSize').slice();
  54458. var layoutParams = this._model.getBoxLayoutParams();
  54459. var cellNumbers = this._orient === 'horizontal' ? [weeks, 7] : [7, weeks];
  54460. zrUtil.each([0, 1], function (idx) {
  54461. if (cellSizeSpecified(cellSize, idx)) {
  54462. layoutParams[whNames[idx]] = cellSize[idx] * cellNumbers[idx];
  54463. }
  54464. });
  54465. var whGlobal = {
  54466. width: api.getWidth(),
  54467. height: api.getHeight()
  54468. };
  54469. var calendarRect = this._rect = layout.getLayoutRect(layoutParams, whGlobal);
  54470. zrUtil.each([0, 1], function (idx) {
  54471. if (!cellSizeSpecified(cellSize, idx)) {
  54472. cellSize[idx] = calendarRect[whNames[idx]] / cellNumbers[idx];
  54473. }
  54474. });
  54475. function cellSizeSpecified(cellSize, idx) {
  54476. return cellSize[idx] != null && cellSize[idx] !== 'auto';
  54477. }
  54478. this._sw = cellSize[0];
  54479. this._sh = cellSize[1];
  54480. },
  54481. /**
  54482. * Convert a time data(time, value) item to (x, y) point.
  54483. *
  54484. * @override
  54485. * @param {Array|number} data data
  54486. * @param {boolean} [clamp=true] out of range
  54487. * @return {Array} point
  54488. */
  54489. dataToPoint: function (data, clamp) {
  54490. zrUtil.isArray(data) && (data = data[0]);
  54491. clamp == null && (clamp = true);
  54492. var dayInfo = this.getDateInfo(data);
  54493. var range = this._rangeInfo;
  54494. var date = dayInfo.formatedDate;
  54495. // if not in range return [NaN, NaN]
  54496. if (clamp && !(dayInfo.time >= range.start.time && dayInfo.time <= range.end.time)) {
  54497. return [NaN, NaN];
  54498. }
  54499. var week = dayInfo.day;
  54500. var nthWeek = this._getRangeInfo([range.start.time, date]).nthWeek;
  54501. if (this._orient === 'vertical') {
  54502. return [
  54503. this._rect.x + week * this._sw + this._sw / 2,
  54504. this._rect.y + nthWeek * this._sh + this._sh / 2
  54505. ];
  54506. }
  54507. return [
  54508. this._rect.x + nthWeek * this._sw + this._sw / 2,
  54509. this._rect.y + week * this._sh + this._sh / 2
  54510. ];
  54511. },
  54512. /**
  54513. * Convert a (x, y) point to time data
  54514. *
  54515. * @override
  54516. * @param {string} point point
  54517. * @return {string} data
  54518. */
  54519. pointToData: function (point) {
  54520. var date = this.pointToDate(point);
  54521. return date && date.time;
  54522. },
  54523. /**
  54524. * Convert a time date item to (x, y) four point.
  54525. *
  54526. * @param {Array} data date[0] is date
  54527. * @param {boolean} [clamp=true] out of range
  54528. * @return {Object} point
  54529. */
  54530. dataToRect: function (data, clamp) {
  54531. var point = this.dataToPoint(data, clamp);
  54532. return {
  54533. contentShape: {
  54534. x: point[0] - (this._sw - this._lineWidth) / 2,
  54535. y: point[1] - (this._sh - this._lineWidth) / 2,
  54536. width: this._sw - this._lineWidth,
  54537. height: this._sh - this._lineWidth
  54538. },
  54539. center: point,
  54540. tl: [
  54541. point[0] - this._sw / 2,
  54542. point[1] - this._sh / 2
  54543. ],
  54544. tr: [
  54545. point[0] + this._sw / 2,
  54546. point[1] - this._sh / 2
  54547. ],
  54548. br: [
  54549. point[0] + this._sw / 2,
  54550. point[1] + this._sh / 2
  54551. ],
  54552. bl: [
  54553. point[0] - this._sw / 2,
  54554. point[1] + this._sh / 2
  54555. ]
  54556. };
  54557. },
  54558. /**
  54559. * Convert a (x, y) point to time date
  54560. *
  54561. * @param {Array} point point
  54562. * @return {Object} date
  54563. */
  54564. pointToDate: function (point) {
  54565. var nthX = Math.floor((point[0] - this._rect.x) / this._sw) + 1;
  54566. var nthY = Math.floor((point[1] - this._rect.y) / this._sh) + 1;
  54567. var range = this._rangeInfo.range;
  54568. if (this._orient === 'vertical') {
  54569. return this._getDateByWeeksAndDay(nthY, nthX - 1, range);
  54570. }
  54571. return this._getDateByWeeksAndDay(nthX, nthY - 1, range);
  54572. },
  54573. /**
  54574. * @inheritDoc
  54575. */
  54576. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  54577. /**
  54578. * @inheritDoc
  54579. */
  54580. convertFromPixel: zrUtil.curry(doConvert, 'pointToData'),
  54581. /**
  54582. * initRange
  54583. *
  54584. * @private
  54585. * @return {Array} [start, end]
  54586. */
  54587. _initRangeOption: function () {
  54588. var range = this._model.get('range');
  54589. var rg = range;
  54590. if (zrUtil.isArray(rg) && rg.length === 1) {
  54591. rg = rg[0];
  54592. }
  54593. if (/^\d{4}$/.test(rg)) {
  54594. range = [rg + '-01-01', rg + '-12-31'];
  54595. }
  54596. if (/^\d{4}[\/|-]\d{1,2}$/.test(rg)) {
  54597. var start = this.getDateInfo(rg);
  54598. var firstDay = start.date;
  54599. firstDay.setMonth(firstDay.getMonth() + 1);
  54600. var end = this.getNextNDay(firstDay, -1);
  54601. range = [start.formatedDate, end.formatedDate];
  54602. }
  54603. if (/^\d{4}[\/|-]\d{1,2}[\/|-]\d{1,2}$/.test(rg)) {
  54604. range = [rg, rg];
  54605. }
  54606. var tmp = this._getRangeInfo(range);
  54607. if (tmp.start.time > tmp.end.time) {
  54608. range.reverse();
  54609. }
  54610. return range;
  54611. },
  54612. /**
  54613. * range info
  54614. *
  54615. * @private
  54616. * @param {Array} range range ['2017-01-01', '2017-07-08']
  54617. * If range[0] > range[1], they will not be reversed.
  54618. * @return {Object} obj
  54619. */
  54620. _getRangeInfo: function (range) {
  54621. range = [
  54622. this.getDateInfo(range[0]),
  54623. this.getDateInfo(range[1])
  54624. ];
  54625. var reversed;
  54626. if (range[0].time > range[1].time) {
  54627. reversed = true;
  54628. range.reverse();
  54629. }
  54630. var allDay = Math.floor(range[1].time / PROXIMATE_ONE_DAY)
  54631. - Math.floor(range[0].time / PROXIMATE_ONE_DAY) + 1;
  54632. // Consider case:
  54633. // Firstly set system timezone as "Time Zone: America/Toronto",
  54634. // ```
  54635. // var first = new Date(1478412000000 - 3600 * 1000 * 2.5);
  54636. // var second = new Date(1478412000000);
  54637. // var allDays = Math.floor(second / ONE_DAY) - Math.floor(first / ONE_DAY) + 1;
  54638. // ```
  54639. // will get wrong result because of DST. So we should fix it.
  54640. var date = new Date(range[0].time);
  54641. var startDateNum = date.getDate();
  54642. var endDateNum = range[1].date.getDate();
  54643. date.setDate(startDateNum + allDay - 1);
  54644. // The bias can not over a month, so just compare date.
  54645. if (date.getDate() !== endDateNum) {
  54646. var sign = date.getTime() - range[1].time > 0 ? 1 : -1;
  54647. while (date.getDate() !== endDateNum && (date.getTime() - range[1].time) * sign > 0) {
  54648. allDay -= sign;
  54649. date.setDate(startDateNum + allDay - 1);
  54650. }
  54651. }
  54652. var weeks = Math.floor((allDay + range[0].day + 6) / 7);
  54653. var nthWeek = reversed ? -weeks + 1: weeks - 1;
  54654. reversed && range.reverse();
  54655. return {
  54656. range: [range[0].formatedDate, range[1].formatedDate],
  54657. start: range[0],
  54658. end: range[1],
  54659. allDay: allDay,
  54660. weeks: weeks,
  54661. // From 0.
  54662. nthWeek: nthWeek,
  54663. fweek: range[0].day,
  54664. lweek: range[1].day
  54665. };
  54666. },
  54667. /**
  54668. * get date by nthWeeks and week day in range
  54669. *
  54670. * @private
  54671. * @param {number} nthWeek the week
  54672. * @param {number} day the week day
  54673. * @param {Array} range [d1, d2]
  54674. * @return {Object}
  54675. */
  54676. _getDateByWeeksAndDay: function (nthWeek, day, range) {
  54677. var rangeInfo = this._getRangeInfo(range);
  54678. if (nthWeek > rangeInfo.weeks
  54679. || (nthWeek === 0 && day < rangeInfo.fweek)
  54680. || (nthWeek === rangeInfo.weeks && day > rangeInfo.lweek)
  54681. ) {
  54682. return false;
  54683. }
  54684. var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
  54685. var date = new Date(rangeInfo.start.time);
  54686. date.setDate(rangeInfo.start.d + nthDay);
  54687. return this.getDateInfo(date);
  54688. }
  54689. };
  54690. Calendar.dimensions = Calendar.prototype.dimensions;
  54691. Calendar.getDimensionsInfo = Calendar.prototype.getDimensionsInfo;
  54692. Calendar.create = function (ecModel, api) {
  54693. var calendarList = [];
  54694. ecModel.eachComponent('calendar', function (calendarModel) {
  54695. var calendar = new Calendar(calendarModel, ecModel, api);
  54696. calendarList.push(calendar);
  54697. calendarModel.coordinateSystem = calendar;
  54698. });
  54699. ecModel.eachSeries(function (calendarSeries) {
  54700. if (calendarSeries.get('coordinateSystem') === 'calendar') {
  54701. // Inject coordinate system
  54702. calendarSeries.coordinateSystem = calendarList[calendarSeries.get('calendarIndex') || 0];
  54703. }
  54704. });
  54705. return calendarList;
  54706. };
  54707. function doConvert(methodName, ecModel, finder, value) {
  54708. var calendarModel = finder.calendarModel;
  54709. var seriesModel = finder.seriesModel;
  54710. var coordSys = calendarModel
  54711. ? calendarModel.coordinateSystem
  54712. : seriesModel
  54713. ? seriesModel.coordinateSystem
  54714. : null;
  54715. return coordSys === this ? coordSys[methodName](value) : null;
  54716. }
  54717. __webpack_require__(79).register('calendar', Calendar);
  54718. module.exports = Calendar;
  54719. /***/ }),
  54720. /* 368 */
  54721. /***/ (function(module, exports, __webpack_require__) {
  54722. 'use strict';
  54723. var ComponentModel = __webpack_require__(72);
  54724. var zrUtil = __webpack_require__(4);
  54725. var layout = __webpack_require__(74);
  54726. var CalendarModel = ComponentModel.extend({
  54727. type: 'calendar',
  54728. /**
  54729. * @type {module:echarts/coord/calendar/Calendar}
  54730. */
  54731. coordinateSystem: null,
  54732. defaultOption: {
  54733. zlevel: 0,
  54734. z: 2,
  54735. left: 80,
  54736. top: 60,
  54737. cellSize: 20,
  54738. // horizontal vertical
  54739. orient: 'horizontal',
  54740. // month separate line style
  54741. splitLine: {
  54742. show: true,
  54743. lineStyle: {
  54744. color: '#000',
  54745. width: 1,
  54746. type: 'solid'
  54747. }
  54748. },
  54749. // rect style temporarily unused emphasis
  54750. itemStyle: {
  54751. normal: {
  54752. color: '#fff',
  54753. borderWidth: 1,
  54754. borderColor: '#ccc'
  54755. }
  54756. },
  54757. // week text style
  54758. dayLabel: {
  54759. show: true,
  54760. // a week first day
  54761. firstDay: 0,
  54762. // start end
  54763. position: 'start',
  54764. margin: '50%', // 50% of cellSize
  54765. nameMap: 'en',
  54766. color: '#000'
  54767. },
  54768. // month text style
  54769. monthLabel: {
  54770. show: true,
  54771. // start end
  54772. position: 'start',
  54773. margin: 5,
  54774. // center or left
  54775. align: 'center',
  54776. // cn en []
  54777. nameMap: 'en',
  54778. formatter: null,
  54779. color: '#000'
  54780. },
  54781. // year text style
  54782. yearLabel: {
  54783. show: true,
  54784. // top bottom left right
  54785. position: null,
  54786. margin: 30,
  54787. formatter: null,
  54788. color: '#ccc',
  54789. fontFamily: 'sans-serif',
  54790. fontWeight: 'bolder',
  54791. fontSize: 20
  54792. }
  54793. },
  54794. /**
  54795. * @override
  54796. */
  54797. init: function (option, parentModel, ecModel, extraOpt) {
  54798. var inputPositionParams = layout.getLayoutParams(option);
  54799. CalendarModel.superApply(this, 'init', arguments);
  54800. mergeAndNormalizeLayoutParams(option, inputPositionParams);
  54801. },
  54802. /**
  54803. * @override
  54804. */
  54805. mergeOption: function (option, extraOpt) {
  54806. CalendarModel.superApply(this, 'mergeOption', arguments);
  54807. mergeAndNormalizeLayoutParams(this.option, option);
  54808. }
  54809. });
  54810. function mergeAndNormalizeLayoutParams(target, raw) {
  54811. // Normalize cellSize
  54812. var cellSize = target.cellSize;
  54813. if (!zrUtil.isArray(cellSize)) {
  54814. cellSize = target.cellSize = [cellSize, cellSize];
  54815. }
  54816. else if (cellSize.length === 1) {
  54817. cellSize[1] = cellSize[0];
  54818. }
  54819. var ignoreSize = zrUtil.map([0, 1], function (hvIdx) {
  54820. // If user have set `width` or both `left` and `right`, cellSize
  54821. // will be automatically set to 'auto', otherwise the default
  54822. // setting of cellSize will make `width` setting not work.
  54823. if (layout.sizeCalculable(raw, hvIdx)) {
  54824. cellSize[hvIdx] = 'auto';
  54825. }
  54826. return cellSize[hvIdx] != null && cellSize[hvIdx] !== 'auto';
  54827. });
  54828. layout.mergeLayoutParam(target, raw, {
  54829. type: 'box', ignoreSize: ignoreSize
  54830. });
  54831. }
  54832. module.exports = CalendarModel;
  54833. /***/ }),
  54834. /* 369 */
  54835. /***/ (function(module, exports, __webpack_require__) {
  54836. 'use strict';
  54837. var zrUtil = __webpack_require__(4);
  54838. var graphic = __webpack_require__(20);
  54839. var formatUtil = __webpack_require__(6);
  54840. var numberUtil = __webpack_require__(7);
  54841. var MONTH_TEXT = {
  54842. EN: [
  54843. 'Jan', 'Feb', 'Mar',
  54844. 'Apr', 'May', 'Jun',
  54845. 'Jul', 'Aug', 'Sep',
  54846. 'Oct', 'Nov', 'Dec'
  54847. ],
  54848. CN: [
  54849. '一月', '二月', '三月',
  54850. '四月', '五月', '六月',
  54851. '七月', '八月', '九月',
  54852. '十月', '十一月', '十二月'
  54853. ]
  54854. };
  54855. var WEEK_TEXT = {
  54856. EN: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
  54857. CN: ['日', '一', '二', '三', '四', '五', '六']
  54858. };
  54859. module.exports = __webpack_require__(1).extendComponentView({
  54860. type: 'calendar',
  54861. /**
  54862. * top/left line points
  54863. * @private
  54864. */
  54865. _tlpoints: null,
  54866. /**
  54867. * bottom/right line points
  54868. * @private
  54869. */
  54870. _blpoints: null,
  54871. /**
  54872. * first day of month
  54873. * @private
  54874. */
  54875. _firstDayOfMonth: null,
  54876. /**
  54877. * first day point of month
  54878. * @private
  54879. */
  54880. _firstDayPoints: null,
  54881. render: function (calendarModel, ecModel, api) {
  54882. var group = this.group;
  54883. group.removeAll();
  54884. var coordSys = calendarModel.coordinateSystem;
  54885. // range info
  54886. var rangeData = coordSys.getRangeInfo();
  54887. var orient = coordSys.getOrient();
  54888. this._renderDayRect(calendarModel, rangeData, group);
  54889. // _renderLines must be called prior to following function
  54890. this._renderLines(calendarModel, rangeData, orient, group);
  54891. this._renderYearText(calendarModel, rangeData, orient, group);
  54892. this._renderMonthText(calendarModel, orient, group);
  54893. this._renderWeekText(calendarModel, rangeData, orient, group);
  54894. },
  54895. // render day rect
  54896. _renderDayRect: function (calendarModel, rangeData, group) {
  54897. var coordSys = calendarModel.coordinateSystem;
  54898. var itemRectStyleModel = calendarModel.getModel('itemStyle.normal').getItemStyle();
  54899. var sw = coordSys.getCellWidth();
  54900. var sh = coordSys.getCellHeight();
  54901. for (var i = rangeData.start.time;
  54902. i <= rangeData.end.time;
  54903. i = coordSys.getNextNDay(i, 1).time
  54904. ) {
  54905. var point = coordSys.dataToRect([i], false).tl;
  54906. // every rect
  54907. var rect = new graphic.Rect({
  54908. shape: {
  54909. x: point[0],
  54910. y: point[1],
  54911. width: sw,
  54912. height: sh
  54913. },
  54914. cursor: 'default',
  54915. style: itemRectStyleModel
  54916. });
  54917. group.add(rect);
  54918. }
  54919. },
  54920. // render separate line
  54921. _renderLines: function (calendarModel, rangeData, orient, group) {
  54922. var self = this;
  54923. var coordSys = calendarModel.coordinateSystem;
  54924. var lineStyleModel = calendarModel.getModel('splitLine.lineStyle').getLineStyle();
  54925. var show = calendarModel.get('splitLine.show');
  54926. var lineWidth = lineStyleModel.lineWidth;
  54927. this._tlpoints = [];
  54928. this._blpoints = [];
  54929. this._firstDayOfMonth = [];
  54930. this._firstDayPoints = [];
  54931. var firstDay = rangeData.start;
  54932. for (var i = 0; firstDay.time <= rangeData.end.time; i++) {
  54933. addPoints(firstDay.formatedDate);
  54934. if (i === 0) {
  54935. firstDay = coordSys.getDateInfo(rangeData.start.y + '-' + rangeData.start.m);
  54936. }
  54937. var date = firstDay.date;
  54938. date.setMonth(date.getMonth() + 1);
  54939. firstDay = coordSys.getDateInfo(date);
  54940. }
  54941. addPoints(coordSys.getNextNDay(rangeData.end.time, 1).formatedDate);
  54942. function addPoints(date) {
  54943. self._firstDayOfMonth.push(coordSys.getDateInfo(date));
  54944. self._firstDayPoints.push(coordSys.dataToRect([date], false).tl);
  54945. var points = self._getLinePointsOfOneWeek(calendarModel, date, orient);
  54946. self._tlpoints.push(points[0]);
  54947. self._blpoints.push(points[points.length - 1]);
  54948. show && self._drawSplitline(points, lineStyleModel, group);
  54949. }
  54950. // render top/left line
  54951. show && this._drawSplitline(self._getEdgesPoints(self._tlpoints, lineWidth, orient), lineStyleModel, group);
  54952. // render bottom/right line
  54953. show && this._drawSplitline(self._getEdgesPoints(self._blpoints, lineWidth, orient), lineStyleModel, group);
  54954. },
  54955. // get points at both ends
  54956. _getEdgesPoints: function (points, lineWidth, orient) {
  54957. var rs = [points[0].slice(), points[points.length - 1].slice()];
  54958. var idx = orient === 'horizontal' ? 0 : 1;
  54959. // both ends of the line are extend half lineWidth
  54960. rs[0][idx] = rs[0][idx] - lineWidth / 2;
  54961. rs[1][idx] = rs[1][idx] + lineWidth / 2;
  54962. return rs;
  54963. },
  54964. // render split line
  54965. _drawSplitline: function (points, lineStyleModel, group) {
  54966. var poyline = new graphic.Polyline({
  54967. z2: 20,
  54968. shape: {
  54969. points: points
  54970. },
  54971. style: lineStyleModel
  54972. });
  54973. group.add(poyline);
  54974. },
  54975. // render month line of one week points
  54976. _getLinePointsOfOneWeek: function (calendarModel, date, orient) {
  54977. var coordSys = calendarModel.coordinateSystem;
  54978. date = coordSys.getDateInfo(date);
  54979. var points = [];
  54980. for (var i = 0; i < 7; i++) {
  54981. var tmpD = coordSys.getNextNDay(date.time, i);
  54982. var point = coordSys.dataToRect([tmpD.time], false);
  54983. points[2 * tmpD.day] = point.tl;
  54984. points[2 * tmpD.day + 1] = point[orient === 'horizontal' ? 'bl' : 'tr'];
  54985. }
  54986. return points;
  54987. },
  54988. _formatterLabel: function (formatter, params) {
  54989. if (typeof formatter === 'string' && formatter) {
  54990. return formatUtil.formatTplSimple(formatter, params);
  54991. }
  54992. if (typeof formatter === 'function') {
  54993. return formatter(params);
  54994. }
  54995. return params.nameMap;
  54996. },
  54997. _yearTextPositionControl: function (textEl, point, orient, position, margin) {
  54998. point = point.slice();
  54999. var aligns = ['center', 'bottom'];
  55000. if (position === 'bottom') {
  55001. point[1] += margin;
  55002. aligns = ['center', 'top'];
  55003. }
  55004. else if (position === 'left') {
  55005. point[0] -= margin;
  55006. }
  55007. else if (position === 'right') {
  55008. point[0] += margin;
  55009. aligns = ['center', 'top'];
  55010. }
  55011. else { // top
  55012. point[1] -= margin;
  55013. }
  55014. var rotate = 0;
  55015. if (position === 'left' || position === 'right') {
  55016. rotate = Math.PI / 2;
  55017. }
  55018. return {
  55019. rotation: rotate,
  55020. position: point,
  55021. style: {
  55022. textAlign: aligns[0],
  55023. textVerticalAlign: aligns[1]
  55024. }
  55025. };
  55026. },
  55027. // render year
  55028. _renderYearText: function (calendarModel, rangeData, orient, group) {
  55029. var yearLabel = calendarModel.getModel('yearLabel');
  55030. if (!yearLabel.get('show')) {
  55031. return;
  55032. }
  55033. var margin = yearLabel.get('margin');
  55034. var pos = yearLabel.get('position');
  55035. if (!pos) {
  55036. pos = orient !== 'horizontal' ? 'top' : 'left';
  55037. }
  55038. var points = [this._tlpoints[this._tlpoints.length - 1], this._blpoints[0]];
  55039. var xc = (points[0][0] + points[1][0]) / 2;
  55040. var yc = (points[0][1] + points[1][1]) / 2;
  55041. var idx = orient === 'horizontal' ? 0 : 1;
  55042. var posPoints = {
  55043. top: [xc, points[idx][1]],
  55044. bottom: [xc, points[1 - idx][1]],
  55045. left: [points[1 - idx][0], yc],
  55046. right: [points[idx][0], yc]
  55047. };
  55048. var name = rangeData.start.y;
  55049. if (+rangeData.end.y > +rangeData.start.y) {
  55050. name = name + '-' + rangeData.end.y;
  55051. }
  55052. var formatter = yearLabel.get('formatter');
  55053. var params = {
  55054. start: rangeData.start.y,
  55055. end: rangeData.end.y,
  55056. nameMap: name
  55057. };
  55058. var content = this._formatterLabel(formatter, params);
  55059. var yearText = new graphic.Text({z2: 30});
  55060. graphic.setTextStyle(yearText.style, yearLabel, {text: content}),
  55061. yearText.attr(this._yearTextPositionControl(yearText, posPoints[pos], orient, pos, margin));
  55062. group.add(yearText);
  55063. },
  55064. _monthTextPositionControl: function (point, isCenter, orient, position, margin) {
  55065. var align = 'left';
  55066. var vAlign = 'top';
  55067. var x = point[0];
  55068. var y = point[1];
  55069. if (orient === 'horizontal') {
  55070. y = y + margin;
  55071. if (isCenter) {
  55072. align = 'center';
  55073. }
  55074. if (position === 'start') {
  55075. vAlign = 'bottom';
  55076. }
  55077. }
  55078. else {
  55079. x = x + margin;
  55080. if (isCenter) {
  55081. vAlign = 'middle';
  55082. }
  55083. if (position === 'start') {
  55084. align = 'right';
  55085. }
  55086. }
  55087. return {
  55088. x: x,
  55089. y: y,
  55090. textAlign: align,
  55091. textVerticalAlign: vAlign
  55092. };
  55093. },
  55094. // render month and year text
  55095. _renderMonthText: function (calendarModel, orient, group) {
  55096. var monthLabel = calendarModel.getModel('monthLabel');
  55097. if (!monthLabel.get('show')) {
  55098. return;
  55099. }
  55100. var nameMap = monthLabel.get('nameMap');
  55101. var margin = monthLabel.get('margin');
  55102. var pos = monthLabel.get('position');
  55103. var align = monthLabel.get('align');
  55104. var termPoints = [this._tlpoints, this._blpoints];
  55105. if (zrUtil.isString(nameMap)) {
  55106. nameMap = MONTH_TEXT[nameMap.toUpperCase()] || [];
  55107. }
  55108. var idx = pos === 'start' ? 0 : 1;
  55109. var axis = orient === 'horizontal' ? 0 : 1;
  55110. margin = pos === 'start' ? -margin : margin;
  55111. var isCenter = (align === 'center');
  55112. for (var i = 0; i < termPoints[idx].length - 1; i++) {
  55113. var tmp = termPoints[idx][i].slice();
  55114. var firstDay = this._firstDayOfMonth[i];
  55115. if (isCenter) {
  55116. var firstDayPoints = this._firstDayPoints[i];
  55117. tmp[axis] = (firstDayPoints[axis] + termPoints[0][i + 1][axis]) / 2;
  55118. }
  55119. var formatter = monthLabel.get('formatter');
  55120. var name = nameMap[+firstDay.m - 1];
  55121. var params = {
  55122. yyyy: firstDay.y,
  55123. yy: (firstDay.y + '').slice(2),
  55124. MM: firstDay.m,
  55125. M: +firstDay.m,
  55126. nameMap: name
  55127. };
  55128. var content = this._formatterLabel(formatter, params);
  55129. var monthText = new graphic.Text({z2: 30});
  55130. zrUtil.extend(
  55131. graphic.setTextStyle(monthText.style, monthLabel, {text: content}),
  55132. this._monthTextPositionControl(tmp, isCenter, orient, pos, margin)
  55133. );
  55134. group.add(monthText);
  55135. }
  55136. },
  55137. _weekTextPositionControl: function (point, orient, position, margin, cellSize) {
  55138. var align = 'center';
  55139. var vAlign = 'middle';
  55140. var x = point[0];
  55141. var y = point[1];
  55142. var isStart = position === 'start';
  55143. if (orient === 'horizontal') {
  55144. x = x + margin + (isStart ? 1 : -1) * cellSize[0] / 2;
  55145. align = isStart ? 'right' : 'left';
  55146. }
  55147. else {
  55148. y = y + margin + (isStart ? 1 : -1) * cellSize[1] / 2;
  55149. vAlign = isStart ? 'bottom' : 'top';
  55150. }
  55151. return {
  55152. x: x,
  55153. y: y,
  55154. textAlign: align,
  55155. textVerticalAlign: vAlign
  55156. };
  55157. },
  55158. // render weeks
  55159. _renderWeekText: function (calendarModel, rangeData, orient, group) {
  55160. var dayLabel = calendarModel.getModel('dayLabel');
  55161. if (!dayLabel.get('show')) {
  55162. return;
  55163. }
  55164. var coordSys = calendarModel.coordinateSystem;
  55165. var pos = dayLabel.get('position');
  55166. var nameMap = dayLabel.get('nameMap');
  55167. var margin = dayLabel.get('margin');
  55168. var firstDayOfWeek = coordSys.getFirstDayOfWeek();
  55169. if (zrUtil.isString(nameMap)) {
  55170. nameMap = WEEK_TEXT[nameMap.toUpperCase()] || [];
  55171. }
  55172. var start = coordSys.getNextNDay(
  55173. rangeData.end.time, (7 - rangeData.lweek)
  55174. ).time;
  55175. var cellSize = [coordSys.getCellWidth(), coordSys.getCellHeight()];
  55176. margin = numberUtil.parsePercent(margin, cellSize[orient === 'horizontal' ? 0 : 1]);
  55177. if (pos === 'start') {
  55178. start = coordSys.getNextNDay(
  55179. rangeData.start.time, -(7 + rangeData.fweek)
  55180. ).time;
  55181. margin = -margin;
  55182. }
  55183. for (var i = 0; i < 7; i++) {
  55184. var tmpD = coordSys.getNextNDay(start, i);
  55185. var point = coordSys.dataToRect([tmpD.time], false).center;
  55186. var day = i;
  55187. day = Math.abs((i + firstDayOfWeek) % 7);
  55188. var weekText = new graphic.Text({z2: 30});
  55189. zrUtil.extend(
  55190. graphic.setTextStyle(weekText.style, dayLabel, {text: nameMap[day]}),
  55191. this._weekTextPositionControl(point, orient, pos, margin, cellSize)
  55192. );
  55193. group.add(weekText);
  55194. }
  55195. }
  55196. });
  55197. /***/ }),
  55198. /* 370 */
  55199. /***/ (function(module, exports, __webpack_require__) {
  55200. 'use strict';
  55201. var echarts = __webpack_require__(1);
  55202. var graphic = __webpack_require__(20);
  55203. var layout = __webpack_require__(74);
  55204. // Model
  55205. echarts.extendComponentModel({
  55206. type: 'title',
  55207. layoutMode: {type: 'box', ignoreSize: true},
  55208. defaultOption: {
  55209. // 一级层叠
  55210. zlevel: 0,
  55211. // 二级层叠
  55212. z: 6,
  55213. show: true,
  55214. text: '',
  55215. // 超链接跳转
  55216. // link: null,
  55217. // 仅支持self | blank
  55218. target: 'blank',
  55219. subtext: '',
  55220. // 超链接跳转
  55221. // sublink: null,
  55222. // 仅支持self | blank
  55223. subtarget: 'blank',
  55224. // 'center' ¦ 'left' ¦ 'right'
  55225. // ¦ {number}(x坐标,单位px)
  55226. left: 0,
  55227. // 'top' ¦ 'bottom' ¦ 'center'
  55228. // ¦ {number}(y坐标,单位px)
  55229. top: 0,
  55230. // 水平对齐
  55231. // 'auto' | 'left' | 'right' | 'center'
  55232. // 默认根据 left 的位置判断是左对齐还是右对齐
  55233. // textAlign: null
  55234. //
  55235. // 垂直对齐
  55236. // 'auto' | 'top' | 'bottom' | 'middle'
  55237. // 默认根据 top 位置判断是上对齐还是下对齐
  55238. // textBaseline: null
  55239. backgroundColor: 'rgba(0,0,0,0)',
  55240. // 标题边框颜色
  55241. borderColor: '#ccc',
  55242. // 标题边框线宽,单位px,默认为0(无边框)
  55243. borderWidth: 0,
  55244. // 标题内边距,单位px,默认各方向内边距为5,
  55245. // 接受数组分别设定上右下左边距,同css
  55246. padding: 5,
  55247. // 主副标题纵向间隔,单位px,默认为10,
  55248. itemGap: 10,
  55249. textStyle: {
  55250. fontSize: 18,
  55251. fontWeight: 'bolder',
  55252. color: '#333'
  55253. },
  55254. subtextStyle: {
  55255. color: '#aaa'
  55256. }
  55257. }
  55258. });
  55259. // View
  55260. echarts.extendComponentView({
  55261. type: 'title',
  55262. render: function (titleModel, ecModel, api) {
  55263. this.group.removeAll();
  55264. if (!titleModel.get('show')) {
  55265. return;
  55266. }
  55267. var group = this.group;
  55268. var textStyleModel = titleModel.getModel('textStyle');
  55269. var subtextStyleModel = titleModel.getModel('subtextStyle');
  55270. var textAlign = titleModel.get('textAlign');
  55271. var textBaseline = titleModel.get('textBaseline');
  55272. var textEl = new graphic.Text({
  55273. style: graphic.setTextStyle({}, textStyleModel, {
  55274. text: titleModel.get('text'),
  55275. textFill: textStyleModel.getTextColor()
  55276. }, {disableBox: true}),
  55277. z2: 10
  55278. });
  55279. var textRect = textEl.getBoundingRect();
  55280. var subText = titleModel.get('subtext');
  55281. var subTextEl = new graphic.Text({
  55282. style: graphic.setTextStyle({}, subtextStyleModel, {
  55283. text: subText,
  55284. textFill: subtextStyleModel.getTextColor(),
  55285. y: textRect.height + titleModel.get('itemGap'),
  55286. textVerticalAlign: 'top'
  55287. }, {disableBox: true}),
  55288. z2: 10
  55289. });
  55290. var link = titleModel.get('link');
  55291. var sublink = titleModel.get('sublink');
  55292. textEl.silent = !link;
  55293. subTextEl.silent = !sublink;
  55294. if (link) {
  55295. textEl.on('click', function () {
  55296. window.open(link, '_' + titleModel.get('target'));
  55297. });
  55298. }
  55299. if (sublink) {
  55300. subTextEl.on('click', function () {
  55301. window.open(sublink, '_' + titleModel.get('subtarget'));
  55302. });
  55303. }
  55304. group.add(textEl);
  55305. subText && group.add(subTextEl);
  55306. // If no subText, but add subTextEl, there will be an empty line.
  55307. var groupRect = group.getBoundingRect();
  55308. var layoutOption = titleModel.getBoxLayoutParams();
  55309. layoutOption.width = groupRect.width;
  55310. layoutOption.height = groupRect.height;
  55311. var layoutRect = layout.getLayoutRect(
  55312. layoutOption, {
  55313. width: api.getWidth(),
  55314. height: api.getHeight()
  55315. }, titleModel.get('padding')
  55316. );
  55317. // Adjust text align based on position
  55318. if (!textAlign) {
  55319. // Align left if title is on the left. center and right is same
  55320. textAlign = titleModel.get('left') || titleModel.get('right');
  55321. if (textAlign === 'middle') {
  55322. textAlign = 'center';
  55323. }
  55324. // Adjust layout by text align
  55325. if (textAlign === 'right') {
  55326. layoutRect.x += layoutRect.width;
  55327. }
  55328. else if (textAlign === 'center') {
  55329. layoutRect.x += layoutRect.width / 2;
  55330. }
  55331. }
  55332. if (!textBaseline) {
  55333. textBaseline = titleModel.get('top') || titleModel.get('bottom');
  55334. if (textBaseline === 'center') {
  55335. textBaseline = 'middle';
  55336. }
  55337. if (textBaseline === 'bottom') {
  55338. layoutRect.y += layoutRect.height;
  55339. }
  55340. else if (textBaseline === 'middle') {
  55341. layoutRect.y += layoutRect.height / 2;
  55342. }
  55343. textBaseline = textBaseline || 'top';
  55344. }
  55345. group.attr('position', [layoutRect.x, layoutRect.y]);
  55346. var alignStyle = {
  55347. textAlign: textAlign,
  55348. textVerticalAlign: textBaseline
  55349. };
  55350. textEl.setStyle(alignStyle);
  55351. subTextEl.setStyle(alignStyle);
  55352. // Render background
  55353. // Get groupRect again because textAlign has been changed
  55354. groupRect = group.getBoundingRect();
  55355. var padding = layoutRect.margin;
  55356. var style = titleModel.getItemStyle(['color', 'opacity']);
  55357. style.fill = titleModel.get('backgroundColor');
  55358. var rect = new graphic.Rect({
  55359. shape: {
  55360. x: groupRect.x - padding[3],
  55361. y: groupRect.y - padding[0],
  55362. width: groupRect.width + padding[1] + padding[3],
  55363. height: groupRect.height + padding[0] + padding[2],
  55364. r: titleModel.get('borderRadius')
  55365. },
  55366. style: style,
  55367. silent: true
  55368. });
  55369. graphic.subPixelOptimizeRect(rect);
  55370. group.add(rect);
  55371. }
  55372. });
  55373. /***/ }),
  55374. /* 371 */
  55375. /***/ (function(module, exports, __webpack_require__) {
  55376. /**
  55377. * DataZoom component entry
  55378. */
  55379. __webpack_require__(372);
  55380. __webpack_require__(373);
  55381. __webpack_require__(376);
  55382. __webpack_require__(377);
  55383. __webpack_require__(378);
  55384. __webpack_require__(379);
  55385. __webpack_require__(380);
  55386. __webpack_require__(382);
  55387. __webpack_require__(383);
  55388. /***/ }),
  55389. /* 372 */
  55390. /***/ (function(module, exports, __webpack_require__) {
  55391. __webpack_require__(72).registerSubTypeDefaulter('dataZoom', function () {
  55392. // Default 'slider' when no type specified.
  55393. return 'slider';
  55394. });
  55395. /***/ }),
  55396. /* 373 */
  55397. /***/ (function(module, exports, __webpack_require__) {
  55398. /**
  55399. * @file Data zoom model
  55400. */
  55401. var zrUtil = __webpack_require__(4);
  55402. var env = __webpack_require__(2);
  55403. var echarts = __webpack_require__(1);
  55404. var modelUtil = __webpack_require__(5);
  55405. var helper = __webpack_require__(374);
  55406. var AxisProxy = __webpack_require__(375);
  55407. var each = zrUtil.each;
  55408. var eachAxisDim = helper.eachAxisDim;
  55409. var DataZoomModel = echarts.extendComponentModel({
  55410. type: 'dataZoom',
  55411. dependencies: [
  55412. 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'singleAxis', 'series'
  55413. ],
  55414. /**
  55415. * @protected
  55416. */
  55417. defaultOption: {
  55418. zlevel: 0,
  55419. z: 4, // Higher than normal component (z: 2).
  55420. orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'.
  55421. xAxisIndex: null, // Default the first horizontal category axis.
  55422. yAxisIndex: null, // Default the first vertical category axis.
  55423. filterMode: 'filter', // Possible values: 'filter' or 'empty' or 'weakFilter'.
  55424. // 'filter': data items which are out of window will be removed. This option is
  55425. // applicable when filtering outliers. For each data item, it will be
  55426. // filtered if one of the relevant dimensions is out of the window.
  55427. // 'weakFilter': data items which are out of window will be removed. This option
  55428. // is applicable when filtering outliers. For each data item, it will be
  55429. // filtered only if all of the relevant dimensions are out of the same
  55430. // side of the window.
  55431. // 'empty': data items which are out of window will be set to empty.
  55432. // This option is applicable when user should not neglect
  55433. // that there are some data items out of window.
  55434. // 'none': Do not filter.
  55435. // Taking line chart as an example, line will be broken in
  55436. // the filtered points when filterModel is set to 'empty', but
  55437. // be connected when set to 'filter'.
  55438. throttle: null, // Dispatch action by the fixed rate, avoid frequency.
  55439. // default 100. Do not throttle when use null/undefined.
  55440. // If animation === true and animationDurationUpdate > 0,
  55441. // default value is 100, otherwise 20.
  55442. start: 0, // Start percent. 0 ~ 100
  55443. end: 100, // End percent. 0 ~ 100
  55444. startValue: null, // Start value. If startValue specified, start is ignored.
  55445. endValue: null, // End value. If endValue specified, end is ignored.
  55446. minSpan: null, // 0 ~ 100
  55447. maxSpan: null, // 0 ~ 100
  55448. minValueSpan: null, // The range of dataZoom can not be smaller than that.
  55449. maxValueSpan: null, // The range of dataZoom can not be larger than that.
  55450. rangeMode: null // Array, can be 'value' or 'percent'.
  55451. },
  55452. /**
  55453. * @override
  55454. */
  55455. init: function (option, parentModel, ecModel) {
  55456. /**
  55457. * key like x_0, y_1
  55458. * @private
  55459. * @type {Object}
  55460. */
  55461. this._dataIntervalByAxis = {};
  55462. /**
  55463. * @private
  55464. */
  55465. this._dataInfo = {};
  55466. /**
  55467. * key like x_0, y_1
  55468. * @private
  55469. */
  55470. this._axisProxies = {};
  55471. /**
  55472. * @readOnly
  55473. */
  55474. this.textStyleModel;
  55475. /**
  55476. * @private
  55477. */
  55478. this._autoThrottle = true;
  55479. /**
  55480. * 'percent' or 'value'
  55481. * @private
  55482. */
  55483. this._rangePropMode = ['percent', 'percent'];
  55484. var rawOption = retrieveRaw(option);
  55485. this.mergeDefaultAndTheme(option, ecModel);
  55486. this.doInit(rawOption);
  55487. },
  55488. /**
  55489. * @override
  55490. */
  55491. mergeOption: function (newOption) {
  55492. var rawOption = retrieveRaw(newOption);
  55493. //FIX #2591
  55494. zrUtil.merge(this.option, newOption, true);
  55495. this.doInit(rawOption);
  55496. },
  55497. /**
  55498. * @protected
  55499. */
  55500. doInit: function (rawOption) {
  55501. var thisOption = this.option;
  55502. // Disable realtime view update if canvas is not supported.
  55503. if (!env.canvasSupported) {
  55504. thisOption.realtime = false;
  55505. }
  55506. this._setDefaultThrottle(rawOption);
  55507. updateRangeUse(this, rawOption);
  55508. each([['start', 'startValue'], ['end', 'endValue']], function (names, index) {
  55509. // start/end has higher priority over startValue/endValue if they
  55510. // both set, but we should make chart.setOption({endValue: 1000})
  55511. // effective, rather than chart.setOption({endValue: 1000, end: null}).
  55512. if (this._rangePropMode[index] === 'value') {
  55513. thisOption[names[0]] = null;
  55514. }
  55515. // Otherwise do nothing and use the merge result.
  55516. }, this);
  55517. this.textStyleModel = this.getModel('textStyle');
  55518. this._resetTarget();
  55519. this._giveAxisProxies();
  55520. },
  55521. /**
  55522. * @private
  55523. */
  55524. _giveAxisProxies: function () {
  55525. var axisProxies = this._axisProxies;
  55526. this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) {
  55527. var axisModel = this.dependentModels[dimNames.axis][axisIndex];
  55528. // If exists, share axisProxy with other dataZoomModels.
  55529. var axisProxy = axisModel.__dzAxisProxy || (
  55530. // Use the first dataZoomModel as the main model of axisProxy.
  55531. axisModel.__dzAxisProxy = new AxisProxy(
  55532. dimNames.name, axisIndex, this, ecModel
  55533. )
  55534. );
  55535. // FIXME
  55536. // dispose __dzAxisProxy
  55537. axisProxies[dimNames.name + '_' + axisIndex] = axisProxy;
  55538. }, this);
  55539. },
  55540. /**
  55541. * @private
  55542. */
  55543. _resetTarget: function () {
  55544. var thisOption = this.option;
  55545. var autoMode = this._judgeAutoMode();
  55546. eachAxisDim(function (dimNames) {
  55547. var axisIndexName = dimNames.axisIndex;
  55548. thisOption[axisIndexName] = modelUtil.normalizeToArray(
  55549. thisOption[axisIndexName]
  55550. );
  55551. }, this);
  55552. if (autoMode === 'axisIndex') {
  55553. this._autoSetAxisIndex();
  55554. }
  55555. else if (autoMode === 'orient') {
  55556. this._autoSetOrient();
  55557. }
  55558. },
  55559. /**
  55560. * @private
  55561. */
  55562. _judgeAutoMode: function () {
  55563. // Auto set only works for setOption at the first time.
  55564. // The following is user's reponsibility. So using merged
  55565. // option is OK.
  55566. var thisOption = this.option;
  55567. var hasIndexSpecified = false;
  55568. eachAxisDim(function (dimNames) {
  55569. // When user set axisIndex as a empty array, we think that user specify axisIndex
  55570. // but do not want use auto mode. Because empty array may be encountered when
  55571. // some error occured.
  55572. if (thisOption[dimNames.axisIndex] != null) {
  55573. hasIndexSpecified = true;
  55574. }
  55575. }, this);
  55576. var orient = thisOption.orient;
  55577. if (orient == null && hasIndexSpecified) {
  55578. return 'orient';
  55579. }
  55580. else if (!hasIndexSpecified) {
  55581. if (orient == null) {
  55582. thisOption.orient = 'horizontal';
  55583. }
  55584. return 'axisIndex';
  55585. }
  55586. },
  55587. /**
  55588. * @private
  55589. */
  55590. _autoSetAxisIndex: function () {
  55591. var autoAxisIndex = true;
  55592. var orient = this.get('orient', true);
  55593. var thisOption = this.option;
  55594. var dependentModels = this.dependentModels;
  55595. if (autoAxisIndex) {
  55596. // Find axis that parallel to dataZoom as default.
  55597. var dimName = orient === 'vertical' ? 'y' : 'x';
  55598. if (dependentModels[dimName + 'Axis'].length) {
  55599. thisOption[dimName + 'AxisIndex'] = [0];
  55600. autoAxisIndex = false;
  55601. }
  55602. else {
  55603. each(dependentModels.singleAxis, function (singleAxisModel) {
  55604. if (autoAxisIndex && singleAxisModel.get('orient', true) === orient) {
  55605. thisOption.singleAxisIndex = [singleAxisModel.componentIndex];
  55606. autoAxisIndex = false;
  55607. }
  55608. });
  55609. }
  55610. }
  55611. if (autoAxisIndex) {
  55612. // Find the first category axis as default. (consider polar)
  55613. eachAxisDim(function (dimNames) {
  55614. if (!autoAxisIndex) {
  55615. return;
  55616. }
  55617. var axisIndices = [];
  55618. var axisModels = this.dependentModels[dimNames.axis];
  55619. if (axisModels.length && !axisIndices.length) {
  55620. for (var i = 0, len = axisModels.length; i < len; i++) {
  55621. if (axisModels[i].get('type') === 'category') {
  55622. axisIndices.push(i);
  55623. }
  55624. }
  55625. }
  55626. thisOption[dimNames.axisIndex] = axisIndices;
  55627. if (axisIndices.length) {
  55628. autoAxisIndex = false;
  55629. }
  55630. }, this);
  55631. }
  55632. if (autoAxisIndex) {
  55633. // FIXME
  55634. // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制),
  55635. // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)?
  55636. // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified,
  55637. // dataZoom component auto adopts series that reference to
  55638. // both xAxis and yAxis which type is 'value'.
  55639. this.ecModel.eachSeries(function (seriesModel) {
  55640. if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) {
  55641. eachAxisDim(function (dimNames) {
  55642. var axisIndices = thisOption[dimNames.axisIndex];
  55643. var axisIndex = seriesModel.get(dimNames.axisIndex);
  55644. var axisId = seriesModel.get(dimNames.axisId);
  55645. var axisModel = seriesModel.ecModel.queryComponents({
  55646. mainType: dimNames.axis,
  55647. index: axisIndex,
  55648. id: axisId
  55649. })[0];
  55650. if (true) {
  55651. if (!axisModel) {
  55652. throw new Error(
  55653. dimNames.axis + ' "' + zrUtil.retrieve(
  55654. axisIndex,
  55655. axisId,
  55656. 0
  55657. ) + '" not found'
  55658. );
  55659. }
  55660. }
  55661. axisIndex = axisModel.componentIndex;
  55662. if (zrUtil.indexOf(axisIndices, axisIndex) < 0) {
  55663. axisIndices.push(axisIndex);
  55664. }
  55665. });
  55666. }
  55667. }, this);
  55668. }
  55669. },
  55670. /**
  55671. * @private
  55672. */
  55673. _autoSetOrient: function () {
  55674. var dim;
  55675. // Find the first axis
  55676. this.eachTargetAxis(function (dimNames) {
  55677. !dim && (dim = dimNames.name);
  55678. }, this);
  55679. this.option.orient = dim === 'y' ? 'vertical' : 'horizontal';
  55680. },
  55681. /**
  55682. * @private
  55683. */
  55684. _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) {
  55685. // FIXME
  55686. // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。
  55687. // 例如series.type === scatter时。
  55688. var is = true;
  55689. eachAxisDim(function (dimNames) {
  55690. var seriesAxisIndex = seriesModel.get(dimNames.axisIndex);
  55691. var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex];
  55692. if (!axisModel || axisModel.get('type') !== axisType) {
  55693. is = false;
  55694. }
  55695. }, this);
  55696. return is;
  55697. },
  55698. /**
  55699. * @private
  55700. */
  55701. _setDefaultThrottle: function (rawOption) {
  55702. // When first time user set throttle, auto throttle ends.
  55703. if (rawOption.hasOwnProperty('throttle')) {
  55704. this._autoThrottle = false;
  55705. }
  55706. if (this._autoThrottle) {
  55707. var globalOption = this.ecModel.option;
  55708. this.option.throttle =
  55709. (globalOption.animation && globalOption.animationDurationUpdate > 0)
  55710. ? 100 : 20;
  55711. }
  55712. },
  55713. /**
  55714. * @public
  55715. */
  55716. getFirstTargetAxisModel: function () {
  55717. var firstAxisModel;
  55718. eachAxisDim(function (dimNames) {
  55719. if (firstAxisModel == null) {
  55720. var indices = this.get(dimNames.axisIndex);
  55721. if (indices.length) {
  55722. firstAxisModel = this.dependentModels[dimNames.axis][indices[0]];
  55723. }
  55724. }
  55725. }, this);
  55726. return firstAxisModel;
  55727. },
  55728. /**
  55729. * @public
  55730. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  55731. */
  55732. eachTargetAxis: function (callback, context) {
  55733. var ecModel = this.ecModel;
  55734. eachAxisDim(function (dimNames) {
  55735. each(
  55736. this.get(dimNames.axisIndex),
  55737. function (axisIndex) {
  55738. callback.call(context, dimNames, axisIndex, this, ecModel);
  55739. },
  55740. this
  55741. );
  55742. }, this);
  55743. },
  55744. /**
  55745. * @param {string} dimName
  55746. * @param {number} axisIndex
  55747. * @return {module:echarts/component/dataZoom/AxisProxy} If not found, return null/undefined.
  55748. */
  55749. getAxisProxy: function (dimName, axisIndex) {
  55750. return this._axisProxies[dimName + '_' + axisIndex];
  55751. },
  55752. /**
  55753. * @param {string} dimName
  55754. * @param {number} axisIndex
  55755. * @return {module:echarts/model/Model} If not found, return null/undefined.
  55756. */
  55757. getAxisModel: function (dimName, axisIndex) {
  55758. var axisProxy = this.getAxisProxy(dimName, axisIndex);
  55759. return axisProxy && axisProxy.getAxisModel();
  55760. },
  55761. /**
  55762. * If not specified, set to undefined.
  55763. *
  55764. * @public
  55765. * @param {Object} opt
  55766. * @param {number} [opt.start]
  55767. * @param {number} [opt.end]
  55768. * @param {number} [opt.startValue]
  55769. * @param {number} [opt.endValue]
  55770. * @param {boolean} [ignoreUpdateRangeUsg=false]
  55771. */
  55772. setRawRange: function (opt, ignoreUpdateRangeUsg) {
  55773. each(['start', 'end', 'startValue', 'endValue'], function (name) {
  55774. // If any of those prop is null/undefined, we should alos set
  55775. // them, because only one pair between start/end and
  55776. // startValue/endValue can work.
  55777. this.option[name] = opt[name];
  55778. }, this);
  55779. !ignoreUpdateRangeUsg && updateRangeUse(this, opt);
  55780. },
  55781. /**
  55782. * @public
  55783. * @return {Array.<number>} [startPercent, endPercent]
  55784. */
  55785. getPercentRange: function () {
  55786. var axisProxy = this.findRepresentativeAxisProxy();
  55787. if (axisProxy) {
  55788. return axisProxy.getDataPercentWindow();
  55789. }
  55790. },
  55791. /**
  55792. * @public
  55793. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  55794. *
  55795. * @param {string} [axisDimName]
  55796. * @param {number} [axisIndex]
  55797. * @return {Array.<number>} [startValue, endValue] value can only be '-' or finite number.
  55798. */
  55799. getValueRange: function (axisDimName, axisIndex) {
  55800. if (axisDimName == null && axisIndex == null) {
  55801. var axisProxy = this.findRepresentativeAxisProxy();
  55802. if (axisProxy) {
  55803. return axisProxy.getDataValueWindow();
  55804. }
  55805. }
  55806. else {
  55807. return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow();
  55808. }
  55809. },
  55810. /**
  55811. * @public
  55812. * @param {module:echarts/model/Model} [axisModel] If axisModel given, find axisProxy
  55813. * corresponding to the axisModel
  55814. * @return {module:echarts/component/dataZoom/AxisProxy}
  55815. */
  55816. findRepresentativeAxisProxy: function (axisModel) {
  55817. if (axisModel) {
  55818. return axisModel.__dzAxisProxy;
  55819. }
  55820. // Find the first hosted axisProxy
  55821. var axisProxies = this._axisProxies;
  55822. for (var key in axisProxies) {
  55823. if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) {
  55824. return axisProxies[key];
  55825. }
  55826. }
  55827. // If no hosted axis find not hosted axisProxy.
  55828. // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis,
  55829. // and the option.start or option.end settings are different. The percentRange
  55830. // should follow axisProxy.
  55831. // (We encounter this problem in toolbox data zoom.)
  55832. for (var key in axisProxies) {
  55833. if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) {
  55834. return axisProxies[key];
  55835. }
  55836. }
  55837. },
  55838. /**
  55839. * @return {Array.<string>}
  55840. */
  55841. getRangePropMode: function () {
  55842. return this._rangePropMode.slice();
  55843. }
  55844. });
  55845. function retrieveRaw(option) {
  55846. var ret = {};
  55847. each(
  55848. ['start', 'end', 'startValue', 'endValue', 'throttle'],
  55849. function (name) {
  55850. option.hasOwnProperty(name) && (ret[name] = option[name]);
  55851. }
  55852. );
  55853. return ret;
  55854. }
  55855. function updateRangeUse(dataZoomModel, rawOption) {
  55856. var rangePropMode = dataZoomModel._rangePropMode;
  55857. var rangeModeInOption = dataZoomModel.get('rangeMode');
  55858. each([['start', 'startValue'], ['end', 'endValue']], function (names, index) {
  55859. var percentSpecified = rawOption[names[0]] != null;
  55860. var valueSpecified = rawOption[names[1]] != null;
  55861. if (percentSpecified && !valueSpecified) {
  55862. rangePropMode[index] = 'percent';
  55863. }
  55864. else if (!percentSpecified && valueSpecified) {
  55865. rangePropMode[index] = 'value';
  55866. }
  55867. else if (rangeModeInOption) {
  55868. rangePropMode[index] = rangeModeInOption[index];
  55869. }
  55870. else if (percentSpecified) { // percentSpecified && valueSpecified
  55871. rangePropMode[index] = 'percent';
  55872. }
  55873. // else remain its original setting.
  55874. });
  55875. }
  55876. module.exports = DataZoomModel;
  55877. /***/ }),
  55878. /* 374 */
  55879. /***/ (function(module, exports, __webpack_require__) {
  55880. var formatUtil = __webpack_require__(6);
  55881. var zrUtil = __webpack_require__(4);
  55882. var helper = {};
  55883. var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle', 'single'];
  55884. // Supported coords.
  55885. var COORDS = ['cartesian2d', 'polar', 'singleAxis'];
  55886. /**
  55887. * @param {string} coordType
  55888. * @return {boolean}
  55889. */
  55890. helper.isCoordSupported = function (coordType) {
  55891. return zrUtil.indexOf(COORDS, coordType) >= 0;
  55892. };
  55893. /**
  55894. * Create "each" method to iterate names.
  55895. *
  55896. * @pubilc
  55897. * @param {Array.<string>} names
  55898. * @param {Array.<string>=} attrs
  55899. * @return {Function}
  55900. */
  55901. helper.createNameEach = function (names, attrs) {
  55902. names = names.slice();
  55903. var capitalNames = zrUtil.map(names, formatUtil.capitalFirst);
  55904. attrs = (attrs || []).slice();
  55905. var capitalAttrs = zrUtil.map(attrs, formatUtil.capitalFirst);
  55906. return function (callback, context) {
  55907. zrUtil.each(names, function (name, index) {
  55908. var nameObj = {name: name, capital: capitalNames[index]};
  55909. for (var j = 0; j < attrs.length; j++) {
  55910. nameObj[attrs[j]] = name + capitalAttrs[j];
  55911. }
  55912. callback.call(context, nameObj);
  55913. });
  55914. };
  55915. };
  55916. /**
  55917. * Iterate each dimension name.
  55918. *
  55919. * @public
  55920. * @param {Function} callback The parameter is like:
  55921. * {
  55922. * name: 'angle',
  55923. * capital: 'Angle',
  55924. * axis: 'angleAxis',
  55925. * axisIndex: 'angleAixs',
  55926. * index: 'angleIndex'
  55927. * }
  55928. * @param {Object} context
  55929. */
  55930. helper.eachAxisDim = helper.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index', 'id']);
  55931. /**
  55932. * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'.
  55933. * dataZoomModels and 'links' make up one or more graphics.
  55934. * This function finds the graphic where the source dataZoomModel is in.
  55935. *
  55936. * @public
  55937. * @param {Function} forEachNode Node iterator.
  55938. * @param {Function} forEachEdgeType edgeType iterator
  55939. * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id.
  55940. * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}}
  55941. */
  55942. helper.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
  55943. return function (sourceNode) {
  55944. var result = {
  55945. nodes: [],
  55946. records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean).
  55947. };
  55948. forEachEdgeType(function (edgeType) {
  55949. result.records[edgeType.name] = {};
  55950. });
  55951. if (!sourceNode) {
  55952. return result;
  55953. }
  55954. absorb(sourceNode, result);
  55955. var existsLink;
  55956. do {
  55957. existsLink = false;
  55958. forEachNode(processSingleNode);
  55959. }
  55960. while (existsLink);
  55961. function processSingleNode(node) {
  55962. if (!isNodeAbsorded(node, result) && isLinked(node, result)) {
  55963. absorb(node, result);
  55964. existsLink = true;
  55965. }
  55966. }
  55967. return result;
  55968. };
  55969. function isNodeAbsorded(node, result) {
  55970. return zrUtil.indexOf(result.nodes, node) >= 0;
  55971. }
  55972. function isLinked(node, result) {
  55973. var hasLink = false;
  55974. forEachEdgeType(function (edgeType) {
  55975. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  55976. result.records[edgeType.name][edgeId] && (hasLink = true);
  55977. });
  55978. });
  55979. return hasLink;
  55980. }
  55981. function absorb(node, result) {
  55982. result.nodes.push(node);
  55983. forEachEdgeType(function (edgeType) {
  55984. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  55985. result.records[edgeType.name][edgeId] = true;
  55986. });
  55987. });
  55988. }
  55989. };
  55990. module.exports = helper;
  55991. /***/ }),
  55992. /* 375 */
  55993. /***/ (function(module, exports, __webpack_require__) {
  55994. /**
  55995. * @file Axis operator
  55996. */
  55997. var zrUtil = __webpack_require__(4);
  55998. var numberUtil = __webpack_require__(7);
  55999. var helper = __webpack_require__(374);
  56000. var each = zrUtil.each;
  56001. var asc = numberUtil.asc;
  56002. /**
  56003. * Operate single axis.
  56004. * One axis can only operated by one axis operator.
  56005. * Different dataZoomModels may be defined to operate the same axis.
  56006. * (i.e. 'inside' data zoom and 'slider' data zoom components)
  56007. * So dataZoomModels share one axisProxy in that case.
  56008. *
  56009. * @class
  56010. */
  56011. var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) {
  56012. /**
  56013. * @private
  56014. * @type {string}
  56015. */
  56016. this._dimName = dimName;
  56017. /**
  56018. * @private
  56019. */
  56020. this._axisIndex = axisIndex;
  56021. /**
  56022. * @private
  56023. * @type {Array.<number>}
  56024. */
  56025. this._valueWindow;
  56026. /**
  56027. * @private
  56028. * @type {Array.<number>}
  56029. */
  56030. this._percentWindow;
  56031. /**
  56032. * @private
  56033. * @type {Array.<number>}
  56034. */
  56035. this._dataExtent;
  56036. /**
  56037. * {minSpan, maxSpan, minValueSpan, maxValueSpan}
  56038. * @private
  56039. * @type {Object}
  56040. */
  56041. this._minMaxSpan;
  56042. /**
  56043. * @readOnly
  56044. * @type {module: echarts/model/Global}
  56045. */
  56046. this.ecModel = ecModel;
  56047. /**
  56048. * @private
  56049. * @type {module: echarts/component/dataZoom/DataZoomModel}
  56050. */
  56051. this._dataZoomModel = dataZoomModel;
  56052. };
  56053. AxisProxy.prototype = {
  56054. constructor: AxisProxy,
  56055. /**
  56056. * Whether the axisProxy is hosted by dataZoomModel.
  56057. *
  56058. * @public
  56059. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  56060. * @return {boolean}
  56061. */
  56062. hostedBy: function (dataZoomModel) {
  56063. return this._dataZoomModel === dataZoomModel;
  56064. },
  56065. /**
  56066. * @return {Array.<number>} Value can only be NaN or finite value.
  56067. */
  56068. getDataValueWindow: function () {
  56069. return this._valueWindow.slice();
  56070. },
  56071. /**
  56072. * @return {Array.<number>}
  56073. */
  56074. getDataPercentWindow: function () {
  56075. return this._percentWindow.slice();
  56076. },
  56077. /**
  56078. * @public
  56079. * @param {number} axisIndex
  56080. * @return {Array} seriesModels
  56081. */
  56082. getTargetSeriesModels: function () {
  56083. var seriesModels = [];
  56084. var ecModel = this.ecModel;
  56085. ecModel.eachSeries(function (seriesModel) {
  56086. if (helper.isCoordSupported(seriesModel.get('coordinateSystem'))) {
  56087. var dimName = this._dimName;
  56088. var axisModel = ecModel.queryComponents({
  56089. mainType: dimName + 'Axis',
  56090. index: seriesModel.get(dimName + 'AxisIndex'),
  56091. id: seriesModel.get(dimName + 'AxisId')
  56092. })[0];
  56093. if (this._axisIndex === (axisModel && axisModel.componentIndex)) {
  56094. seriesModels.push(seriesModel);
  56095. }
  56096. }
  56097. }, this);
  56098. return seriesModels;
  56099. },
  56100. getAxisModel: function () {
  56101. return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex);
  56102. },
  56103. getOtherAxisModel: function () {
  56104. var axisDim = this._dimName;
  56105. var ecModel = this.ecModel;
  56106. var axisModel = this.getAxisModel();
  56107. var isCartesian = axisDim === 'x' || axisDim === 'y';
  56108. var otherAxisDim;
  56109. var coordSysIndexName;
  56110. if (isCartesian) {
  56111. coordSysIndexName = 'gridIndex';
  56112. otherAxisDim = axisDim === 'x' ? 'y' : 'x';
  56113. }
  56114. else {
  56115. coordSysIndexName = 'polarIndex';
  56116. otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle';
  56117. }
  56118. var foundOtherAxisModel;
  56119. ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) {
  56120. if ((otherAxisModel.get(coordSysIndexName) || 0)
  56121. === (axisModel.get(coordSysIndexName) || 0)
  56122. ) {
  56123. foundOtherAxisModel = otherAxisModel;
  56124. }
  56125. });
  56126. return foundOtherAxisModel;
  56127. },
  56128. getMinMaxSpan: function () {
  56129. return zrUtil.clone(this._minMaxSpan);
  56130. },
  56131. /**
  56132. * Only calculate by given range and this._dataExtent, do not change anything.
  56133. *
  56134. * @param {Object} opt
  56135. * @param {number} [opt.start]
  56136. * @param {number} [opt.end]
  56137. * @param {number} [opt.startValue]
  56138. * @param {number} [opt.endValue]
  56139. */
  56140. calculateDataWindow: function (opt) {
  56141. var dataExtent = this._dataExtent;
  56142. var axisModel = this.getAxisModel();
  56143. var scale = axisModel.axis.scale;
  56144. var rangePropMode = this._dataZoomModel.getRangePropMode();
  56145. var percentExtent = [0, 100];
  56146. var percentWindow = [
  56147. opt.start,
  56148. opt.end
  56149. ];
  56150. var valueWindow = [];
  56151. each(['startValue', 'endValue'], function (prop) {
  56152. valueWindow.push(opt[prop] != null ? scale.parse(opt[prop]) : null);
  56153. });
  56154. // Normalize bound.
  56155. each([0, 1], function (idx) {
  56156. var boundValue = valueWindow[idx];
  56157. var boundPercent = percentWindow[idx];
  56158. // Notice: dataZoom is based either on `percentProp` ('start', 'end') or
  56159. // on `valueProp` ('startValue', 'endValue'). The former one is suitable
  56160. // for cases that a dataZoom component controls multiple axes with different
  56161. // unit or extent, and the latter one is suitable for accurate zoom by pixel
  56162. // (e.g., in dataZoomSelect). `valueProp` can be calculated from `percentProp`,
  56163. // but it is awkward that `percentProp` can not be obtained from `valueProp`
  56164. // accurately (because all of values that are overflow the `dataExtent` will
  56165. // be calculated to percent '100%'). So we have to use
  56166. // `dataZoom.getRangePropMode()` to mark which prop is used.
  56167. // `rangePropMode` is updated only when setOption or dispatchAction, otherwise
  56168. // it remains its original value.
  56169. if (rangePropMode[idx] === 'percent') {
  56170. if (boundPercent == null) {
  56171. boundPercent = percentExtent[idx];
  56172. }
  56173. // Use scale.parse to math round for category or time axis.
  56174. boundValue = scale.parse(numberUtil.linearMap(
  56175. boundPercent, percentExtent, dataExtent, true
  56176. ));
  56177. }
  56178. else {
  56179. // Calculating `percent` from `value` may be not accurate, because
  56180. // This calculation can not be inversed, because all of values that
  56181. // are overflow the `dataExtent` will be calculated to percent '100%'
  56182. boundPercent = numberUtil.linearMap(
  56183. boundValue, dataExtent, percentExtent, true
  56184. );
  56185. }
  56186. // valueWindow[idx] = round(boundValue);
  56187. // percentWindow[idx] = round(boundPercent);
  56188. valueWindow[idx] = boundValue;
  56189. percentWindow[idx] = boundPercent;
  56190. });
  56191. return {
  56192. valueWindow: asc(valueWindow),
  56193. percentWindow: asc(percentWindow)
  56194. };
  56195. },
  56196. /**
  56197. * Notice: reset should not be called before series.restoreData() called,
  56198. * so it is recommanded to be called in "process stage" but not "model init
  56199. * stage".
  56200. *
  56201. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  56202. */
  56203. reset: function (dataZoomModel) {
  56204. if (dataZoomModel !== this._dataZoomModel) {
  56205. return;
  56206. }
  56207. // Culculate data window and data extent, and record them.
  56208. this._dataExtent = calculateDataExtent(
  56209. this, this._dimName, this.getTargetSeriesModels()
  56210. );
  56211. var dataWindow = this.calculateDataWindow(dataZoomModel.option);
  56212. this._valueWindow = dataWindow.valueWindow;
  56213. this._percentWindow = dataWindow.percentWindow;
  56214. setMinMaxSpan(this);
  56215. // Update axis setting then.
  56216. setAxisModel(this);
  56217. },
  56218. /**
  56219. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  56220. */
  56221. restore: function (dataZoomModel) {
  56222. if (dataZoomModel !== this._dataZoomModel) {
  56223. return;
  56224. }
  56225. this._valueWindow = this._percentWindow = null;
  56226. setAxisModel(this, true);
  56227. },
  56228. /**
  56229. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  56230. */
  56231. filterData: function (dataZoomModel) {
  56232. if (dataZoomModel !== this._dataZoomModel) {
  56233. return;
  56234. }
  56235. var axisDim = this._dimName;
  56236. var seriesModels = this.getTargetSeriesModels();
  56237. var filterMode = dataZoomModel.get('filterMode');
  56238. var valueWindow = this._valueWindow;
  56239. if (filterMode === 'none') {
  56240. return;
  56241. }
  56242. // FIXME
  56243. // Toolbox may has dataZoom injected. And if there are stacked bar chart
  56244. // with NaN data, NaN will be filtered and stack will be wrong.
  56245. // So we need to force the mode to be set empty.
  56246. // In fect, it is not a big deal that do not support filterMode-'filter'
  56247. // when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
  56248. // selection" some day, which might need "adapt to data extent on the
  56249. // otherAxis", which is disabled by filterMode-'empty'.
  56250. var otherAxisModel = this.getOtherAxisModel();
  56251. if (dataZoomModel.get('$fromToolbox')
  56252. && otherAxisModel
  56253. && otherAxisModel.get('type') === 'category'
  56254. ) {
  56255. filterMode = 'empty';
  56256. }
  56257. // Process series data
  56258. each(seriesModels, function (seriesModel) {
  56259. var seriesData = seriesModel.getData();
  56260. var dataDims = seriesModel.coordDimToDataDim(axisDim);
  56261. if (filterMode === 'weakFilter') {
  56262. seriesData && seriesData.filterSelf(function (dataIndex) {
  56263. var leftOut;
  56264. var rightOut;
  56265. var hasValue;
  56266. for (var i = 0; i < dataDims.length; i++) {
  56267. var value = seriesData.get(dataDims[i], dataIndex);
  56268. var thisHasValue = !isNaN(value);
  56269. var thisLeftOut = value < valueWindow[0];
  56270. var thisRightOut = value > valueWindow[1];
  56271. if (thisHasValue && !thisLeftOut && !thisRightOut) {
  56272. return true;
  56273. }
  56274. thisHasValue && (hasValue = true);
  56275. thisLeftOut && (leftOut = true);
  56276. thisRightOut && (rightOut = true);
  56277. }
  56278. // If both left out and right out, do not filter.
  56279. return hasValue && leftOut && rightOut;
  56280. });
  56281. }
  56282. else {
  56283. seriesData && each(dataDims, function (dim) {
  56284. if (filterMode === 'empty') {
  56285. seriesModel.setData(
  56286. seriesData.map(dim, function (value) {
  56287. return !isInWindow(value) ? NaN : value;
  56288. })
  56289. );
  56290. }
  56291. else {
  56292. seriesData.filterSelf(dim, isInWindow);
  56293. }
  56294. });
  56295. }
  56296. });
  56297. function isInWindow(value) {
  56298. return value >= valueWindow[0] && value <= valueWindow[1];
  56299. }
  56300. }
  56301. };
  56302. function calculateDataExtent(axisProxy, axisDim, seriesModels) {
  56303. var dataExtent = [Infinity, -Infinity];
  56304. each(seriesModels, function (seriesModel) {
  56305. var seriesData = seriesModel.getData();
  56306. if (seriesData) {
  56307. each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  56308. var seriesExtent = seriesData.getDataExtent(dim);
  56309. seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]);
  56310. seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]);
  56311. });
  56312. }
  56313. });
  56314. if (dataExtent[1] < dataExtent[0]) {
  56315. dataExtent = [NaN, NaN];
  56316. }
  56317. // It is important to get "consistent" extent when more then one axes is
  56318. // controlled by a `dataZoom`, otherwise those axes will not be synchronized
  56319. // when zooming. But it is difficult to know what is "consistent", considering
  56320. // axes have different type or even different meanings (For example, two
  56321. // time axes are used to compare data of the same date in different years).
  56322. // So basically dataZoom just obtains extent by series.data (in category axis
  56323. // extent can be obtained from axis.data).
  56324. // Nevertheless, user can set min/max/scale on axes to make extent of axes
  56325. // consistent.
  56326. fixExtentByAxis(axisProxy, dataExtent);
  56327. return dataExtent;
  56328. }
  56329. function fixExtentByAxis(axisProxy, dataExtent) {
  56330. var axisModel = axisProxy.getAxisModel();
  56331. var min = axisModel.getMin(true);
  56332. // For category axis, if min/max/scale are not set, extent is determined
  56333. // by axis.data by default.
  56334. var isCategoryAxis = axisModel.get('type') === 'category';
  56335. var axisDataLen = isCategoryAxis && (axisModel.get('data') || []).length;
  56336. if (min != null && min !== 'dataMin' && typeof min !== 'function') {
  56337. dataExtent[0] = min;
  56338. }
  56339. else if (isCategoryAxis) {
  56340. dataExtent[0] = axisDataLen > 0 ? 0 : NaN;
  56341. }
  56342. var max = axisModel.getMax(true);
  56343. if (max != null && max !== 'dataMax' && typeof max !== 'function') {
  56344. dataExtent[1] = max;
  56345. }
  56346. else if (isCategoryAxis) {
  56347. dataExtent[1] = axisDataLen > 0 ? axisDataLen - 1 : NaN;
  56348. }
  56349. if (!axisModel.get('scale', true)) {
  56350. dataExtent[0] > 0 && (dataExtent[0] = 0);
  56351. dataExtent[1] < 0 && (dataExtent[1] = 0);
  56352. }
  56353. // For value axis, if min/max/scale are not set, we just use the extent obtained
  56354. // by series data, which may be a little different from the extent calculated by
  56355. // `axisHelper.getScaleExtent`. But the different just affects the experience a
  56356. // little when zooming. So it will not be fixed until some users require it strongly.
  56357. return dataExtent;
  56358. }
  56359. function setAxisModel(axisProxy, isRestore) {
  56360. var axisModel = axisProxy.getAxisModel();
  56361. var percentWindow = axisProxy._percentWindow;
  56362. var valueWindow = axisProxy._valueWindow;
  56363. if (!percentWindow) {
  56364. return;
  56365. }
  56366. // [0, 500]: arbitrary value, guess axis extent.
  56367. var precision = numberUtil.getPixelPrecision(valueWindow, [0, 500]);
  56368. precision = Math.min(precision, 20);
  56369. // isRestore or isFull
  56370. var useOrigin = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100);
  56371. axisModel.setRange(
  56372. useOrigin ? null : +valueWindow[0].toFixed(precision),
  56373. useOrigin ? null : +valueWindow[1].toFixed(precision)
  56374. );
  56375. }
  56376. function setMinMaxSpan(axisProxy) {
  56377. var minMaxSpan = axisProxy._minMaxSpan = {};
  56378. var dataZoomModel = axisProxy._dataZoomModel;
  56379. each(['min', 'max'], function (minMax) {
  56380. minMaxSpan[minMax + 'Span'] = dataZoomModel.get(minMax + 'Span');
  56381. // minValueSpan and maxValueSpan has higher priority than minSpan and maxSpan
  56382. var valueSpan = dataZoomModel.get(minMax + 'ValueSpan');
  56383. if (valueSpan != null) {
  56384. minMaxSpan[minMax + 'ValueSpan'] = valueSpan;
  56385. valueSpan = axisProxy.getAxisModel().axis.scale.parse(valueSpan);
  56386. if (valueSpan != null) {
  56387. minMaxSpan[minMax + 'Span'] = numberUtil.linearMap(
  56388. valueSpan, axisProxy._dataExtent, [0, 100], true
  56389. );
  56390. }
  56391. }
  56392. });
  56393. }
  56394. module.exports = AxisProxy;
  56395. /***/ }),
  56396. /* 376 */
  56397. /***/ (function(module, exports, __webpack_require__) {
  56398. var ComponentView = __webpack_require__(84);
  56399. module.exports = ComponentView.extend({
  56400. type: 'dataZoom',
  56401. render: function (dataZoomModel, ecModel, api, payload) {
  56402. this.dataZoomModel = dataZoomModel;
  56403. this.ecModel = ecModel;
  56404. this.api = api;
  56405. },
  56406. /**
  56407. * Find the first target coordinate system.
  56408. *
  56409. * @protected
  56410. * @return {Object} {
  56411. * grid: [
  56412. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  56413. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  56414. * ...
  56415. * ], // cartesians must not be null/undefined.
  56416. * polar: [
  56417. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  56418. * ...
  56419. * ], // polars must not be null/undefined.
  56420. * singleAxis: [
  56421. * {model: coord0, axisModels: [], coordIndex: 0}
  56422. * ]
  56423. */
  56424. getTargetCoordInfo: function () {
  56425. var dataZoomModel = this.dataZoomModel;
  56426. var ecModel = this.ecModel;
  56427. var coordSysLists = {};
  56428. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  56429. var axisModel = ecModel.getComponent(dimNames.axis, axisIndex);
  56430. if (axisModel) {
  56431. var coordModel = axisModel.getCoordSysModel();
  56432. coordModel && save(
  56433. coordModel,
  56434. axisModel,
  56435. coordSysLists[coordModel.mainType] || (coordSysLists[coordModel.mainType] = []),
  56436. coordModel.componentIndex
  56437. );
  56438. }
  56439. }, this);
  56440. function save(coordModel, axisModel, store, coordIndex) {
  56441. var item;
  56442. for (var i = 0; i < store.length; i++) {
  56443. if (store[i].model === coordModel) {
  56444. item = store[i];
  56445. break;
  56446. }
  56447. }
  56448. if (!item) {
  56449. store.push(item = {
  56450. model: coordModel, axisModels: [], coordIndex: coordIndex
  56451. });
  56452. }
  56453. item.axisModels.push(axisModel);
  56454. }
  56455. return coordSysLists;
  56456. }
  56457. });
  56458. /***/ }),
  56459. /* 377 */
  56460. /***/ (function(module, exports, __webpack_require__) {
  56461. /**
  56462. * @file Data zoom model
  56463. */
  56464. var DataZoomModel = __webpack_require__(373);
  56465. var SliderZoomModel = DataZoomModel.extend({
  56466. type: 'dataZoom.slider',
  56467. layoutMode: 'box',
  56468. /**
  56469. * @protected
  56470. */
  56471. defaultOption: {
  56472. show: true,
  56473. // ph => placeholder. Using placehoder here because
  56474. // deault value can only be drived in view stage.
  56475. right: 'ph', // Default align to grid rect.
  56476. top: 'ph', // Default align to grid rect.
  56477. width: 'ph', // Default align to grid rect.
  56478. height: 'ph', // Default align to grid rect.
  56479. left: null, // Default align to grid rect.
  56480. bottom: null, // Default align to grid rect.
  56481. backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component.
  56482. // dataBackgroundColor: '#ddd', // Background coor of data shadow and border of box,
  56483. // highest priority, remain for compatibility of
  56484. // previous version, but not recommended any more.
  56485. dataBackground: {
  56486. lineStyle: {
  56487. color: '#2f4554',
  56488. width: 0.5,
  56489. opacity: 0.3
  56490. },
  56491. areaStyle: {
  56492. color: 'rgba(47,69,84,0.3)',
  56493. opacity: 0.3
  56494. }
  56495. },
  56496. borderColor: '#ddd', // border color of the box. For compatibility,
  56497. // if dataBackgroundColor is set, borderColor
  56498. // is ignored.
  56499. fillerColor: 'rgba(167,183,204,0.4)', // Color of selected area.
  56500. // handleColor: 'rgba(89,170,216,0.95)', // Color of handle.
  56501. // 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',
  56502. 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',
  56503. // Percent of the slider height
  56504. handleSize: '100%',
  56505. handleStyle: {
  56506. color: '#a7b7cc'
  56507. },
  56508. labelPrecision: null,
  56509. labelFormatter: null,
  56510. showDetail: true,
  56511. showDataShadow: 'auto', // Default auto decision.
  56512. realtime: true,
  56513. zoomLock: false, // Whether disable zoom.
  56514. textStyle: {
  56515. color: '#333'
  56516. }
  56517. }
  56518. });
  56519. module.exports = SliderZoomModel;
  56520. /***/ }),
  56521. /* 378 */
  56522. /***/ (function(module, exports, __webpack_require__) {
  56523. var zrUtil = __webpack_require__(4);
  56524. var graphic = __webpack_require__(20);
  56525. var throttle = __webpack_require__(86);
  56526. var DataZoomView = __webpack_require__(376);
  56527. var Rect = graphic.Rect;
  56528. var numberUtil = __webpack_require__(7);
  56529. var linearMap = numberUtil.linearMap;
  56530. var layout = __webpack_require__(74);
  56531. var sliderMove = __webpack_require__(242);
  56532. var eventTool = __webpack_require__(93);
  56533. var asc = numberUtil.asc;
  56534. var bind = zrUtil.bind;
  56535. // var mathMax = Math.max;
  56536. var each = zrUtil.each;
  56537. // Constants
  56538. var DEFAULT_LOCATION_EDGE_GAP = 7;
  56539. var DEFAULT_FRAME_BORDER_WIDTH = 1;
  56540. var DEFAULT_FILLER_SIZE = 30;
  56541. var HORIZONTAL = 'horizontal';
  56542. var VERTICAL = 'vertical';
  56543. var LABEL_GAP = 5;
  56544. var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter'];
  56545. var SliderZoomView = DataZoomView.extend({
  56546. type: 'dataZoom.slider',
  56547. init: function (ecModel, api) {
  56548. /**
  56549. * @private
  56550. * @type {Object}
  56551. */
  56552. this._displayables = {};
  56553. /**
  56554. * @private
  56555. * @type {string}
  56556. */
  56557. this._orient;
  56558. /**
  56559. * [0, 100]
  56560. * @private
  56561. */
  56562. this._range;
  56563. /**
  56564. * [coord of the first handle, coord of the second handle]
  56565. * @private
  56566. */
  56567. this._handleEnds;
  56568. /**
  56569. * [length, thick]
  56570. * @private
  56571. * @type {Array.<number>}
  56572. */
  56573. this._size;
  56574. /**
  56575. * @private
  56576. * @type {number}
  56577. */
  56578. this._handleWidth;
  56579. /**
  56580. * @private
  56581. * @type {number}
  56582. */
  56583. this._handleHeight;
  56584. /**
  56585. * @private
  56586. */
  56587. this._location;
  56588. /**
  56589. * @private
  56590. */
  56591. this._dragging;
  56592. /**
  56593. * @private
  56594. */
  56595. this._dataShadowInfo;
  56596. this.api = api;
  56597. },
  56598. /**
  56599. * @override
  56600. */
  56601. render: function (dataZoomModel, ecModel, api, payload) {
  56602. SliderZoomView.superApply(this, 'render', arguments);
  56603. throttle.createOrUpdate(
  56604. this,
  56605. '_dispatchZoomAction',
  56606. this.dataZoomModel.get('throttle'),
  56607. 'fixRate'
  56608. );
  56609. this._orient = dataZoomModel.get('orient');
  56610. if (this.dataZoomModel.get('show') === false) {
  56611. this.group.removeAll();
  56612. return;
  56613. }
  56614. // Notice: this._resetInterval() should not be executed when payload.type
  56615. // is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
  56616. // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
  56617. if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) {
  56618. this._buildView();
  56619. }
  56620. this._updateView();
  56621. },
  56622. /**
  56623. * @override
  56624. */
  56625. remove: function () {
  56626. SliderZoomView.superApply(this, 'remove', arguments);
  56627. throttle.clear(this, '_dispatchZoomAction');
  56628. },
  56629. /**
  56630. * @override
  56631. */
  56632. dispose: function () {
  56633. SliderZoomView.superApply(this, 'dispose', arguments);
  56634. throttle.clear(this, '_dispatchZoomAction');
  56635. },
  56636. _buildView: function () {
  56637. var thisGroup = this.group;
  56638. thisGroup.removeAll();
  56639. this._resetLocation();
  56640. this._resetInterval();
  56641. var barGroup = this._displayables.barGroup = new graphic.Group();
  56642. this._renderBackground();
  56643. this._renderHandle();
  56644. this._renderDataShadow();
  56645. thisGroup.add(barGroup);
  56646. this._positionGroup();
  56647. },
  56648. /**
  56649. * @private
  56650. */
  56651. _resetLocation: function () {
  56652. var dataZoomModel = this.dataZoomModel;
  56653. var api = this.api;
  56654. // If some of x/y/width/height are not specified,
  56655. // auto-adapt according to target grid.
  56656. var coordRect = this._findCoordRect();
  56657. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  56658. // Default align by coordinate system rect.
  56659. var positionInfo = this._orient === HORIZONTAL
  56660. ? {
  56661. // Why using 'right', because right should be used in vertical,
  56662. // and it is better to be consistent for dealing with position param merge.
  56663. right: ecSize.width - coordRect.x - coordRect.width,
  56664. top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP),
  56665. width: coordRect.width,
  56666. height: DEFAULT_FILLER_SIZE
  56667. }
  56668. : { // vertical
  56669. right: DEFAULT_LOCATION_EDGE_GAP,
  56670. top: coordRect.y,
  56671. width: DEFAULT_FILLER_SIZE,
  56672. height: coordRect.height
  56673. };
  56674. // Do not write back to option and replace value 'ph', because
  56675. // the 'ph' value should be recalculated when resize.
  56676. var layoutParams = layout.getLayoutParams(dataZoomModel.option);
  56677. // Replace the placeholder value.
  56678. zrUtil.each(['right', 'top', 'width', 'height'], function (name) {
  56679. if (layoutParams[name] === 'ph') {
  56680. layoutParams[name] = positionInfo[name];
  56681. }
  56682. });
  56683. var layoutRect = layout.getLayoutRect(
  56684. layoutParams,
  56685. ecSize,
  56686. dataZoomModel.padding
  56687. );
  56688. this._location = {x: layoutRect.x, y: layoutRect.y};
  56689. this._size = [layoutRect.width, layoutRect.height];
  56690. this._orient === VERTICAL && this._size.reverse();
  56691. },
  56692. /**
  56693. * @private
  56694. */
  56695. _positionGroup: function () {
  56696. var thisGroup = this.group;
  56697. var location = this._location;
  56698. var orient = this._orient;
  56699. // Just use the first axis to determine mapping.
  56700. var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel();
  56701. var inverse = targetAxisModel && targetAxisModel.get('inverse');
  56702. var barGroup = this._displayables.barGroup;
  56703. var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse;
  56704. // Transform barGroup.
  56705. barGroup.attr(
  56706. (orient === HORIZONTAL && !inverse)
  56707. ? {scale: otherAxisInverse ? [1, 1] : [1, -1]}
  56708. : (orient === HORIZONTAL && inverse)
  56709. ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]}
  56710. : (orient === VERTICAL && !inverse)
  56711. ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2}
  56712. // Dont use Math.PI, considering shadow direction.
  56713. : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2}
  56714. );
  56715. // Position barGroup
  56716. var rect = thisGroup.getBoundingRect([barGroup]);
  56717. thisGroup.attr('position', [location.x - rect.x, location.y - rect.y]);
  56718. },
  56719. /**
  56720. * @private
  56721. */
  56722. _getViewExtent: function () {
  56723. return [0, this._size[0]];
  56724. },
  56725. _renderBackground: function () {
  56726. var dataZoomModel = this.dataZoomModel;
  56727. var size = this._size;
  56728. var barGroup = this._displayables.barGroup;
  56729. barGroup.add(new Rect({
  56730. silent: true,
  56731. shape: {
  56732. x: 0, y: 0, width: size[0], height: size[1]
  56733. },
  56734. style: {
  56735. fill: dataZoomModel.get('backgroundColor')
  56736. },
  56737. z2: -40
  56738. }));
  56739. // Click panel, over shadow, below handles.
  56740. barGroup.add(new Rect({
  56741. shape: {
  56742. x: 0, y: 0, width: size[0], height: size[1]
  56743. },
  56744. style: {
  56745. fill: 'transparent'
  56746. },
  56747. z2: 0,
  56748. onclick: zrUtil.bind(this._onClickPanelClick, this)
  56749. }));
  56750. },
  56751. _renderDataShadow: function () {
  56752. var info = this._dataShadowInfo = this._prepareDataShadowInfo();
  56753. if (!info) {
  56754. return;
  56755. }
  56756. var size = this._size;
  56757. var seriesModel = info.series;
  56758. var data = seriesModel.getRawData();
  56759. var otherDim = seriesModel.getShadowDim
  56760. ? seriesModel.getShadowDim() // @see candlestick
  56761. : info.otherDim;
  56762. if (otherDim == null) {
  56763. return;
  56764. }
  56765. var otherDataExtent = data.getDataExtent(otherDim);
  56766. // Nice extent.
  56767. var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
  56768. otherDataExtent = [
  56769. otherDataExtent[0] - otherOffset,
  56770. otherDataExtent[1] + otherOffset
  56771. ];
  56772. var otherShadowExtent = [0, size[1]];
  56773. var thisShadowExtent = [0, size[0]];
  56774. var areaPoints = [[size[0], 0], [0, 0]];
  56775. var linePoints = [];
  56776. var step = thisShadowExtent[1] / (data.count() - 1);
  56777. var thisCoord = 0;
  56778. // Optimize for large data shadow
  56779. var stride = Math.round(data.count() / size[0]);
  56780. var lastIsEmpty;
  56781. data.each([otherDim], function (value, index) {
  56782. if (stride > 0 && (index % stride)) {
  56783. thisCoord += step;
  56784. return;
  56785. }
  56786. // FIXME
  56787. // Should consider axis.min/axis.max when drawing dataShadow.
  56788. // FIXME
  56789. // 应该使用统一的空判断?还是在list里进行空判断?
  56790. var isEmpty = value == null || isNaN(value) || value === '';
  56791. // See #4235.
  56792. var otherCoord = isEmpty
  56793. ? 0 : linearMap(value, otherDataExtent, otherShadowExtent, true);
  56794. // Attempt to draw data shadow precisely when there are empty value.
  56795. if (isEmpty && !lastIsEmpty && index) {
  56796. areaPoints.push([areaPoints[areaPoints.length - 1][0], 0]);
  56797. linePoints.push([linePoints[linePoints.length - 1][0], 0]);
  56798. }
  56799. else if (!isEmpty && lastIsEmpty) {
  56800. areaPoints.push([thisCoord, 0]);
  56801. linePoints.push([thisCoord, 0]);
  56802. }
  56803. areaPoints.push([thisCoord, otherCoord]);
  56804. linePoints.push([thisCoord, otherCoord]);
  56805. thisCoord += step;
  56806. lastIsEmpty = isEmpty;
  56807. });
  56808. var dataZoomModel = this.dataZoomModel;
  56809. // var dataBackgroundModel = dataZoomModel.getModel('dataBackground');
  56810. this._displayables.barGroup.add(new graphic.Polygon({
  56811. shape: {points: areaPoints},
  56812. style: zrUtil.defaults(
  56813. {fill: dataZoomModel.get('dataBackgroundColor')},
  56814. dataZoomModel.getModel('dataBackground.areaStyle').getAreaStyle()
  56815. ),
  56816. silent: true,
  56817. z2: -20
  56818. }));
  56819. this._displayables.barGroup.add(new graphic.Polyline({
  56820. shape: {points: linePoints},
  56821. style: dataZoomModel.getModel('dataBackground.lineStyle').getLineStyle(),
  56822. silent: true,
  56823. z2: -19
  56824. }));
  56825. },
  56826. _prepareDataShadowInfo: function () {
  56827. var dataZoomModel = this.dataZoomModel;
  56828. var showDataShadow = dataZoomModel.get('showDataShadow');
  56829. if (showDataShadow === false) {
  56830. return;
  56831. }
  56832. // Find a representative series.
  56833. var result;
  56834. var ecModel = this.ecModel;
  56835. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  56836. var seriesModels = dataZoomModel
  56837. .getAxisProxy(dimNames.name, axisIndex)
  56838. .getTargetSeriesModels();
  56839. zrUtil.each(seriesModels, function (seriesModel) {
  56840. if (result) {
  56841. return;
  56842. }
  56843. if (showDataShadow !== true && zrUtil.indexOf(
  56844. SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')
  56845. ) < 0
  56846. ) {
  56847. return;
  56848. }
  56849. var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis;
  56850. var otherDim = getOtherDim(dimNames.name);
  56851. var otherAxisInverse;
  56852. var coordSys = seriesModel.coordinateSystem;
  56853. if (otherDim != null && coordSys.getOtherAxis) {
  56854. otherAxisInverse = coordSys.getOtherAxis(thisAxis).inverse;
  56855. }
  56856. result = {
  56857. thisAxis: thisAxis,
  56858. series: seriesModel,
  56859. thisDim: dimNames.name,
  56860. otherDim: otherDim,
  56861. otherAxisInverse: otherAxisInverse
  56862. };
  56863. }, this);
  56864. }, this);
  56865. return result;
  56866. },
  56867. _renderHandle: function () {
  56868. var displaybles = this._displayables;
  56869. var handles = displaybles.handles = [];
  56870. var handleLabels = displaybles.handleLabels = [];
  56871. var barGroup = this._displayables.barGroup;
  56872. var size = this._size;
  56873. var dataZoomModel = this.dataZoomModel;
  56874. barGroup.add(displaybles.filler = new Rect({
  56875. draggable: true,
  56876. cursor: getCursor(this._orient),
  56877. drift: bind(this._onDragMove, this, 'all'),
  56878. onmousemove: function (e) {
  56879. // Fot mobile devicem, prevent screen slider on the button.
  56880. eventTool.stop(e.event);
  56881. },
  56882. ondragstart: bind(this._showDataInfo, this, true),
  56883. ondragend: bind(this._onDragEnd, this),
  56884. onmouseover: bind(this._showDataInfo, this, true),
  56885. onmouseout: bind(this._showDataInfo, this, false),
  56886. style: {
  56887. fill: dataZoomModel.get('fillerColor'),
  56888. textPosition : 'inside'
  56889. }
  56890. }));
  56891. // Frame border.
  56892. barGroup.add(new Rect(graphic.subPixelOptimizeRect({
  56893. silent: true,
  56894. shape: {
  56895. x: 0,
  56896. y: 0,
  56897. width: size[0],
  56898. height: size[1]
  56899. },
  56900. style: {
  56901. stroke: dataZoomModel.get('dataBackgroundColor')
  56902. || dataZoomModel.get('borderColor'),
  56903. lineWidth: DEFAULT_FRAME_BORDER_WIDTH,
  56904. fill: 'rgba(0,0,0,0)'
  56905. }
  56906. })));
  56907. each([0, 1], function (handleIndex) {
  56908. var path = graphic.createIcon(
  56909. dataZoomModel.get('handleIcon'),
  56910. {
  56911. cursor: getCursor(this._orient),
  56912. draggable: true,
  56913. drift: bind(this._onDragMove, this, handleIndex),
  56914. onmousemove: function (e) {
  56915. // Fot mobile devicem, prevent screen slider on the button.
  56916. eventTool.stop(e.event);
  56917. },
  56918. ondragend: bind(this._onDragEnd, this),
  56919. onmouseover: bind(this._showDataInfo, this, true),
  56920. onmouseout: bind(this._showDataInfo, this, false)
  56921. },
  56922. {x: -1, y: 0, width: 2, height: 2}
  56923. );
  56924. var bRect = path.getBoundingRect();
  56925. this._handleHeight = numberUtil.parsePercent(dataZoomModel.get('handleSize'), this._size[1]);
  56926. this._handleWidth = bRect.width / bRect.height * this._handleHeight;
  56927. path.setStyle(dataZoomModel.getModel('handleStyle').getItemStyle());
  56928. var handleColor = dataZoomModel.get('handleColor');
  56929. // Compatitable with previous version
  56930. if (handleColor != null) {
  56931. path.style.fill = handleColor;
  56932. }
  56933. barGroup.add(handles[handleIndex] = path);
  56934. var textStyleModel = dataZoomModel.textStyleModel;
  56935. this.group.add(
  56936. handleLabels[handleIndex] = new graphic.Text({
  56937. silent: true,
  56938. invisible: true,
  56939. style: {
  56940. x: 0, y: 0, text: '',
  56941. textVerticalAlign: 'middle',
  56942. textAlign: 'center',
  56943. textFill: textStyleModel.getTextColor(),
  56944. textFont: textStyleModel.getFont()
  56945. },
  56946. z2: 10
  56947. }));
  56948. }, this);
  56949. },
  56950. /**
  56951. * @private
  56952. */
  56953. _resetInterval: function () {
  56954. var range = this._range = this.dataZoomModel.getPercentRange();
  56955. var viewExtent = this._getViewExtent();
  56956. this._handleEnds = [
  56957. linearMap(range[0], [0, 100], viewExtent, true),
  56958. linearMap(range[1], [0, 100], viewExtent, true)
  56959. ];
  56960. },
  56961. /**
  56962. * @private
  56963. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  56964. * @param {number} delta
  56965. */
  56966. _updateInterval: function (handleIndex, delta) {
  56967. var dataZoomModel = this.dataZoomModel;
  56968. var handleEnds = this._handleEnds;
  56969. var viewExtend = this._getViewExtent();
  56970. var minMaxSpan = dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
  56971. var percentExtent = [0, 100];
  56972. sliderMove(
  56973. delta,
  56974. handleEnds,
  56975. viewExtend,
  56976. dataZoomModel.get('zoomLock') ? 'all' : handleIndex,
  56977. minMaxSpan.minSpan != null
  56978. ? linearMap(minMaxSpan.minSpan, percentExtent, viewExtend, true) : null,
  56979. minMaxSpan.maxSpan != null
  56980. ? linearMap(minMaxSpan.maxSpan, percentExtent, viewExtend, true) : null
  56981. );
  56982. this._range = asc([
  56983. linearMap(handleEnds[0], viewExtend, percentExtent, true),
  56984. linearMap(handleEnds[1], viewExtend, percentExtent, true)
  56985. ]);
  56986. },
  56987. /**
  56988. * @private
  56989. */
  56990. _updateView: function (nonRealtime) {
  56991. var displaybles = this._displayables;
  56992. var handleEnds = this._handleEnds;
  56993. var handleInterval = asc(handleEnds.slice());
  56994. var size = this._size;
  56995. each([0, 1], function (handleIndex) {
  56996. // Handles
  56997. var handle = displaybles.handles[handleIndex];
  56998. var handleHeight = this._handleHeight;
  56999. handle.attr({
  57000. scale: [handleHeight / 2, handleHeight / 2],
  57001. position: [handleEnds[handleIndex], size[1] / 2 - handleHeight / 2]
  57002. });
  57003. }, this);
  57004. // Filler
  57005. displaybles.filler.setShape({
  57006. x: handleInterval[0],
  57007. y: 0,
  57008. width: handleInterval[1] - handleInterval[0],
  57009. height: size[1]
  57010. });
  57011. this._updateDataInfo(nonRealtime);
  57012. },
  57013. /**
  57014. * @private
  57015. */
  57016. _updateDataInfo: function (nonRealtime) {
  57017. var dataZoomModel = this.dataZoomModel;
  57018. var displaybles = this._displayables;
  57019. var handleLabels = displaybles.handleLabels;
  57020. var orient = this._orient;
  57021. var labelTexts = ['', ''];
  57022. // FIXME
  57023. // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter)
  57024. if (dataZoomModel.get('showDetail')) {
  57025. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  57026. if (axisProxy) {
  57027. var axis = axisProxy.getAxisModel().axis;
  57028. var range = this._range;
  57029. var dataInterval = nonRealtime
  57030. // See #4434, data and axis are not processed and reset yet in non-realtime mode.
  57031. ? axisProxy.calculateDataWindow({
  57032. start: range[0], end: range[1]
  57033. }).valueWindow
  57034. : axisProxy.getDataValueWindow();
  57035. labelTexts = [
  57036. this._formatLabel(dataInterval[0], axis),
  57037. this._formatLabel(dataInterval[1], axis)
  57038. ];
  57039. }
  57040. }
  57041. var orderedHandleEnds = asc(this._handleEnds.slice());
  57042. setLabel.call(this, 0);
  57043. setLabel.call(this, 1);
  57044. function setLabel(handleIndex) {
  57045. // Label
  57046. // Text should not transform by barGroup.
  57047. // Ignore handlers transform
  57048. var barTransform = graphic.getTransform(
  57049. displaybles.handles[handleIndex].parent, this.group
  57050. );
  57051. var direction = graphic.transformDirection(
  57052. handleIndex === 0 ? 'right' : 'left', barTransform
  57053. );
  57054. var offset = this._handleWidth / 2 + LABEL_GAP;
  57055. var textPoint = graphic.applyTransform(
  57056. [
  57057. orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset),
  57058. this._size[1] / 2
  57059. ],
  57060. barTransform
  57061. );
  57062. handleLabels[handleIndex].setStyle({
  57063. x: textPoint[0],
  57064. y: textPoint[1],
  57065. textVerticalAlign: orient === HORIZONTAL ? 'middle' : direction,
  57066. textAlign: orient === HORIZONTAL ? direction : 'center',
  57067. text: labelTexts[handleIndex]
  57068. });
  57069. }
  57070. },
  57071. /**
  57072. * @private
  57073. */
  57074. _formatLabel: function (value, axis) {
  57075. var dataZoomModel = this.dataZoomModel;
  57076. var labelFormatter = dataZoomModel.get('labelFormatter');
  57077. var labelPrecision = dataZoomModel.get('labelPrecision');
  57078. if (labelPrecision == null || labelPrecision === 'auto') {
  57079. labelPrecision = axis.getPixelPrecision();
  57080. }
  57081. var valueStr = (value == null || isNaN(value))
  57082. ? ''
  57083. // FIXME Glue code
  57084. : (axis.type === 'category' || axis.type === 'time')
  57085. ? axis.scale.getLabel(Math.round(value))
  57086. // param of toFixed should less then 20.
  57087. : value.toFixed(Math.min(labelPrecision, 20));
  57088. return zrUtil.isFunction(labelFormatter)
  57089. ? labelFormatter(value, valueStr)
  57090. : zrUtil.isString(labelFormatter)
  57091. ? labelFormatter.replace('{value}', valueStr)
  57092. : valueStr;
  57093. },
  57094. /**
  57095. * @private
  57096. * @param {boolean} showOrHide true: show, false: hide
  57097. */
  57098. _showDataInfo: function (showOrHide) {
  57099. // Always show when drgging.
  57100. showOrHide = this._dragging || showOrHide;
  57101. var handleLabels = this._displayables.handleLabels;
  57102. handleLabels[0].attr('invisible', !showOrHide);
  57103. handleLabels[1].attr('invisible', !showOrHide);
  57104. },
  57105. _onDragMove: function (handleIndex, dx, dy) {
  57106. this._dragging = true;
  57107. // Transform dx, dy to bar coordination.
  57108. var barTransform = this._displayables.barGroup.getLocalTransform();
  57109. var vertex = graphic.applyTransform([dx, dy], barTransform, true);
  57110. this._updateInterval(handleIndex, vertex[0]);
  57111. var realtime = this.dataZoomModel.get('realtime');
  57112. this._updateView(!realtime);
  57113. if (realtime) {
  57114. realtime && this._dispatchZoomAction();
  57115. }
  57116. },
  57117. _onDragEnd: function () {
  57118. this._dragging = false;
  57119. this._showDataInfo(false);
  57120. this._dispatchZoomAction();
  57121. },
  57122. _onClickPanelClick: function (e) {
  57123. var size = this._size;
  57124. var localPoint = this._displayables.barGroup.transformCoordToLocal(e.offsetX, e.offsetY);
  57125. if (localPoint[0] < 0 || localPoint[0] > size[0]
  57126. || localPoint[1] < 0 || localPoint[1] > size[1]
  57127. ) {
  57128. return;
  57129. }
  57130. var handleEnds = this._handleEnds;
  57131. var center = (handleEnds[0] + handleEnds[1]) / 2;
  57132. this._updateInterval('all', localPoint[0] - center);
  57133. this._updateView();
  57134. this._dispatchZoomAction();
  57135. },
  57136. /**
  57137. * This action will be throttled.
  57138. * @private
  57139. */
  57140. _dispatchZoomAction: function () {
  57141. var range = this._range;
  57142. this.api.dispatchAction({
  57143. type: 'dataZoom',
  57144. from: this.uid,
  57145. dataZoomId: this.dataZoomModel.id,
  57146. start: range[0],
  57147. end: range[1]
  57148. });
  57149. },
  57150. /**
  57151. * @private
  57152. */
  57153. _findCoordRect: function () {
  57154. // Find the grid coresponding to the first axis referred by dataZoom.
  57155. var rect;
  57156. each(this.getTargetCoordInfo(), function (coordInfoList) {
  57157. if (!rect && coordInfoList.length) {
  57158. var coordSys = coordInfoList[0].model.coordinateSystem;
  57159. rect = coordSys.getRect && coordSys.getRect();
  57160. }
  57161. });
  57162. if (!rect) {
  57163. var width = this.api.getWidth();
  57164. var height = this.api.getHeight();
  57165. rect = {
  57166. x: width * 0.2,
  57167. y: height * 0.2,
  57168. width: width * 0.6,
  57169. height: height * 0.6
  57170. };
  57171. }
  57172. return rect;
  57173. }
  57174. });
  57175. function getOtherDim(thisDim) {
  57176. // FIXME
  57177. // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
  57178. var map = {x: 'y', y: 'x', radius: 'angle', angle: 'radius'};
  57179. return map[thisDim];
  57180. }
  57181. function getCursor(orient) {
  57182. return orient === 'vertical' ? 'ns-resize' : 'ew-resize';
  57183. }
  57184. module.exports = SliderZoomView;
  57185. /***/ }),
  57186. /* 379 */
  57187. /***/ (function(module, exports, __webpack_require__) {
  57188. /**
  57189. * @file Data zoom model
  57190. */
  57191. module.exports = __webpack_require__(373).extend({
  57192. type: 'dataZoom.inside',
  57193. /**
  57194. * @protected
  57195. */
  57196. defaultOption: {
  57197. disabled: false, // Whether disable this inside zoom.
  57198. zoomLock: false, // Whether disable zoom but only pan.
  57199. zoomOnMouseWheel: true, // Can be: true / false / 'shift' / 'ctrl' / 'alt'.
  57200. moveOnMouseMove: true, // Can be: true / false / 'shift' / 'ctrl' / 'alt'.
  57201. preventDefaultMouseMove: true
  57202. }
  57203. });
  57204. /***/ }),
  57205. /* 380 */
  57206. /***/ (function(module, exports, __webpack_require__) {
  57207. var DataZoomView = __webpack_require__(376);
  57208. var zrUtil = __webpack_require__(4);
  57209. var sliderMove = __webpack_require__(242);
  57210. var roams = __webpack_require__(381);
  57211. var bind = zrUtil.bind;
  57212. var InsideZoomView = DataZoomView.extend({
  57213. type: 'dataZoom.inside',
  57214. /**
  57215. * @override
  57216. */
  57217. init: function (ecModel, api) {
  57218. /**
  57219. * 'throttle' is used in this.dispatchAction, so we save range
  57220. * to avoid missing some 'pan' info.
  57221. * @private
  57222. * @type {Array.<number>}
  57223. */
  57224. this._range;
  57225. },
  57226. /**
  57227. * @override
  57228. */
  57229. render: function (dataZoomModel, ecModel, api, payload) {
  57230. InsideZoomView.superApply(this, 'render', arguments);
  57231. // Notice: origin this._range should be maintained, and should not be re-fetched
  57232. // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom'
  57233. // info will be missed because of 'throttle' of this.dispatchAction.
  57234. if (roams.shouldRecordRange(payload, dataZoomModel.id)) {
  57235. this._range = dataZoomModel.getPercentRange();
  57236. }
  57237. // Reset controllers.
  57238. zrUtil.each(this.getTargetCoordInfo(), function (coordInfoList, coordSysName) {
  57239. var allCoordIds = zrUtil.map(coordInfoList, function (coordInfo) {
  57240. return roams.generateCoordId(coordInfo.model);
  57241. });
  57242. zrUtil.each(coordInfoList, function (coordInfo) {
  57243. var coordModel = coordInfo.model;
  57244. var dataZoomOption = dataZoomModel.option;
  57245. roams.register(
  57246. api,
  57247. {
  57248. coordId: roams.generateCoordId(coordModel),
  57249. allCoordIds: allCoordIds,
  57250. containsPoint: function (e, x, y) {
  57251. return coordModel.coordinateSystem.containPoint([x, y]);
  57252. },
  57253. dataZoomId: dataZoomModel.id,
  57254. throttleRate: dataZoomModel.get('throttle', true),
  57255. panGetRange: bind(this._onPan, this, coordInfo, coordSysName),
  57256. zoomGetRange: bind(this._onZoom, this, coordInfo, coordSysName),
  57257. zoomLock: dataZoomOption.zoomLock,
  57258. disabled: dataZoomOption.disabled,
  57259. roamControllerOpt: {
  57260. zoomOnMouseWheel: dataZoomOption.zoomOnMouseWheel,
  57261. moveOnMouseMove: dataZoomOption.moveOnMouseMove,
  57262. preventDefaultMouseMove: dataZoomOption.preventDefaultMouseMove
  57263. }
  57264. }
  57265. );
  57266. }, this);
  57267. }, this);
  57268. },
  57269. /**
  57270. * @override
  57271. */
  57272. dispose: function () {
  57273. roams.unregister(this.api, this.dataZoomModel.id);
  57274. InsideZoomView.superApply(this, 'dispose', arguments);
  57275. this._range = null;
  57276. },
  57277. /**
  57278. * @private
  57279. */
  57280. _onPan: function (coordInfo, coordSysName, controller, dx, dy, oldX, oldY, newX, newY) {
  57281. var range = this._range.slice();
  57282. // Calculate transform by the first axis.
  57283. var axisModel = coordInfo.axisModels[0];
  57284. if (!axisModel) {
  57285. return;
  57286. }
  57287. var directionInfo = getDirectionInfo[coordSysName](
  57288. [oldX, oldY], [newX, newY], axisModel, controller, coordInfo
  57289. );
  57290. var percentDelta = directionInfo.signal
  57291. * (range[1] - range[0])
  57292. * directionInfo.pixel / directionInfo.pixelLength;
  57293. sliderMove(percentDelta, range, [0, 100], 'all');
  57294. return (this._range = range);
  57295. },
  57296. /**
  57297. * @private
  57298. */
  57299. _onZoom: function (coordInfo, coordSysName, controller, scale, mouseX, mouseY) {
  57300. var range = this._range.slice();
  57301. // Calculate transform by the first axis.
  57302. var axisModel = coordInfo.axisModels[0];
  57303. if (!axisModel) {
  57304. return;
  57305. }
  57306. var directionInfo = getDirectionInfo[coordSysName](
  57307. null, [mouseX, mouseY], axisModel, controller, coordInfo
  57308. );
  57309. var percentPoint = (
  57310. directionInfo.signal > 0
  57311. ? (directionInfo.pixelStart + directionInfo.pixelLength - directionInfo.pixel)
  57312. : (directionInfo.pixel - directionInfo.pixelStart)
  57313. ) / directionInfo.pixelLength * (range[1] - range[0]) + range[0];
  57314. scale = Math.max(1 / scale, 0);
  57315. range[0] = (range[0] - percentPoint) * scale + percentPoint;
  57316. range[1] = (range[1] - percentPoint) * scale + percentPoint;
  57317. // Restrict range.
  57318. var minMaxSpan = this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
  57319. sliderMove(0, range, [0, 100], 0, minMaxSpan.minSpan, minMaxSpan.maxSpan);
  57320. return (this._range = range);
  57321. }
  57322. });
  57323. var getDirectionInfo = {
  57324. grid: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  57325. var axis = axisModel.axis;
  57326. var ret = {};
  57327. var rect = coordInfo.model.coordinateSystem.getRect();
  57328. oldPoint = oldPoint || [0, 0];
  57329. if (axis.dim === 'x') {
  57330. ret.pixel = newPoint[0] - oldPoint[0];
  57331. ret.pixelLength = rect.width;
  57332. ret.pixelStart = rect.x;
  57333. ret.signal = axis.inverse ? 1 : -1;
  57334. }
  57335. else { // axis.dim === 'y'
  57336. ret.pixel = newPoint[1] - oldPoint[1];
  57337. ret.pixelLength = rect.height;
  57338. ret.pixelStart = rect.y;
  57339. ret.signal = axis.inverse ? -1 : 1;
  57340. }
  57341. return ret;
  57342. },
  57343. polar: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  57344. var axis = axisModel.axis;
  57345. var ret = {};
  57346. var polar = coordInfo.model.coordinateSystem;
  57347. var radiusExtent = polar.getRadiusAxis().getExtent();
  57348. var angleExtent = polar.getAngleAxis().getExtent();
  57349. oldPoint = oldPoint ? polar.pointToCoord(oldPoint) : [0, 0];
  57350. newPoint = polar.pointToCoord(newPoint);
  57351. if (axisModel.mainType === 'radiusAxis') {
  57352. ret.pixel = newPoint[0] - oldPoint[0];
  57353. // ret.pixelLength = Math.abs(radiusExtent[1] - radiusExtent[0]);
  57354. // ret.pixelStart = Math.min(radiusExtent[0], radiusExtent[1]);
  57355. ret.pixelLength = radiusExtent[1] - radiusExtent[0];
  57356. ret.pixelStart = radiusExtent[0];
  57357. ret.signal = axis.inverse ? 1 : -1;
  57358. }
  57359. else { // 'angleAxis'
  57360. ret.pixel = newPoint[1] - oldPoint[1];
  57361. // ret.pixelLength = Math.abs(angleExtent[1] - angleExtent[0]);
  57362. // ret.pixelStart = Math.min(angleExtent[0], angleExtent[1]);
  57363. ret.pixelLength = angleExtent[1] - angleExtent[0];
  57364. ret.pixelStart = angleExtent[0];
  57365. ret.signal = axis.inverse ? -1 : 1;
  57366. }
  57367. return ret;
  57368. },
  57369. singleAxis: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  57370. var axis = axisModel.axis;
  57371. var rect = coordInfo.model.coordinateSystem.getRect();
  57372. var ret = {};
  57373. oldPoint = oldPoint || [0, 0];
  57374. if (axis.orient === 'horizontal') {
  57375. ret.pixel = newPoint[0] - oldPoint[0];
  57376. ret.pixelLength = rect.width;
  57377. ret.pixelStart = rect.x;
  57378. ret.signal = axis.inverse ? 1 : -1;
  57379. }
  57380. else { // 'vertical'
  57381. ret.pixel = newPoint[1] - oldPoint[1];
  57382. ret.pixelLength = rect.height;
  57383. ret.pixelStart = rect.y;
  57384. ret.signal = axis.inverse ? -1 : 1;
  57385. }
  57386. return ret;
  57387. }
  57388. };
  57389. module.exports = InsideZoomView;
  57390. /***/ }),
  57391. /* 381 */
  57392. /***/ (function(module, exports, __webpack_require__) {
  57393. /**
  57394. * @file Roam controller manager.
  57395. */
  57396. // Only create one roam controller for each coordinate system.
  57397. // one roam controller might be refered by two inside data zoom
  57398. // components (for example, one for x and one for y). When user
  57399. // pan or zoom, only dispatch one action for those data zoom
  57400. // components.
  57401. var zrUtil = __webpack_require__(4);
  57402. var RoamController = __webpack_require__(186);
  57403. var throttle = __webpack_require__(86);
  57404. var curry = zrUtil.curry;
  57405. var ATTR = '\0_ec_dataZoom_roams';
  57406. var roams = {
  57407. /**
  57408. * @public
  57409. * @param {module:echarts/ExtensionAPI} api
  57410. * @param {Object} dataZoomInfo
  57411. * @param {string} dataZoomInfo.coordId
  57412. * @param {Function} dataZoomInfo.containsPoint
  57413. * @param {Array.<string>} dataZoomInfo.allCoordIds
  57414. * @param {string} dataZoomInfo.dataZoomId
  57415. * @param {number} dataZoomInfo.throttleRate
  57416. * @param {Function} dataZoomInfo.panGetRange
  57417. * @param {Function} dataZoomInfo.zoomGetRange
  57418. * @param {boolean} [dataZoomInfo.zoomLock]
  57419. * @param {boolean} [dataZoomInfo.disabled]
  57420. */
  57421. register: function (api, dataZoomInfo) {
  57422. var store = giveStore(api);
  57423. var theDataZoomId = dataZoomInfo.dataZoomId;
  57424. var theCoordId = dataZoomInfo.coordId;
  57425. // Do clean when a dataZoom changes its target coordnate system.
  57426. // Avoid memory leak, dispose all not-used-registered.
  57427. zrUtil.each(store, function (record, coordId) {
  57428. var dataZoomInfos = record.dataZoomInfos;
  57429. if (dataZoomInfos[theDataZoomId]
  57430. && zrUtil.indexOf(dataZoomInfo.allCoordIds, theCoordId) < 0
  57431. ) {
  57432. delete dataZoomInfos[theDataZoomId];
  57433. record.count--;
  57434. }
  57435. });
  57436. cleanStore(store);
  57437. var record = store[theCoordId];
  57438. // Create if needed.
  57439. if (!record) {
  57440. record = store[theCoordId] = {
  57441. coordId: theCoordId,
  57442. dataZoomInfos: {},
  57443. count: 0
  57444. };
  57445. record.controller = createController(api, record);
  57446. record.dispatchAction = zrUtil.curry(dispatchAction, api);
  57447. }
  57448. // Update reference of dataZoom.
  57449. !(record.dataZoomInfos[theDataZoomId]) && record.count++;
  57450. record.dataZoomInfos[theDataZoomId] = dataZoomInfo;
  57451. var controllerParams = mergeControllerParams(record.dataZoomInfos);
  57452. record.controller.enable(controllerParams.controlType, controllerParams.opt);
  57453. // Consider resize, area should be always updated.
  57454. record.controller.setPointerChecker(dataZoomInfo.containsPoint);
  57455. // Update throttle.
  57456. throttle.createOrUpdate(
  57457. record,
  57458. 'dispatchAction',
  57459. dataZoomInfo.throttleRate,
  57460. 'fixRate'
  57461. );
  57462. },
  57463. /**
  57464. * @public
  57465. * @param {module:echarts/ExtensionAPI} api
  57466. * @param {string} dataZoomId
  57467. */
  57468. unregister: function (api, dataZoomId) {
  57469. var store = giveStore(api);
  57470. zrUtil.each(store, function (record) {
  57471. record.controller.dispose();
  57472. var dataZoomInfos = record.dataZoomInfos;
  57473. if (dataZoomInfos[dataZoomId]) {
  57474. delete dataZoomInfos[dataZoomId];
  57475. record.count--;
  57476. }
  57477. });
  57478. cleanStore(store);
  57479. },
  57480. /**
  57481. * @public
  57482. */
  57483. shouldRecordRange: function (payload, dataZoomId) {
  57484. if (payload && payload.type === 'dataZoom' && payload.batch) {
  57485. for (var i = 0, len = payload.batch.length; i < len; i++) {
  57486. if (payload.batch[i].dataZoomId === dataZoomId) {
  57487. return false;
  57488. }
  57489. }
  57490. }
  57491. return true;
  57492. },
  57493. /**
  57494. * @public
  57495. */
  57496. generateCoordId: function (coordModel) {
  57497. return coordModel.type + '\0_' + coordModel.id;
  57498. }
  57499. };
  57500. /**
  57501. * Key: coordId, value: {dataZoomInfos: [], count, controller}
  57502. * @type {Array.<Object>}
  57503. */
  57504. function giveStore(api) {
  57505. // Mount store on zrender instance, so that we do not
  57506. // need to worry about dispose.
  57507. var zr = api.getZr();
  57508. return zr[ATTR] || (zr[ATTR] = {});
  57509. }
  57510. function createController(api, newRecord) {
  57511. var controller = new RoamController(api.getZr());
  57512. controller.on('pan', curry(onPan, newRecord));
  57513. controller.on('zoom', curry(onZoom, newRecord));
  57514. return controller;
  57515. }
  57516. function cleanStore(store) {
  57517. zrUtil.each(store, function (record, coordId) {
  57518. if (!record.count) {
  57519. record.controller.dispose();
  57520. delete store[coordId];
  57521. }
  57522. });
  57523. }
  57524. function onPan(record, dx, dy, oldX, oldY, newX, newY) {
  57525. wrapAndDispatch(record, function (info) {
  57526. return info.panGetRange(record.controller, dx, dy, oldX, oldY, newX, newY);
  57527. });
  57528. }
  57529. function onZoom(record, scale, mouseX, mouseY) {
  57530. wrapAndDispatch(record, function (info) {
  57531. return info.zoomGetRange(record.controller, scale, mouseX, mouseY);
  57532. });
  57533. }
  57534. function wrapAndDispatch(record, getRange) {
  57535. var batch = [];
  57536. zrUtil.each(record.dataZoomInfos, function (info) {
  57537. var range = getRange(info);
  57538. !info.disabled && range && batch.push({
  57539. dataZoomId: info.dataZoomId,
  57540. start: range[0],
  57541. end: range[1]
  57542. });
  57543. });
  57544. record.dispatchAction(batch);
  57545. }
  57546. /**
  57547. * This action will be throttled.
  57548. */
  57549. function dispatchAction(api, batch) {
  57550. api.dispatchAction({
  57551. type: 'dataZoom',
  57552. batch: batch
  57553. });
  57554. }
  57555. /**
  57556. * Merge roamController settings when multiple dataZooms share one roamController.
  57557. */
  57558. function mergeControllerParams(dataZoomInfos) {
  57559. var controlType;
  57560. var opt = {};
  57561. var typePriority = {
  57562. 'true': 2,
  57563. 'move': 1,
  57564. 'false': 0,
  57565. 'undefined': -1
  57566. };
  57567. zrUtil.each(dataZoomInfos, function (dataZoomInfo) {
  57568. var oneType = dataZoomInfo.disabled ? false : dataZoomInfo.zoomLock ? 'move' : true;
  57569. typePriority[oneType] > typePriority[controlType] && (controlType = oneType);
  57570. // Do not support that different 'shift'/'ctrl'/'alt' setting used in one coord sys.
  57571. zrUtil.extend(opt, dataZoomInfo.roamControllerOpt);
  57572. });
  57573. return {
  57574. controlType: controlType,
  57575. opt: opt
  57576. };
  57577. }
  57578. module.exports = roams;
  57579. /***/ }),
  57580. /* 382 */
  57581. /***/ (function(module, exports, __webpack_require__) {
  57582. /**
  57583. * @file Data zoom processor
  57584. */
  57585. var echarts = __webpack_require__(1);
  57586. echarts.registerProcessor(function (ecModel, api) {
  57587. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  57588. // We calculate window and reset axis here but not in model
  57589. // init stage and not after action dispatch handler, because
  57590. // reset should be called after seriesData.restoreData.
  57591. dataZoomModel.eachTargetAxis(resetSingleAxis);
  57592. // Caution: data zoom filtering is order sensitive when using
  57593. // percent range and no min/max/scale set on axis.
  57594. // For example, we have dataZoom definition:
  57595. // [
  57596. // {xAxisIndex: 0, start: 30, end: 70},
  57597. // {yAxisIndex: 0, start: 20, end: 80}
  57598. // ]
  57599. // In this case, [20, 80] of y-dataZoom should be based on data
  57600. // that have filtered by x-dataZoom using range of [30, 70],
  57601. // but should not be based on full raw data. Thus sliding
  57602. // x-dataZoom will change both ranges of xAxis and yAxis,
  57603. // while sliding y-dataZoom will only change the range of yAxis.
  57604. // So we should filter x-axis after reset x-axis immediately,
  57605. // and then reset y-axis and filter y-axis.
  57606. dataZoomModel.eachTargetAxis(filterSingleAxis);
  57607. });
  57608. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  57609. // Fullfill all of the range props so that user
  57610. // is able to get them from chart.getOption().
  57611. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  57612. var percentRange = axisProxy.getDataPercentWindow();
  57613. var valueRange = axisProxy.getDataValueWindow();
  57614. dataZoomModel.setRawRange({
  57615. start: percentRange[0],
  57616. end: percentRange[1],
  57617. startValue: valueRange[0],
  57618. endValue: valueRange[1]
  57619. }, true);
  57620. });
  57621. });
  57622. function resetSingleAxis(dimNames, axisIndex, dataZoomModel) {
  57623. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel);
  57624. }
  57625. function filterSingleAxis(dimNames, axisIndex, dataZoomModel) {
  57626. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel);
  57627. }
  57628. /***/ }),
  57629. /* 383 */
  57630. /***/ (function(module, exports, __webpack_require__) {
  57631. /**
  57632. * @file Data zoom action
  57633. */
  57634. var zrUtil = __webpack_require__(4);
  57635. var helper = __webpack_require__(374);
  57636. var echarts = __webpack_require__(1);
  57637. echarts.registerAction('dataZoom', function (payload, ecModel) {
  57638. var linkedNodesFinder = helper.createLinkedNodesFinder(
  57639. zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'),
  57640. helper.eachAxisDim,
  57641. function (model, dimNames) {
  57642. return model.get(dimNames.axisIndex);
  57643. }
  57644. );
  57645. var effectedModels = [];
  57646. ecModel.eachComponent(
  57647. {mainType: 'dataZoom', query: payload},
  57648. function (model, index) {
  57649. effectedModels.push.apply(
  57650. effectedModels, linkedNodesFinder(model).nodes
  57651. );
  57652. }
  57653. );
  57654. zrUtil.each(effectedModels, function (dataZoomModel, index) {
  57655. dataZoomModel.setRawRange({
  57656. start: payload.start,
  57657. end: payload.end,
  57658. startValue: payload.startValue,
  57659. endValue: payload.endValue
  57660. });
  57661. });
  57662. });
  57663. /***/ }),
  57664. /* 384 */
  57665. /***/ (function(module, exports, __webpack_require__) {
  57666. /**
  57667. * visualMap component entry
  57668. */
  57669. __webpack_require__(385);
  57670. __webpack_require__(396);
  57671. /***/ }),
  57672. /* 385 */
  57673. /***/ (function(module, exports, __webpack_require__) {
  57674. /**
  57675. * DataZoom component entry
  57676. */
  57677. __webpack_require__(1).registerPreprocessor(
  57678. __webpack_require__(386)
  57679. );
  57680. __webpack_require__(387);
  57681. __webpack_require__(388);
  57682. __webpack_require__(389);
  57683. __webpack_require__(392);
  57684. __webpack_require__(395);
  57685. /***/ }),
  57686. /* 386 */
  57687. /***/ (function(module, exports, __webpack_require__) {
  57688. /**
  57689. * @file VisualMap preprocessor
  57690. */
  57691. var zrUtil = __webpack_require__(4);
  57692. var each = zrUtil.each;
  57693. module.exports = function (option) {
  57694. var visualMap = option && option.visualMap;
  57695. if (!zrUtil.isArray(visualMap)) {
  57696. visualMap = visualMap ? [visualMap] : [];
  57697. }
  57698. each(visualMap, function (opt) {
  57699. if (!opt) {
  57700. return;
  57701. }
  57702. // rename splitList to pieces
  57703. if (has(opt, 'splitList') && !has(opt, 'pieces')) {
  57704. opt.pieces = opt.splitList;
  57705. delete opt.splitList;
  57706. }
  57707. var pieces = opt.pieces;
  57708. if (pieces && zrUtil.isArray(pieces)) {
  57709. each(pieces, function (piece) {
  57710. if (zrUtil.isObject(piece)) {
  57711. if (has(piece, 'start') && !has(piece, 'min')) {
  57712. piece.min = piece.start;
  57713. }
  57714. if (has(piece, 'end') && !has(piece, 'max')) {
  57715. piece.max = piece.end;
  57716. }
  57717. }
  57718. });
  57719. }
  57720. });
  57721. };
  57722. function has(obj, name) {
  57723. return obj && obj.hasOwnProperty && obj.hasOwnProperty(name);
  57724. }
  57725. /***/ }),
  57726. /* 387 */
  57727. /***/ (function(module, exports, __webpack_require__) {
  57728. __webpack_require__(72).registerSubTypeDefaulter('visualMap', function (option) {
  57729. // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used.
  57730. return (
  57731. !option.categories
  57732. && (
  57733. !(
  57734. option.pieces
  57735. ? option.pieces.length > 0
  57736. : option.splitNumber > 0
  57737. )
  57738. || option.calculable
  57739. )
  57740. )
  57741. ? 'continuous' : 'piecewise';
  57742. });
  57743. /***/ }),
  57744. /* 388 */
  57745. /***/ (function(module, exports, __webpack_require__) {
  57746. /**
  57747. * @file Data range visual coding.
  57748. */
  57749. var echarts = __webpack_require__(1);
  57750. var visualSolution = __webpack_require__(357);
  57751. var VisualMapping = __webpack_require__(206);
  57752. var zrUtil = __webpack_require__(4);
  57753. echarts.registerVisual(echarts.PRIORITY.VISUAL.COMPONENT, function (ecModel) {
  57754. ecModel.eachComponent('visualMap', function (visualMapModel) {
  57755. processSingleVisualMap(visualMapModel, ecModel);
  57756. });
  57757. prepareVisualMeta(ecModel);
  57758. });
  57759. function processSingleVisualMap(visualMapModel, ecModel) {
  57760. visualMapModel.eachTargetSeries(function (seriesModel) {
  57761. var data = seriesModel.getData();
  57762. visualSolution.applyVisual(
  57763. visualMapModel.stateList,
  57764. visualMapModel.targetVisuals,
  57765. data,
  57766. visualMapModel.getValueState,
  57767. visualMapModel,
  57768. visualMapModel.getDataDimension(data)
  57769. );
  57770. });
  57771. }
  57772. // Only support color.
  57773. function prepareVisualMeta(ecModel) {
  57774. ecModel.eachSeries(function (seriesModel) {
  57775. var data = seriesModel.getData();
  57776. var visualMetaList = [];
  57777. ecModel.eachComponent('visualMap', function (visualMapModel) {
  57778. if (visualMapModel.isTargetSeries(seriesModel)) {
  57779. var visualMeta = visualMapModel.getVisualMeta(
  57780. zrUtil.bind(getColorVisual, null, seriesModel, visualMapModel)
  57781. ) || {stops: [], outerColors: []};
  57782. visualMeta.dimension = visualMapModel.getDataDimension(data);
  57783. visualMetaList.push(visualMeta);
  57784. }
  57785. });
  57786. // console.log(JSON.stringify(visualMetaList.map(a => a.stops)));
  57787. seriesModel.getData().setVisual('visualMeta', visualMetaList);
  57788. });
  57789. }
  57790. // FIXME
  57791. // performance and export for heatmap?
  57792. // value can be Infinity or -Infinity
  57793. function getColorVisual(seriesModel, visualMapModel, value, valueState) {
  57794. var mappings = visualMapModel.targetVisuals[valueState];
  57795. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  57796. var resultVisual = {
  57797. color: seriesModel.getData().getVisual('color') // default color.
  57798. };
  57799. for (var i = 0, len = visualTypes.length; i < len; i++) {
  57800. var type = visualTypes[i];
  57801. var mapping = mappings[
  57802. type === 'opacity' ? '__alphaForOpacity' : type
  57803. ];
  57804. mapping && mapping.applyVisual(value, getVisual, setVisual);
  57805. }
  57806. return resultVisual.color;
  57807. function getVisual(key) {
  57808. return resultVisual[key];
  57809. }
  57810. function setVisual(key, value) {
  57811. resultVisual[key] = value;
  57812. }
  57813. }
  57814. /***/ }),
  57815. /* 389 */
  57816. /***/ (function(module, exports, __webpack_require__) {
  57817. /**
  57818. * @file Data zoom model
  57819. */
  57820. var VisualMapModel = __webpack_require__(390);
  57821. var zrUtil = __webpack_require__(4);
  57822. var numberUtil = __webpack_require__(7);
  57823. // Constant
  57824. var DEFAULT_BAR_BOUND = [20, 140];
  57825. var ContinuousModel = VisualMapModel.extend({
  57826. type: 'visualMap.continuous',
  57827. /**
  57828. * @protected
  57829. */
  57830. defaultOption: {
  57831. align: 'auto', // 'auto', 'left', 'right', 'top', 'bottom'
  57832. calculable: false, // This prop effect default component type determine,
  57833. // See echarts/component/visualMap/typeDefaulter.
  57834. range: null, // selected range. In default case `range` is [min, max]
  57835. // and can auto change along with modification of min max,
  57836. // util use specifid a range.
  57837. realtime: true, // Whether realtime update.
  57838. itemHeight: null, // The length of the range control edge.
  57839. itemWidth: null, // The length of the other side.
  57840. hoverLink: true, // Enable hover highlight.
  57841. hoverLinkDataSize: null,// The size of hovered data.
  57842. hoverLinkOnHandle: null // Whether trigger hoverLink when hover handle.
  57843. // If not specified, follow the value of `realtime`.
  57844. },
  57845. /**
  57846. * @override
  57847. */
  57848. optionUpdated: function (newOption, isInit) {
  57849. ContinuousModel.superApply(this, 'optionUpdated', arguments);
  57850. this.resetExtent();
  57851. this.resetVisual(function (mappingOption) {
  57852. mappingOption.mappingMethod = 'linear';
  57853. mappingOption.dataExtent = this.getExtent();
  57854. });
  57855. this._resetRange();
  57856. },
  57857. /**
  57858. * @protected
  57859. * @override
  57860. */
  57861. resetItemSize: function () {
  57862. ContinuousModel.superApply(this, 'resetItemSize', arguments);
  57863. var itemSize = this.itemSize;
  57864. this._orient === 'horizontal' && itemSize.reverse();
  57865. (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]);
  57866. (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]);
  57867. },
  57868. /**
  57869. * @private
  57870. */
  57871. _resetRange: function () {
  57872. var dataExtent = this.getExtent();
  57873. var range = this.option.range;
  57874. if (!range || range.auto) {
  57875. // `range` should always be array (so we dont use other
  57876. // value like 'auto') for user-friend. (consider getOption).
  57877. dataExtent.auto = 1;
  57878. this.option.range = dataExtent;
  57879. }
  57880. else if (zrUtil.isArray(range)) {
  57881. if (range[0] > range[1]) {
  57882. range.reverse();
  57883. }
  57884. range[0] = Math.max(range[0], dataExtent[0]);
  57885. range[1] = Math.min(range[1], dataExtent[1]);
  57886. }
  57887. },
  57888. /**
  57889. * @protected
  57890. * @override
  57891. */
  57892. completeVisualOption: function () {
  57893. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  57894. zrUtil.each(this.stateList, function (state) {
  57895. var symbolSize = this.option.controller[state].symbolSize;
  57896. if (symbolSize && symbolSize[0] !== symbolSize[1]) {
  57897. symbolSize[0] = 0; // For good looking.
  57898. }
  57899. }, this);
  57900. },
  57901. /**
  57902. * @override
  57903. */
  57904. setSelected: function (selected) {
  57905. this.option.range = selected.slice();
  57906. this._resetRange();
  57907. },
  57908. /**
  57909. * @public
  57910. */
  57911. getSelected: function () {
  57912. var dataExtent = this.getExtent();
  57913. var dataInterval = numberUtil.asc(
  57914. (this.get('range') || []).slice()
  57915. );
  57916. // Clamp
  57917. dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]);
  57918. dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]);
  57919. dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]);
  57920. dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]);
  57921. return dataInterval;
  57922. },
  57923. /**
  57924. * @override
  57925. */
  57926. getValueState: function (value) {
  57927. var range = this.option.range;
  57928. var dataExtent = this.getExtent();
  57929. // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'.
  57930. // range[1] is processed likewise.
  57931. return (
  57932. (range[0] <= dataExtent[0] || range[0] <= value)
  57933. && (range[1] >= dataExtent[1] || value <= range[1])
  57934. ) ? 'inRange' : 'outOfRange';
  57935. },
  57936. /**
  57937. * @params {Array.<number>} range target value: range[0] <= value && value <= range[1]
  57938. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  57939. */
  57940. findTargetDataIndices: function (range) {
  57941. var result = [];
  57942. this.eachTargetSeries(function (seriesModel) {
  57943. var dataIndices = [];
  57944. var data = seriesModel.getData();
  57945. data.each(this.getDataDimension(data), function (value, dataIndex) {
  57946. range[0] <= value && value <= range[1] && dataIndices.push(dataIndex);
  57947. }, true, this);
  57948. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  57949. }, this);
  57950. return result;
  57951. },
  57952. /**
  57953. * @implement
  57954. */
  57955. getVisualMeta: function (getColorVisual) {
  57956. var oVals = getColorStopValues(this, 'outOfRange', this.getExtent());
  57957. var iVals = getColorStopValues(this, 'inRange', this.option.range.slice());
  57958. var stops = [];
  57959. function setStop(value, valueState) {
  57960. stops.push({
  57961. value: value,
  57962. color: getColorVisual(value, valueState)
  57963. });
  57964. }
  57965. // Format to: outOfRange -- inRange -- outOfRange.
  57966. var iIdx = 0;
  57967. var oIdx = 0;
  57968. var iLen = iVals.length;
  57969. var oLen = oVals.length;
  57970. for (; oIdx < oLen && (!iVals.length || oVals[oIdx] <= iVals[0]); oIdx++) {
  57971. // If oVal[oIdx] === iVals[iIdx], oVal[oIdx] should be ignored.
  57972. if (oVals[oIdx] < iVals[iIdx]) {
  57973. setStop(oVals[oIdx], 'outOfRange');
  57974. }
  57975. }
  57976. for (var first = 1; iIdx < iLen; iIdx++, first = 0) {
  57977. // If range is full, value beyond min, max will be clamped.
  57978. // make a singularity
  57979. first && stops.length && setStop(iVals[iIdx], 'outOfRange');
  57980. setStop(iVals[iIdx], 'inRange');
  57981. }
  57982. for (var first = 1; oIdx < oLen; oIdx++) {
  57983. if (!iVals.length || iVals[iVals.length - 1] < oVals[oIdx]) {
  57984. // make a singularity
  57985. if (first) {
  57986. stops.length && setStop(stops[stops.length - 1].value, 'outOfRange');
  57987. first = 0;
  57988. }
  57989. setStop(oVals[oIdx], 'outOfRange');
  57990. }
  57991. }
  57992. var stopsLen = stops.length;
  57993. return {
  57994. stops: stops,
  57995. outerColors: [
  57996. stopsLen ? stops[0].color : 'transparent',
  57997. stopsLen ? stops[stopsLen - 1].color : 'transparent'
  57998. ]
  57999. };
  58000. }
  58001. });
  58002. function getColorStopValues(visualMapModel, valueState, dataExtent) {
  58003. if (dataExtent[0] === dataExtent[1]) {
  58004. return dataExtent.slice();
  58005. }
  58006. // When using colorHue mapping, it is not linear color any more.
  58007. // Moreover, canvas gradient seems not to be accurate linear.
  58008. // FIXME
  58009. // Should be arbitrary value 100? or based on pixel size?
  58010. var count = 200;
  58011. var step = (dataExtent[1] - dataExtent[0]) / count;
  58012. var value = dataExtent[0];
  58013. var stopValues = [];
  58014. for (var i = 0; i <= count && value < dataExtent[1]; i++) {
  58015. stopValues.push(value);
  58016. value += step;
  58017. }
  58018. stopValues.push(dataExtent[1]);
  58019. return stopValues;
  58020. }
  58021. module.exports = ContinuousModel;
  58022. /***/ }),
  58023. /* 390 */
  58024. /***/ (function(module, exports, __webpack_require__) {
  58025. /**
  58026. * @file Controller visual map model
  58027. */
  58028. var echarts = __webpack_require__(1);
  58029. var zrUtil = __webpack_require__(4);
  58030. var env = __webpack_require__(2);
  58031. var visualDefault = __webpack_require__(391);
  58032. var VisualMapping = __webpack_require__(206);
  58033. var visualSolution = __webpack_require__(357);
  58034. var mapVisual = VisualMapping.mapVisual;
  58035. var modelUtil = __webpack_require__(5);
  58036. var eachVisual = VisualMapping.eachVisual;
  58037. var numberUtil = __webpack_require__(7);
  58038. var isArray = zrUtil.isArray;
  58039. var each = zrUtil.each;
  58040. var asc = numberUtil.asc;
  58041. var linearMap = numberUtil.linearMap;
  58042. var noop = zrUtil.noop;
  58043. var DEFAULT_COLOR = ['#f6efa6', '#d88273', '#bf444c'];
  58044. var VisualMapModel = echarts.extendComponentModel({
  58045. type: 'visualMap',
  58046. dependencies: ['series'],
  58047. /**
  58048. * @readOnly
  58049. * @type {Array.<string>}
  58050. */
  58051. stateList: ['inRange', 'outOfRange'],
  58052. /**
  58053. * @readOnly
  58054. * @type {Array.<string>}
  58055. */
  58056. replacableOptionKeys: [
  58057. 'inRange', 'outOfRange', 'target', 'controller', 'color'
  58058. ],
  58059. /**
  58060. * [lowerBound, upperBound]
  58061. *
  58062. * @readOnly
  58063. * @type {Array.<number>}
  58064. */
  58065. dataBound: [-Infinity, Infinity],
  58066. /**
  58067. * @readOnly
  58068. * @type {string|Object}
  58069. */
  58070. layoutMode: {type: 'box', ignoreSize: true},
  58071. /**
  58072. * @protected
  58073. */
  58074. defaultOption: {
  58075. show: true,
  58076. zlevel: 0,
  58077. z: 4,
  58078. seriesIndex: 'all', // 'all' or null/undefined: all series.
  58079. // A number or an array of number: the specified series.
  58080. // set min: 0, max: 200, only for campatible with ec2.
  58081. // In fact min max should not have default value.
  58082. min: 0, // min value, must specified if pieces is not specified.
  58083. max: 200, // max value, must specified if pieces is not specified.
  58084. dimension: null,
  58085. inRange: null, // 'color', 'colorHue', 'colorSaturation', 'colorLightness', 'colorAlpha',
  58086. // 'symbol', 'symbolSize'
  58087. outOfRange: null, // 'color', 'colorHue', 'colorSaturation',
  58088. // 'colorLightness', 'colorAlpha',
  58089. // 'symbol', 'symbolSize'
  58090. left: 0, // 'center' ¦ 'left' ¦ 'right' ¦ {number} (px)
  58091. right: null, // The same as left.
  58092. top: null, // 'top' ¦ 'bottom' ¦ 'center' ¦ {number} (px)
  58093. bottom: 0, // The same as top.
  58094. itemWidth: null,
  58095. itemHeight: null,
  58096. inverse: false,
  58097. orient: 'vertical', // 'horizontal' ¦ 'vertical'
  58098. backgroundColor: 'rgba(0,0,0,0)',
  58099. borderColor: '#ccc', // 值域边框颜色
  58100. contentColor: '#5793f3',
  58101. inactiveColor: '#aaa',
  58102. borderWidth: 0, // 值域边框线宽,单位px,默认为0(无边框)
  58103. padding: 5, // 值域内边距,单位px,默认各方向内边距为5,
  58104. // 接受数组分别设定上右下左边距,同css
  58105. textGap: 10, //
  58106. precision: 0, // 小数精度,默认为0,无小数点
  58107. color: null, //颜色(deprecated,兼容ec2,顺序同pieces,不同于inRange/outOfRange)
  58108. formatter: null,
  58109. text: null, // 文本,如['高', '低'],兼容ec2,text[0]对应高值,text[1]对应低值
  58110. textStyle: {
  58111. color: '#333' // 值域文字颜色
  58112. }
  58113. },
  58114. /**
  58115. * @protected
  58116. */
  58117. init: function (option, parentModel, ecModel) {
  58118. /**
  58119. * @private
  58120. * @type {Array.<number>}
  58121. */
  58122. this._dataExtent;
  58123. /**
  58124. * @readOnly
  58125. */
  58126. this.targetVisuals = {};
  58127. /**
  58128. * @readOnly
  58129. */
  58130. this.controllerVisuals = {};
  58131. /**
  58132. * @readOnly
  58133. */
  58134. this.textStyleModel;
  58135. /**
  58136. * [width, height]
  58137. * @readOnly
  58138. * @type {Array.<number>}
  58139. */
  58140. this.itemSize;
  58141. this.mergeDefaultAndTheme(option, ecModel);
  58142. },
  58143. /**
  58144. * @protected
  58145. */
  58146. optionUpdated: function (newOption, isInit) {
  58147. var thisOption = this.option;
  58148. // FIXME
  58149. // necessary?
  58150. // Disable realtime view update if canvas is not supported.
  58151. if (!env.canvasSupported) {
  58152. thisOption.realtime = false;
  58153. }
  58154. !isInit && visualSolution.replaceVisualOption(
  58155. thisOption, newOption, this.replacableOptionKeys
  58156. );
  58157. this.textStyleModel = this.getModel('textStyle');
  58158. this.resetItemSize();
  58159. this.completeVisualOption();
  58160. },
  58161. /**
  58162. * @protected
  58163. */
  58164. resetVisual: function (supplementVisualOption) {
  58165. var stateList = this.stateList;
  58166. supplementVisualOption = zrUtil.bind(supplementVisualOption, this);
  58167. this.controllerVisuals = visualSolution.createVisualMappings(
  58168. this.option.controller, stateList, supplementVisualOption
  58169. );
  58170. this.targetVisuals = visualSolution.createVisualMappings(
  58171. this.option.target, stateList, supplementVisualOption
  58172. );
  58173. },
  58174. /**
  58175. * @protected
  58176. * @return {Array.<number>} An array of series indices.
  58177. */
  58178. getTargetSeriesIndices: function () {
  58179. var optionSeriesIndex = this.option.seriesIndex;
  58180. var seriesIndices = [];
  58181. if (optionSeriesIndex == null || optionSeriesIndex === 'all') {
  58182. this.ecModel.eachSeries(function (seriesModel, index) {
  58183. seriesIndices.push(index);
  58184. });
  58185. }
  58186. else {
  58187. seriesIndices = modelUtil.normalizeToArray(optionSeriesIndex);
  58188. }
  58189. return seriesIndices;
  58190. },
  58191. /**
  58192. * @public
  58193. */
  58194. eachTargetSeries: function (callback, context) {
  58195. zrUtil.each(this.getTargetSeriesIndices(), function (seriesIndex) {
  58196. callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex));
  58197. }, this);
  58198. },
  58199. /**
  58200. * @pubilc
  58201. */
  58202. isTargetSeries: function (seriesModel) {
  58203. var is = false;
  58204. this.eachTargetSeries(function (model) {
  58205. model === seriesModel && (is = true);
  58206. });
  58207. return is;
  58208. },
  58209. /**
  58210. * @example
  58211. * this.formatValueText(someVal); // format single numeric value to text.
  58212. * this.formatValueText(someVal, true); // format single category value to text.
  58213. * this.formatValueText([min, max]); // format numeric min-max to text.
  58214. * this.formatValueText([this.dataBound[0], max]); // using data lower bound.
  58215. * this.formatValueText([min, this.dataBound[1]]); // using data upper bound.
  58216. *
  58217. * @param {number|Array.<number>} value Real value, or this.dataBound[0 or 1].
  58218. * @param {boolean} [isCategory=false] Only available when value is number.
  58219. * @param {Array.<string>} edgeSymbols Open-close symbol when value is interval.
  58220. * @return {string}
  58221. * @protected
  58222. */
  58223. formatValueText: function(value, isCategory, edgeSymbols) {
  58224. var option = this.option;
  58225. var precision = option.precision;
  58226. var dataBound = this.dataBound;
  58227. var formatter = option.formatter;
  58228. var isMinMax;
  58229. var textValue;
  58230. edgeSymbols = edgeSymbols || ['<', '>'];
  58231. if (zrUtil.isArray(value)) {
  58232. value = value.slice();
  58233. isMinMax = true;
  58234. }
  58235. textValue = isCategory
  58236. ? value
  58237. : (isMinMax
  58238. ? [toFixed(value[0]), toFixed(value[1])]
  58239. : toFixed(value)
  58240. );
  58241. if (zrUtil.isString(formatter)) {
  58242. return formatter
  58243. .replace('{value}', isMinMax ? textValue[0] : textValue)
  58244. .replace('{value2}', isMinMax ? textValue[1] : textValue);
  58245. }
  58246. else if (zrUtil.isFunction(formatter)) {
  58247. return isMinMax
  58248. ? formatter(value[0], value[1])
  58249. : formatter(value);
  58250. }
  58251. if (isMinMax) {
  58252. if (value[0] === dataBound[0]) {
  58253. return edgeSymbols[0] + ' ' + textValue[1];
  58254. }
  58255. else if (value[1] === dataBound[1]) {
  58256. return edgeSymbols[1] + ' ' + textValue[0];
  58257. }
  58258. else {
  58259. return textValue[0] + ' - ' + textValue[1];
  58260. }
  58261. }
  58262. else { // Format single value (includes category case).
  58263. return textValue;
  58264. }
  58265. function toFixed(val) {
  58266. return val === dataBound[0]
  58267. ? 'min'
  58268. : val === dataBound[1]
  58269. ? 'max'
  58270. : (+val).toFixed(Math.min(precision, 20));
  58271. }
  58272. },
  58273. /**
  58274. * @protected
  58275. */
  58276. resetExtent: function () {
  58277. var thisOption = this.option;
  58278. // Can not calculate data extent by data here.
  58279. // Because series and data may be modified in processing stage.
  58280. // So we do not support the feature "auto min/max".
  58281. var extent = asc([thisOption.min, thisOption.max]);
  58282. this._dataExtent = extent;
  58283. },
  58284. /**
  58285. * @public
  58286. * @param {module:echarts/data/List} list
  58287. * @return {string} Concrete dimention. If return null/undefined,
  58288. * no dimension used.
  58289. */
  58290. getDataDimension: function (list) {
  58291. var optDim = this.option.dimension;
  58292. return optDim != null
  58293. ? optDim : list.dimensions.length - 1;
  58294. },
  58295. /**
  58296. * @public
  58297. * @override
  58298. */
  58299. getExtent: function () {
  58300. return this._dataExtent.slice();
  58301. },
  58302. /**
  58303. * @protected
  58304. */
  58305. completeVisualOption: function () {
  58306. var thisOption = this.option;
  58307. var base = {inRange: thisOption.inRange, outOfRange: thisOption.outOfRange};
  58308. var target = thisOption.target || (thisOption.target = {});
  58309. var controller = thisOption.controller || (thisOption.controller = {});
  58310. zrUtil.merge(target, base); // Do not override
  58311. zrUtil.merge(controller, base); // Do not override
  58312. var isCategory = this.isCategory();
  58313. completeSingle.call(this, target);
  58314. completeSingle.call(this, controller);
  58315. completeInactive.call(this, target, 'inRange', 'outOfRange');
  58316. // completeInactive.call(this, target, 'outOfRange', 'inRange');
  58317. completeController.call(this, controller);
  58318. function completeSingle(base) {
  58319. // Compatible with ec2 dataRange.color.
  58320. // The mapping order of dataRange.color is: [high value, ..., low value]
  58321. // whereas inRange.color and outOfRange.color is [low value, ..., high value]
  58322. // Notice: ec2 has no inverse.
  58323. if (isArray(thisOption.color)
  58324. // If there has been inRange: {symbol: ...}, adding color is a mistake.
  58325. // So adding color only when no inRange defined.
  58326. && !base.inRange
  58327. ) {
  58328. base.inRange = {color: thisOption.color.slice().reverse()};
  58329. }
  58330. // Compatible with previous logic, always give a defautl color, otherwise
  58331. // simple config with no inRange and outOfRange will not work.
  58332. // Originally we use visualMap.color as the default color, but setOption at
  58333. // the second time the default color will be erased. So we change to use
  58334. // constant DEFAULT_COLOR.
  58335. // If user do not want the defualt color, set inRange: {color: null}.
  58336. base.inRange = base.inRange || {color: DEFAULT_COLOR};
  58337. // If using shortcut like: {inRange: 'symbol'}, complete default value.
  58338. each(this.stateList, function (state) {
  58339. var visualType = base[state];
  58340. if (zrUtil.isString(visualType)) {
  58341. var defa = visualDefault.get(visualType, 'active', isCategory);
  58342. if (defa) {
  58343. base[state] = {};
  58344. base[state][visualType] = defa;
  58345. }
  58346. else {
  58347. // Mark as not specified.
  58348. delete base[state];
  58349. }
  58350. }
  58351. }, this);
  58352. }
  58353. function completeInactive(base, stateExist, stateAbsent) {
  58354. var optExist = base[stateExist];
  58355. var optAbsent = base[stateAbsent];
  58356. if (optExist && !optAbsent) {
  58357. optAbsent = base[stateAbsent] = {};
  58358. each(optExist, function (visualData, visualType) {
  58359. if (!VisualMapping.isValidType(visualType)) {
  58360. return;
  58361. }
  58362. var defa = visualDefault.get(visualType, 'inactive', isCategory);
  58363. if (defa != null) {
  58364. optAbsent[visualType] = defa;
  58365. // Compatibable with ec2:
  58366. // Only inactive color to rgba(0,0,0,0) can not
  58367. // make label transparent, so use opacity also.
  58368. if (visualType === 'color'
  58369. && !optAbsent.hasOwnProperty('opacity')
  58370. && !optAbsent.hasOwnProperty('colorAlpha')
  58371. ) {
  58372. optAbsent.opacity = [0, 0];
  58373. }
  58374. }
  58375. });
  58376. }
  58377. }
  58378. function completeController(controller) {
  58379. var symbolExists = (controller.inRange || {}).symbol
  58380. || (controller.outOfRange || {}).symbol;
  58381. var symbolSizeExists = (controller.inRange || {}).symbolSize
  58382. || (controller.outOfRange || {}).symbolSize;
  58383. var inactiveColor = this.get('inactiveColor');
  58384. each(this.stateList, function (state) {
  58385. var itemSize = this.itemSize;
  58386. var visuals = controller[state];
  58387. // Set inactive color for controller if no other color
  58388. // attr (like colorAlpha) specified.
  58389. if (!visuals) {
  58390. visuals = controller[state] = {
  58391. color: isCategory ? inactiveColor : [inactiveColor]
  58392. };
  58393. }
  58394. // Consistent symbol and symbolSize if not specified.
  58395. if (visuals.symbol == null) {
  58396. visuals.symbol = symbolExists
  58397. && zrUtil.clone(symbolExists)
  58398. || (isCategory ? 'roundRect' : ['roundRect']);
  58399. }
  58400. if (visuals.symbolSize == null) {
  58401. visuals.symbolSize = symbolSizeExists
  58402. && zrUtil.clone(symbolSizeExists)
  58403. || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]);
  58404. }
  58405. // Filter square and none.
  58406. visuals.symbol = mapVisual(visuals.symbol, function (symbol) {
  58407. return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol;
  58408. });
  58409. // Normalize symbolSize
  58410. var symbolSize = visuals.symbolSize;
  58411. if (symbolSize != null) {
  58412. var max = -Infinity;
  58413. // symbolSize can be object when categories defined.
  58414. eachVisual(symbolSize, function (value) {
  58415. value > max && (max = value);
  58416. });
  58417. visuals.symbolSize = mapVisual(symbolSize, function (value) {
  58418. return linearMap(value, [0, max], [0, itemSize[0]], true);
  58419. });
  58420. }
  58421. }, this);
  58422. }
  58423. },
  58424. /**
  58425. * @protected
  58426. */
  58427. resetItemSize: function () {
  58428. this.itemSize = [
  58429. parseFloat(this.get('itemWidth')),
  58430. parseFloat(this.get('itemHeight'))
  58431. ];
  58432. },
  58433. /**
  58434. * @public
  58435. */
  58436. isCategory: function () {
  58437. return !!this.option.categories;
  58438. },
  58439. /**
  58440. * @public
  58441. * @abstract
  58442. */
  58443. setSelected: noop,
  58444. /**
  58445. * @public
  58446. * @abstract
  58447. * @param {*|module:echarts/data/List} valueOrData
  58448. * @param {number} dataIndex
  58449. * @return {string} state See this.stateList
  58450. */
  58451. getValueState: noop,
  58452. /**
  58453. * FIXME
  58454. * Do not publish to thirt-part-dev temporarily
  58455. * util the interface is stable. (Should it return
  58456. * a function but not visual meta?)
  58457. *
  58458. * @pubilc
  58459. * @abstract
  58460. * @param {Function} getColorVisual
  58461. * params: value, valueState
  58462. * return: color
  58463. * @return {Object} visualMeta
  58464. * should includes {stops, outerColors}
  58465. * outerColor means [colorBeyondMinValue, colorBeyondMaxValue]
  58466. */
  58467. getVisualMeta: noop
  58468. });
  58469. module.exports = VisualMapModel;
  58470. /***/ }),
  58471. /* 391 */
  58472. /***/ (function(module, exports, __webpack_require__) {
  58473. /**
  58474. * @file Visual mapping.
  58475. */
  58476. var zrUtil = __webpack_require__(4);
  58477. var visualDefault = {
  58478. /**
  58479. * @public
  58480. */
  58481. get: function (visualType, key, isCategory) {
  58482. var value = zrUtil.clone(
  58483. (defaultOption[visualType] || {})[key]
  58484. );
  58485. return isCategory
  58486. ? (zrUtil.isArray(value) ? value[value.length - 1] : value)
  58487. : value;
  58488. }
  58489. };
  58490. var defaultOption = {
  58491. color: {
  58492. active: ['#006edd', '#e0ffff'],
  58493. inactive: ['rgba(0,0,0,0)']
  58494. },
  58495. colorHue: {
  58496. active: [0, 360],
  58497. inactive: [0, 0]
  58498. },
  58499. colorSaturation: {
  58500. active: [0.3, 1],
  58501. inactive: [0, 0]
  58502. },
  58503. colorLightness: {
  58504. active: [0.9, 0.5],
  58505. inactive: [0, 0]
  58506. },
  58507. colorAlpha: {
  58508. active: [0.3, 1],
  58509. inactive: [0, 0]
  58510. },
  58511. opacity: {
  58512. active: [0.3, 1],
  58513. inactive: [0, 0]
  58514. },
  58515. symbol: {
  58516. active: ['circle', 'roundRect', 'diamond'],
  58517. inactive: ['none']
  58518. },
  58519. symbolSize: {
  58520. active: [10, 50],
  58521. inactive: [0, 0]
  58522. }
  58523. };
  58524. module.exports = visualDefault;
  58525. /***/ }),
  58526. /* 392 */
  58527. /***/ (function(module, exports, __webpack_require__) {
  58528. var VisualMapView = __webpack_require__(393);
  58529. var graphic = __webpack_require__(20);
  58530. var zrUtil = __webpack_require__(4);
  58531. var numberUtil = __webpack_require__(7);
  58532. var sliderMove = __webpack_require__(242);
  58533. var LinearGradient = __webpack_require__(68);
  58534. var helper = __webpack_require__(394);
  58535. var modelUtil = __webpack_require__(5);
  58536. var eventTool = __webpack_require__(93);
  58537. var linearMap = numberUtil.linearMap;
  58538. var each = zrUtil.each;
  58539. var mathMin = Math.min;
  58540. var mathMax = Math.max;
  58541. // Arbitrary value
  58542. var HOVER_LINK_SIZE = 12;
  58543. var HOVER_LINK_OUT = 6;
  58544. // Notice:
  58545. // Any "interval" should be by the order of [low, high].
  58546. // "handle0" (handleIndex === 0) maps to
  58547. // low data value: this._dataInterval[0] and has low coord.
  58548. // "handle1" (handleIndex === 1) maps to
  58549. // high data value: this._dataInterval[1] and has high coord.
  58550. // The logic of transform is implemented in this._createBarGroup.
  58551. var ContinuousView = VisualMapView.extend({
  58552. type: 'visualMap.continuous',
  58553. /**
  58554. * @override
  58555. */
  58556. init: function () {
  58557. ContinuousView.superApply(this, 'init', arguments);
  58558. /**
  58559. * @private
  58560. */
  58561. this._shapes = {};
  58562. /**
  58563. * @private
  58564. */
  58565. this._dataInterval = [];
  58566. /**
  58567. * @private
  58568. */
  58569. this._handleEnds = [];
  58570. /**
  58571. * @private
  58572. */
  58573. this._orient;
  58574. /**
  58575. * @private
  58576. */
  58577. this._useHandle;
  58578. /**
  58579. * @private
  58580. */
  58581. this._hoverLinkDataIndices = [];
  58582. /**
  58583. * @private
  58584. */
  58585. this._dragging;
  58586. /**
  58587. * @private
  58588. */
  58589. this._hovering;
  58590. },
  58591. /**
  58592. * @protected
  58593. * @override
  58594. */
  58595. doRender: function (visualMapModel, ecModel, api, payload) {
  58596. if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) {
  58597. this._buildView();
  58598. }
  58599. },
  58600. /**
  58601. * @private
  58602. */
  58603. _buildView: function () {
  58604. this.group.removeAll();
  58605. var visualMapModel = this.visualMapModel;
  58606. var thisGroup = this.group;
  58607. this._orient = visualMapModel.get('orient');
  58608. this._useHandle = visualMapModel.get('calculable');
  58609. this._resetInterval();
  58610. this._renderBar(thisGroup);
  58611. var dataRangeText = visualMapModel.get('text');
  58612. this._renderEndsText(thisGroup, dataRangeText, 0);
  58613. this._renderEndsText(thisGroup, dataRangeText, 1);
  58614. // Do this for background size calculation.
  58615. this._updateView(true);
  58616. // After updating view, inner shapes is built completely,
  58617. // and then background can be rendered.
  58618. this.renderBackground(thisGroup);
  58619. // Real update view
  58620. this._updateView();
  58621. this._enableHoverLinkToSeries();
  58622. this._enableHoverLinkFromSeries();
  58623. this.positionGroup(thisGroup);
  58624. },
  58625. /**
  58626. * @private
  58627. */
  58628. _renderEndsText: function (group, dataRangeText, endsIndex) {
  58629. if (!dataRangeText) {
  58630. return;
  58631. }
  58632. // Compatible with ec2, text[0] map to high value, text[1] map low value.
  58633. var text = dataRangeText[1 - endsIndex];
  58634. text = text != null ? text + '' : '';
  58635. var visualMapModel = this.visualMapModel;
  58636. var textGap = visualMapModel.get('textGap');
  58637. var itemSize = visualMapModel.itemSize;
  58638. var barGroup = this._shapes.barGroup;
  58639. var position = this._applyTransform(
  58640. [
  58641. itemSize[0] / 2,
  58642. endsIndex === 0 ? -textGap : itemSize[1] + textGap
  58643. ],
  58644. barGroup
  58645. );
  58646. var align = this._applyTransform(
  58647. endsIndex === 0 ? 'bottom' : 'top',
  58648. barGroup
  58649. );
  58650. var orient = this._orient;
  58651. var textStyleModel = this.visualMapModel.textStyleModel;
  58652. this.group.add(new graphic.Text({
  58653. style: {
  58654. x: position[0],
  58655. y: position[1],
  58656. textVerticalAlign: orient === 'horizontal' ? 'middle' : align,
  58657. textAlign: orient === 'horizontal' ? align : 'center',
  58658. text: text,
  58659. textFont: textStyleModel.getFont(),
  58660. textFill: textStyleModel.getTextColor()
  58661. }
  58662. }));
  58663. },
  58664. /**
  58665. * @private
  58666. */
  58667. _renderBar: function (targetGroup) {
  58668. var visualMapModel = this.visualMapModel;
  58669. var shapes = this._shapes;
  58670. var itemSize = visualMapModel.itemSize;
  58671. var orient = this._orient;
  58672. var useHandle = this._useHandle;
  58673. var itemAlign = helper.getItemAlign(visualMapModel, this.api, itemSize);
  58674. var barGroup = shapes.barGroup = this._createBarGroup(itemAlign);
  58675. // Bar
  58676. barGroup.add(shapes.outOfRange = createPolygon());
  58677. barGroup.add(shapes.inRange = createPolygon(
  58678. null,
  58679. useHandle ? getCursor(this._orient) : null,
  58680. zrUtil.bind(this._dragHandle, this, 'all', false),
  58681. zrUtil.bind(this._dragHandle, this, 'all', true)
  58682. ));
  58683. var textRect = visualMapModel.textStyleModel.getTextRect('国');
  58684. var textSize = mathMax(textRect.width, textRect.height);
  58685. // Handle
  58686. if (useHandle) {
  58687. shapes.handleThumbs = [];
  58688. shapes.handleLabels = [];
  58689. shapes.handleLabelPoints = [];
  58690. this._createHandle(barGroup, 0, itemSize, textSize, orient, itemAlign);
  58691. this._createHandle(barGroup, 1, itemSize, textSize, orient, itemAlign);
  58692. }
  58693. this._createIndicator(barGroup, itemSize, textSize, orient);
  58694. targetGroup.add(barGroup);
  58695. },
  58696. /**
  58697. * @private
  58698. */
  58699. _createHandle: function (barGroup, handleIndex, itemSize, textSize, orient) {
  58700. var onDrift = zrUtil.bind(this._dragHandle, this, handleIndex, false);
  58701. var onDragEnd = zrUtil.bind(this._dragHandle, this, handleIndex, true);
  58702. var handleThumb = createPolygon(
  58703. createHandlePoints(handleIndex, textSize),
  58704. getCursor(this._orient),
  58705. onDrift,
  58706. onDragEnd
  58707. );
  58708. handleThumb.position[0] = itemSize[0];
  58709. barGroup.add(handleThumb);
  58710. // Text is always horizontal layout but should not be effected by
  58711. // transform (orient/inverse). So label is built separately but not
  58712. // use zrender/graphic/helper/RectText, and is located based on view
  58713. // group (according to handleLabelPoint) but not barGroup.
  58714. var textStyleModel = this.visualMapModel.textStyleModel;
  58715. var handleLabel = new graphic.Text({
  58716. draggable: true,
  58717. drift: onDrift,
  58718. onmousemove: function (e) {
  58719. // Fot mobile devicem, prevent screen slider on the button.
  58720. eventTool.stop(e.event);
  58721. },
  58722. ondragend: onDragEnd,
  58723. style: {
  58724. x: 0, y: 0, text: '',
  58725. textFont: textStyleModel.getFont(),
  58726. textFill: textStyleModel.getTextColor()
  58727. }
  58728. });
  58729. this.group.add(handleLabel);
  58730. var handleLabelPoint = [
  58731. orient === 'horizontal'
  58732. ? textSize / 2
  58733. : textSize * 1.5,
  58734. orient === 'horizontal'
  58735. ? (handleIndex === 0 ? -(textSize * 1.5) : (textSize * 1.5))
  58736. : (handleIndex === 0 ? -textSize / 2 : textSize / 2)
  58737. ];
  58738. var shapes = this._shapes;
  58739. shapes.handleThumbs[handleIndex] = handleThumb;
  58740. shapes.handleLabelPoints[handleIndex] = handleLabelPoint;
  58741. shapes.handleLabels[handleIndex] = handleLabel;
  58742. },
  58743. /**
  58744. * @private
  58745. */
  58746. _createIndicator: function (barGroup, itemSize, textSize, orient) {
  58747. var indicator = createPolygon([[0, 0]], 'move');
  58748. indicator.position[0] = itemSize[0];
  58749. indicator.attr({invisible: true, silent: true});
  58750. barGroup.add(indicator);
  58751. var textStyleModel = this.visualMapModel.textStyleModel;
  58752. var indicatorLabel = new graphic.Text({
  58753. silent: true,
  58754. invisible: true,
  58755. style: {
  58756. x: 0, y: 0, text: '',
  58757. textFont: textStyleModel.getFont(),
  58758. textFill: textStyleModel.getTextColor()
  58759. }
  58760. });
  58761. this.group.add(indicatorLabel);
  58762. var indicatorLabelPoint = [
  58763. orient === 'horizontal' ? textSize / 2 : HOVER_LINK_OUT + 3,
  58764. 0
  58765. ];
  58766. var shapes = this._shapes;
  58767. shapes.indicator = indicator;
  58768. shapes.indicatorLabel = indicatorLabel;
  58769. shapes.indicatorLabelPoint = indicatorLabelPoint;
  58770. },
  58771. /**
  58772. * @private
  58773. */
  58774. _dragHandle: function (handleIndex, isEnd, dx, dy) {
  58775. if (!this._useHandle) {
  58776. return;
  58777. }
  58778. this._dragging = !isEnd;
  58779. if (!isEnd) {
  58780. // Transform dx, dy to bar coordination.
  58781. var vertex = this._applyTransform([dx, dy], this._shapes.barGroup, true);
  58782. this._updateInterval(handleIndex, vertex[1]);
  58783. // Considering realtime, update view should be executed
  58784. // before dispatch action.
  58785. this._updateView();
  58786. }
  58787. // dragEnd do not dispatch action when realtime.
  58788. if (isEnd === !this.visualMapModel.get('realtime')) { // jshint ignore:line
  58789. this.api.dispatchAction({
  58790. type: 'selectDataRange',
  58791. from: this.uid,
  58792. visualMapId: this.visualMapModel.id,
  58793. selected: this._dataInterval.slice()
  58794. });
  58795. }
  58796. if (isEnd) {
  58797. !this._hovering && this._clearHoverLinkToSeries();
  58798. }
  58799. else if (useHoverLinkOnHandle(this.visualMapModel)) {
  58800. this._doHoverLinkToSeries(this._handleEnds[handleIndex], false);
  58801. }
  58802. },
  58803. /**
  58804. * @private
  58805. */
  58806. _resetInterval: function () {
  58807. var visualMapModel = this.visualMapModel;
  58808. var dataInterval = this._dataInterval = visualMapModel.getSelected();
  58809. var dataExtent = visualMapModel.getExtent();
  58810. var sizeExtent = [0, visualMapModel.itemSize[1]];
  58811. this._handleEnds = [
  58812. linearMap(dataInterval[0], dataExtent, sizeExtent, true),
  58813. linearMap(dataInterval[1], dataExtent, sizeExtent, true)
  58814. ];
  58815. },
  58816. /**
  58817. * @private
  58818. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  58819. * @param {number} dx
  58820. * @param {number} dy
  58821. */
  58822. _updateInterval: function (handleIndex, delta) {
  58823. delta = delta || 0;
  58824. var visualMapModel = this.visualMapModel;
  58825. var handleEnds = this._handleEnds;
  58826. var sizeExtent = [0, visualMapModel.itemSize[1]];
  58827. sliderMove(
  58828. delta,
  58829. handleEnds,
  58830. sizeExtent,
  58831. handleIndex,
  58832. // cross is forbiden
  58833. 0
  58834. );
  58835. var dataExtent = visualMapModel.getExtent();
  58836. // Update data interval.
  58837. this._dataInterval = [
  58838. linearMap(handleEnds[0], sizeExtent, dataExtent, true),
  58839. linearMap(handleEnds[1], sizeExtent, dataExtent, true)
  58840. ];
  58841. },
  58842. /**
  58843. * @private
  58844. */
  58845. _updateView: function (forSketch) {
  58846. var visualMapModel = this.visualMapModel;
  58847. var dataExtent = visualMapModel.getExtent();
  58848. var shapes = this._shapes;
  58849. var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]];
  58850. var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds;
  58851. var visualInRange = this._createBarVisual(
  58852. this._dataInterval, dataExtent, inRangeHandleEnds, 'inRange'
  58853. );
  58854. var visualOutOfRange = this._createBarVisual(
  58855. dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange'
  58856. );
  58857. shapes.inRange
  58858. .setStyle({
  58859. fill: visualInRange.barColor,
  58860. opacity: visualInRange.opacity
  58861. })
  58862. .setShape('points', visualInRange.barPoints);
  58863. shapes.outOfRange
  58864. .setStyle({
  58865. fill: visualOutOfRange.barColor,
  58866. opacity: visualOutOfRange.opacity
  58867. })
  58868. .setShape('points', visualOutOfRange.barPoints);
  58869. this._updateHandle(inRangeHandleEnds, visualInRange);
  58870. },
  58871. /**
  58872. * @private
  58873. */
  58874. _createBarVisual: function (dataInterval, dataExtent, handleEnds, forceState) {
  58875. var opts = {
  58876. forceState: forceState,
  58877. convertOpacityToAlpha: true
  58878. };
  58879. var colorStops = this._makeColorGradient(dataInterval, opts);
  58880. var symbolSizes = [
  58881. this.getControllerVisual(dataInterval[0], 'symbolSize', opts),
  58882. this.getControllerVisual(dataInterval[1], 'symbolSize', opts)
  58883. ];
  58884. var barPoints = this._createBarPoints(handleEnds, symbolSizes);
  58885. return {
  58886. barColor: new LinearGradient(0, 0, 0, 1, colorStops),
  58887. barPoints: barPoints,
  58888. handlesColor: [
  58889. colorStops[0].color,
  58890. colorStops[colorStops.length - 1].color
  58891. ]
  58892. };
  58893. },
  58894. /**
  58895. * @private
  58896. */
  58897. _makeColorGradient: function (dataInterval, opts) {
  58898. // Considering colorHue, which is not linear, so we have to sample
  58899. // to calculate gradient color stops, but not only caculate head
  58900. // and tail.
  58901. var sampleNumber = 100; // Arbitrary value.
  58902. var colorStops = [];
  58903. var step = (dataInterval[1] - dataInterval[0]) / sampleNumber;
  58904. colorStops.push({
  58905. color: this.getControllerVisual(dataInterval[0], 'color', opts),
  58906. offset: 0
  58907. });
  58908. for (var i = 1; i < sampleNumber; i++) {
  58909. var currValue = dataInterval[0] + step * i;
  58910. if (currValue > dataInterval[1]) {
  58911. break;
  58912. }
  58913. colorStops.push({
  58914. color: this.getControllerVisual(currValue, 'color', opts),
  58915. offset: i / sampleNumber
  58916. });
  58917. }
  58918. colorStops.push({
  58919. color: this.getControllerVisual(dataInterval[1], 'color', opts),
  58920. offset: 1
  58921. });
  58922. return colorStops;
  58923. },
  58924. /**
  58925. * @private
  58926. */
  58927. _createBarPoints: function (handleEnds, symbolSizes) {
  58928. var itemSize = this.visualMapModel.itemSize;
  58929. return [
  58930. [itemSize[0] - symbolSizes[0], handleEnds[0]],
  58931. [itemSize[0], handleEnds[0]],
  58932. [itemSize[0], handleEnds[1]],
  58933. [itemSize[0] - symbolSizes[1], handleEnds[1]]
  58934. ];
  58935. },
  58936. /**
  58937. * @private
  58938. */
  58939. _createBarGroup: function (itemAlign) {
  58940. var orient = this._orient;
  58941. var inverse = this.visualMapModel.get('inverse');
  58942. return new graphic.Group(
  58943. (orient === 'horizontal' && !inverse)
  58944. ? {scale: itemAlign === 'bottom' ? [1, 1] : [-1, 1], rotation: Math.PI / 2}
  58945. : (orient === 'horizontal' && inverse)
  58946. ? {scale: itemAlign === 'bottom' ? [-1, 1] : [1, 1], rotation: -Math.PI / 2}
  58947. : (orient === 'vertical' && !inverse)
  58948. ? {scale: itemAlign === 'left' ? [1, -1] : [-1, -1]}
  58949. : {scale: itemAlign === 'left' ? [1, 1] : [-1, 1]}
  58950. );
  58951. },
  58952. /**
  58953. * @private
  58954. */
  58955. _updateHandle: function (handleEnds, visualInRange) {
  58956. if (!this._useHandle) {
  58957. return;
  58958. }
  58959. var shapes = this._shapes;
  58960. var visualMapModel = this.visualMapModel;
  58961. var handleThumbs = shapes.handleThumbs;
  58962. var handleLabels = shapes.handleLabels;
  58963. each([0, 1], function (handleIndex) {
  58964. var handleThumb = handleThumbs[handleIndex];
  58965. handleThumb.setStyle('fill', visualInRange.handlesColor[handleIndex]);
  58966. handleThumb.position[1] = handleEnds[handleIndex];
  58967. // Update handle label position.
  58968. var textPoint = graphic.applyTransform(
  58969. shapes.handleLabelPoints[handleIndex],
  58970. graphic.getTransform(handleThumb, this.group)
  58971. );
  58972. handleLabels[handleIndex].setStyle({
  58973. x: textPoint[0],
  58974. y: textPoint[1],
  58975. text: visualMapModel.formatValueText(this._dataInterval[handleIndex]),
  58976. textVerticalAlign: 'middle',
  58977. textAlign: this._applyTransform(
  58978. this._orient === 'horizontal'
  58979. ? (handleIndex === 0 ? 'bottom' : 'top')
  58980. : 'left',
  58981. shapes.barGroup
  58982. )
  58983. });
  58984. }, this);
  58985. },
  58986. /**
  58987. * @private
  58988. * @param {number} cursorValue
  58989. * @param {number} textValue
  58990. * @param {string} [rangeSymbol]
  58991. * @param {number} [halfHoverLinkSize]
  58992. */
  58993. _showIndicator: function (cursorValue, textValue, rangeSymbol, halfHoverLinkSize) {
  58994. var visualMapModel = this.visualMapModel;
  58995. var dataExtent = visualMapModel.getExtent();
  58996. var itemSize = visualMapModel.itemSize;
  58997. var sizeExtent = [0, itemSize[1]];
  58998. var pos = linearMap(cursorValue, dataExtent, sizeExtent, true);
  58999. var shapes = this._shapes;
  59000. var indicator = shapes.indicator;
  59001. if (!indicator) {
  59002. return;
  59003. }
  59004. indicator.position[1] = pos;
  59005. indicator.attr('invisible', false);
  59006. indicator.setShape('points', createIndicatorPoints(
  59007. !!rangeSymbol, halfHoverLinkSize, pos, itemSize[1]
  59008. ));
  59009. var opts = {convertOpacityToAlpha: true};
  59010. var color = this.getControllerVisual(cursorValue, 'color', opts);
  59011. indicator.setStyle('fill', color);
  59012. // Update handle label position.
  59013. var textPoint = graphic.applyTransform(
  59014. shapes.indicatorLabelPoint,
  59015. graphic.getTransform(indicator, this.group)
  59016. );
  59017. var indicatorLabel = shapes.indicatorLabel;
  59018. indicatorLabel.attr('invisible', false);
  59019. var align = this._applyTransform('left', shapes.barGroup);
  59020. var orient = this._orient;
  59021. indicatorLabel.setStyle({
  59022. text: (rangeSymbol ? rangeSymbol : '') + visualMapModel.formatValueText(textValue),
  59023. textVerticalAlign: orient === 'horizontal' ? align : 'middle',
  59024. textAlign: orient === 'horizontal' ? 'center' : align,
  59025. x: textPoint[0],
  59026. y: textPoint[1]
  59027. });
  59028. },
  59029. /**
  59030. * @private
  59031. */
  59032. _enableHoverLinkToSeries: function () {
  59033. var self = this;
  59034. this._shapes.barGroup
  59035. .on('mousemove', function (e) {
  59036. self._hovering = true;
  59037. if (!self._dragging) {
  59038. var itemSize = self.visualMapModel.itemSize;
  59039. var pos = self._applyTransform(
  59040. [e.offsetX, e.offsetY], self._shapes.barGroup, true, true
  59041. );
  59042. // For hover link show when hover handle, which might be
  59043. // below or upper than sizeExtent.
  59044. pos[1] = mathMin(mathMax(0, pos[1]), itemSize[1]);
  59045. self._doHoverLinkToSeries(
  59046. pos[1],
  59047. 0 <= pos[0] && pos[0] <= itemSize[0]
  59048. );
  59049. }
  59050. })
  59051. .on('mouseout', function () {
  59052. // When mouse is out of handle, hoverLink still need
  59053. // to be displayed when realtime is set as false.
  59054. self._hovering = false;
  59055. !self._dragging && self._clearHoverLinkToSeries();
  59056. });
  59057. },
  59058. /**
  59059. * @private
  59060. */
  59061. _enableHoverLinkFromSeries: function () {
  59062. var zr = this.api.getZr();
  59063. if (this.visualMapModel.option.hoverLink) {
  59064. zr.on('mouseover', this._hoverLinkFromSeriesMouseOver, this);
  59065. zr.on('mouseout', this._hideIndicator, this);
  59066. }
  59067. else {
  59068. this._clearHoverLinkFromSeries();
  59069. }
  59070. },
  59071. /**
  59072. * @private
  59073. */
  59074. _doHoverLinkToSeries: function (cursorPos, hoverOnBar) {
  59075. var visualMapModel = this.visualMapModel;
  59076. var itemSize = visualMapModel.itemSize;
  59077. if (!visualMapModel.option.hoverLink) {
  59078. return;
  59079. }
  59080. var sizeExtent = [0, itemSize[1]];
  59081. var dataExtent = visualMapModel.getExtent();
  59082. // For hover link show when hover handle, which might be below or upper than sizeExtent.
  59083. cursorPos = mathMin(mathMax(sizeExtent[0], cursorPos), sizeExtent[1]);
  59084. var halfHoverLinkSize = getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent);
  59085. var hoverRange = [cursorPos - halfHoverLinkSize, cursorPos + halfHoverLinkSize];
  59086. var cursorValue = linearMap(cursorPos, sizeExtent, dataExtent, true);
  59087. var valueRange = [
  59088. linearMap(hoverRange[0], sizeExtent, dataExtent, true),
  59089. linearMap(hoverRange[1], sizeExtent, dataExtent, true)
  59090. ];
  59091. // Consider data range is out of visualMap range, see test/visualMap-continuous.html,
  59092. // where china and india has very large population.
  59093. hoverRange[0] < sizeExtent[0] && (valueRange[0] = -Infinity);
  59094. hoverRange[1] > sizeExtent[1] && (valueRange[1] = Infinity);
  59095. // Do not show indicator when mouse is over handle,
  59096. // otherwise labels overlap, especially when dragging.
  59097. if (hoverOnBar) {
  59098. if (valueRange[0] === -Infinity) {
  59099. this._showIndicator(cursorValue, valueRange[1], '< ', halfHoverLinkSize);
  59100. }
  59101. else if (valueRange[1] === Infinity) {
  59102. this._showIndicator(cursorValue, valueRange[0], '> ', halfHoverLinkSize);
  59103. }
  59104. else {
  59105. this._showIndicator(cursorValue, cursorValue, '≈ ', halfHoverLinkSize);
  59106. }
  59107. }
  59108. // When realtime is set as false, handles, which are in barGroup,
  59109. // also trigger hoverLink, which help user to realize where they
  59110. // focus on when dragging. (see test/heatmap-large.html)
  59111. // When realtime is set as true, highlight will not show when hover
  59112. // handle, because the label on handle, which displays a exact value
  59113. // but not range, might mislead users.
  59114. var oldBatch = this._hoverLinkDataIndices;
  59115. var newBatch = [];
  59116. if (hoverOnBar || useHoverLinkOnHandle(visualMapModel)) {
  59117. newBatch = this._hoverLinkDataIndices = visualMapModel.findTargetDataIndices(valueRange);
  59118. }
  59119. var resultBatches = modelUtil.compressBatches(oldBatch, newBatch);
  59120. this._dispatchHighDown('downplay', helper.convertDataIndex(resultBatches[0]));
  59121. this._dispatchHighDown('highlight', helper.convertDataIndex(resultBatches[1]));
  59122. },
  59123. /**
  59124. * @private
  59125. */
  59126. _hoverLinkFromSeriesMouseOver: function (e) {
  59127. var el = e.target;
  59128. var visualMapModel = this.visualMapModel;
  59129. if (!el || el.dataIndex == null) {
  59130. return;
  59131. }
  59132. var dataModel = this.ecModel.getSeriesByIndex(el.seriesIndex);
  59133. if (!visualMapModel.isTargetSeries(dataModel)) {
  59134. return;
  59135. }
  59136. var data = dataModel.getData(el.dataType);
  59137. var dim = data.getDimension(visualMapModel.getDataDimension(data));
  59138. var value = data.get(dim, el.dataIndex, true);
  59139. if (!isNaN(value)) {
  59140. this._showIndicator(value, value);
  59141. }
  59142. },
  59143. /**
  59144. * @private
  59145. */
  59146. _hideIndicator: function () {
  59147. var shapes = this._shapes;
  59148. shapes.indicator && shapes.indicator.attr('invisible', true);
  59149. shapes.indicatorLabel && shapes.indicatorLabel.attr('invisible', true);
  59150. },
  59151. /**
  59152. * @private
  59153. */
  59154. _clearHoverLinkToSeries: function () {
  59155. this._hideIndicator();
  59156. var indices = this._hoverLinkDataIndices;
  59157. this._dispatchHighDown('downplay', helper.convertDataIndex(indices));
  59158. indices.length = 0;
  59159. },
  59160. /**
  59161. * @private
  59162. */
  59163. _clearHoverLinkFromSeries: function () {
  59164. this._hideIndicator();
  59165. var zr = this.api.getZr();
  59166. zr.off('mouseover', this._hoverLinkFromSeriesMouseOver);
  59167. zr.off('mouseout', this._hideIndicator);
  59168. },
  59169. /**
  59170. * @private
  59171. */
  59172. _applyTransform: function (vertex, element, inverse, global) {
  59173. var transform = graphic.getTransform(element, global ? null : this.group);
  59174. return graphic[
  59175. zrUtil.isArray(vertex) ? 'applyTransform' : 'transformDirection'
  59176. ](vertex, transform, inverse);
  59177. },
  59178. /**
  59179. * @private
  59180. */
  59181. _dispatchHighDown: function (type, batch) {
  59182. batch && batch.length && this.api.dispatchAction({
  59183. type: type,
  59184. batch: batch
  59185. });
  59186. },
  59187. /**
  59188. * @override
  59189. */
  59190. dispose: function () {
  59191. this._clearHoverLinkFromSeries();
  59192. this._clearHoverLinkToSeries();
  59193. },
  59194. /**
  59195. * @override
  59196. */
  59197. remove: function () {
  59198. this._clearHoverLinkFromSeries();
  59199. this._clearHoverLinkToSeries();
  59200. }
  59201. });
  59202. function createPolygon(points, cursor, onDrift, onDragEnd) {
  59203. return new graphic.Polygon({
  59204. shape: {points: points},
  59205. draggable: !!onDrift,
  59206. cursor: cursor,
  59207. drift: onDrift,
  59208. onmousemove: function (e) {
  59209. // Fot mobile devicem, prevent screen slider on the button.
  59210. eventTool.stop(e.event);
  59211. },
  59212. ondragend: onDragEnd
  59213. });
  59214. }
  59215. function createHandlePoints(handleIndex, textSize) {
  59216. return handleIndex === 0
  59217. ? [[0, 0], [textSize, 0], [textSize, -textSize]]
  59218. : [[0, 0], [textSize, 0], [textSize, textSize]];
  59219. }
  59220. function createIndicatorPoints(isRange, halfHoverLinkSize, pos, extentMax) {
  59221. return isRange
  59222. ? [ // indicate range
  59223. [0, -mathMin(halfHoverLinkSize, mathMax(pos, 0))],
  59224. [HOVER_LINK_OUT, 0],
  59225. [0, mathMin(halfHoverLinkSize, mathMax(extentMax - pos, 0))]
  59226. ]
  59227. : [ // indicate single value
  59228. [0, 0], [5, -5], [5, 5]
  59229. ];
  59230. }
  59231. function getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent) {
  59232. var halfHoverLinkSize = HOVER_LINK_SIZE / 2;
  59233. var hoverLinkDataSize = visualMapModel.get('hoverLinkDataSize');
  59234. if (hoverLinkDataSize) {
  59235. halfHoverLinkSize = linearMap(hoverLinkDataSize, dataExtent, sizeExtent, true) / 2;
  59236. }
  59237. return halfHoverLinkSize;
  59238. }
  59239. function useHoverLinkOnHandle(visualMapModel) {
  59240. var hoverLinkOnHandle = visualMapModel.get('hoverLinkOnHandle');
  59241. return !!(hoverLinkOnHandle == null ? visualMapModel.get('realtime') : hoverLinkOnHandle);
  59242. }
  59243. function getCursor(orient) {
  59244. return orient === 'vertical' ? 'ns-resize' : 'ew-resize';
  59245. }
  59246. module.exports = ContinuousView;
  59247. /***/ }),
  59248. /* 393 */
  59249. /***/ (function(module, exports, __webpack_require__) {
  59250. var zrUtil = __webpack_require__(4);
  59251. var graphic = __webpack_require__(20);
  59252. var formatUtil = __webpack_require__(6);
  59253. var layout = __webpack_require__(74);
  59254. var echarts = __webpack_require__(1);
  59255. var VisualMapping = __webpack_require__(206);
  59256. module.exports = echarts.extendComponentView({
  59257. type: 'visualMap',
  59258. /**
  59259. * @readOnly
  59260. * @type {Object}
  59261. */
  59262. autoPositionValues: {left: 1, right: 1, top: 1, bottom: 1},
  59263. init: function (ecModel, api) {
  59264. /**
  59265. * @readOnly
  59266. * @type {module:echarts/model/Global}
  59267. */
  59268. this.ecModel = ecModel;
  59269. /**
  59270. * @readOnly
  59271. * @type {module:echarts/ExtensionAPI}
  59272. */
  59273. this.api = api;
  59274. /**
  59275. * @readOnly
  59276. * @type {module:echarts/component/visualMap/visualMapModel}
  59277. */
  59278. this.visualMapModel;
  59279. },
  59280. /**
  59281. * @protected
  59282. */
  59283. render: function (visualMapModel, ecModel, api, payload) {
  59284. this.visualMapModel = visualMapModel;
  59285. if (visualMapModel.get('show') === false) {
  59286. this.group.removeAll();
  59287. return;
  59288. }
  59289. this.doRender.apply(this, arguments);
  59290. },
  59291. /**
  59292. * @protected
  59293. */
  59294. renderBackground: function (group) {
  59295. var visualMapModel = this.visualMapModel;
  59296. var padding = formatUtil.normalizeCssArray(visualMapModel.get('padding') || 0);
  59297. var rect = group.getBoundingRect();
  59298. group.add(new graphic.Rect({
  59299. z2: -1, // Lay background rect on the lowest layer.
  59300. silent: true,
  59301. shape: {
  59302. x: rect.x - padding[3],
  59303. y: rect.y - padding[0],
  59304. width: rect.width + padding[3] + padding[1],
  59305. height: rect.height + padding[0] + padding[2]
  59306. },
  59307. style: {
  59308. fill: visualMapModel.get('backgroundColor'),
  59309. stroke: visualMapModel.get('borderColor'),
  59310. lineWidth: visualMapModel.get('borderWidth')
  59311. }
  59312. }));
  59313. },
  59314. /**
  59315. * @protected
  59316. * @param {number} targetValue can be Infinity or -Infinity
  59317. * @param {string=} visualCluster Only can be 'color' 'opacity' 'symbol' 'symbolSize'
  59318. * @param {Object} [opts]
  59319. * @param {string=} [opts.forceState] Specify state, instead of using getValueState method.
  59320. * @param {string=} [opts.convertOpacityToAlpha=false] For color gradient in controller widget.
  59321. * @return {*} Visual value.
  59322. */
  59323. getControllerVisual: function (targetValue, visualCluster, opts) {
  59324. opts = opts || {};
  59325. var forceState = opts.forceState;
  59326. var visualMapModel = this.visualMapModel;
  59327. var visualObj = {};
  59328. // Default values.
  59329. if (visualCluster === 'symbol') {
  59330. visualObj.symbol = visualMapModel.get('itemSymbol');
  59331. }
  59332. if (visualCluster === 'color') {
  59333. var defaultColor = visualMapModel.get('contentColor');
  59334. visualObj.color = defaultColor;
  59335. }
  59336. function getter(key) {
  59337. return visualObj[key];
  59338. }
  59339. function setter(key, value) {
  59340. visualObj[key] = value;
  59341. }
  59342. var mappings = visualMapModel.controllerVisuals[
  59343. forceState || visualMapModel.getValueState(targetValue)
  59344. ];
  59345. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  59346. zrUtil.each(visualTypes, function (type) {
  59347. var visualMapping = mappings[type];
  59348. if (opts.convertOpacityToAlpha && type === 'opacity') {
  59349. type = 'colorAlpha';
  59350. visualMapping = mappings.__alphaForOpacity;
  59351. }
  59352. if (VisualMapping.dependsOn(type, visualCluster)) {
  59353. visualMapping && visualMapping.applyVisual(
  59354. targetValue, getter, setter
  59355. );
  59356. }
  59357. });
  59358. return visualObj[visualCluster];
  59359. },
  59360. /**
  59361. * @protected
  59362. */
  59363. positionGroup: function (group) {
  59364. var model = this.visualMapModel;
  59365. var api = this.api;
  59366. layout.positionElement(
  59367. group,
  59368. model.getBoxLayoutParams(),
  59369. {width: api.getWidth(), height: api.getHeight()}
  59370. );
  59371. },
  59372. /**
  59373. * @protected
  59374. * @abstract
  59375. */
  59376. doRender: zrUtil.noop
  59377. });
  59378. /***/ }),
  59379. /* 394 */
  59380. /***/ (function(module, exports, __webpack_require__) {
  59381. var zrUtil = __webpack_require__(4);
  59382. var layout = __webpack_require__(74);
  59383. var helper = {
  59384. /**
  59385. * @param {module:echarts/component/visualMap/VisualMapModel} visualMapModel\
  59386. * @param {module:echarts/ExtensionAPI} api
  59387. * @param {Array.<number>} itemSize always [short, long]
  59388. * @return {string} 'left' or 'right' or 'top' or 'bottom'
  59389. */
  59390. getItemAlign: function (visualMapModel, api, itemSize) {
  59391. var modelOption = visualMapModel.option;
  59392. var itemAlign = modelOption.align;
  59393. if (itemAlign != null && itemAlign !== 'auto') {
  59394. return itemAlign;
  59395. }
  59396. // Auto decision align.
  59397. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  59398. var realIndex = modelOption.orient === 'horizontal' ? 1 : 0;
  59399. var paramsSet = [
  59400. ['left', 'right', 'width'],
  59401. ['top', 'bottom', 'height']
  59402. ];
  59403. var reals = paramsSet[realIndex];
  59404. var fakeValue = [0, null, 10];
  59405. var layoutInput = {};
  59406. for (var i = 0; i < 3; i++) {
  59407. layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i];
  59408. layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]];
  59409. }
  59410. var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex];
  59411. var rect = layout.getLayoutRect(layoutInput, ecSize, modelOption.padding);
  59412. return reals[
  59413. (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5
  59414. < ecSize[rParam[1]] * 0.5 ? 0 : 1
  59415. ];
  59416. },
  59417. /**
  59418. * Prepare dataIndex for outside usage, where dataIndex means rawIndex, and
  59419. * dataIndexInside means filtered index.
  59420. */
  59421. convertDataIndex: function (batch) {
  59422. zrUtil.each(batch || [], function (batchItem) {
  59423. if (batch.dataIndex != null) {
  59424. batch.dataIndexInside = batch.dataIndex;
  59425. batch.dataIndex = null;
  59426. }
  59427. });
  59428. return batch;
  59429. }
  59430. };
  59431. module.exports = helper;
  59432. /***/ }),
  59433. /* 395 */
  59434. /***/ (function(module, exports, __webpack_require__) {
  59435. /**
  59436. * @file Data range action
  59437. */
  59438. var echarts = __webpack_require__(1);
  59439. var actionInfo = {
  59440. type: 'selectDataRange',
  59441. event: 'dataRangeSelected',
  59442. // FIXME use updateView appears wrong
  59443. update: 'update'
  59444. };
  59445. echarts.registerAction(actionInfo, function (payload, ecModel) {
  59446. ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) {
  59447. model.setSelected(payload.selected);
  59448. });
  59449. });
  59450. /***/ }),
  59451. /* 396 */
  59452. /***/ (function(module, exports, __webpack_require__) {
  59453. /**
  59454. * DataZoom component entry
  59455. */
  59456. __webpack_require__(1).registerPreprocessor(
  59457. __webpack_require__(386)
  59458. );
  59459. __webpack_require__(387);
  59460. __webpack_require__(388);
  59461. __webpack_require__(397);
  59462. __webpack_require__(398);
  59463. __webpack_require__(395);
  59464. /***/ }),
  59465. /* 397 */
  59466. /***/ (function(module, exports, __webpack_require__) {
  59467. var VisualMapModel = __webpack_require__(390);
  59468. var zrUtil = __webpack_require__(4);
  59469. var VisualMapping = __webpack_require__(206);
  59470. var visualDefault = __webpack_require__(391);
  59471. var reformIntervals = __webpack_require__(7).reformIntervals;
  59472. var PiecewiseModel = VisualMapModel.extend({
  59473. type: 'visualMap.piecewise',
  59474. /**
  59475. * Order Rule:
  59476. *
  59477. * option.categories / option.pieces / option.text / option.selected:
  59478. * If !option.inverse,
  59479. * Order when vertical: ['top', ..., 'bottom'].
  59480. * Order when horizontal: ['left', ..., 'right'].
  59481. * If option.inverse, the meaning of
  59482. * the order should be reversed.
  59483. *
  59484. * this._pieceList:
  59485. * The order is always [low, ..., high].
  59486. *
  59487. * Mapping from location to low-high:
  59488. * If !option.inverse
  59489. * When vertical, top is high.
  59490. * When horizontal, right is high.
  59491. * If option.inverse, reverse.
  59492. */
  59493. /**
  59494. * @protected
  59495. */
  59496. defaultOption: {
  59497. selected: null, // Object. If not specified, means selected.
  59498. // When pieces and splitNumber: {'0': true, '5': true}
  59499. // When categories: {'cate1': false, 'cate3': true}
  59500. // When selected === false, means all unselected.
  59501. minOpen: false, // Whether include values that smaller than `min`.
  59502. maxOpen: false, // Whether include values that bigger than `max`.
  59503. align: 'auto', // 'auto', 'left', 'right'
  59504. itemWidth: 20, // When put the controller vertically, it is the length of
  59505. // horizontal side of each item. Otherwise, vertical side.
  59506. itemHeight: 14, // When put the controller vertically, it is the length of
  59507. // vertical side of each item. Otherwise, horizontal side.
  59508. itemSymbol: 'roundRect',
  59509. pieceList: null, // Each item is Object, with some of those attrs:
  59510. // {min, max, lt, gt, lte, gte, value,
  59511. // color, colorSaturation, colorAlpha, opacity,
  59512. // symbol, symbolSize}, which customize the range or visual
  59513. // coding of the certain piece. Besides, see "Order Rule".
  59514. categories: null, // category names, like: ['some1', 'some2', 'some3'].
  59515. // Attr min/max are ignored when categories set. See "Order Rule"
  59516. splitNumber: 5, // If set to 5, auto split five pieces equally.
  59517. // If set to 0 and component type not set, component type will be
  59518. // determined as "continuous". (It is less reasonable but for ec2
  59519. // compatibility, see echarts/component/visualMap/typeDefaulter)
  59520. selectedMode: 'multiple', // Can be 'multiple' or 'single'.
  59521. itemGap: 10, // The gap between two items, in px.
  59522. hoverLink: true, // Enable hover highlight.
  59523. showLabel: null // By default, when text is used, label will hide (the logic
  59524. // is remained for compatibility reason)
  59525. },
  59526. /**
  59527. * @override
  59528. */
  59529. optionUpdated: function (newOption, isInit) {
  59530. PiecewiseModel.superApply(this, 'optionUpdated', arguments);
  59531. /**
  59532. * The order is always [low, ..., high].
  59533. * [{text: string, interval: Array.<number>}, ...]
  59534. * @private
  59535. * @type {Array.<Object>}
  59536. */
  59537. this._pieceList = [];
  59538. this.resetExtent();
  59539. /**
  59540. * 'pieces', 'categories', 'splitNumber'
  59541. * @type {string}
  59542. */
  59543. var mode = this._mode = this._determineMode();
  59544. resetMethods[this._mode].call(this);
  59545. this._resetSelected(newOption, isInit);
  59546. var categories = this.option.categories;
  59547. this.resetVisual(function (mappingOption, state) {
  59548. if (mode === 'categories') {
  59549. mappingOption.mappingMethod = 'category';
  59550. mappingOption.categories = zrUtil.clone(categories);
  59551. }
  59552. else {
  59553. mappingOption.dataExtent = this.getExtent();
  59554. mappingOption.mappingMethod = 'piecewise';
  59555. mappingOption.pieceList = zrUtil.map(this._pieceList, function (piece) {
  59556. var piece = zrUtil.clone(piece);
  59557. if (state !== 'inRange') {
  59558. // FIXME
  59559. // outOfRange do not support special visual in pieces.
  59560. piece.visual = null;
  59561. }
  59562. return piece;
  59563. });
  59564. }
  59565. });
  59566. },
  59567. /**
  59568. * @protected
  59569. * @override
  59570. */
  59571. completeVisualOption: function () {
  59572. // Consider this case:
  59573. // visualMap: {
  59574. // pieces: [{symbol: 'circle', lt: 0}, {symbol: 'rect', gte: 0}]
  59575. // }
  59576. // where no inRange/outOfRange set but only pieces. So we should make
  59577. // default inRange/outOfRange for this case, otherwise visuals that only
  59578. // appear in `pieces` will not be taken into account in visual encoding.
  59579. var option = this.option;
  59580. var visualTypesInPieces = {};
  59581. var visualTypes = VisualMapping.listVisualTypes();
  59582. var isCategory = this.isCategory();
  59583. zrUtil.each(option.pieces, function (piece) {
  59584. zrUtil.each(visualTypes, function (visualType) {
  59585. if (piece.hasOwnProperty(visualType)) {
  59586. visualTypesInPieces[visualType] = 1;
  59587. }
  59588. });
  59589. });
  59590. zrUtil.each(visualTypesInPieces, function (v, visualType) {
  59591. var exists = 0;
  59592. zrUtil.each(this.stateList, function (state) {
  59593. exists |= has(option, state, visualType)
  59594. || has(option.target, state, visualType);
  59595. }, this);
  59596. !exists && zrUtil.each(this.stateList, function (state) {
  59597. (option[state] || (option[state] = {}))[visualType] = visualDefault.get(
  59598. visualType, state === 'inRange' ? 'active' : 'inactive', isCategory
  59599. );
  59600. });
  59601. }, this);
  59602. function has(obj, state, visualType) {
  59603. return obj && obj[state] && (
  59604. zrUtil.isObject(obj[state])
  59605. ? obj[state].hasOwnProperty(visualType)
  59606. : obj[state] === visualType // e.g., inRange: 'symbol'
  59607. );
  59608. }
  59609. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  59610. },
  59611. _resetSelected: function (newOption, isInit) {
  59612. var thisOption = this.option;
  59613. var pieceList = this._pieceList;
  59614. // Selected do not merge but all override.
  59615. var selected = (isInit ? thisOption : newOption).selected || {};
  59616. thisOption.selected = selected;
  59617. // Consider 'not specified' means true.
  59618. zrUtil.each(pieceList, function (piece, index) {
  59619. var key = this.getSelectedMapKey(piece);
  59620. if (!selected.hasOwnProperty(key)) {
  59621. selected[key] = true;
  59622. }
  59623. }, this);
  59624. if (thisOption.selectedMode === 'single') {
  59625. // Ensure there is only one selected.
  59626. var hasSel = false;
  59627. zrUtil.each(pieceList, function (piece, index) {
  59628. var key = this.getSelectedMapKey(piece);
  59629. if (selected[key]) {
  59630. hasSel
  59631. ? (selected[key] = false)
  59632. : (hasSel = true);
  59633. }
  59634. }, this);
  59635. }
  59636. // thisOption.selectedMode === 'multiple', default: all selected.
  59637. },
  59638. /**
  59639. * @public
  59640. */
  59641. getSelectedMapKey: function (piece) {
  59642. return this._mode === 'categories'
  59643. ? piece.value + '' : piece.index + '';
  59644. },
  59645. /**
  59646. * @public
  59647. */
  59648. getPieceList: function () {
  59649. return this._pieceList;
  59650. },
  59651. /**
  59652. * @private
  59653. * @return {string}
  59654. */
  59655. _determineMode: function () {
  59656. var option = this.option;
  59657. return option.pieces && option.pieces.length > 0
  59658. ? 'pieces'
  59659. : this.option.categories
  59660. ? 'categories'
  59661. : 'splitNumber';
  59662. },
  59663. /**
  59664. * @public
  59665. * @override
  59666. */
  59667. setSelected: function (selected) {
  59668. this.option.selected = zrUtil.clone(selected);
  59669. },
  59670. /**
  59671. * @public
  59672. * @override
  59673. */
  59674. getValueState: function (value) {
  59675. var index = VisualMapping.findPieceIndex(value, this._pieceList);
  59676. return index != null
  59677. ? (this.option.selected[this.getSelectedMapKey(this._pieceList[index])]
  59678. ? 'inRange' : 'outOfRange'
  59679. )
  59680. : 'outOfRange';
  59681. },
  59682. /**
  59683. * @public
  59684. * @params {number} pieceIndex piece index in visualMapModel.getPieceList()
  59685. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  59686. */
  59687. findTargetDataIndices: function (pieceIndex) {
  59688. var result = [];
  59689. this.eachTargetSeries(function (seriesModel) {
  59690. var dataIndices = [];
  59691. var data = seriesModel.getData();
  59692. data.each(this.getDataDimension(data), function (value, dataIndex) {
  59693. // Should always base on model pieceList, because it is order sensitive.
  59694. var pIdx = VisualMapping.findPieceIndex(value, this._pieceList);
  59695. pIdx === pieceIndex && dataIndices.push(dataIndex);
  59696. }, true, this);
  59697. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  59698. }, this);
  59699. return result;
  59700. },
  59701. /**
  59702. * @private
  59703. * @param {Object} piece piece.value or piece.interval is required.
  59704. * @return {number} Can be Infinity or -Infinity
  59705. */
  59706. getRepresentValue: function (piece) {
  59707. var representValue;
  59708. if (this.isCategory()) {
  59709. representValue = piece.value;
  59710. }
  59711. else {
  59712. if (piece.value != null) {
  59713. representValue = piece.value;
  59714. }
  59715. else {
  59716. var pieceInterval = piece.interval || [];
  59717. representValue = (pieceInterval[0] === -Infinity && pieceInterval[1] === Infinity)
  59718. ? 0
  59719. : (pieceInterval[0] + pieceInterval[1]) / 2;
  59720. }
  59721. }
  59722. return representValue;
  59723. },
  59724. getVisualMeta: function (getColorVisual) {
  59725. // Do not support category. (category axis is ordinal, numerical)
  59726. if (this.isCategory()) {
  59727. return;
  59728. }
  59729. var stops = [];
  59730. var outerColors = [];
  59731. var visualMapModel = this;
  59732. function setStop(interval, valueState) {
  59733. var representValue = visualMapModel.getRepresentValue({interval: interval});
  59734. if (!valueState) {
  59735. valueState = visualMapModel.getValueState(representValue);
  59736. }
  59737. var color = getColorVisual(representValue, valueState);
  59738. if (interval[0] === -Infinity) {
  59739. outerColors[0] = color;
  59740. }
  59741. else if (interval[1] === Infinity) {
  59742. outerColors[1] = color;
  59743. }
  59744. else {
  59745. stops.push(
  59746. {value: interval[0], color: color},
  59747. {value: interval[1], color: color}
  59748. );
  59749. }
  59750. }
  59751. // Suplement
  59752. var pieceList = this._pieceList.slice();
  59753. if (!pieceList.length) {
  59754. pieceList.push({interval: [-Infinity, Infinity]});
  59755. }
  59756. else {
  59757. var edge = pieceList[0].interval[0];
  59758. edge !== -Infinity && pieceList.unshift({interval: [-Infinity, edge]});
  59759. edge = pieceList[pieceList.length - 1].interval[1];
  59760. edge !== Infinity && pieceList.push({interval: [edge, Infinity]});
  59761. }
  59762. var curr = -Infinity;
  59763. zrUtil.each(pieceList, function (piece) {
  59764. var interval = piece.interval;
  59765. if (interval) {
  59766. // Fulfill gap.
  59767. interval[0] > curr && setStop([curr, interval[0]], 'outOfRange');
  59768. setStop(interval.slice());
  59769. curr = interval[1];
  59770. }
  59771. }, this);
  59772. return {stops: stops, outerColors: outerColors};
  59773. }
  59774. });
  59775. /**
  59776. * Key is this._mode
  59777. * @type {Object}
  59778. * @this {module:echarts/component/viusalMap/PiecewiseMode}
  59779. */
  59780. var resetMethods = {
  59781. splitNumber: function () {
  59782. var thisOption = this.option;
  59783. var pieceList = this._pieceList;
  59784. var precision = Math.min(thisOption.precision, 20);
  59785. var dataExtent = this.getExtent();
  59786. var splitNumber = thisOption.splitNumber;
  59787. splitNumber = Math.max(parseInt(splitNumber, 10), 1);
  59788. thisOption.splitNumber = splitNumber;
  59789. var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber;
  59790. // Precision auto-adaption
  59791. while (+splitStep.toFixed(precision) !== splitStep && precision < 5) {
  59792. precision++;
  59793. }
  59794. thisOption.precision = precision;
  59795. splitStep = +splitStep.toFixed(precision);
  59796. var index = 0;
  59797. if (thisOption.minOpen) {
  59798. pieceList.push({
  59799. index: index++,
  59800. interval: [-Infinity, dataExtent[0]],
  59801. close: [0, 0]
  59802. });
  59803. }
  59804. for (
  59805. var curr = dataExtent[0], len = index + splitNumber;
  59806. index < len;
  59807. curr += splitStep
  59808. ) {
  59809. var max = index === splitNumber - 1 ? dataExtent[1] : (curr + splitStep);
  59810. pieceList.push({
  59811. index: index++,
  59812. interval: [curr, max],
  59813. close: [1, 1]
  59814. });
  59815. }
  59816. if (thisOption.maxOpen) {
  59817. pieceList.push({
  59818. index: index++,
  59819. interval: [dataExtent[1], Infinity],
  59820. close: [0, 0]
  59821. });
  59822. }
  59823. reformIntervals(pieceList);
  59824. zrUtil.each(pieceList, function (piece) {
  59825. piece.text = this.formatValueText(piece.interval);
  59826. }, this);
  59827. },
  59828. categories: function () {
  59829. var thisOption = this.option;
  59830. zrUtil.each(thisOption.categories, function (cate) {
  59831. // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。
  59832. // 是否改一致。
  59833. this._pieceList.push({
  59834. text: this.formatValueText(cate, true),
  59835. value: cate
  59836. });
  59837. }, this);
  59838. // See "Order Rule".
  59839. normalizeReverse(thisOption, this._pieceList);
  59840. },
  59841. pieces: function () {
  59842. var thisOption = this.option;
  59843. var pieceList = this._pieceList;
  59844. zrUtil.each(thisOption.pieces, function (pieceListItem, index) {
  59845. if (!zrUtil.isObject(pieceListItem)) {
  59846. pieceListItem = {value: pieceListItem};
  59847. }
  59848. var item = {text: '', index: index};
  59849. if (pieceListItem.label != null) {
  59850. item.text = pieceListItem.label;
  59851. }
  59852. if (pieceListItem.hasOwnProperty('value')) {
  59853. var value = item.value = pieceListItem.value;
  59854. item.interval = [value, value];
  59855. item.close = [1, 1];
  59856. }
  59857. else {
  59858. // `min` `max` is legacy option.
  59859. // `lt` `gt` `lte` `gte` is recommanded.
  59860. var interval = item.interval = [];
  59861. var close = item.close = [0, 0];
  59862. var closeList = [1, 0, 1];
  59863. var infinityList = [-Infinity, Infinity];
  59864. var useMinMax = [];
  59865. for (var lg = 0; lg < 2; lg++) {
  59866. var names = [['gte', 'gt', 'min'], ['lte', 'lt', 'max']][lg];
  59867. for (var i = 0; i < 3 && interval[lg] == null; i++) {
  59868. interval[lg] = pieceListItem[names[i]];
  59869. close[lg] = closeList[i];
  59870. useMinMax[lg] = i === 2;
  59871. }
  59872. interval[lg] == null && (interval[lg] = infinityList[lg]);
  59873. }
  59874. useMinMax[0] && interval[1] === Infinity && (close[0] = 0);
  59875. useMinMax[1] && interval[0] === -Infinity && (close[1] = 0);
  59876. if (true) {
  59877. if (interval[0] > interval[1]) {
  59878. console.warn(
  59879. 'Piece ' + index + 'is illegal: ' + interval
  59880. + ' lower bound should not greater then uppper bound.'
  59881. );
  59882. }
  59883. }
  59884. if (interval[0] === interval[1] && close[0] && close[1]) {
  59885. // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}],
  59886. // we use value to lift the priority when min === max
  59887. item.value = interval[0];
  59888. }
  59889. }
  59890. item.visual = VisualMapping.retrieveVisuals(pieceListItem);
  59891. pieceList.push(item);
  59892. }, this);
  59893. // See "Order Rule".
  59894. normalizeReverse(thisOption, pieceList);
  59895. // Only pieces
  59896. reformIntervals(pieceList);
  59897. zrUtil.each(pieceList, function (piece) {
  59898. var close = piece.close;
  59899. var edgeSymbols = [['<', '≤'][close[1]], ['>', '≥'][close[0]]];
  59900. piece.text = piece.text || this.formatValueText(
  59901. piece.value != null ? piece.value : piece.interval,
  59902. false,
  59903. edgeSymbols
  59904. );
  59905. }, this);
  59906. }
  59907. };
  59908. function normalizeReverse(thisOption, pieceList) {
  59909. var inverse = thisOption.inverse;
  59910. if (thisOption.orient === 'vertical' ? !inverse : inverse) {
  59911. pieceList.reverse();
  59912. }
  59913. }
  59914. module.exports = PiecewiseModel;
  59915. /***/ }),
  59916. /* 398 */
  59917. /***/ (function(module, exports, __webpack_require__) {
  59918. var VisualMapView = __webpack_require__(393);
  59919. var zrUtil = __webpack_require__(4);
  59920. var graphic = __webpack_require__(20);
  59921. var symbolCreators = __webpack_require__(114);
  59922. var layout = __webpack_require__(74);
  59923. var helper = __webpack_require__(394);
  59924. var PiecewiseVisualMapView = VisualMapView.extend({
  59925. type: 'visualMap.piecewise',
  59926. /**
  59927. * @protected
  59928. * @override
  59929. */
  59930. doRender: function () {
  59931. var thisGroup = this.group;
  59932. thisGroup.removeAll();
  59933. var visualMapModel = this.visualMapModel;
  59934. var textGap = visualMapModel.get('textGap');
  59935. var textStyleModel = visualMapModel.textStyleModel;
  59936. var textFont = textStyleModel.getFont();
  59937. var textFill = textStyleModel.getTextColor();
  59938. var itemAlign = this._getItemAlign();
  59939. var itemSize = visualMapModel.itemSize;
  59940. var viewData = this._getViewData();
  59941. var endsText = viewData.endsText;
  59942. var showLabel = zrUtil.retrieve(visualMapModel.get('showLabel', true), !endsText);
  59943. endsText && this._renderEndsText(
  59944. thisGroup, endsText[0], itemSize, showLabel, itemAlign
  59945. );
  59946. zrUtil.each(viewData.viewPieceList, renderItem, this);
  59947. endsText && this._renderEndsText(
  59948. thisGroup, endsText[1], itemSize, showLabel, itemAlign
  59949. );
  59950. layout.box(
  59951. visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap')
  59952. );
  59953. this.renderBackground(thisGroup);
  59954. this.positionGroup(thisGroup);
  59955. function renderItem(item) {
  59956. var piece = item.piece;
  59957. var itemGroup = new graphic.Group();
  59958. itemGroup.onclick = zrUtil.bind(this._onItemClick, this, piece);
  59959. this._enableHoverLink(itemGroup, item.indexInModelPieceList);
  59960. var representValue = visualMapModel.getRepresentValue(piece);
  59961. this._createItemSymbol(
  59962. itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]]
  59963. );
  59964. if (showLabel) {
  59965. var visualState = this.visualMapModel.getValueState(representValue);
  59966. itemGroup.add(new graphic.Text({
  59967. style: {
  59968. x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
  59969. y: itemSize[1] / 2,
  59970. text: piece.text,
  59971. textVerticalAlign: 'middle',
  59972. textAlign: itemAlign,
  59973. textFont: textFont,
  59974. textFill: textFill,
  59975. opacity: visualState === 'outOfRange' ? 0.5 : 1
  59976. }
  59977. }));
  59978. }
  59979. thisGroup.add(itemGroup);
  59980. }
  59981. },
  59982. /**
  59983. * @private
  59984. */
  59985. _enableHoverLink: function (itemGroup, pieceIndex) {
  59986. itemGroup
  59987. .on('mouseover', zrUtil.bind(onHoverLink, this, 'highlight'))
  59988. .on('mouseout', zrUtil.bind(onHoverLink, this, 'downplay'));
  59989. function onHoverLink(method) {
  59990. var visualMapModel = this.visualMapModel;
  59991. visualMapModel.option.hoverLink && this.api.dispatchAction({
  59992. type: method,
  59993. batch: helper.convertDataIndex(
  59994. visualMapModel.findTargetDataIndices(pieceIndex)
  59995. )
  59996. });
  59997. }
  59998. },
  59999. /**
  60000. * @private
  60001. */
  60002. _getItemAlign: function () {
  60003. var visualMapModel = this.visualMapModel;
  60004. var modelOption = visualMapModel.option;
  60005. if (modelOption.orient === 'vertical') {
  60006. return helper.getItemAlign(
  60007. visualMapModel, this.api, visualMapModel.itemSize
  60008. );
  60009. }
  60010. else { // horizontal, most case left unless specifying right.
  60011. var align = modelOption.align;
  60012. if (!align || align === 'auto') {
  60013. align = 'left';
  60014. }
  60015. return align;
  60016. }
  60017. },
  60018. /**
  60019. * @private
  60020. */
  60021. _renderEndsText: function (group, text, itemSize, showLabel, itemAlign) {
  60022. if (!text) {
  60023. return;
  60024. }
  60025. var itemGroup = new graphic.Group();
  60026. var textStyleModel = this.visualMapModel.textStyleModel;
  60027. itemGroup.add(new graphic.Text({
  60028. style: {
  60029. x: showLabel ? (itemAlign === 'right' ? itemSize[0] : 0) : itemSize[0] / 2,
  60030. y: itemSize[1] / 2,
  60031. textVerticalAlign: 'middle',
  60032. textAlign: showLabel ? itemAlign : 'center',
  60033. text: text,
  60034. textFont: textStyleModel.getFont(),
  60035. textFill: textStyleModel.getTextColor()
  60036. }
  60037. }));
  60038. group.add(itemGroup);
  60039. },
  60040. /**
  60041. * @private
  60042. * @return {Object} {peiceList, endsText} The order is the same as screen pixel order.
  60043. */
  60044. _getViewData: function () {
  60045. var visualMapModel = this.visualMapModel;
  60046. var viewPieceList = zrUtil.map(visualMapModel.getPieceList(), function (piece, index) {
  60047. return {piece: piece, indexInModelPieceList: index};
  60048. });
  60049. var endsText = visualMapModel.get('text');
  60050. // Consider orient and inverse.
  60051. var orient = visualMapModel.get('orient');
  60052. var inverse = visualMapModel.get('inverse');
  60053. // Order of model pieceList is always [low, ..., high]
  60054. if (orient === 'horizontal' ? inverse : !inverse) {
  60055. viewPieceList.reverse();
  60056. }
  60057. // Origin order of endsText is [high, low]
  60058. else if (endsText) {
  60059. endsText = endsText.slice().reverse();
  60060. }
  60061. return {viewPieceList: viewPieceList, endsText: endsText};
  60062. },
  60063. /**
  60064. * @private
  60065. */
  60066. _createItemSymbol: function (group, representValue, shapeParam) {
  60067. group.add(symbolCreators.createSymbol(
  60068. this.getControllerVisual(representValue, 'symbol'),
  60069. shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3],
  60070. this.getControllerVisual(representValue, 'color')
  60071. ));
  60072. },
  60073. /**
  60074. * @private
  60075. */
  60076. _onItemClick: function (piece) {
  60077. var visualMapModel = this.visualMapModel;
  60078. var option = visualMapModel.option;
  60079. var selected = zrUtil.clone(option.selected);
  60080. var newKey = visualMapModel.getSelectedMapKey(piece);
  60081. if (option.selectedMode === 'single') {
  60082. selected[newKey] = true;
  60083. zrUtil.each(selected, function (o, key) {
  60084. selected[key] = key === newKey;
  60085. });
  60086. }
  60087. else {
  60088. selected[newKey] = !selected[newKey];
  60089. }
  60090. this.api.dispatchAction({
  60091. type: 'selectDataRange',
  60092. from: this.uid,
  60093. visualMapId: this.visualMapModel.id,
  60094. selected: selected
  60095. });
  60096. }
  60097. });
  60098. module.exports = PiecewiseVisualMapView;
  60099. /***/ }),
  60100. /* 399 */
  60101. /***/ (function(module, exports, __webpack_require__) {
  60102. // HINT Markpoint can't be used too much
  60103. __webpack_require__(400);
  60104. __webpack_require__(402);
  60105. __webpack_require__(1).registerPreprocessor(function (opt) {
  60106. // Make sure markPoint component is enabled
  60107. opt.markPoint = opt.markPoint || {};
  60108. });
  60109. /***/ }),
  60110. /* 400 */
  60111. /***/ (function(module, exports, __webpack_require__) {
  60112. module.exports = __webpack_require__(401).extend({
  60113. type: 'markPoint',
  60114. defaultOption: {
  60115. zlevel: 0,
  60116. z: 5,
  60117. symbol: 'pin',
  60118. symbolSize: 50,
  60119. //symbolRotate: 0,
  60120. //symbolOffset: [0, 0]
  60121. tooltip: {
  60122. trigger: 'item'
  60123. },
  60124. label: {
  60125. normal: {
  60126. show: true,
  60127. position: 'inside'
  60128. },
  60129. emphasis: {
  60130. show: true
  60131. }
  60132. },
  60133. itemStyle: {
  60134. normal: {
  60135. borderWidth: 2
  60136. }
  60137. }
  60138. }
  60139. });
  60140. /***/ }),
  60141. /* 401 */
  60142. /***/ (function(module, exports, __webpack_require__) {
  60143. var modelUtil = __webpack_require__(5);
  60144. var zrUtil = __webpack_require__(4);
  60145. var env = __webpack_require__(2);
  60146. var formatUtil = __webpack_require__(6);
  60147. var addCommas = formatUtil.addCommas;
  60148. var encodeHTML = formatUtil.encodeHTML;
  60149. function fillLabel(opt) {
  60150. modelUtil.defaultEmphasis(opt.label, ['show']);
  60151. }
  60152. var MarkerModel = __webpack_require__(1).extendComponentModel({
  60153. type: 'marker',
  60154. dependencies: ['series', 'grid', 'polar', 'geo'],
  60155. /**
  60156. * @overrite
  60157. */
  60158. init: function (option, parentModel, ecModel, extraOpt) {
  60159. if (true) {
  60160. if (this.type === 'marker') {
  60161. throw new Error('Marker component is abstract component. Use markLine, markPoint, markArea instead.');
  60162. }
  60163. }
  60164. this.mergeDefaultAndTheme(option, ecModel);
  60165. this.mergeOption(option, ecModel, extraOpt.createdBySelf, true);
  60166. },
  60167. /**
  60168. * @return {boolean}
  60169. */
  60170. isAnimationEnabled: function () {
  60171. if (env.node) {
  60172. return false;
  60173. }
  60174. var hostSeries = this.__hostSeries;
  60175. return this.getShallow('animation') && hostSeries && hostSeries.isAnimationEnabled();
  60176. },
  60177. mergeOption: function (newOpt, ecModel, createdBySelf, isInit) {
  60178. var MarkerModel = this.constructor;
  60179. var modelPropName = this.mainType + 'Model';
  60180. if (!createdBySelf) {
  60181. ecModel.eachSeries(function (seriesModel) {
  60182. var markerOpt = seriesModel.get(this.mainType);
  60183. var markerModel = seriesModel[modelPropName];
  60184. if (!markerOpt || !markerOpt.data) {
  60185. seriesModel[modelPropName] = null;
  60186. return;
  60187. }
  60188. if (!markerModel) {
  60189. if (isInit) {
  60190. // Default label emphasis `position` and `show`
  60191. fillLabel(markerOpt);
  60192. }
  60193. zrUtil.each(markerOpt.data, function (item) {
  60194. // FIXME Overwrite fillLabel method ?
  60195. if (item instanceof Array) {
  60196. fillLabel(item[0]);
  60197. fillLabel(item[1]);
  60198. }
  60199. else {
  60200. fillLabel(item);
  60201. }
  60202. });
  60203. markerModel = new MarkerModel(
  60204. markerOpt, this, ecModel
  60205. );
  60206. zrUtil.extend(markerModel, {
  60207. mainType: this.mainType,
  60208. // Use the same series index and name
  60209. seriesIndex: seriesModel.seriesIndex,
  60210. name: seriesModel.name,
  60211. createdBySelf: true
  60212. });
  60213. markerModel.__hostSeries = seriesModel;
  60214. }
  60215. else {
  60216. markerModel.mergeOption(markerOpt, ecModel, true);
  60217. }
  60218. seriesModel[modelPropName] = markerModel;
  60219. }, this);
  60220. }
  60221. },
  60222. formatTooltip: function (dataIndex) {
  60223. var data = this.getData();
  60224. var value = this.getRawValue(dataIndex);
  60225. var formattedValue = zrUtil.isArray(value)
  60226. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  60227. var name = data.getName(dataIndex);
  60228. var html = encodeHTML(this.name);
  60229. if (value != null || name) {
  60230. html += '<br />';
  60231. }
  60232. if (name) {
  60233. html += encodeHTML(name);
  60234. if (value != null) {
  60235. html += ' : ';
  60236. }
  60237. }
  60238. if (value != null) {
  60239. html += encodeHTML(formattedValue);
  60240. }
  60241. return html;
  60242. },
  60243. getData: function () {
  60244. return this._data;
  60245. },
  60246. setData: function (data) {
  60247. this._data = data;
  60248. }
  60249. });
  60250. zrUtil.mixin(MarkerModel, modelUtil.dataFormatMixin);
  60251. module.exports = MarkerModel;
  60252. /***/ }),
  60253. /* 402 */
  60254. /***/ (function(module, exports, __webpack_require__) {
  60255. var SymbolDraw = __webpack_require__(119);
  60256. var zrUtil = __webpack_require__(4);
  60257. var numberUtil = __webpack_require__(7);
  60258. var List = __webpack_require__(101);
  60259. var markerHelper = __webpack_require__(403);
  60260. function updateMarkerLayout(mpData, seriesModel, api) {
  60261. var coordSys = seriesModel.coordinateSystem;
  60262. mpData.each(function (idx) {
  60263. var itemModel = mpData.getItemModel(idx);
  60264. var point;
  60265. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  60266. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  60267. if (!isNaN(xPx) && !isNaN(yPx)) {
  60268. point = [xPx, yPx];
  60269. }
  60270. // Chart like bar may have there own marker positioning logic
  60271. else if (seriesModel.getMarkerPosition) {
  60272. // Use the getMarkerPoisition
  60273. point = seriesModel.getMarkerPosition(
  60274. mpData.getValues(mpData.dimensions, idx)
  60275. );
  60276. }
  60277. else if (coordSys) {
  60278. var x = mpData.get(coordSys.dimensions[0], idx);
  60279. var y = mpData.get(coordSys.dimensions[1], idx);
  60280. point = coordSys.dataToPoint([x, y]);
  60281. }
  60282. // Use x, y if has any
  60283. if (!isNaN(xPx)) {
  60284. point[0] = xPx;
  60285. }
  60286. if (!isNaN(yPx)) {
  60287. point[1] = yPx;
  60288. }
  60289. mpData.setItemLayout(idx, point);
  60290. });
  60291. }
  60292. __webpack_require__(404).extend({
  60293. type: 'markPoint',
  60294. updateLayout: function (markPointModel, ecModel, api) {
  60295. ecModel.eachSeries(function (seriesModel) {
  60296. var mpModel = seriesModel.markPointModel;
  60297. if (mpModel) {
  60298. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  60299. this.markerGroupMap.get(seriesModel.id).updateLayout(mpModel);
  60300. }
  60301. }, this);
  60302. },
  60303. renderSeries: function (seriesModel, mpModel, ecModel, api) {
  60304. var coordSys = seriesModel.coordinateSystem;
  60305. var seriesId = seriesModel.id;
  60306. var seriesData = seriesModel.getData();
  60307. var symbolDrawMap = this.markerGroupMap;
  60308. var symbolDraw = symbolDrawMap.get(seriesId)
  60309. || symbolDrawMap.set(seriesId, new SymbolDraw());
  60310. var mpData = createList(coordSys, seriesModel, mpModel);
  60311. // FIXME
  60312. mpModel.setData(mpData);
  60313. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  60314. mpData.each(function (idx) {
  60315. var itemModel = mpData.getItemModel(idx);
  60316. var symbolSize = itemModel.getShallow('symbolSize');
  60317. if (typeof symbolSize === 'function') {
  60318. // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据?
  60319. symbolSize = symbolSize(
  60320. mpModel.getRawValue(idx), mpModel.getDataParams(idx)
  60321. );
  60322. }
  60323. mpData.setItemVisual(idx, {
  60324. symbolSize: symbolSize,
  60325. color: itemModel.get('itemStyle.normal.color')
  60326. || seriesData.getVisual('color'),
  60327. symbol: itemModel.getShallow('symbol')
  60328. });
  60329. });
  60330. // TODO Text are wrong
  60331. symbolDraw.updateData(mpData);
  60332. this.group.add(symbolDraw.group);
  60333. // Set host model for tooltip
  60334. // FIXME
  60335. mpData.eachItemGraphicEl(function (el) {
  60336. el.traverse(function (child) {
  60337. child.dataModel = mpModel;
  60338. });
  60339. });
  60340. symbolDraw.__keep = true;
  60341. symbolDraw.group.silent = mpModel.get('silent') || seriesModel.get('silent');
  60342. }
  60343. });
  60344. /**
  60345. * @inner
  60346. * @param {module:echarts/coord/*} [coordSys]
  60347. * @param {module:echarts/model/Series} seriesModel
  60348. * @param {module:echarts/model/Model} mpModel
  60349. */
  60350. function createList(coordSys, seriesModel, mpModel) {
  60351. var coordDimsInfos;
  60352. if (coordSys) {
  60353. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  60354. var info = seriesModel.getData().getDimensionInfo(
  60355. seriesModel.coordDimToDataDim(coordDim)[0]
  60356. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  60357. info.name = coordDim;
  60358. return info;
  60359. });
  60360. }
  60361. else {
  60362. coordDimsInfos =[{
  60363. name: 'value',
  60364. type: 'float'
  60365. }];
  60366. }
  60367. var mpData = new List(coordDimsInfos, mpModel);
  60368. var dataOpt = zrUtil.map(mpModel.get('data'), zrUtil.curry(
  60369. markerHelper.dataTransform, seriesModel
  60370. ));
  60371. if (coordSys) {
  60372. dataOpt = zrUtil.filter(
  60373. dataOpt, zrUtil.curry(markerHelper.dataFilter, coordSys)
  60374. );
  60375. }
  60376. mpData.initData(dataOpt, null,
  60377. coordSys ? markerHelper.dimValueGetter : function (item) {
  60378. return item.value;
  60379. }
  60380. );
  60381. return mpData;
  60382. }
  60383. /***/ }),
  60384. /* 403 */
  60385. /***/ (function(module, exports, __webpack_require__) {
  60386. var zrUtil = __webpack_require__(4);
  60387. var numberUtil = __webpack_require__(7);
  60388. var indexOf = zrUtil.indexOf;
  60389. function hasXOrY(item) {
  60390. return !(isNaN(parseFloat(item.x)) && isNaN(parseFloat(item.y)));
  60391. }
  60392. function hasXAndY(item) {
  60393. return !isNaN(parseFloat(item.x)) && !isNaN(parseFloat(item.y));
  60394. }
  60395. function getPrecision(data, valueAxisDim, dataIndex) {
  60396. var precision = -1;
  60397. do {
  60398. precision = Math.max(
  60399. numberUtil.getPrecision(data.get(
  60400. valueAxisDim, dataIndex
  60401. )),
  60402. precision
  60403. );
  60404. data = data.stackedOn;
  60405. } while (data);
  60406. return precision;
  60407. }
  60408. function markerTypeCalculatorWithExtent(
  60409. mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
  60410. ) {
  60411. var coordArr = [];
  60412. var value = numCalculate(data, targetDataDim, mlType);
  60413. var dataIndex = data.indicesOfNearest(targetDataDim, value, true)[0];
  60414. coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex, true);
  60415. coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex, true);
  60416. var precision = getPrecision(data, targetDataDim, dataIndex);
  60417. precision = Math.min(precision, 20);
  60418. if (precision >= 0) {
  60419. coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
  60420. }
  60421. return coordArr;
  60422. }
  60423. var curry = zrUtil.curry;
  60424. // TODO Specified percent
  60425. var markerTypeCalculator = {
  60426. /**
  60427. * @method
  60428. * @param {module:echarts/data/List} data
  60429. * @param {string} baseAxisDim
  60430. * @param {string} valueAxisDim
  60431. */
  60432. min: curry(markerTypeCalculatorWithExtent, 'min'),
  60433. /**
  60434. * @method
  60435. * @param {module:echarts/data/List} data
  60436. * @param {string} baseAxisDim
  60437. * @param {string} valueAxisDim
  60438. */
  60439. max: curry(markerTypeCalculatorWithExtent, 'max'),
  60440. /**
  60441. * @method
  60442. * @param {module:echarts/data/List} data
  60443. * @param {string} baseAxisDim
  60444. * @param {string} valueAxisDim
  60445. */
  60446. average: curry(markerTypeCalculatorWithExtent, 'average')
  60447. };
  60448. /**
  60449. * Transform markPoint data item to format used in List by do the following
  60450. * 1. Calculate statistic like `max`, `min`, `average`
  60451. * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
  60452. * @param {module:echarts/model/Series} seriesModel
  60453. * @param {module:echarts/coord/*} [coordSys]
  60454. * @param {Object} item
  60455. * @return {Object}
  60456. */
  60457. var dataTransform = function (seriesModel, item) {
  60458. var data = seriesModel.getData();
  60459. var coordSys = seriesModel.coordinateSystem;
  60460. // 1. If not specify the position with pixel directly
  60461. // 2. If `coord` is not a data array. Which uses `xAxis`,
  60462. // `yAxis` to specify the coord on each dimension
  60463. // parseFloat first because item.x and item.y can be percent string like '20%'
  60464. if (item && !hasXAndY(item) && !zrUtil.isArray(item.coord) && coordSys) {
  60465. var dims = coordSys.dimensions;
  60466. var axisInfo = getAxisInfo(item, data, coordSys, seriesModel);
  60467. // Clone the option
  60468. // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
  60469. item = zrUtil.clone(item);
  60470. if (item.type
  60471. && markerTypeCalculator[item.type]
  60472. && axisInfo.baseAxis && axisInfo.valueAxis
  60473. ) {
  60474. var otherCoordIndex = indexOf(dims, axisInfo.baseAxis.dim);
  60475. var targetCoordIndex = indexOf(dims, axisInfo.valueAxis.dim);
  60476. item.coord = markerTypeCalculator[item.type](
  60477. data, axisInfo.baseDataDim, axisInfo.valueDataDim,
  60478. otherCoordIndex, targetCoordIndex
  60479. );
  60480. // Force to use the value of calculated value.
  60481. item.value = item.coord[targetCoordIndex];
  60482. }
  60483. else {
  60484. // FIXME Only has one of xAxis and yAxis.
  60485. var coord = [
  60486. item.xAxis != null ? item.xAxis : item.radiusAxis,
  60487. item.yAxis != null ? item.yAxis : item.angleAxis
  60488. ];
  60489. // Each coord support max, min, average
  60490. for (var i = 0; i < 2; i++) {
  60491. if (markerTypeCalculator[coord[i]]) {
  60492. var dataDim = seriesModel.coordDimToDataDim(dims[i])[0];
  60493. coord[i] = numCalculate(data, dataDim, coord[i]);
  60494. }
  60495. }
  60496. item.coord = coord;
  60497. }
  60498. }
  60499. return item;
  60500. };
  60501. var getAxisInfo = function (item, data, coordSys, seriesModel) {
  60502. var ret = {};
  60503. if (item.valueIndex != null || item.valueDim != null) {
  60504. ret.valueDataDim = item.valueIndex != null
  60505. ? data.getDimension(item.valueIndex) : item.valueDim;
  60506. ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim));
  60507. ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis);
  60508. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  60509. }
  60510. else {
  60511. ret.baseAxis = seriesModel.getBaseAxis();
  60512. ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis);
  60513. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  60514. ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0];
  60515. }
  60516. return ret;
  60517. };
  60518. /**
  60519. * Filter data which is out of coordinateSystem range
  60520. * [dataFilter description]
  60521. * @param {module:echarts/coord/*} [coordSys]
  60522. * @param {Object} item
  60523. * @return {boolean}
  60524. */
  60525. var dataFilter = function (coordSys, item) {
  60526. // Alwalys return true if there is no coordSys
  60527. return (coordSys && coordSys.containData && item.coord && !hasXOrY(item))
  60528. ? coordSys.containData(item.coord) : true;
  60529. };
  60530. var dimValueGetter = function (item, dimName, dataIndex, dimIndex) {
  60531. // x, y, radius, angle
  60532. if (dimIndex < 2) {
  60533. return item.coord && item.coord[dimIndex];
  60534. }
  60535. return item.value;
  60536. };
  60537. var numCalculate = function (data, valueDataDim, type) {
  60538. if (type === 'average') {
  60539. var sum = 0;
  60540. var count = 0;
  60541. data.each(valueDataDim, function (val, idx) {
  60542. if (!isNaN(val)) {
  60543. sum += val;
  60544. count++;
  60545. }
  60546. }, true);
  60547. return sum / count;
  60548. }
  60549. else {
  60550. return data.getDataExtent(valueDataDim, true)[type === 'max' ? 1 : 0];
  60551. }
  60552. };
  60553. module.exports = {
  60554. dataTransform: dataTransform,
  60555. dataFilter: dataFilter,
  60556. dimValueGetter: dimValueGetter,
  60557. getAxisInfo: getAxisInfo,
  60558. numCalculate: numCalculate
  60559. };
  60560. /***/ }),
  60561. /* 404 */
  60562. /***/ (function(module, exports, __webpack_require__) {
  60563. var zrUtil = __webpack_require__(4);
  60564. module.exports = __webpack_require__(1).extendComponentView({
  60565. type: 'marker',
  60566. init: function () {
  60567. /**
  60568. * Markline grouped by series
  60569. * @private
  60570. * @type {module:zrender/core/util.HashMap}
  60571. */
  60572. this.markerGroupMap = zrUtil.createHashMap();
  60573. },
  60574. render: function (markerModel, ecModel, api) {
  60575. var markerGroupMap = this.markerGroupMap;
  60576. markerGroupMap.each(function (item) {
  60577. item.__keep = false;
  60578. });
  60579. var markerModelKey = this.type + 'Model';
  60580. ecModel.eachSeries(function (seriesModel) {
  60581. var markerModel = seriesModel[markerModelKey];
  60582. markerModel && this.renderSeries(seriesModel, markerModel, ecModel, api);
  60583. }, this);
  60584. markerGroupMap.each(function (item) {
  60585. !item.__keep && this.group.remove(item.group);
  60586. }, this);
  60587. },
  60588. renderSeries: function () {}
  60589. });
  60590. /***/ }),
  60591. /* 405 */
  60592. /***/ (function(module, exports, __webpack_require__) {
  60593. __webpack_require__(406);
  60594. __webpack_require__(407);
  60595. __webpack_require__(1).registerPreprocessor(function (opt) {
  60596. // Make sure markLine component is enabled
  60597. opt.markLine = opt.markLine || {};
  60598. });
  60599. /***/ }),
  60600. /* 406 */
  60601. /***/ (function(module, exports, __webpack_require__) {
  60602. module.exports = __webpack_require__(401).extend({
  60603. type: 'markLine',
  60604. defaultOption: {
  60605. zlevel: 0,
  60606. z: 5,
  60607. symbol: ['circle', 'arrow'],
  60608. symbolSize: [8, 16],
  60609. //symbolRotate: 0,
  60610. precision: 2,
  60611. tooltip: {
  60612. trigger: 'item'
  60613. },
  60614. label: {
  60615. normal: {
  60616. show: true,
  60617. position: 'end'
  60618. },
  60619. emphasis: {
  60620. show: true
  60621. }
  60622. },
  60623. lineStyle: {
  60624. normal: {
  60625. type: 'dashed'
  60626. },
  60627. emphasis: {
  60628. width: 3
  60629. }
  60630. },
  60631. animationEasing: 'linear'
  60632. }
  60633. });
  60634. /***/ }),
  60635. /* 407 */
  60636. /***/ (function(module, exports, __webpack_require__) {
  60637. var zrUtil = __webpack_require__(4);
  60638. var List = __webpack_require__(101);
  60639. var numberUtil = __webpack_require__(7);
  60640. var markerHelper = __webpack_require__(403);
  60641. var LineDraw = __webpack_require__(213);
  60642. var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
  60643. var data = seriesModel.getData();
  60644. // Special type markLine like 'min', 'max', 'average'
  60645. var mlType = item.type;
  60646. if (!zrUtil.isArray(item)
  60647. && (
  60648. mlType === 'min' || mlType === 'max' || mlType === 'average'
  60649. // In case
  60650. // data: [{
  60651. // yAxis: 10
  60652. // }]
  60653. || (item.xAxis != null || item.yAxis != null)
  60654. )
  60655. ) {
  60656. var valueAxis;
  60657. var valueDataDim;
  60658. var value;
  60659. if (item.yAxis != null || item.xAxis != null) {
  60660. valueDataDim = item.yAxis != null ? 'y' : 'x';
  60661. valueAxis = coordSys.getAxis(valueDataDim);
  60662. value = zrUtil.retrieve(item.yAxis, item.xAxis);
  60663. }
  60664. else {
  60665. var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);
  60666. valueDataDim = axisInfo.valueDataDim;
  60667. valueAxis = axisInfo.valueAxis;
  60668. value = markerHelper.numCalculate(data, valueDataDim, mlType);
  60669. }
  60670. var valueIndex = valueDataDim === 'x' ? 0 : 1;
  60671. var baseIndex = 1 - valueIndex;
  60672. var mlFrom = zrUtil.clone(item);
  60673. var mlTo = {};
  60674. mlFrom.type = null;
  60675. mlFrom.coord = [];
  60676. mlTo.coord = [];
  60677. mlFrom.coord[baseIndex] = -Infinity;
  60678. mlTo.coord[baseIndex] = Infinity;
  60679. var precision = mlModel.get('precision');
  60680. if (precision >= 0 && typeof value === 'number') {
  60681. value = +value.toFixed(Math.min(precision, 20));
  60682. }
  60683. mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
  60684. item = [mlFrom, mlTo, { // Extra option for tooltip and label
  60685. type: mlType,
  60686. valueIndex: item.valueIndex,
  60687. // Force to use the value of calculated value.
  60688. value: value
  60689. }];
  60690. }
  60691. item = [
  60692. markerHelper.dataTransform(seriesModel, item[0]),
  60693. markerHelper.dataTransform(seriesModel, item[1]),
  60694. zrUtil.extend({}, item[2])
  60695. ];
  60696. // Avoid line data type is extended by from(to) data type
  60697. item[2].type = item[2].type || '';
  60698. // Merge from option and to option into line option
  60699. zrUtil.merge(item[2], item[0]);
  60700. zrUtil.merge(item[2], item[1]);
  60701. return item;
  60702. };
  60703. function isInifinity(val) {
  60704. return !isNaN(val) && !isFinite(val);
  60705. }
  60706. // If a markLine has one dim
  60707. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  60708. var otherDimIndex = 1 - dimIndex;
  60709. var dimName = coordSys.dimensions[dimIndex];
  60710. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
  60711. && fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
  60712. }
  60713. function markLineFilter(coordSys, item) {
  60714. if (coordSys.type === 'cartesian2d') {
  60715. var fromCoord = item[0].coord;
  60716. var toCoord = item[1].coord;
  60717. // In case
  60718. // {
  60719. // markLine: {
  60720. // data: [{ yAxis: 2 }]
  60721. // }
  60722. // }
  60723. if (
  60724. fromCoord && toCoord &&
  60725. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  60726. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  60727. ) {
  60728. return true;
  60729. }
  60730. }
  60731. return markerHelper.dataFilter(coordSys, item[0])
  60732. && markerHelper.dataFilter(coordSys, item[1]);
  60733. }
  60734. function updateSingleMarkerEndLayout(
  60735. data, idx, isFrom, seriesModel, api
  60736. ) {
  60737. var coordSys = seriesModel.coordinateSystem;
  60738. var itemModel = data.getItemModel(idx);
  60739. var point;
  60740. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  60741. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  60742. if (!isNaN(xPx) && !isNaN(yPx)) {
  60743. point = [xPx, yPx];
  60744. }
  60745. else {
  60746. // Chart like bar may have there own marker positioning logic
  60747. if (seriesModel.getMarkerPosition) {
  60748. // Use the getMarkerPoisition
  60749. point = seriesModel.getMarkerPosition(
  60750. data.getValues(data.dimensions, idx)
  60751. );
  60752. }
  60753. else {
  60754. var dims = coordSys.dimensions;
  60755. var x = data.get(dims[0], idx);
  60756. var y = data.get(dims[1], idx);
  60757. point = coordSys.dataToPoint([x, y]);
  60758. }
  60759. // Expand line to the edge of grid if value on one axis is Inifnity
  60760. // In case
  60761. // markLine: {
  60762. // data: [{
  60763. // yAxis: 2
  60764. // // or
  60765. // type: 'average'
  60766. // }]
  60767. // }
  60768. if (coordSys.type === 'cartesian2d') {
  60769. var xAxis = coordSys.getAxis('x');
  60770. var yAxis = coordSys.getAxis('y');
  60771. var dims = coordSys.dimensions;
  60772. if (isInifinity(data.get(dims[0], idx))) {
  60773. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
  60774. }
  60775. else if (isInifinity(data.get(dims[1], idx))) {
  60776. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
  60777. }
  60778. }
  60779. // Use x, y if has any
  60780. if (!isNaN(xPx)) {
  60781. point[0] = xPx;
  60782. }
  60783. if (!isNaN(yPx)) {
  60784. point[1] = yPx;
  60785. }
  60786. }
  60787. data.setItemLayout(idx, point);
  60788. }
  60789. __webpack_require__(404).extend({
  60790. type: 'markLine',
  60791. updateLayout: function (markLineModel, ecModel, api) {
  60792. ecModel.eachSeries(function (seriesModel) {
  60793. var mlModel = seriesModel.markLineModel;
  60794. if (mlModel) {
  60795. var mlData = mlModel.getData();
  60796. var fromData = mlModel.__from;
  60797. var toData = mlModel.__to;
  60798. // Update visual and layout of from symbol and to symbol
  60799. fromData.each(function (idx) {
  60800. updateSingleMarkerEndLayout(fromData, idx, true, seriesModel, api);
  60801. updateSingleMarkerEndLayout(toData, idx, false, seriesModel, api);
  60802. });
  60803. // Update layout of line
  60804. mlData.each(function (idx) {
  60805. mlData.setItemLayout(idx, [
  60806. fromData.getItemLayout(idx),
  60807. toData.getItemLayout(idx)
  60808. ]);
  60809. });
  60810. this.markerGroupMap.get(seriesModel.id).updateLayout();
  60811. }
  60812. }, this);
  60813. },
  60814. renderSeries: function (seriesModel, mlModel, ecModel, api) {
  60815. var coordSys = seriesModel.coordinateSystem;
  60816. var seriesId = seriesModel.id;
  60817. var seriesData = seriesModel.getData();
  60818. var lineDrawMap = this.markerGroupMap;
  60819. var lineDraw = lineDrawMap.get(seriesId)
  60820. || lineDrawMap.set(seriesId, new LineDraw());
  60821. this.group.add(lineDraw.group);
  60822. var mlData = createList(coordSys, seriesModel, mlModel);
  60823. var fromData = mlData.from;
  60824. var toData = mlData.to;
  60825. var lineData = mlData.line;
  60826. mlModel.__from = fromData;
  60827. mlModel.__to = toData;
  60828. // Line data for tooltip and formatter
  60829. mlModel.setData(lineData);
  60830. var symbolType = mlModel.get('symbol');
  60831. var symbolSize = mlModel.get('symbolSize');
  60832. if (!zrUtil.isArray(symbolType)) {
  60833. symbolType = [symbolType, symbolType];
  60834. }
  60835. if (typeof symbolSize === 'number') {
  60836. symbolSize = [symbolSize, symbolSize];
  60837. }
  60838. // Update visual and layout of from symbol and to symbol
  60839. mlData.from.each(function (idx) {
  60840. updateDataVisualAndLayout(fromData, idx, true);
  60841. updateDataVisualAndLayout(toData, idx, false);
  60842. });
  60843. // Update visual and layout of line
  60844. lineData.each(function (idx) {
  60845. var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color');
  60846. lineData.setItemVisual(idx, {
  60847. color: lineColor || fromData.getItemVisual(idx, 'color')
  60848. });
  60849. lineData.setItemLayout(idx, [
  60850. fromData.getItemLayout(idx),
  60851. toData.getItemLayout(idx)
  60852. ]);
  60853. lineData.setItemVisual(idx, {
  60854. 'fromSymbolSize': fromData.getItemVisual(idx, 'symbolSize'),
  60855. 'fromSymbol': fromData.getItemVisual(idx, 'symbol'),
  60856. 'toSymbolSize': toData.getItemVisual(idx, 'symbolSize'),
  60857. 'toSymbol': toData.getItemVisual(idx, 'symbol')
  60858. });
  60859. });
  60860. lineDraw.updateData(lineData);
  60861. // Set host model for tooltip
  60862. // FIXME
  60863. mlData.line.eachItemGraphicEl(function (el, idx) {
  60864. el.traverse(function (child) {
  60865. child.dataModel = mlModel;
  60866. });
  60867. });
  60868. function updateDataVisualAndLayout(data, idx, isFrom) {
  60869. var itemModel = data.getItemModel(idx);
  60870. updateSingleMarkerEndLayout(
  60871. data, idx, isFrom, seriesModel, api
  60872. );
  60873. data.setItemVisual(idx, {
  60874. symbolSize: itemModel.get('symbolSize') || symbolSize[isFrom ? 0 : 1],
  60875. symbol: itemModel.get('symbol', true) || symbolType[isFrom ? 0 : 1],
  60876. color: itemModel.get('itemStyle.normal.color') || seriesData.getVisual('color')
  60877. });
  60878. }
  60879. lineDraw.__keep = true;
  60880. lineDraw.group.silent = mlModel.get('silent') || seriesModel.get('silent');
  60881. }
  60882. });
  60883. /**
  60884. * @inner
  60885. * @param {module:echarts/coord/*} coordSys
  60886. * @param {module:echarts/model/Series} seriesModel
  60887. * @param {module:echarts/model/Model} mpModel
  60888. */
  60889. function createList(coordSys, seriesModel, mlModel) {
  60890. var coordDimsInfos;
  60891. if (coordSys) {
  60892. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  60893. var info = seriesModel.getData().getDimensionInfo(
  60894. seriesModel.coordDimToDataDim(coordDim)[0]
  60895. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  60896. info.name = coordDim;
  60897. return info;
  60898. });
  60899. }
  60900. else {
  60901. coordDimsInfos =[{
  60902. name: 'value',
  60903. type: 'float'
  60904. }];
  60905. }
  60906. var fromData = new List(coordDimsInfos, mlModel);
  60907. var toData = new List(coordDimsInfos, mlModel);
  60908. // No dimensions
  60909. var lineData = new List([], mlModel);
  60910. var optData = zrUtil.map(mlModel.get('data'), zrUtil.curry(
  60911. markLineTransform, seriesModel, coordSys, mlModel
  60912. ));
  60913. if (coordSys) {
  60914. optData = zrUtil.filter(
  60915. optData, zrUtil.curry(markLineFilter, coordSys)
  60916. );
  60917. }
  60918. var dimValueGetter = coordSys ? markerHelper.dimValueGetter : function (item) {
  60919. return item.value;
  60920. };
  60921. fromData.initData(
  60922. zrUtil.map(optData, function (item) { return item[0]; }),
  60923. null, dimValueGetter
  60924. );
  60925. toData.initData(
  60926. zrUtil.map(optData, function (item) { return item[1]; }),
  60927. null, dimValueGetter
  60928. );
  60929. lineData.initData(
  60930. zrUtil.map(optData, function (item) { return item[2]; })
  60931. );
  60932. lineData.hasItemOption = true;
  60933. return {
  60934. from: fromData,
  60935. to: toData,
  60936. line: lineData
  60937. };
  60938. }
  60939. /***/ }),
  60940. /* 408 */
  60941. /***/ (function(module, exports, __webpack_require__) {
  60942. __webpack_require__(409);
  60943. __webpack_require__(410);
  60944. __webpack_require__(1).registerPreprocessor(function (opt) {
  60945. // Make sure markArea component is enabled
  60946. opt.markArea = opt.markArea || {};
  60947. });
  60948. /***/ }),
  60949. /* 409 */
  60950. /***/ (function(module, exports, __webpack_require__) {
  60951. module.exports = __webpack_require__(401).extend({
  60952. type: 'markArea',
  60953. defaultOption: {
  60954. zlevel: 0,
  60955. // PENDING
  60956. z: 1,
  60957. tooltip: {
  60958. trigger: 'item'
  60959. },
  60960. // markArea should fixed on the coordinate system
  60961. animation: false,
  60962. label: {
  60963. normal: {
  60964. show: true,
  60965. position: 'top'
  60966. },
  60967. emphasis: {
  60968. show: true,
  60969. position: 'top'
  60970. }
  60971. },
  60972. itemStyle: {
  60973. normal: {
  60974. // color and borderColor default to use color from series
  60975. // color: 'auto'
  60976. // borderColor: 'auto'
  60977. borderWidth: 0
  60978. }
  60979. }
  60980. }
  60981. });
  60982. /***/ }),
  60983. /* 410 */
  60984. /***/ (function(module, exports, __webpack_require__) {
  60985. // TODO Better on polar
  60986. var zrUtil = __webpack_require__(4);
  60987. var List = __webpack_require__(101);
  60988. var numberUtil = __webpack_require__(7);
  60989. var graphic = __webpack_require__(20);
  60990. var colorUtil = __webpack_require__(33);
  60991. var markerHelper = __webpack_require__(403);
  60992. var markAreaTransform = function (seriesModel, coordSys, maModel, item) {
  60993. var lt = markerHelper.dataTransform(seriesModel, item[0]);
  60994. var rb = markerHelper.dataTransform(seriesModel, item[1]);
  60995. var retrieve = zrUtil.retrieve;
  60996. // FIXME make sure lt is less than rb
  60997. var ltCoord = lt.coord;
  60998. var rbCoord = rb.coord;
  60999. ltCoord[0] = retrieve(ltCoord[0], -Infinity);
  61000. ltCoord[1] = retrieve(ltCoord[1], -Infinity);
  61001. rbCoord[0] = retrieve(rbCoord[0], Infinity);
  61002. rbCoord[1] = retrieve(rbCoord[1], Infinity);
  61003. // Merge option into one
  61004. var result = zrUtil.mergeAll([{}, lt, rb]);
  61005. result.coord = [
  61006. lt.coord, rb.coord
  61007. ];
  61008. result.x0 = lt.x;
  61009. result.y0 = lt.y;
  61010. result.x1 = rb.x;
  61011. result.y1 = rb.y;
  61012. return result;
  61013. };
  61014. function isInifinity(val) {
  61015. return !isNaN(val) && !isFinite(val);
  61016. }
  61017. // If a markArea has one dim
  61018. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  61019. var otherDimIndex = 1 - dimIndex;
  61020. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
  61021. }
  61022. function markAreaFilter(coordSys, item) {
  61023. var fromCoord = item.coord[0];
  61024. var toCoord = item.coord[1];
  61025. if (coordSys.type === 'cartesian2d') {
  61026. // In case
  61027. // {
  61028. // markArea: {
  61029. // data: [{ yAxis: 2 }]
  61030. // }
  61031. // }
  61032. if (
  61033. fromCoord && toCoord &&
  61034. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  61035. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  61036. ) {
  61037. return true;
  61038. }
  61039. }
  61040. return markerHelper.dataFilter(coordSys, {
  61041. coord: fromCoord,
  61042. x: item.x0,
  61043. y: item.y0
  61044. })
  61045. || markerHelper.dataFilter(coordSys, {
  61046. coord: toCoord,
  61047. x: item.x1,
  61048. y: item.y1
  61049. });
  61050. }
  61051. // dims can be ['x0', 'y0'], ['x1', 'y1'], ['x0', 'y1'], ['x1', 'y0']
  61052. function getSingleMarkerEndPoint(data, idx, dims, seriesModel, api) {
  61053. var coordSys = seriesModel.coordinateSystem;
  61054. var itemModel = data.getItemModel(idx);
  61055. var point;
  61056. var xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
  61057. var yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
  61058. if (!isNaN(xPx) && !isNaN(yPx)) {
  61059. point = [xPx, yPx];
  61060. }
  61061. else {
  61062. // Chart like bar may have there own marker positioning logic
  61063. if (seriesModel.getMarkerPosition) {
  61064. // Use the getMarkerPoisition
  61065. point = seriesModel.getMarkerPosition(
  61066. data.getValues(dims, idx)
  61067. );
  61068. }
  61069. else {
  61070. var x = data.get(dims[0], idx);
  61071. var y = data.get(dims[1], idx);
  61072. point = coordSys.dataToPoint([x, y], true);
  61073. }
  61074. if (coordSys.type === 'cartesian2d') {
  61075. var xAxis = coordSys.getAxis('x');
  61076. var yAxis = coordSys.getAxis('y');
  61077. var x = data.get(dims[0], idx);
  61078. var y = data.get(dims[1], idx);
  61079. if (isInifinity(x)) {
  61080. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
  61081. }
  61082. else if (isInifinity(y)) {
  61083. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
  61084. }
  61085. }
  61086. // Use x, y if has any
  61087. if (!isNaN(xPx)) {
  61088. point[0] = xPx;
  61089. }
  61090. if (!isNaN(yPx)) {
  61091. point[1] = yPx;
  61092. }
  61093. }
  61094. return point;
  61095. }
  61096. var dimPermutations = [['x0', 'y0'], ['x1', 'y0'], ['x1', 'y1'], ['x0', 'y1']];
  61097. __webpack_require__(404).extend({
  61098. type: 'markArea',
  61099. updateLayout: function (markAreaModel, ecModel, api) {
  61100. ecModel.eachSeries(function (seriesModel) {
  61101. var maModel = seriesModel.markAreaModel;
  61102. if (maModel) {
  61103. var areaData = maModel.getData();
  61104. areaData.each(function (idx) {
  61105. var points = zrUtil.map(dimPermutations, function (dim) {
  61106. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  61107. });
  61108. // Layout
  61109. areaData.setItemLayout(idx, points);
  61110. var el = areaData.getItemGraphicEl(idx);
  61111. el.setShape('points', points);
  61112. });
  61113. }
  61114. }, this);
  61115. },
  61116. renderSeries: function (seriesModel, maModel, ecModel, api) {
  61117. var coordSys = seriesModel.coordinateSystem;
  61118. var seriesName = seriesModel.name;
  61119. var seriesData = seriesModel.getData();
  61120. var areaGroupMap = this.markerGroupMap;
  61121. var polygonGroup = areaGroupMap.get(seriesName)
  61122. || areaGroupMap.set(seriesName, {group: new graphic.Group()});
  61123. this.group.add(polygonGroup.group);
  61124. polygonGroup.__keep = true;
  61125. var areaData = createList(coordSys, seriesModel, maModel);
  61126. // Line data for tooltip and formatter
  61127. maModel.setData(areaData);
  61128. // Update visual and layout of line
  61129. areaData.each(function (idx) {
  61130. // Layout
  61131. areaData.setItemLayout(idx, zrUtil.map(dimPermutations, function (dim) {
  61132. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  61133. }));
  61134. // Visual
  61135. areaData.setItemVisual(idx, {
  61136. color: seriesData.getVisual('color')
  61137. });
  61138. });
  61139. areaData.diff(polygonGroup.__data)
  61140. .add(function (idx) {
  61141. var polygon = new graphic.Polygon({
  61142. shape: {
  61143. points: areaData.getItemLayout(idx)
  61144. }
  61145. });
  61146. areaData.setItemGraphicEl(idx, polygon);
  61147. polygonGroup.group.add(polygon);
  61148. })
  61149. .update(function (newIdx, oldIdx) {
  61150. var polygon = polygonGroup.__data.getItemGraphicEl(oldIdx);
  61151. graphic.updateProps(polygon, {
  61152. shape: {
  61153. points: areaData.getItemLayout(newIdx)
  61154. }
  61155. }, maModel, newIdx);
  61156. polygonGroup.group.add(polygon);
  61157. areaData.setItemGraphicEl(newIdx, polygon);
  61158. })
  61159. .remove(function (idx) {
  61160. var polygon = polygonGroup.__data.getItemGraphicEl(idx);
  61161. polygonGroup.group.remove(polygon);
  61162. })
  61163. .execute();
  61164. areaData.eachItemGraphicEl(function (polygon, idx) {
  61165. var itemModel = areaData.getItemModel(idx);
  61166. var labelModel = itemModel.getModel('label.normal');
  61167. var labelHoverModel = itemModel.getModel('label.emphasis');
  61168. var color = areaData.getItemVisual(idx, 'color');
  61169. polygon.useStyle(
  61170. zrUtil.defaults(
  61171. itemModel.getModel('itemStyle.normal').getItemStyle(),
  61172. {
  61173. fill: colorUtil.modifyAlpha(color, 0.4),
  61174. stroke: color
  61175. }
  61176. )
  61177. );
  61178. polygon.hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  61179. graphic.setLabelStyle(
  61180. polygon.style, polygon.hoverStyle, labelModel, labelHoverModel,
  61181. {
  61182. labelFetcher: maModel,
  61183. labelDataIndex: idx,
  61184. defaultText: areaData.getName(idx) || '',
  61185. isRectText: true,
  61186. autoColor: color
  61187. }
  61188. );
  61189. graphic.setHoverStyle(polygon, {});
  61190. polygon.dataModel = maModel;
  61191. });
  61192. polygonGroup.__data = areaData;
  61193. polygonGroup.group.silent = maModel.get('silent') || seriesModel.get('silent');
  61194. }
  61195. });
  61196. /**
  61197. * @inner
  61198. * @param {module:echarts/coord/*} coordSys
  61199. * @param {module:echarts/model/Series} seriesModel
  61200. * @param {module:echarts/model/Model} mpModel
  61201. */
  61202. function createList(coordSys, seriesModel, maModel) {
  61203. var coordDimsInfos;
  61204. var areaData;
  61205. var dims = ['x0', 'y0', 'x1', 'y1'];
  61206. if (coordSys) {
  61207. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  61208. var info = seriesModel.getData().getDimensionInfo(
  61209. seriesModel.coordDimToDataDim(coordDim)[0]
  61210. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  61211. info.name = coordDim;
  61212. return info;
  61213. });
  61214. areaData = new List(zrUtil.map(dims, function (dim, idx) {
  61215. return {
  61216. name: dim,
  61217. type: coordDimsInfos[idx % 2].type
  61218. };
  61219. }), maModel);
  61220. }
  61221. else {
  61222. coordDimsInfos =[{
  61223. name: 'value',
  61224. type: 'float'
  61225. }];
  61226. areaData = new List(coordDimsInfos, maModel);
  61227. }
  61228. var optData = zrUtil.map(maModel.get('data'), zrUtil.curry(
  61229. markAreaTransform, seriesModel, coordSys, maModel
  61230. ));
  61231. if (coordSys) {
  61232. optData = zrUtil.filter(
  61233. optData, zrUtil.curry(markAreaFilter, coordSys)
  61234. );
  61235. }
  61236. var dimValueGetter = coordSys ? function (item, dimName, dataIndex, dimIndex) {
  61237. return item.coord[Math.floor(dimIndex / 2)][dimIndex % 2];
  61238. } : function (item) {
  61239. return item.value;
  61240. };
  61241. areaData.initData(optData, null, dimValueGetter);
  61242. areaData.hasItemOption = true;
  61243. return areaData;
  61244. }
  61245. /***/ }),
  61246. /* 411 */
  61247. /***/ (function(module, exports, __webpack_require__) {
  61248. /**
  61249. * DataZoom component entry
  61250. */
  61251. var echarts = __webpack_require__(1);
  61252. echarts.registerPreprocessor(__webpack_require__(412));
  61253. __webpack_require__(413);
  61254. __webpack_require__(414);
  61255. __webpack_require__(415);
  61256. __webpack_require__(417);
  61257. /***/ }),
  61258. /* 412 */
  61259. /***/ (function(module, exports, __webpack_require__) {
  61260. /**
  61261. * @file Timeline preprocessor
  61262. */
  61263. var zrUtil = __webpack_require__(4);
  61264. module.exports = function (option) {
  61265. var timelineOpt = option && option.timeline;
  61266. if (!zrUtil.isArray(timelineOpt)) {
  61267. timelineOpt = timelineOpt ? [timelineOpt] : [];
  61268. }
  61269. zrUtil.each(timelineOpt, function (opt) {
  61270. if (!opt) {
  61271. return;
  61272. }
  61273. compatibleEC2(opt);
  61274. });
  61275. };
  61276. function compatibleEC2(opt) {
  61277. var type = opt.type;
  61278. var ec2Types = {'number': 'value', 'time': 'time'};
  61279. // Compatible with ec2
  61280. if (ec2Types[type]) {
  61281. opt.axisType = ec2Types[type];
  61282. delete opt.type;
  61283. }
  61284. transferItem(opt);
  61285. if (has(opt, 'controlPosition')) {
  61286. var controlStyle = opt.controlStyle || (opt.controlStyle = {});
  61287. if (!has(controlStyle, 'position')) {
  61288. controlStyle.position = opt.controlPosition;
  61289. }
  61290. if (controlStyle.position === 'none' && !has(controlStyle, 'show')) {
  61291. controlStyle.show = false;
  61292. delete controlStyle.position;
  61293. }
  61294. delete opt.controlPosition;
  61295. }
  61296. zrUtil.each(opt.data || [], function (dataItem) {
  61297. if (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) {
  61298. if (!has(dataItem, 'value') && has(dataItem, 'name')) {
  61299. // In ec2, using name as value.
  61300. dataItem.value = dataItem.name;
  61301. }
  61302. transferItem(dataItem);
  61303. }
  61304. });
  61305. }
  61306. function transferItem(opt) {
  61307. var itemStyle = opt.itemStyle || (opt.itemStyle = {});
  61308. var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {});
  61309. // Transfer label out
  61310. var label = opt.label || (opt.label || {});
  61311. var labelNormal = label.normal || (label.normal = {});
  61312. var excludeLabelAttr = {normal: 1, emphasis: 1};
  61313. zrUtil.each(label, function (value, name) {
  61314. if (!excludeLabelAttr[name] && !has(labelNormal, name)) {
  61315. labelNormal[name] = value;
  61316. }
  61317. });
  61318. if (itemStyleEmphasis.label && !has(label, 'emphasis')) {
  61319. label.emphasis = itemStyleEmphasis.label;
  61320. delete itemStyleEmphasis.label;
  61321. }
  61322. }
  61323. function has(obj, attr) {
  61324. return obj.hasOwnProperty(attr);
  61325. }
  61326. /***/ }),
  61327. /* 413 */
  61328. /***/ (function(module, exports, __webpack_require__) {
  61329. __webpack_require__(72).registerSubTypeDefaulter('timeline', function () {
  61330. // Only slider now.
  61331. return 'slider';
  61332. });
  61333. /***/ }),
  61334. /* 414 */
  61335. /***/ (function(module, exports, __webpack_require__) {
  61336. /**
  61337. * @file Timeilne action
  61338. */
  61339. var echarts = __webpack_require__(1);
  61340. var zrUtil = __webpack_require__(4);
  61341. echarts.registerAction(
  61342. {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'},
  61343. function (payload, ecModel) {
  61344. var timelineModel = ecModel.getComponent('timeline');
  61345. if (timelineModel && payload.currentIndex != null) {
  61346. timelineModel.setCurrentIndex(payload.currentIndex);
  61347. if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) {
  61348. timelineModel.setPlayState(false);
  61349. }
  61350. }
  61351. // Set normalized currentIndex to payload.
  61352. ecModel.resetOption('timeline');
  61353. return zrUtil.defaults({
  61354. currentIndex: timelineModel.option.currentIndex
  61355. }, payload);
  61356. }
  61357. );
  61358. echarts.registerAction(
  61359. {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'},
  61360. function (payload, ecModel) {
  61361. var timelineModel = ecModel.getComponent('timeline');
  61362. if (timelineModel && payload.playState != null) {
  61363. timelineModel.setPlayState(payload.playState);
  61364. }
  61365. }
  61366. );
  61367. /***/ }),
  61368. /* 415 */
  61369. /***/ (function(module, exports, __webpack_require__) {
  61370. /**
  61371. * @file Silder timeline model
  61372. */
  61373. var TimelineModel = __webpack_require__(416);
  61374. var zrUtil = __webpack_require__(4);
  61375. var modelUtil = __webpack_require__(5);
  61376. var SliderTimelineModel = TimelineModel.extend({
  61377. type: 'timeline.slider',
  61378. /**
  61379. * @protected
  61380. */
  61381. defaultOption: {
  61382. backgroundColor: 'rgba(0,0,0,0)', // 时间轴背景颜色
  61383. borderColor: '#ccc', // 时间轴边框颜色
  61384. borderWidth: 0, // 时间轴边框线宽,单位px,默认为0(无边框)
  61385. orient: 'horizontal', // 'vertical'
  61386. inverse: false,
  61387. tooltip: { // boolean or Object
  61388. trigger: 'item' // data item may also have tootip attr.
  61389. },
  61390. symbol: 'emptyCircle',
  61391. symbolSize: 10,
  61392. lineStyle: {
  61393. show: true,
  61394. width: 2,
  61395. color: '#304654'
  61396. },
  61397. label: { // 文本标签
  61398. position: 'auto', // auto left right top bottom
  61399. // When using number, label position is not
  61400. // restricted by viewRect.
  61401. // positive: right/bottom, negative: left/top
  61402. normal: {
  61403. show: true,
  61404. interval: 'auto',
  61405. rotate: 0,
  61406. // formatter: null,
  61407. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  61408. color: '#304654'
  61409. },
  61410. emphasis: {
  61411. show: true,
  61412. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  61413. color: '#c23531'
  61414. }
  61415. },
  61416. itemStyle: {
  61417. normal: {
  61418. color: '#304654',
  61419. borderWidth: 1
  61420. },
  61421. emphasis: {
  61422. color: '#c23531'
  61423. }
  61424. },
  61425. checkpointStyle: {
  61426. symbol: 'circle',
  61427. symbolSize: 13,
  61428. color: '#c23531',
  61429. borderWidth: 5,
  61430. borderColor: 'rgba(194,53,49, 0.5)',
  61431. animation: true,
  61432. animationDuration: 300,
  61433. animationEasing: 'quinticInOut'
  61434. },
  61435. controlStyle: {
  61436. show: true,
  61437. showPlayBtn: true,
  61438. showPrevBtn: true,
  61439. showNextBtn: true,
  61440. itemSize: 22,
  61441. itemGap: 12,
  61442. position: 'left', // 'left' 'right' 'top' 'bottom'
  61443. 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
  61444. 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
  61445. 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
  61446. 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
  61447. normal: {
  61448. color: '#304654',
  61449. borderColor: '#304654',
  61450. borderWidth: 1
  61451. },
  61452. emphasis: {
  61453. color: '#c23531',
  61454. borderColor: '#c23531',
  61455. borderWidth: 2
  61456. }
  61457. },
  61458. data: []
  61459. }
  61460. });
  61461. zrUtil.mixin(SliderTimelineModel, modelUtil.dataFormatMixin);
  61462. module.exports = SliderTimelineModel;
  61463. /***/ }),
  61464. /* 416 */
  61465. /***/ (function(module, exports, __webpack_require__) {
  61466. /**
  61467. * @file Timeline model
  61468. */
  61469. var ComponentModel = __webpack_require__(72);
  61470. var List = __webpack_require__(101);
  61471. var zrUtil = __webpack_require__(4);
  61472. var modelUtil = __webpack_require__(5);
  61473. var TimelineModel = ComponentModel.extend({
  61474. type: 'timeline',
  61475. layoutMode: 'box',
  61476. /**
  61477. * @protected
  61478. */
  61479. defaultOption: {
  61480. zlevel: 0, // 一级层叠
  61481. z: 4, // 二级层叠
  61482. show: true,
  61483. axisType: 'time', // 模式是时间类型,支持 value, category
  61484. realtime: true,
  61485. left: '20%',
  61486. top: null,
  61487. right: '20%',
  61488. bottom: 0,
  61489. width: null,
  61490. height: 40,
  61491. padding: 5,
  61492. controlPosition: 'left', // 'left' 'right' 'top' 'bottom' 'none'
  61493. autoPlay: false,
  61494. rewind: false, // 反向播放
  61495. loop: true,
  61496. playInterval: 2000, // 播放时间间隔,单位ms
  61497. currentIndex: 0,
  61498. itemStyle: {
  61499. normal: {},
  61500. emphasis: {}
  61501. },
  61502. label: {
  61503. normal: {
  61504. color: '#000'
  61505. },
  61506. emphasis: {}
  61507. },
  61508. data: []
  61509. },
  61510. /**
  61511. * @override
  61512. */
  61513. init: function (option, parentModel, ecModel) {
  61514. /**
  61515. * @private
  61516. * @type {module:echarts/data/List}
  61517. */
  61518. this._data;
  61519. /**
  61520. * @private
  61521. * @type {Array.<string>}
  61522. */
  61523. this._names;
  61524. this.mergeDefaultAndTheme(option, ecModel);
  61525. this._initData();
  61526. },
  61527. /**
  61528. * @override
  61529. */
  61530. mergeOption: function (option) {
  61531. TimelineModel.superApply(this, 'mergeOption', arguments);
  61532. this._initData();
  61533. },
  61534. /**
  61535. * @param {number} [currentIndex]
  61536. */
  61537. setCurrentIndex: function (currentIndex) {
  61538. if (currentIndex == null) {
  61539. currentIndex = this.option.currentIndex;
  61540. }
  61541. var count = this._data.count();
  61542. if (this.option.loop) {
  61543. currentIndex = (currentIndex % count + count) % count;
  61544. }
  61545. else {
  61546. currentIndex >= count && (currentIndex = count - 1);
  61547. currentIndex < 0 && (currentIndex = 0);
  61548. }
  61549. this.option.currentIndex = currentIndex;
  61550. },
  61551. /**
  61552. * @return {number} currentIndex
  61553. */
  61554. getCurrentIndex: function () {
  61555. return this.option.currentIndex;
  61556. },
  61557. /**
  61558. * @return {boolean}
  61559. */
  61560. isIndexMax: function () {
  61561. return this.getCurrentIndex() >= this._data.count() - 1;
  61562. },
  61563. /**
  61564. * @param {boolean} state true: play, false: stop
  61565. */
  61566. setPlayState: function (state) {
  61567. this.option.autoPlay = !!state;
  61568. },
  61569. /**
  61570. * @return {boolean} true: play, false: stop
  61571. */
  61572. getPlayState: function () {
  61573. return !!this.option.autoPlay;
  61574. },
  61575. /**
  61576. * @private
  61577. */
  61578. _initData: function () {
  61579. var thisOption = this.option;
  61580. var dataArr = thisOption.data || [];
  61581. var axisType = thisOption.axisType;
  61582. var names = this._names = [];
  61583. if (axisType === 'category') {
  61584. var idxArr = [];
  61585. zrUtil.each(dataArr, function (item, index) {
  61586. var value = modelUtil.getDataItemValue(item);
  61587. var newItem;
  61588. if (zrUtil.isObject(item)) {
  61589. newItem = zrUtil.clone(item);
  61590. newItem.value = index;
  61591. }
  61592. else {
  61593. newItem = index;
  61594. }
  61595. idxArr.push(newItem);
  61596. if (!zrUtil.isString(value) && (value == null || isNaN(value))) {
  61597. value = '';
  61598. }
  61599. names.push(value + '');
  61600. });
  61601. dataArr = idxArr;
  61602. }
  61603. var dimType = ({category: 'ordinal', time: 'time'})[axisType] || 'number';
  61604. var data = this._data = new List([{name: 'value', type: dimType}], this);
  61605. data.initData(dataArr, names);
  61606. },
  61607. getData: function () {
  61608. return this._data;
  61609. },
  61610. /**
  61611. * @public
  61612. * @return {Array.<string>} categoreis
  61613. */
  61614. getCategories: function () {
  61615. if (this.get('axisType') === 'category') {
  61616. return this._names.slice();
  61617. }
  61618. }
  61619. });
  61620. module.exports = TimelineModel;
  61621. /***/ }),
  61622. /* 417 */
  61623. /***/ (function(module, exports, __webpack_require__) {
  61624. /**
  61625. * @file Silder timeline view
  61626. */
  61627. var zrUtil = __webpack_require__(4);
  61628. var graphic = __webpack_require__(20);
  61629. var layout = __webpack_require__(74);
  61630. var TimelineView = __webpack_require__(418);
  61631. var TimelineAxis = __webpack_require__(419);
  61632. var symbolUtil = __webpack_require__(114);
  61633. var axisHelper = __webpack_require__(104);
  61634. var BoundingRect = __webpack_require__(9);
  61635. var matrix = __webpack_require__(11);
  61636. var numberUtil = __webpack_require__(7);
  61637. var formatUtil = __webpack_require__(6);
  61638. var encodeHTML = formatUtil.encodeHTML;
  61639. var bind = zrUtil.bind;
  61640. var each = zrUtil.each;
  61641. var PI = Math.PI;
  61642. module.exports = TimelineView.extend({
  61643. type: 'timeline.slider',
  61644. init: function (ecModel, api) {
  61645. this.api = api;
  61646. /**
  61647. * @private
  61648. * @type {module:echarts/component/timeline/TimelineAxis}
  61649. */
  61650. this._axis;
  61651. /**
  61652. * @private
  61653. * @type {module:zrender/core/BoundingRect}
  61654. */
  61655. this._viewRect;
  61656. /**
  61657. * @type {number}
  61658. */
  61659. this._timer;
  61660. /**
  61661. * @type {module:zrender/Element}
  61662. */
  61663. this._currentPointer;
  61664. /**
  61665. * @type {module:zrender/container/Group}
  61666. */
  61667. this._mainGroup;
  61668. /**
  61669. * @type {module:zrender/container/Group}
  61670. */
  61671. this._labelGroup;
  61672. },
  61673. /**
  61674. * @override
  61675. */
  61676. render: function (timelineModel, ecModel, api, payload) {
  61677. this.model = timelineModel;
  61678. this.api = api;
  61679. this.ecModel = ecModel;
  61680. this.group.removeAll();
  61681. if (timelineModel.get('show', true)) {
  61682. var layoutInfo = this._layout(timelineModel, api);
  61683. var mainGroup = this._createGroup('mainGroup');
  61684. var labelGroup = this._createGroup('labelGroup');
  61685. /**
  61686. * @private
  61687. * @type {module:echarts/component/timeline/TimelineAxis}
  61688. */
  61689. var axis = this._axis = this._createAxis(layoutInfo, timelineModel);
  61690. timelineModel.formatTooltip = function (dataIndex) {
  61691. return encodeHTML(axis.scale.getLabel(dataIndex));
  61692. };
  61693. each(
  61694. ['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'],
  61695. function (name) {
  61696. this['_render' + name](layoutInfo, mainGroup, axis, timelineModel);
  61697. },
  61698. this
  61699. );
  61700. this._renderAxisLabel(layoutInfo, labelGroup, axis, timelineModel);
  61701. this._position(layoutInfo, timelineModel);
  61702. }
  61703. this._doPlayStop();
  61704. },
  61705. /**
  61706. * @override
  61707. */
  61708. remove: function () {
  61709. this._clearTimer();
  61710. this.group.removeAll();
  61711. },
  61712. /**
  61713. * @override
  61714. */
  61715. dispose: function () {
  61716. this._clearTimer();
  61717. },
  61718. _layout: function (timelineModel, api) {
  61719. var labelPosOpt = timelineModel.get('label.normal.position');
  61720. var orient = timelineModel.get('orient');
  61721. var viewRect = getViewRect(timelineModel, api);
  61722. // Auto label offset.
  61723. if (labelPosOpt == null || labelPosOpt === 'auto') {
  61724. labelPosOpt = orient === 'horizontal'
  61725. ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+')
  61726. : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-');
  61727. }
  61728. else if (isNaN(labelPosOpt)) {
  61729. labelPosOpt = ({
  61730. horizontal: {top: '-', bottom: '+'},
  61731. vertical: {left: '-', right: '+'}
  61732. })[orient][labelPosOpt];
  61733. }
  61734. var labelAlignMap = {
  61735. horizontal: 'center',
  61736. vertical: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'left' : 'right'
  61737. };
  61738. var labelBaselineMap = {
  61739. horizontal: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'top' : 'bottom',
  61740. vertical: 'middle'
  61741. };
  61742. var rotationMap = {
  61743. horizontal: 0,
  61744. vertical: PI / 2
  61745. };
  61746. // Position
  61747. var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width;
  61748. var controlModel = timelineModel.getModel('controlStyle');
  61749. var showControl = controlModel.get('show');
  61750. var controlSize = showControl ? controlModel.get('itemSize') : 0;
  61751. var controlGap = showControl ? controlModel.get('itemGap') : 0;
  61752. var sizePlusGap = controlSize + controlGap;
  61753. // Special label rotate.
  61754. var labelRotation = timelineModel.get('label.normal.rotate') || 0;
  61755. labelRotation = labelRotation * PI / 180; // To radian.
  61756. var playPosition;
  61757. var prevBtnPosition;
  61758. var nextBtnPosition;
  61759. var axisExtent;
  61760. var controlPosition = controlModel.get('position', true);
  61761. var showControl = controlModel.get('show', true);
  61762. var showPlayBtn = showControl && controlModel.get('showPlayBtn', true);
  61763. var showPrevBtn = showControl && controlModel.get('showPrevBtn', true);
  61764. var showNextBtn = showControl && controlModel.get('showNextBtn', true);
  61765. var xLeft = 0;
  61766. var xRight = mainLength;
  61767. // position[0] means left, position[1] means middle.
  61768. if (controlPosition === 'left' || controlPosition === 'bottom') {
  61769. showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap);
  61770. showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap);
  61771. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  61772. }
  61773. else { // 'top' 'right'
  61774. showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  61775. showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap);
  61776. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  61777. }
  61778. axisExtent = [xLeft, xRight];
  61779. if (timelineModel.get('inverse')) {
  61780. axisExtent.reverse();
  61781. }
  61782. return {
  61783. viewRect: viewRect,
  61784. mainLength: mainLength,
  61785. orient: orient,
  61786. rotation: rotationMap[orient],
  61787. labelRotation: labelRotation,
  61788. labelPosOpt: labelPosOpt,
  61789. labelAlign: timelineModel.get('label.normal.align') || labelAlignMap[orient],
  61790. labelBaseline: timelineModel.get('label.normal.verticalAlign')
  61791. || timelineModel.get('label.normal.baseline')
  61792. || labelBaselineMap[orient],
  61793. // Based on mainGroup.
  61794. playPosition: playPosition,
  61795. prevBtnPosition: prevBtnPosition,
  61796. nextBtnPosition: nextBtnPosition,
  61797. axisExtent: axisExtent,
  61798. controlSize: controlSize,
  61799. controlGap: controlGap
  61800. };
  61801. },
  61802. _position: function (layoutInfo, timelineModel) {
  61803. // Position is be called finally, because bounding rect is needed for
  61804. // adapt content to fill viewRect (auto adapt offset).
  61805. // Timeline may be not all in the viewRect when 'offset' is specified
  61806. // as a number, because it is more appropriate that label aligns at
  61807. // 'offset' but not the other edge defined by viewRect.
  61808. var mainGroup = this._mainGroup;
  61809. var labelGroup = this._labelGroup;
  61810. var viewRect = layoutInfo.viewRect;
  61811. if (layoutInfo.orient === 'vertical') {
  61812. // transfrom to horizontal, inverse rotate by left-top point.
  61813. var m = matrix.create();
  61814. var rotateOriginX = viewRect.x;
  61815. var rotateOriginY = viewRect.y + viewRect.height;
  61816. matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]);
  61817. matrix.rotate(m, m, -PI / 2);
  61818. matrix.translate(m, m, [rotateOriginX, rotateOriginY]);
  61819. viewRect = viewRect.clone();
  61820. viewRect.applyTransform(m);
  61821. }
  61822. var viewBound = getBound(viewRect);
  61823. var mainBound = getBound(mainGroup.getBoundingRect());
  61824. var labelBound = getBound(labelGroup.getBoundingRect());
  61825. var mainPosition = mainGroup.position;
  61826. var labelsPosition = labelGroup.position;
  61827. labelsPosition[0] = mainPosition[0] = viewBound[0][0];
  61828. var labelPosOpt = layoutInfo.labelPosOpt;
  61829. if (isNaN(labelPosOpt)) { // '+' or '-'
  61830. var mainBoundIdx = labelPosOpt === '+' ? 0 : 1;
  61831. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  61832. toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx);
  61833. }
  61834. else {
  61835. var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1;
  61836. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  61837. labelsPosition[1] = mainPosition[1] + labelPosOpt;
  61838. }
  61839. mainGroup.attr('position', mainPosition);
  61840. labelGroup.attr('position', labelsPosition);
  61841. mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation;
  61842. setOrigin(mainGroup);
  61843. setOrigin(labelGroup);
  61844. function setOrigin(targetGroup) {
  61845. var pos = targetGroup.position;
  61846. targetGroup.origin = [
  61847. viewBound[0][0] - pos[0],
  61848. viewBound[1][0] - pos[1]
  61849. ];
  61850. }
  61851. function getBound(rect) {
  61852. // [[xmin, xmax], [ymin, ymax]]
  61853. return [
  61854. [rect.x, rect.x + rect.width],
  61855. [rect.y, rect.y + rect.height]
  61856. ];
  61857. }
  61858. function toBound(fromPos, from, to, dimIdx, boundIdx) {
  61859. fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx];
  61860. }
  61861. },
  61862. _createAxis: function (layoutInfo, timelineModel) {
  61863. var data = timelineModel.getData();
  61864. var axisType = timelineModel.get('axisType');
  61865. var scale = axisHelper.createScaleByModel(timelineModel, axisType);
  61866. var dataExtent = data.getDataExtent('value');
  61867. scale.setExtent(dataExtent[0], dataExtent[1]);
  61868. this._customizeScale(scale, data);
  61869. scale.niceTicks();
  61870. var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType);
  61871. axis.model = timelineModel;
  61872. return axis;
  61873. },
  61874. _customizeScale: function (scale, data) {
  61875. scale.getTicks = function () {
  61876. return data.mapArray(['value'], function (value) {
  61877. return value;
  61878. });
  61879. };
  61880. scale.getTicksLabels = function () {
  61881. return zrUtil.map(this.getTicks(), scale.getLabel, scale);
  61882. };
  61883. },
  61884. _createGroup: function (name) {
  61885. var newGroup = this['_' + name] = new graphic.Group();
  61886. this.group.add(newGroup);
  61887. return newGroup;
  61888. },
  61889. _renderAxisLine: function (layoutInfo, group, axis, timelineModel) {
  61890. var axisExtent = axis.getExtent();
  61891. if (!timelineModel.get('lineStyle.show')) {
  61892. return;
  61893. }
  61894. group.add(new graphic.Line({
  61895. shape: {
  61896. x1: axisExtent[0], y1: 0,
  61897. x2: axisExtent[1], y2: 0
  61898. },
  61899. style: zrUtil.extend(
  61900. {lineCap: 'round'},
  61901. timelineModel.getModel('lineStyle').getLineStyle()
  61902. ),
  61903. silent: true,
  61904. z2: 1
  61905. }));
  61906. },
  61907. /**
  61908. * @private
  61909. */
  61910. _renderAxisTick: function (layoutInfo, group, axis, timelineModel) {
  61911. var data = timelineModel.getData();
  61912. var ticks = axis.scale.getTicks();
  61913. each(ticks, function (value, dataIndex) {
  61914. var tickCoord = axis.dataToCoord(value);
  61915. var itemModel = data.getItemModel(dataIndex);
  61916. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  61917. var hoverStyleModel = itemModel.getModel('itemStyle.emphasis');
  61918. var symbolOpt = {
  61919. position: [tickCoord, 0],
  61920. onclick: bind(this._changeTimeline, this, dataIndex)
  61921. };
  61922. var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt);
  61923. graphic.setHoverStyle(el, hoverStyleModel.getItemStyle());
  61924. if (itemModel.get('tooltip')) {
  61925. el.dataIndex = dataIndex;
  61926. el.dataModel = timelineModel;
  61927. }
  61928. else {
  61929. el.dataIndex = el.dataModel = null;
  61930. }
  61931. }, this);
  61932. },
  61933. /**
  61934. * @private
  61935. */
  61936. _renderAxisLabel: function (layoutInfo, group, axis, timelineModel) {
  61937. var labelModel = timelineModel.getModel('label.normal');
  61938. if (!labelModel.get('show')) {
  61939. return;
  61940. }
  61941. var data = timelineModel.getData();
  61942. var ticks = axis.scale.getTicks();
  61943. var labels = axisHelper.getFormattedLabels(
  61944. axis, labelModel.get('formatter')
  61945. );
  61946. var labelInterval = axis.getLabelInterval();
  61947. each(ticks, function (tick, dataIndex) {
  61948. if (axis.isLabelIgnored(dataIndex, labelInterval)) {
  61949. return;
  61950. }
  61951. var itemModel = data.getItemModel(dataIndex);
  61952. var normalLabelModel = itemModel.getModel('label.normal');
  61953. var hoverLabelModel = itemModel.getModel('label.emphasis');
  61954. var tickCoord = axis.dataToCoord(tick);
  61955. var textEl = new graphic.Text({
  61956. position: [tickCoord, 0],
  61957. rotation: layoutInfo.labelRotation - layoutInfo.rotation,
  61958. onclick: bind(this._changeTimeline, this, dataIndex),
  61959. silent: false
  61960. });
  61961. graphic.setTextStyle(textEl.style, normalLabelModel, {
  61962. text: labels[dataIndex],
  61963. textAlign: layoutInfo.labelAlign,
  61964. textVerticalAlign: layoutInfo.labelBaseline
  61965. });
  61966. group.add(textEl);
  61967. graphic.setHoverStyle(
  61968. textEl, graphic.setTextStyle({}, hoverLabelModel)
  61969. );
  61970. }, this);
  61971. },
  61972. /**
  61973. * @private
  61974. */
  61975. _renderControl: function (layoutInfo, group, axis, timelineModel) {
  61976. var controlSize = layoutInfo.controlSize;
  61977. var rotation = layoutInfo.rotation;
  61978. var itemStyle = timelineModel.getModel('controlStyle.normal').getItemStyle();
  61979. var hoverStyle = timelineModel.getModel('controlStyle.emphasis').getItemStyle();
  61980. var rect = [0, -controlSize / 2, controlSize, controlSize];
  61981. var playState = timelineModel.getPlayState();
  61982. var inverse = timelineModel.get('inverse', true);
  61983. makeBtn(
  61984. layoutInfo.nextBtnPosition,
  61985. 'controlStyle.nextIcon',
  61986. bind(this._changeTimeline, this, inverse ? '-' : '+')
  61987. );
  61988. makeBtn(
  61989. layoutInfo.prevBtnPosition,
  61990. 'controlStyle.prevIcon',
  61991. bind(this._changeTimeline, this, inverse ? '+' : '-')
  61992. );
  61993. makeBtn(
  61994. layoutInfo.playPosition,
  61995. 'controlStyle.' + (playState ? 'stopIcon' : 'playIcon'),
  61996. bind(this._handlePlayClick, this, !playState),
  61997. true
  61998. );
  61999. function makeBtn(position, iconPath, onclick, willRotate) {
  62000. if (!position) {
  62001. return;
  62002. }
  62003. var opt = {
  62004. position: position,
  62005. origin: [controlSize / 2, 0],
  62006. rotation: willRotate ? -rotation : 0,
  62007. rectHover: true,
  62008. style: itemStyle,
  62009. onclick: onclick
  62010. };
  62011. var btn = makeIcon(timelineModel, iconPath, rect, opt);
  62012. group.add(btn);
  62013. graphic.setHoverStyle(btn, hoverStyle);
  62014. }
  62015. },
  62016. _renderCurrentPointer: function (layoutInfo, group, axis, timelineModel) {
  62017. var data = timelineModel.getData();
  62018. var currentIndex = timelineModel.getCurrentIndex();
  62019. var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle');
  62020. var me = this;
  62021. var callback = {
  62022. onCreate: function (pointer) {
  62023. pointer.draggable = true;
  62024. pointer.drift = bind(me._handlePointerDrag, me);
  62025. pointer.ondragend = bind(me._handlePointerDragend, me);
  62026. pointerMoveTo(pointer, currentIndex, axis, timelineModel, true);
  62027. },
  62028. onUpdate: function (pointer) {
  62029. pointerMoveTo(pointer, currentIndex, axis, timelineModel);
  62030. }
  62031. };
  62032. // Reuse when exists, for animation and drag.
  62033. this._currentPointer = giveSymbol(
  62034. pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback
  62035. );
  62036. },
  62037. _handlePlayClick: function (nextState) {
  62038. this._clearTimer();
  62039. this.api.dispatchAction({
  62040. type: 'timelinePlayChange',
  62041. playState: nextState,
  62042. from: this.uid
  62043. });
  62044. },
  62045. _handlePointerDrag: function (dx, dy, e) {
  62046. this._clearTimer();
  62047. this._pointerChangeTimeline([e.offsetX, e.offsetY]);
  62048. },
  62049. _handlePointerDragend: function (e) {
  62050. this._pointerChangeTimeline([e.offsetX, e.offsetY], true);
  62051. },
  62052. _pointerChangeTimeline: function (mousePos, trigger) {
  62053. var toCoord = this._toAxisCoord(mousePos)[0];
  62054. var axis = this._axis;
  62055. var axisExtent = numberUtil.asc(axis.getExtent().slice());
  62056. toCoord > axisExtent[1] && (toCoord = axisExtent[1]);
  62057. toCoord < axisExtent[0] && (toCoord = axisExtent[0]);
  62058. this._currentPointer.position[0] = toCoord;
  62059. this._currentPointer.dirty();
  62060. var targetDataIndex = this._findNearestTick(toCoord);
  62061. var timelineModel = this.model;
  62062. if (trigger || (
  62063. targetDataIndex !== timelineModel.getCurrentIndex()
  62064. && timelineModel.get('realtime')
  62065. )) {
  62066. this._changeTimeline(targetDataIndex);
  62067. }
  62068. },
  62069. _doPlayStop: function () {
  62070. this._clearTimer();
  62071. if (this.model.getPlayState()) {
  62072. this._timer = setTimeout(
  62073. bind(handleFrame, this),
  62074. this.model.get('playInterval')
  62075. );
  62076. }
  62077. function handleFrame() {
  62078. // Do not cache
  62079. var timelineModel = this.model;
  62080. this._changeTimeline(
  62081. timelineModel.getCurrentIndex()
  62082. + (timelineModel.get('rewind', true) ? -1 : 1)
  62083. );
  62084. }
  62085. },
  62086. _toAxisCoord: function (vertex) {
  62087. var trans = this._mainGroup.getLocalTransform();
  62088. return graphic.applyTransform(vertex, trans, true);
  62089. },
  62090. _findNearestTick: function (axisCoord) {
  62091. var data = this.model.getData();
  62092. var dist = Infinity;
  62093. var targetDataIndex;
  62094. var axis = this._axis;
  62095. data.each(['value'], function (value, dataIndex) {
  62096. var coord = axis.dataToCoord(value);
  62097. var d = Math.abs(coord - axisCoord);
  62098. if (d < dist) {
  62099. dist = d;
  62100. targetDataIndex = dataIndex;
  62101. }
  62102. });
  62103. return targetDataIndex;
  62104. },
  62105. _clearTimer: function () {
  62106. if (this._timer) {
  62107. clearTimeout(this._timer);
  62108. this._timer = null;
  62109. }
  62110. },
  62111. _changeTimeline: function (nextIndex) {
  62112. var currentIndex = this.model.getCurrentIndex();
  62113. if (nextIndex === '+') {
  62114. nextIndex = currentIndex + 1;
  62115. }
  62116. else if (nextIndex === '-') {
  62117. nextIndex = currentIndex - 1;
  62118. }
  62119. this.api.dispatchAction({
  62120. type: 'timelineChange',
  62121. currentIndex: nextIndex,
  62122. from: this.uid
  62123. });
  62124. }
  62125. });
  62126. function getViewRect(model, api) {
  62127. return layout.getLayoutRect(
  62128. model.getBoxLayoutParams(),
  62129. {
  62130. width: api.getWidth(),
  62131. height: api.getHeight()
  62132. },
  62133. model.get('padding')
  62134. );
  62135. }
  62136. function makeIcon(timelineModel, objPath, rect, opts) {
  62137. var icon = graphic.makePath(
  62138. timelineModel.get(objPath).replace(/^path:\/\//, ''),
  62139. zrUtil.clone(opts || {}),
  62140. new BoundingRect(rect[0], rect[1], rect[2], rect[3]),
  62141. 'center'
  62142. );
  62143. return icon;
  62144. }
  62145. /**
  62146. * Create symbol or update symbol
  62147. * opt: basic position and event handlers
  62148. */
  62149. function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
  62150. var color = itemStyleModel.get('color');
  62151. if (!symbol) {
  62152. var symbolType = hostModel.get('symbol');
  62153. symbol = symbolUtil.createSymbol(symbolType, -1, -1, 2, 2, color);
  62154. symbol.setStyle('strokeNoScale', true);
  62155. group.add(symbol);
  62156. callback && callback.onCreate(symbol);
  62157. }
  62158. else {
  62159. symbol.setColor(color);
  62160. group.add(symbol); // Group may be new, also need to add.
  62161. callback && callback.onUpdate(symbol);
  62162. }
  62163. // Style
  62164. var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']);
  62165. symbol.setStyle(itemStyle);
  62166. // Transform and events.
  62167. opt = zrUtil.merge({
  62168. rectHover: true,
  62169. z2: 100
  62170. }, opt, true);
  62171. var symbolSize = hostModel.get('symbolSize');
  62172. symbolSize = symbolSize instanceof Array
  62173. ? symbolSize.slice()
  62174. : [+symbolSize, +symbolSize];
  62175. symbolSize[0] /= 2;
  62176. symbolSize[1] /= 2;
  62177. opt.scale = symbolSize;
  62178. var symbolOffset = hostModel.get('symbolOffset');
  62179. if (symbolOffset) {
  62180. var pos = opt.position = opt.position || [0, 0];
  62181. pos[0] += numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  62182. pos[1] += numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  62183. }
  62184. var symbolRotate = hostModel.get('symbolRotate');
  62185. opt.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  62186. symbol.attr(opt);
  62187. // FIXME
  62188. // (1) When symbol.style.strokeNoScale is true and updateTransform is not performed,
  62189. // getBoundingRect will return wrong result.
  62190. // (This is supposed to be resolved in zrender, but it is a little difficult to
  62191. // leverage performance and auto updateTransform)
  62192. // (2) All of ancesters of symbol do not scale, so we can just updateTransform symbol.
  62193. symbol.updateTransform();
  62194. return symbol;
  62195. }
  62196. function pointerMoveTo(pointer, dataIndex, axis, timelineModel, noAnimation) {
  62197. if (pointer.dragging) {
  62198. return;
  62199. }
  62200. var pointerModel = timelineModel.getModel('checkpointStyle');
  62201. var toCoord = axis.dataToCoord(timelineModel.getData().get(['value'], dataIndex));
  62202. if (noAnimation || !pointerModel.get('animation', true)) {
  62203. pointer.attr({position: [toCoord, 0]});
  62204. }
  62205. else {
  62206. pointer.stopAnimation(true);
  62207. pointer.animateTo(
  62208. {position: [toCoord, 0]},
  62209. pointerModel.get('animationDuration', true),
  62210. pointerModel.get('animationEasing', true)
  62211. );
  62212. }
  62213. }
  62214. /***/ }),
  62215. /* 418 */
  62216. /***/ (function(module, exports, __webpack_require__) {
  62217. /**
  62218. * @file Timeline view
  62219. */
  62220. // var zrUtil = require('zrender/lib/core/util');
  62221. // var graphic = require('../../util/graphic');
  62222. var ComponentView = __webpack_require__(84);
  62223. module.exports = ComponentView.extend({
  62224. type: 'timeline'
  62225. });
  62226. /***/ }),
  62227. /* 419 */
  62228. /***/ (function(module, exports, __webpack_require__) {
  62229. var zrUtil = __webpack_require__(4);
  62230. var Axis = __webpack_require__(103);
  62231. var axisHelper = __webpack_require__(104);
  62232. /**
  62233. * Extend axis 2d
  62234. * @constructor module:echarts/coord/cartesian/Axis2D
  62235. * @extends {module:echarts/coord/cartesian/Axis}
  62236. * @param {string} dim
  62237. * @param {*} scale
  62238. * @param {Array.<number>} coordExtent
  62239. * @param {string} axisType
  62240. * @param {string} position
  62241. */
  62242. var TimelineAxis = function (dim, scale, coordExtent, axisType) {
  62243. Axis.call(this, dim, scale, coordExtent);
  62244. /**
  62245. * Axis type
  62246. * - 'category'
  62247. * - 'value'
  62248. * - 'time'
  62249. * - 'log'
  62250. * @type {string}
  62251. */
  62252. this.type = axisType || 'value';
  62253. /**
  62254. * @private
  62255. * @type {number}
  62256. */
  62257. this._autoLabelInterval;
  62258. /**
  62259. * Axis model
  62260. * @param {module:echarts/component/TimelineModel}
  62261. */
  62262. this.model = null;
  62263. };
  62264. TimelineAxis.prototype = {
  62265. constructor: TimelineAxis,
  62266. /**
  62267. * @public
  62268. * @return {number}
  62269. */
  62270. getLabelInterval: function () {
  62271. var timelineModel = this.model;
  62272. var labelModel = timelineModel.getModel('label.normal');
  62273. var labelInterval = labelModel.get('interval');
  62274. if (labelInterval != null && labelInterval != 'auto') {
  62275. return labelInterval;
  62276. }
  62277. var labelInterval = this._autoLabelInterval;
  62278. if (!labelInterval) {
  62279. labelInterval = this._autoLabelInterval = axisHelper.getAxisLabelInterval(
  62280. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  62281. axisHelper.getFormattedLabels(this, labelModel.get('formatter')),
  62282. labelModel.getFont(),
  62283. timelineModel.get('orient') === 'horizontal'
  62284. );
  62285. }
  62286. return labelInterval;
  62287. },
  62288. /**
  62289. * If label is ignored.
  62290. * Automatically used when axis is category and label can not be all shown
  62291. * @public
  62292. * @param {number} idx
  62293. * @return {boolean}
  62294. */
  62295. isLabelIgnored: function (idx) {
  62296. if (this.type === 'category') {
  62297. var labelInterval = this.getLabelInterval();
  62298. return ((typeof labelInterval === 'function')
  62299. && !labelInterval(idx, this.scale.getLabel(idx)))
  62300. || idx % (labelInterval + 1);
  62301. }
  62302. }
  62303. };
  62304. zrUtil.inherits(TimelineAxis, Axis);
  62305. module.exports = TimelineAxis;
  62306. /***/ }),
  62307. /* 420 */
  62308. /***/ (function(module, exports, __webpack_require__) {
  62309. __webpack_require__(421);
  62310. __webpack_require__(422);
  62311. __webpack_require__(423);
  62312. __webpack_require__(424);
  62313. __webpack_require__(425);
  62314. __webpack_require__(426);
  62315. __webpack_require__(431);
  62316. /***/ }),
  62317. /* 421 */
  62318. /***/ (function(module, exports, __webpack_require__) {
  62319. var featureManager = __webpack_require__(364);
  62320. var zrUtil = __webpack_require__(4);
  62321. var ToolboxModel = __webpack_require__(1).extendComponentModel({
  62322. type: 'toolbox',
  62323. layoutMode: {
  62324. type: 'box',
  62325. ignoreSize: true
  62326. },
  62327. mergeDefaultAndTheme: function (option) {
  62328. ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments);
  62329. zrUtil.each(this.option.feature, function (featureOpt, featureName) {
  62330. var Feature = featureManager.get(featureName);
  62331. Feature && zrUtil.merge(featureOpt, Feature.defaultOption);
  62332. });
  62333. },
  62334. defaultOption: {
  62335. show: true,
  62336. z: 6,
  62337. zlevel: 0,
  62338. orient: 'horizontal',
  62339. left: 'right',
  62340. top: 'top',
  62341. // right
  62342. // bottom
  62343. backgroundColor: 'transparent',
  62344. borderColor: '#ccc',
  62345. borderRadius: 0,
  62346. borderWidth: 0,
  62347. padding: 5,
  62348. itemSize: 15,
  62349. itemGap: 8,
  62350. showTitle: true,
  62351. iconStyle: {
  62352. normal: {
  62353. borderColor: '#666',
  62354. color: 'none'
  62355. },
  62356. emphasis: {
  62357. borderColor: '#3E98C5'
  62358. }
  62359. }
  62360. // textStyle: {},
  62361. // feature
  62362. }
  62363. });
  62364. module.exports = ToolboxModel;
  62365. /***/ }),
  62366. /* 422 */
  62367. /***/ (function(module, exports, __webpack_require__) {
  62368. /* WEBPACK VAR INJECTION */(function(process) {
  62369. var featureManager = __webpack_require__(364);
  62370. var zrUtil = __webpack_require__(4);
  62371. var graphic = __webpack_require__(20);
  62372. var Model = __webpack_require__(14);
  62373. var DataDiffer = __webpack_require__(102);
  62374. var listComponentHelper = __webpack_require__(329);
  62375. var textContain = __webpack_require__(8);
  62376. module.exports = __webpack_require__(1).extendComponentView({
  62377. type: 'toolbox',
  62378. render: function (toolboxModel, ecModel, api, payload) {
  62379. var group = this.group;
  62380. group.removeAll();
  62381. if (!toolboxModel.get('show')) {
  62382. return;
  62383. }
  62384. var itemSize = +toolboxModel.get('itemSize');
  62385. var featureOpts = toolboxModel.get('feature') || {};
  62386. var features = this._features || (this._features = {});
  62387. var featureNames = [];
  62388. zrUtil.each(featureOpts, function (opt, name) {
  62389. featureNames.push(name);
  62390. });
  62391. (new DataDiffer(this._featureNames || [], featureNames))
  62392. .add(process)
  62393. .update(process)
  62394. .remove(zrUtil.curry(process, null))
  62395. .execute();
  62396. // Keep for diff.
  62397. this._featureNames = featureNames;
  62398. function process(newIndex, oldIndex) {
  62399. var featureName = featureNames[newIndex];
  62400. var oldName = featureNames[oldIndex];
  62401. var featureOpt = featureOpts[featureName];
  62402. var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
  62403. var feature;
  62404. if (featureName && !oldName) { // Create
  62405. if (isUserFeatureName(featureName)) {
  62406. feature = {
  62407. model: featureModel,
  62408. onclick: featureModel.option.onclick,
  62409. featureName: featureName
  62410. };
  62411. }
  62412. else {
  62413. var Feature = featureManager.get(featureName);
  62414. if (!Feature) {
  62415. return;
  62416. }
  62417. feature = new Feature(featureModel, ecModel, api);
  62418. }
  62419. features[featureName] = feature;
  62420. }
  62421. else {
  62422. feature = features[oldName];
  62423. // If feature does not exsit.
  62424. if (!feature) {
  62425. return;
  62426. }
  62427. feature.model = featureModel;
  62428. feature.ecModel = ecModel;
  62429. feature.api = api;
  62430. }
  62431. if (!featureName && oldName) {
  62432. feature.dispose && feature.dispose(ecModel, api);
  62433. return;
  62434. }
  62435. if (!featureModel.get('show') || feature.unusable) {
  62436. feature.remove && feature.remove(ecModel, api);
  62437. return;
  62438. }
  62439. createIconPaths(featureModel, feature, featureName);
  62440. featureModel.setIconStatus = function (iconName, status) {
  62441. var option = this.option;
  62442. var iconPaths = this.iconPaths;
  62443. option.iconStatus = option.iconStatus || {};
  62444. option.iconStatus[iconName] = status;
  62445. // FIXME
  62446. iconPaths[iconName] && iconPaths[iconName].trigger(status);
  62447. };
  62448. if (feature.render) {
  62449. feature.render(featureModel, ecModel, api, payload);
  62450. }
  62451. }
  62452. function createIconPaths(featureModel, feature, featureName) {
  62453. var iconStyleModel = featureModel.getModel('iconStyle');
  62454. // If one feature has mutiple icon. they are orginaized as
  62455. // {
  62456. // icon: {
  62457. // foo: '',
  62458. // bar: ''
  62459. // },
  62460. // title: {
  62461. // foo: '',
  62462. // bar: ''
  62463. // }
  62464. // }
  62465. var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon');
  62466. var titles = featureModel.get('title') || {};
  62467. if (typeof icons === 'string') {
  62468. var icon = icons;
  62469. var title = titles;
  62470. icons = {};
  62471. titles = {};
  62472. icons[featureName] = icon;
  62473. titles[featureName] = title;
  62474. }
  62475. var iconPaths = featureModel.iconPaths = {};
  62476. zrUtil.each(icons, function (iconStr, iconName) {
  62477. var path = graphic.createIcon(
  62478. iconStr,
  62479. {},
  62480. {
  62481. x: -itemSize / 2,
  62482. y: -itemSize / 2,
  62483. width: itemSize,
  62484. height: itemSize
  62485. }
  62486. );
  62487. path.setStyle(iconStyleModel.getModel('normal').getItemStyle());
  62488. path.hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  62489. graphic.setHoverStyle(path);
  62490. if (toolboxModel.get('showTitle')) {
  62491. path.__title = titles[iconName];
  62492. path.on('mouseover', function () {
  62493. // Should not reuse above hoverStyle, which might be modified.
  62494. var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  62495. path.setStyle({
  62496. text: titles[iconName],
  62497. textPosition: hoverStyle.textPosition || 'bottom',
  62498. textFill: hoverStyle.fill || hoverStyle.stroke || '#000',
  62499. textAlign: hoverStyle.textAlign || 'center'
  62500. });
  62501. })
  62502. .on('mouseout', function () {
  62503. path.setStyle({
  62504. textFill: null
  62505. });
  62506. });
  62507. }
  62508. path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal');
  62509. group.add(path);
  62510. path.on('click', zrUtil.bind(
  62511. feature.onclick, feature, ecModel, api, iconName
  62512. ));
  62513. iconPaths[iconName] = path;
  62514. });
  62515. }
  62516. listComponentHelper.layout(group, toolboxModel, api);
  62517. // Render background after group is layout
  62518. // FIXME
  62519. group.add(listComponentHelper.makeBackground(group.getBoundingRect(), toolboxModel));
  62520. // Adjust icon title positions to avoid them out of screen
  62521. group.eachChild(function (icon) {
  62522. var titleText = icon.__title;
  62523. var hoverStyle = icon.hoverStyle;
  62524. // May be background element
  62525. if (hoverStyle && titleText) {
  62526. var rect = textContain.getBoundingRect(
  62527. titleText, textContain.makeFont(hoverStyle)
  62528. );
  62529. var offsetX = icon.position[0] + group.position[0];
  62530. var offsetY = icon.position[1] + group.position[1] + itemSize;
  62531. var needPutOnTop = false;
  62532. if (offsetY + rect.height > api.getHeight()) {
  62533. hoverStyle.textPosition = 'top';
  62534. needPutOnTop = true;
  62535. }
  62536. var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8);
  62537. if (offsetX + rect.width / 2 > api.getWidth()) {
  62538. hoverStyle.textPosition = ['100%', topOffset];
  62539. hoverStyle.textAlign = 'right';
  62540. }
  62541. else if (offsetX - rect.width / 2 < 0) {
  62542. hoverStyle.textPosition = [0, topOffset];
  62543. hoverStyle.textAlign = 'left';
  62544. }
  62545. }
  62546. });
  62547. },
  62548. updateView: function (toolboxModel, ecModel, api, payload) {
  62549. zrUtil.each(this._features, function (feature) {
  62550. feature.updateView && feature.updateView(feature.model, ecModel, api, payload);
  62551. });
  62552. },
  62553. updateLayout: function (toolboxModel, ecModel, api, payload) {
  62554. zrUtil.each(this._features, function (feature) {
  62555. feature.updateLayout && feature.updateLayout(feature.model, ecModel, api, payload);
  62556. });
  62557. },
  62558. remove: function (ecModel, api) {
  62559. zrUtil.each(this._features, function (feature) {
  62560. feature.remove && feature.remove(ecModel, api);
  62561. });
  62562. this.group.removeAll();
  62563. },
  62564. dispose: function (ecModel, api) {
  62565. zrUtil.each(this._features, function (feature) {
  62566. feature.dispose && feature.dispose(ecModel, api);
  62567. });
  62568. }
  62569. });
  62570. function isUserFeatureName(featureName) {
  62571. return featureName.indexOf('my') === 0;
  62572. }
  62573. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(313)))
  62574. /***/ }),
  62575. /* 423 */
  62576. /***/ (function(module, exports, __webpack_require__) {
  62577. var env = __webpack_require__(2);
  62578. var lang = __webpack_require__(365).toolbox.saveAsImage;
  62579. function SaveAsImage (model) {
  62580. this.model = model;
  62581. }
  62582. SaveAsImage.defaultOption = {
  62583. show: true,
  62584. 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',
  62585. title: lang.title,
  62586. type: 'png',
  62587. // Default use option.backgroundColor
  62588. // backgroundColor: '#fff',
  62589. name: '',
  62590. excludeComponents: ['toolbox'],
  62591. pixelRatio: 1,
  62592. lang: lang.lang.slice()
  62593. };
  62594. SaveAsImage.prototype.unusable = !env.canvasSupported;
  62595. var proto = SaveAsImage.prototype;
  62596. proto.onclick = function (ecModel, api) {
  62597. var model = this.model;
  62598. var title = model.get('name') || ecModel.get('title.0.text') || 'echarts';
  62599. var $a = document.createElement('a');
  62600. var type = model.get('type', true) || 'png';
  62601. $a.download = title + '.' + type;
  62602. $a.target = '_blank';
  62603. var url = api.getConnectedDataURL({
  62604. type: type,
  62605. backgroundColor: model.get('backgroundColor', true)
  62606. || ecModel.get('backgroundColor') || '#fff',
  62607. excludeComponents: model.get('excludeComponents'),
  62608. pixelRatio: model.get('pixelRatio')
  62609. });
  62610. $a.href = url;
  62611. // Chrome and Firefox
  62612. if (typeof MouseEvent === 'function' && !env.browser.ie && !env.browser.edge) {
  62613. var evt = new MouseEvent('click', {
  62614. view: window,
  62615. bubbles: true,
  62616. cancelable: false
  62617. });
  62618. $a.dispatchEvent(evt);
  62619. }
  62620. // IE
  62621. else {
  62622. if (window.navigator.msSaveOrOpenBlob) {
  62623. var bstr = atob(url.split(',')[1]);
  62624. var n = bstr.length;
  62625. var u8arr = new Uint8Array(n);
  62626. while(n--) {
  62627. u8arr[n] = bstr.charCodeAt(n);
  62628. }
  62629. var blob = new Blob([u8arr]);
  62630. window.navigator.msSaveOrOpenBlob(blob, title + '.' + type);
  62631. }
  62632. else {
  62633. var lang = model.get('lang');
  62634. var html = '' +
  62635. '<body style="margin:0;">' +
  62636. '<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />' +
  62637. '</body>';
  62638. var tab = window.open();
  62639. tab.document.write(html);
  62640. }
  62641. }
  62642. };
  62643. __webpack_require__(364).register(
  62644. 'saveAsImage', SaveAsImage
  62645. );
  62646. module.exports = SaveAsImage;
  62647. /***/ }),
  62648. /* 424 */
  62649. /***/ (function(module, exports, __webpack_require__) {
  62650. 'use strict';
  62651. var zrUtil = __webpack_require__(4);
  62652. var lang = __webpack_require__(365).toolbox.magicType;
  62653. function MagicType(model) {
  62654. this.model = model;
  62655. }
  62656. MagicType.defaultOption = {
  62657. show: true,
  62658. type: [],
  62659. // Icon group
  62660. icon: {
  62661. line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
  62662. bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
  62663. 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
  62664. tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
  62665. },
  62666. // `line`, `bar`, `stack`, `tiled`
  62667. title: zrUtil.clone(lang.title),
  62668. option: {},
  62669. seriesIndex: {}
  62670. };
  62671. var proto = MagicType.prototype;
  62672. proto.getIcons = function () {
  62673. var model = this.model;
  62674. var availableIcons = model.get('icon');
  62675. var icons = {};
  62676. zrUtil.each(model.get('type'), function (type) {
  62677. if (availableIcons[type]) {
  62678. icons[type] = availableIcons[type];
  62679. }
  62680. });
  62681. return icons;
  62682. };
  62683. var seriesOptGenreator = {
  62684. 'line': function (seriesType, seriesId, seriesModel, model) {
  62685. if (seriesType === 'bar') {
  62686. return zrUtil.merge({
  62687. id: seriesId,
  62688. type: 'line',
  62689. // Preserve data related option
  62690. data: seriesModel.get('data'),
  62691. stack: seriesModel.get('stack'),
  62692. markPoint: seriesModel.get('markPoint'),
  62693. markLine: seriesModel.get('markLine')
  62694. }, model.get('option.line') || {}, true);
  62695. }
  62696. },
  62697. 'bar': function (seriesType, seriesId, seriesModel, model) {
  62698. if (seriesType === 'line') {
  62699. return zrUtil.merge({
  62700. id: seriesId,
  62701. type: 'bar',
  62702. // Preserve data related option
  62703. data: seriesModel.get('data'),
  62704. stack: seriesModel.get('stack'),
  62705. markPoint: seriesModel.get('markPoint'),
  62706. markLine: seriesModel.get('markLine')
  62707. }, model.get('option.bar') || {}, true);
  62708. }
  62709. },
  62710. 'stack': function (seriesType, seriesId, seriesModel, model) {
  62711. if (seriesType === 'line' || seriesType === 'bar') {
  62712. return zrUtil.merge({
  62713. id: seriesId,
  62714. stack: '__ec_magicType_stack__'
  62715. }, model.get('option.stack') || {}, true);
  62716. }
  62717. },
  62718. 'tiled': function (seriesType, seriesId, seriesModel, model) {
  62719. if (seriesType === 'line' || seriesType === 'bar') {
  62720. return zrUtil.merge({
  62721. id: seriesId,
  62722. stack: ''
  62723. }, model.get('option.tiled') || {}, true);
  62724. }
  62725. }
  62726. };
  62727. var radioTypes = [
  62728. ['line', 'bar'],
  62729. ['stack', 'tiled']
  62730. ];
  62731. proto.onclick = function (ecModel, api, type) {
  62732. var model = this.model;
  62733. var seriesIndex = model.get('seriesIndex.' + type);
  62734. // Not supported magicType
  62735. if (!seriesOptGenreator[type]) {
  62736. return;
  62737. }
  62738. var newOption = {
  62739. series: []
  62740. };
  62741. var generateNewSeriesTypes = function (seriesModel) {
  62742. var seriesType = seriesModel.subType;
  62743. var seriesId = seriesModel.id;
  62744. var newSeriesOpt = seriesOptGenreator[type](
  62745. seriesType, seriesId, seriesModel, model
  62746. );
  62747. if (newSeriesOpt) {
  62748. // PENDING If merge original option?
  62749. zrUtil.defaults(newSeriesOpt, seriesModel.option);
  62750. newOption.series.push(newSeriesOpt);
  62751. }
  62752. // Modify boundaryGap
  62753. var coordSys = seriesModel.coordinateSystem;
  62754. if (coordSys && coordSys.type === 'cartesian2d' && (type === 'line' || type === 'bar')) {
  62755. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  62756. if (categoryAxis) {
  62757. var axisDim = categoryAxis.dim;
  62758. var axisType = axisDim + 'Axis';
  62759. var axisModel = ecModel.queryComponents({
  62760. mainType: axisType,
  62761. index: seriesModel.get(name + 'Index'),
  62762. id: seriesModel.get(name + 'Id')
  62763. })[0];
  62764. var axisIndex = axisModel.componentIndex;
  62765. newOption[axisType] = newOption[axisType] || [];
  62766. for (var i = 0; i <= axisIndex; i++) {
  62767. newOption[axisType][axisIndex] = newOption[axisType][axisIndex] || {};
  62768. }
  62769. newOption[axisType][axisIndex].boundaryGap = type === 'bar' ? true : false;
  62770. }
  62771. }
  62772. };
  62773. zrUtil.each(radioTypes, function (radio) {
  62774. if (zrUtil.indexOf(radio, type) >= 0) {
  62775. zrUtil.each(radio, function (item) {
  62776. model.setIconStatus(item, 'normal');
  62777. });
  62778. }
  62779. });
  62780. model.setIconStatus(type, 'emphasis');
  62781. ecModel.eachComponent(
  62782. {
  62783. mainType: 'series',
  62784. query: seriesIndex == null ? null : {
  62785. seriesIndex: seriesIndex
  62786. }
  62787. }, generateNewSeriesTypes
  62788. );
  62789. api.dispatchAction({
  62790. type: 'changeMagicType',
  62791. currentType: type,
  62792. newOption: newOption
  62793. });
  62794. };
  62795. var echarts = __webpack_require__(1);
  62796. echarts.registerAction({
  62797. type: 'changeMagicType',
  62798. event: 'magicTypeChanged',
  62799. update: 'prepareAndUpdate'
  62800. }, function (payload, ecModel) {
  62801. ecModel.mergeOption(payload.newOption);
  62802. });
  62803. __webpack_require__(364).register('magicType', MagicType);
  62804. module.exports = MagicType;
  62805. /***/ }),
  62806. /* 425 */
  62807. /***/ (function(module, exports, __webpack_require__) {
  62808. /**
  62809. * @module echarts/component/toolbox/feature/DataView
  62810. */
  62811. var zrUtil = __webpack_require__(4);
  62812. var eventTool = __webpack_require__(93);
  62813. var lang = __webpack_require__(365).toolbox.dataView;
  62814. var BLOCK_SPLITER = new Array(60).join('-');
  62815. var ITEM_SPLITER = '\t';
  62816. /**
  62817. * Group series into two types
  62818. * 1. on category axis, like line, bar
  62819. * 2. others, like scatter, pie
  62820. * @param {module:echarts/model/Global} ecModel
  62821. * @return {Object}
  62822. * @inner
  62823. */
  62824. function groupSeries(ecModel) {
  62825. var seriesGroupByCategoryAxis = {};
  62826. var otherSeries = [];
  62827. var meta = [];
  62828. ecModel.eachRawSeries(function (seriesModel) {
  62829. var coordSys = seriesModel.coordinateSystem;
  62830. if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
  62831. var baseAxis = coordSys.getBaseAxis();
  62832. if (baseAxis.type === 'category') {
  62833. var key = baseAxis.dim + '_' + baseAxis.index;
  62834. if (!seriesGroupByCategoryAxis[key]) {
  62835. seriesGroupByCategoryAxis[key] = {
  62836. categoryAxis: baseAxis,
  62837. valueAxis: coordSys.getOtherAxis(baseAxis),
  62838. series: []
  62839. };
  62840. meta.push({
  62841. axisDim: baseAxis.dim,
  62842. axisIndex: baseAxis.index
  62843. });
  62844. }
  62845. seriesGroupByCategoryAxis[key].series.push(seriesModel);
  62846. }
  62847. else {
  62848. otherSeries.push(seriesModel);
  62849. }
  62850. }
  62851. else {
  62852. otherSeries.push(seriesModel);
  62853. }
  62854. });
  62855. return {
  62856. seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
  62857. other: otherSeries,
  62858. meta: meta
  62859. };
  62860. }
  62861. /**
  62862. * Assemble content of series on cateogory axis
  62863. * @param {Array.<module:echarts/model/Series>} series
  62864. * @return {string}
  62865. * @inner
  62866. */
  62867. function assembleSeriesWithCategoryAxis(series) {
  62868. var tables = [];
  62869. zrUtil.each(series, function (group, key) {
  62870. var categoryAxis = group.categoryAxis;
  62871. var valueAxis = group.valueAxis;
  62872. var valueAxisDim = valueAxis.dim;
  62873. var headers = [' '].concat(zrUtil.map(group.series, function (series) {
  62874. return series.name;
  62875. }));
  62876. var columns = [categoryAxis.model.getCategories()];
  62877. zrUtil.each(group.series, function (series) {
  62878. columns.push(series.getRawData().mapArray(valueAxisDim, function (val) {
  62879. return val;
  62880. }));
  62881. });
  62882. // Assemble table content
  62883. var lines = [headers.join(ITEM_SPLITER)];
  62884. for (var i = 0; i < columns[0].length; i++) {
  62885. var items = [];
  62886. for (var j = 0; j < columns.length; j++) {
  62887. items.push(columns[j][i]);
  62888. }
  62889. lines.push(items.join(ITEM_SPLITER));
  62890. }
  62891. tables.push(lines.join('\n'));
  62892. });
  62893. return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
  62894. }
  62895. /**
  62896. * Assemble content of other series
  62897. * @param {Array.<module:echarts/model/Series>} series
  62898. * @return {string}
  62899. * @inner
  62900. */
  62901. function assembleOtherSeries(series) {
  62902. return zrUtil.map(series, function (series) {
  62903. var data = series.getRawData();
  62904. var lines = [series.name];
  62905. var vals = [];
  62906. data.each(data.dimensions, function () {
  62907. var argLen = arguments.length;
  62908. var dataIndex = arguments[argLen - 1];
  62909. var name = data.getName(dataIndex);
  62910. for (var i = 0; i < argLen - 1; i++) {
  62911. vals[i] = arguments[i];
  62912. }
  62913. lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
  62914. });
  62915. return lines.join('\n');
  62916. }).join('\n\n' + BLOCK_SPLITER + '\n\n');
  62917. }
  62918. /**
  62919. * @param {module:echarts/model/Global}
  62920. * @return {Object}
  62921. * @inner
  62922. */
  62923. function getContentFromModel(ecModel) {
  62924. var result = groupSeries(ecModel);
  62925. return {
  62926. value: zrUtil.filter([
  62927. assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis),
  62928. assembleOtherSeries(result.other)
  62929. ], function (str) {
  62930. return str.replace(/[\n\t\s]/g, '');
  62931. }).join('\n\n' + BLOCK_SPLITER + '\n\n'),
  62932. meta: result.meta
  62933. };
  62934. }
  62935. function trim(str) {
  62936. return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  62937. }
  62938. /**
  62939. * If a block is tsv format
  62940. */
  62941. function isTSVFormat(block) {
  62942. // Simple method to find out if a block is tsv format
  62943. var firstLine = block.slice(0, block.indexOf('\n'));
  62944. if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
  62945. return true;
  62946. }
  62947. }
  62948. var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g');
  62949. /**
  62950. * @param {string} tsv
  62951. * @return {Object}
  62952. */
  62953. function parseTSVContents(tsv) {
  62954. var tsvLines = tsv.split(/\n+/g);
  62955. var headers = trim(tsvLines.shift()).split(itemSplitRegex);
  62956. var categories = [];
  62957. var series = zrUtil.map(headers, function (header) {
  62958. return {
  62959. name: header,
  62960. data: []
  62961. };
  62962. });
  62963. for (var i = 0; i < tsvLines.length; i++) {
  62964. var items = trim(tsvLines[i]).split(itemSplitRegex);
  62965. categories.push(items.shift());
  62966. for (var j = 0; j < items.length; j++) {
  62967. series[j] && (series[j].data[i] = items[j]);
  62968. }
  62969. }
  62970. return {
  62971. series: series,
  62972. categories: categories
  62973. };
  62974. }
  62975. /**
  62976. * @param {string} str
  62977. * @return {Array.<Object>}
  62978. * @inner
  62979. */
  62980. function parseListContents(str) {
  62981. var lines = str.split(/\n+/g);
  62982. var seriesName = trim(lines.shift());
  62983. var data = [];
  62984. for (var i = 0; i < lines.length; i++) {
  62985. var items = trim(lines[i]).split(itemSplitRegex);
  62986. var name = '';
  62987. var value;
  62988. var hasName = false;
  62989. if (isNaN(items[0])) { // First item is name
  62990. hasName = true;
  62991. name = items[0];
  62992. items = items.slice(1);
  62993. data[i] = {
  62994. name: name,
  62995. value: []
  62996. };
  62997. value = data[i].value;
  62998. }
  62999. else {
  63000. value = data[i] = [];
  63001. }
  63002. for (var j = 0; j < items.length; j++) {
  63003. value.push(+items[j]);
  63004. }
  63005. if (value.length === 1) {
  63006. hasName ? (data[i].value = value[0]) : (data[i] = value[0]);
  63007. }
  63008. }
  63009. return {
  63010. name: seriesName,
  63011. data: data
  63012. };
  63013. }
  63014. /**
  63015. * @param {string} str
  63016. * @param {Array.<Object>} blockMetaList
  63017. * @return {Object}
  63018. * @inner
  63019. */
  63020. function parseContents(str, blockMetaList) {
  63021. var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g'));
  63022. var newOption = {
  63023. series: []
  63024. };
  63025. zrUtil.each(blocks, function (block, idx) {
  63026. if (isTSVFormat(block)) {
  63027. var result = parseTSVContents(block);
  63028. var blockMeta = blockMetaList[idx];
  63029. var axisKey = blockMeta.axisDim + 'Axis';
  63030. if (blockMeta) {
  63031. newOption[axisKey] = newOption[axisKey] || [];
  63032. newOption[axisKey][blockMeta.axisIndex] = {
  63033. data: result.categories
  63034. };
  63035. newOption.series = newOption.series.concat(result.series);
  63036. }
  63037. }
  63038. else {
  63039. var result = parseListContents(block);
  63040. newOption.series.push(result);
  63041. }
  63042. });
  63043. return newOption;
  63044. }
  63045. /**
  63046. * @alias {module:echarts/component/toolbox/feature/DataView}
  63047. * @constructor
  63048. * @param {module:echarts/model/Model} model
  63049. */
  63050. function DataView(model) {
  63051. this._dom = null;
  63052. this.model = model;
  63053. }
  63054. DataView.defaultOption = {
  63055. show: true,
  63056. readOnly: false,
  63057. optionToContent: null,
  63058. contentToOption: null,
  63059. 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',
  63060. title: zrUtil.clone(lang.title),
  63061. lang: zrUtil.clone(lang.lang),
  63062. backgroundColor: '#fff',
  63063. textColor: '#000',
  63064. textareaColor: '#fff',
  63065. textareaBorderColor: '#333',
  63066. buttonColor: '#c23531',
  63067. buttonTextColor: '#fff'
  63068. };
  63069. DataView.prototype.onclick = function (ecModel, api) {
  63070. var container = api.getDom();
  63071. var model = this.model;
  63072. if (this._dom) {
  63073. container.removeChild(this._dom);
  63074. }
  63075. var root = document.createElement('div');
  63076. root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;';
  63077. root.style.backgroundColor = model.get('backgroundColor') || '#fff';
  63078. // Create elements
  63079. var header = document.createElement('h4');
  63080. var lang = model.get('lang') || [];
  63081. header.innerHTML = lang[0] || model.get('title');
  63082. header.style.cssText = 'margin: 10px 20px;';
  63083. header.style.color = model.get('textColor');
  63084. var viewMain = document.createElement('div');
  63085. var textarea = document.createElement('textarea');
  63086. viewMain.style.cssText = 'display:block;width:100%;overflow:auto;';
  63087. var optionToContent = model.get('optionToContent');
  63088. var contentToOption = model.get('contentToOption');
  63089. var result = getContentFromModel(ecModel);
  63090. if (typeof optionToContent === 'function') {
  63091. var htmlOrDom = optionToContent(api.getOption());
  63092. if (typeof htmlOrDom === 'string') {
  63093. viewMain.innerHTML = htmlOrDom;
  63094. }
  63095. else if (zrUtil.isDom(htmlOrDom)) {
  63096. viewMain.appendChild(htmlOrDom);
  63097. }
  63098. }
  63099. else {
  63100. // Use default textarea
  63101. viewMain.appendChild(textarea);
  63102. textarea.readOnly = model.get('readOnly');
  63103. textarea.style.cssText = 'width:100%;height:100%;font-family:monospace;font-size:14px;line-height:1.6rem;';
  63104. textarea.style.color = model.get('textColor');
  63105. textarea.style.borderColor = model.get('textareaBorderColor');
  63106. textarea.style.backgroundColor = model.get('textareaColor');
  63107. textarea.value = result.value;
  63108. }
  63109. var blockMetaList = result.meta;
  63110. var buttonContainer = document.createElement('div');
  63111. buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;';
  63112. var buttonStyle = 'float:right;margin-right:20px;border:none;'
  63113. + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px';
  63114. var closeButton = document.createElement('div');
  63115. var refreshButton = document.createElement('div');
  63116. buttonStyle += ';background-color:' + model.get('buttonColor');
  63117. buttonStyle += ';color:' + model.get('buttonTextColor');
  63118. var self = this;
  63119. function close() {
  63120. container.removeChild(root);
  63121. self._dom = null;
  63122. }
  63123. eventTool.addEventListener(closeButton, 'click', close);
  63124. eventTool.addEventListener(refreshButton, 'click', function () {
  63125. var newOption;
  63126. try {
  63127. if (typeof contentToOption === 'function') {
  63128. newOption = contentToOption(viewMain, api.getOption());
  63129. }
  63130. else {
  63131. newOption = parseContents(textarea.value, blockMetaList);
  63132. }
  63133. }
  63134. catch (e) {
  63135. close();
  63136. throw new Error('Data view format error ' + e);
  63137. }
  63138. if (newOption) {
  63139. api.dispatchAction({
  63140. type: 'changeDataView',
  63141. newOption: newOption
  63142. });
  63143. }
  63144. close();
  63145. });
  63146. closeButton.innerHTML = lang[1];
  63147. refreshButton.innerHTML = lang[2];
  63148. refreshButton.style.cssText = buttonStyle;
  63149. closeButton.style.cssText = buttonStyle;
  63150. !model.get('readOnly') && buttonContainer.appendChild(refreshButton);
  63151. buttonContainer.appendChild(closeButton);
  63152. // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea
  63153. eventTool.addEventListener(textarea, 'keydown', function (e) {
  63154. if ((e.keyCode || e.which) === 9) {
  63155. // get caret position/selection
  63156. var val = this.value;
  63157. var start = this.selectionStart;
  63158. var end = this.selectionEnd;
  63159. // set textarea value to: text before caret + tab + text after caret
  63160. this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end);
  63161. // put caret at right position again
  63162. this.selectionStart = this.selectionEnd = start + 1;
  63163. // prevent the focus lose
  63164. eventTool.stop(e);
  63165. }
  63166. });
  63167. root.appendChild(header);
  63168. root.appendChild(viewMain);
  63169. root.appendChild(buttonContainer);
  63170. viewMain.style.height = (container.clientHeight - 80) + 'px';
  63171. container.appendChild(root);
  63172. this._dom = root;
  63173. };
  63174. DataView.prototype.remove = function (ecModel, api) {
  63175. this._dom && api.getDom().removeChild(this._dom);
  63176. };
  63177. DataView.prototype.dispose = function (ecModel, api) {
  63178. this.remove(ecModel, api);
  63179. };
  63180. /**
  63181. * @inner
  63182. */
  63183. function tryMergeDataOption(newData, originalData) {
  63184. return zrUtil.map(newData, function (newVal, idx) {
  63185. var original = originalData && originalData[idx];
  63186. if (zrUtil.isObject(original) && !zrUtil.isArray(original)) {
  63187. if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) {
  63188. newVal = newVal.value;
  63189. }
  63190. // Original data has option
  63191. return zrUtil.defaults({
  63192. value: newVal
  63193. }, original);
  63194. }
  63195. else {
  63196. return newVal;
  63197. }
  63198. });
  63199. }
  63200. __webpack_require__(364).register('dataView', DataView);
  63201. __webpack_require__(1).registerAction({
  63202. type: 'changeDataView',
  63203. event: 'dataViewChanged',
  63204. update: 'prepareAndUpdate'
  63205. }, function (payload, ecModel) {
  63206. var newSeriesOptList = [];
  63207. zrUtil.each(payload.newOption.series, function (seriesOpt) {
  63208. var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0];
  63209. if (!seriesModel) {
  63210. // New created series
  63211. // Geuss the series type
  63212. newSeriesOptList.push(zrUtil.extend({
  63213. // Default is scatter
  63214. type: 'scatter'
  63215. }, seriesOpt));
  63216. }
  63217. else {
  63218. var originalData = seriesModel.get('data');
  63219. newSeriesOptList.push({
  63220. name: seriesOpt.name,
  63221. data: tryMergeDataOption(seriesOpt.data, originalData)
  63222. });
  63223. }
  63224. });
  63225. ecModel.mergeOption(zrUtil.defaults({
  63226. series: newSeriesOptList
  63227. }, payload.newOption));
  63228. });
  63229. module.exports = DataView;
  63230. /***/ }),
  63231. /* 426 */
  63232. /***/ (function(module, exports, __webpack_require__) {
  63233. 'use strict';
  63234. var zrUtil = __webpack_require__(4);
  63235. var BrushController = __webpack_require__(248);
  63236. var BrushTargetManager = __webpack_require__(359);
  63237. var history = __webpack_require__(427);
  63238. var sliderMove = __webpack_require__(242);
  63239. var lang = __webpack_require__(365).toolbox.dataZoom;
  63240. var each = zrUtil.each;
  63241. // Use dataZoomSelect
  63242. __webpack_require__(428);
  63243. // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId
  63244. var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_';
  63245. function DataZoom(model, ecModel, api) {
  63246. /**
  63247. * @private
  63248. * @type {module:echarts/component/helper/BrushController}
  63249. */
  63250. (this._brushController = new BrushController(api.getZr()))
  63251. .on('brush', zrUtil.bind(this._onBrush, this))
  63252. .mount();
  63253. /**
  63254. * @private
  63255. * @type {boolean}
  63256. */
  63257. this._isZoomActive;
  63258. }
  63259. DataZoom.defaultOption = {
  63260. show: true,
  63261. // Icon group
  63262. icon: {
  63263. zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
  63264. back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
  63265. },
  63266. // `zoom`, `back`
  63267. title: zrUtil.clone(lang.title)
  63268. };
  63269. var proto = DataZoom.prototype;
  63270. proto.render = function (featureModel, ecModel, api, payload) {
  63271. this.model = featureModel;
  63272. this.ecModel = ecModel;
  63273. this.api = api;
  63274. updateZoomBtnStatus(featureModel, ecModel, this, payload, api);
  63275. updateBackBtnStatus(featureModel, ecModel);
  63276. };
  63277. proto.onclick = function (ecModel, api, type) {
  63278. handlers[type].call(this);
  63279. };
  63280. proto.remove = function (ecModel, api) {
  63281. this._brushController.unmount();
  63282. };
  63283. proto.dispose = function (ecModel, api) {
  63284. this._brushController.dispose();
  63285. };
  63286. /**
  63287. * @private
  63288. */
  63289. var handlers = {
  63290. zoom: function () {
  63291. var nextActive = !this._isZoomActive;
  63292. this.api.dispatchAction({
  63293. type: 'takeGlobalCursor',
  63294. key: 'dataZoomSelect',
  63295. dataZoomSelectActive: nextActive
  63296. });
  63297. },
  63298. back: function () {
  63299. this._dispatchZoomAction(history.pop(this.ecModel));
  63300. }
  63301. };
  63302. /**
  63303. * @private
  63304. */
  63305. proto._onBrush = function (areas, opt) {
  63306. if (!opt.isEnd || !areas.length) {
  63307. return;
  63308. }
  63309. var snapshot = {};
  63310. var ecModel = this.ecModel;
  63311. this._brushController.updateCovers([]); // remove cover
  63312. var brushTargetManager = new BrushTargetManager(
  63313. retrieveAxisSetting(this.model.option), ecModel, {include: ['grid']}
  63314. );
  63315. brushTargetManager.matchOutputRanges(areas, ecModel, function (area, coordRange, coordSys) {
  63316. if (coordSys.type !== 'cartesian2d') {
  63317. return;
  63318. }
  63319. var brushType = area.brushType;
  63320. if (brushType === 'rect') {
  63321. setBatch('x', coordSys, coordRange[0]);
  63322. setBatch('y', coordSys, coordRange[1]);
  63323. }
  63324. else {
  63325. setBatch(({lineX: 'x', lineY: 'y'})[brushType], coordSys, coordRange);
  63326. }
  63327. });
  63328. history.push(ecModel, snapshot);
  63329. this._dispatchZoomAction(snapshot);
  63330. function setBatch(dimName, coordSys, minMax) {
  63331. var axis = coordSys.getAxis(dimName);
  63332. var axisModel = axis.model;
  63333. var dataZoomModel = findDataZoom(dimName, axisModel, ecModel);
  63334. // Restrict range.
  63335. var minMaxSpan = dataZoomModel.findRepresentativeAxisProxy(axisModel).getMinMaxSpan();
  63336. if (minMaxSpan.minValueSpan != null || minMaxSpan.maxValueSpan != null) {
  63337. minMax = sliderMove(
  63338. 0, minMax.slice(), axis.scale.getExtent(), 0,
  63339. minMaxSpan.minValueSpan, minMaxSpan.maxValueSpan
  63340. );
  63341. }
  63342. dataZoomModel && (snapshot[dataZoomModel.id] = {
  63343. dataZoomId: dataZoomModel.id,
  63344. startValue: minMax[0],
  63345. endValue: minMax[1]
  63346. });
  63347. }
  63348. function findDataZoom(dimName, axisModel, ecModel) {
  63349. var found;
  63350. ecModel.eachComponent({mainType: 'dataZoom', subType: 'select'}, function (dzModel) {
  63351. var has = dzModel.getAxisModel(dimName, axisModel.componentIndex);
  63352. has && (found = dzModel);
  63353. });
  63354. return found;
  63355. }
  63356. };
  63357. /**
  63358. * @private
  63359. */
  63360. proto._dispatchZoomAction = function (snapshot) {
  63361. var batch = [];
  63362. // Convert from hash map to array.
  63363. each(snapshot, function (batchItem, dataZoomId) {
  63364. batch.push(zrUtil.clone(batchItem));
  63365. });
  63366. batch.length && this.api.dispatchAction({
  63367. type: 'dataZoom',
  63368. from: this.uid,
  63369. batch: batch
  63370. });
  63371. };
  63372. function retrieveAxisSetting(option) {
  63373. var setting = {};
  63374. // Compatible with previous setting: null => all axis, false => no axis.
  63375. zrUtil.each(['xAxisIndex', 'yAxisIndex'], function (name) {
  63376. setting[name] = option[name];
  63377. setting[name] == null && (setting[name] = 'all');
  63378. (setting[name] === false || setting[name] === 'none') && (setting[name] = []);
  63379. });
  63380. return setting;
  63381. }
  63382. function updateBackBtnStatus(featureModel, ecModel) {
  63383. featureModel.setIconStatus(
  63384. 'back',
  63385. history.count(ecModel) > 1 ? 'emphasis' : 'normal'
  63386. );
  63387. }
  63388. function updateZoomBtnStatus(featureModel, ecModel, view, payload, api) {
  63389. var zoomActive = view._isZoomActive;
  63390. if (payload && payload.type === 'takeGlobalCursor') {
  63391. zoomActive = payload.key === 'dataZoomSelect'
  63392. ? payload.dataZoomSelectActive : false;
  63393. }
  63394. view._isZoomActive = zoomActive;
  63395. featureModel.setIconStatus('zoom', zoomActive ? 'emphasis' : 'normal');
  63396. var brushTargetManager = new BrushTargetManager(
  63397. retrieveAxisSetting(featureModel.option), ecModel, {include: ['grid']}
  63398. );
  63399. view._brushController
  63400. .setPanels(brushTargetManager.makePanelOpts(api, function (targetInfo) {
  63401. return (targetInfo.xAxisDeclared && !targetInfo.yAxisDeclared)
  63402. ? 'lineX'
  63403. : (!targetInfo.xAxisDeclared && targetInfo.yAxisDeclared)
  63404. ? 'lineY'
  63405. : 'rect';
  63406. }))
  63407. .enableBrush(
  63408. zoomActive
  63409. ? {
  63410. brushType: 'auto',
  63411. brushStyle: {
  63412. // FIXME user customized?
  63413. lineWidth: 0,
  63414. fill: 'rgba(0,0,0,0.2)'
  63415. }
  63416. }
  63417. : false
  63418. );
  63419. }
  63420. __webpack_require__(364).register('dataZoom', DataZoom);
  63421. // Create special dataZoom option for select
  63422. __webpack_require__(1).registerPreprocessor(function (option) {
  63423. if (!option) {
  63424. return;
  63425. }
  63426. var dataZoomOpts = option.dataZoom || (option.dataZoom = []);
  63427. if (!zrUtil.isArray(dataZoomOpts)) {
  63428. option.dataZoom = dataZoomOpts = [dataZoomOpts];
  63429. }
  63430. var toolboxOpt = option.toolbox;
  63431. if (toolboxOpt) {
  63432. // Assume there is only one toolbox
  63433. if (zrUtil.isArray(toolboxOpt)) {
  63434. toolboxOpt = toolboxOpt[0];
  63435. }
  63436. if (toolboxOpt && toolboxOpt.feature) {
  63437. var dataZoomOpt = toolboxOpt.feature.dataZoom;
  63438. addForAxis('xAxis', dataZoomOpt);
  63439. addForAxis('yAxis', dataZoomOpt);
  63440. }
  63441. }
  63442. function addForAxis(axisName, dataZoomOpt) {
  63443. if (!dataZoomOpt) {
  63444. return;
  63445. }
  63446. // Try not to modify model, because it is not merged yet.
  63447. var axisIndicesName = axisName + 'Index';
  63448. var givenAxisIndices = dataZoomOpt[axisIndicesName];
  63449. if (givenAxisIndices != null
  63450. && givenAxisIndices != 'all'
  63451. && !zrUtil.isArray(givenAxisIndices)
  63452. ) {
  63453. givenAxisIndices = (givenAxisIndices === false || givenAxisIndices === 'none') ? [] : [givenAxisIndices];
  63454. }
  63455. forEachComponent(axisName, function (axisOpt, axisIndex) {
  63456. if (givenAxisIndices != null
  63457. && givenAxisIndices != 'all'
  63458. && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1
  63459. ) {
  63460. return;
  63461. }
  63462. var newOpt = {
  63463. type: 'select',
  63464. $fromToolbox: true,
  63465. // Id for merge mapping.
  63466. id: DATA_ZOOM_ID_BASE + axisName + axisIndex
  63467. };
  63468. // FIXME
  63469. // Only support one axis now.
  63470. newOpt[axisIndicesName] = axisIndex;
  63471. dataZoomOpts.push(newOpt);
  63472. });
  63473. }
  63474. function forEachComponent(mainType, cb) {
  63475. var opts = option[mainType];
  63476. if (!zrUtil.isArray(opts)) {
  63477. opts = opts ? [opts] : [];
  63478. }
  63479. each(opts, cb);
  63480. }
  63481. });
  63482. module.exports = DataZoom;
  63483. /***/ }),
  63484. /* 427 */
  63485. /***/ (function(module, exports, __webpack_require__) {
  63486. /**
  63487. * @file History manager.
  63488. */
  63489. var zrUtil = __webpack_require__(4);
  63490. var each = zrUtil.each;
  63491. var ATTR = '\0_ec_hist_store';
  63492. var history = {
  63493. /**
  63494. * @public
  63495. * @param {module:echarts/model/Global} ecModel
  63496. * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]}
  63497. */
  63498. push: function (ecModel, newSnapshot) {
  63499. var store = giveStore(ecModel);
  63500. // If previous dataZoom can not be found,
  63501. // complete an range with current range.
  63502. each(newSnapshot, function (batchItem, dataZoomId) {
  63503. var i = store.length - 1;
  63504. for (; i >= 0; i--) {
  63505. var snapshot = store[i];
  63506. if (snapshot[dataZoomId]) {
  63507. break;
  63508. }
  63509. }
  63510. if (i < 0) {
  63511. // No origin range set, create one by current range.
  63512. var dataZoomModel = ecModel.queryComponents(
  63513. {mainType: 'dataZoom', subType: 'select', id: dataZoomId}
  63514. )[0];
  63515. if (dataZoomModel) {
  63516. var percentRange = dataZoomModel.getPercentRange();
  63517. store[0][dataZoomId] = {
  63518. dataZoomId: dataZoomId,
  63519. start: percentRange[0],
  63520. end: percentRange[1]
  63521. };
  63522. }
  63523. }
  63524. });
  63525. store.push(newSnapshot);
  63526. },
  63527. /**
  63528. * @public
  63529. * @param {module:echarts/model/Global} ecModel
  63530. * @return {Object} snapshot
  63531. */
  63532. pop: function (ecModel) {
  63533. var store = giveStore(ecModel);
  63534. var head = store[store.length - 1];
  63535. store.length > 1 && store.pop();
  63536. // Find top for all dataZoom.
  63537. var snapshot = {};
  63538. each(head, function (batchItem, dataZoomId) {
  63539. for (var i = store.length - 1; i >= 0; i--) {
  63540. var batchItem = store[i][dataZoomId];
  63541. if (batchItem) {
  63542. snapshot[dataZoomId] = batchItem;
  63543. break;
  63544. }
  63545. }
  63546. });
  63547. return snapshot;
  63548. },
  63549. /**
  63550. * @public
  63551. */
  63552. clear: function (ecModel) {
  63553. ecModel[ATTR] = null;
  63554. },
  63555. /**
  63556. * @public
  63557. * @param {module:echarts/model/Global} ecModel
  63558. * @return {number} records. always >= 1.
  63559. */
  63560. count: function (ecModel) {
  63561. return giveStore(ecModel).length;
  63562. }
  63563. };
  63564. /**
  63565. * [{key: dataZoomId, value: {dataZoomId, range}}, ...]
  63566. * History length of each dataZoom may be different.
  63567. * this._history[0] is used to store origin range.
  63568. * @type {Array.<Object>}
  63569. */
  63570. function giveStore(ecModel) {
  63571. var store = ecModel[ATTR];
  63572. if (!store) {
  63573. store = ecModel[ATTR] = [{}];
  63574. }
  63575. return store;
  63576. }
  63577. module.exports = history;
  63578. /***/ }),
  63579. /* 428 */
  63580. /***/ (function(module, exports, __webpack_require__) {
  63581. /**
  63582. * DataZoom component entry
  63583. */
  63584. __webpack_require__(372);
  63585. __webpack_require__(373);
  63586. __webpack_require__(376);
  63587. __webpack_require__(429);
  63588. __webpack_require__(430);
  63589. __webpack_require__(382);
  63590. __webpack_require__(383);
  63591. /***/ }),
  63592. /* 429 */
  63593. /***/ (function(module, exports, __webpack_require__) {
  63594. /**
  63595. * @file Data zoom model
  63596. */
  63597. var DataZoomModel = __webpack_require__(373);
  63598. module.exports = DataZoomModel.extend({
  63599. type: 'dataZoom.select'
  63600. });
  63601. /***/ }),
  63602. /* 430 */
  63603. /***/ (function(module, exports, __webpack_require__) {
  63604. module.exports = __webpack_require__(376).extend({
  63605. type: 'dataZoom.select'
  63606. });
  63607. /***/ }),
  63608. /* 431 */
  63609. /***/ (function(module, exports, __webpack_require__) {
  63610. 'use strict';
  63611. var history = __webpack_require__(427);
  63612. var lang = __webpack_require__(365).toolbox.restore;
  63613. function Restore(model) {
  63614. this.model = model;
  63615. }
  63616. Restore.defaultOption = {
  63617. show: true,
  63618. 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',
  63619. title: lang.title
  63620. };
  63621. var proto = Restore.prototype;
  63622. proto.onclick = function (ecModel, api, type) {
  63623. history.clear(ecModel);
  63624. api.dispatchAction({
  63625. type: 'restore',
  63626. from: this.uid
  63627. });
  63628. };
  63629. __webpack_require__(364).register('restore', Restore);
  63630. __webpack_require__(1).registerAction(
  63631. {type: 'restore', event: 'restore', update: 'prepareAndUpdate'},
  63632. function (payload, ecModel) {
  63633. ecModel.resetOption('recreate');
  63634. }
  63635. );
  63636. module.exports = Restore;
  63637. /***/ }),
  63638. /* 432 */
  63639. /***/ (function(module, exports, __webpack_require__) {
  63640. __webpack_require__(433);
  63641. __webpack_require__(87).registerPainter('vml', __webpack_require__(435));
  63642. /***/ }),
  63643. /* 433 */
  63644. /***/ (function(module, exports, __webpack_require__) {
  63645. // http://www.w3.org/TR/NOTE-VML
  63646. // TODO Use proxy like svg instead of overwrite brush methods
  63647. if (!__webpack_require__(2).canvasSupported) {
  63648. var vec2 = __webpack_require__(10);
  63649. var BoundingRect = __webpack_require__(9);
  63650. var CMD = __webpack_require__(39).CMD;
  63651. var colorTool = __webpack_require__(33);
  63652. var textContain = __webpack_require__(8);
  63653. var textHelper = __webpack_require__(37);
  63654. var RectText = __webpack_require__(36);
  63655. var Displayable = __webpack_require__(23);
  63656. var ZImage = __webpack_require__(52);
  63657. var Text = __webpack_require__(53);
  63658. var Path = __webpack_require__(22);
  63659. var PathProxy = __webpack_require__(39);
  63660. var Gradient = __webpack_require__(69);
  63661. var vmlCore = __webpack_require__(434);
  63662. var round = Math.round;
  63663. var sqrt = Math.sqrt;
  63664. var abs = Math.abs;
  63665. var cos = Math.cos;
  63666. var sin = Math.sin;
  63667. var mathMax = Math.max;
  63668. var applyTransform = vec2.applyTransform;
  63669. var comma = ',';
  63670. var imageTransformPrefix = 'progid:DXImageTransform.Microsoft';
  63671. var Z = 21600;
  63672. var Z2 = Z / 2;
  63673. var ZLEVEL_BASE = 100000;
  63674. var Z_BASE = 1000;
  63675. var initRootElStyle = function (el) {
  63676. el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;';
  63677. el.coordsize = Z + ',' + Z;
  63678. el.coordorigin = '0,0';
  63679. };
  63680. var encodeHtmlAttribute = function (s) {
  63681. return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
  63682. };
  63683. var rgb2Str = function (r, g, b) {
  63684. return 'rgb(' + [r, g, b].join(',') + ')';
  63685. };
  63686. var append = function (parent, child) {
  63687. if (child && parent && child.parentNode !== parent) {
  63688. parent.appendChild(child);
  63689. }
  63690. };
  63691. var remove = function (parent, child) {
  63692. if (child && parent && child.parentNode === parent) {
  63693. parent.removeChild(child);
  63694. }
  63695. };
  63696. var getZIndex = function (zlevel, z, z2) {
  63697. // z 的取值范围为 [0, 1000]
  63698. return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2;
  63699. };
  63700. var parsePercent = function (value, maxValue) {
  63701. if (typeof value === 'string') {
  63702. if (value.lastIndexOf('%') >= 0) {
  63703. return parseFloat(value) / 100 * maxValue;
  63704. }
  63705. return parseFloat(value);
  63706. }
  63707. return value;
  63708. };
  63709. /***************************************************
  63710. * PATH
  63711. **************************************************/
  63712. var setColorAndOpacity = function (el, color, opacity) {
  63713. var colorArr = colorTool.parse(color);
  63714. opacity = +opacity;
  63715. if (isNaN(opacity)) {
  63716. opacity = 1;
  63717. }
  63718. if (colorArr) {
  63719. el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]);
  63720. el.opacity = opacity * colorArr[3];
  63721. }
  63722. };
  63723. var getColorAndAlpha = function (color) {
  63724. var colorArr = colorTool.parse(color);
  63725. return [
  63726. rgb2Str(colorArr[0], colorArr[1], colorArr[2]),
  63727. colorArr[3]
  63728. ];
  63729. };
  63730. var updateFillNode = function (el, style, zrEl) {
  63731. // TODO pattern
  63732. var fill = style.fill;
  63733. if (fill != null) {
  63734. // Modified from excanvas
  63735. if (fill instanceof Gradient) {
  63736. var gradientType;
  63737. var angle = 0;
  63738. var focus = [0, 0];
  63739. // additional offset
  63740. var shift = 0;
  63741. // scale factor for offset
  63742. var expansion = 1;
  63743. var rect = zrEl.getBoundingRect();
  63744. var rectWidth = rect.width;
  63745. var rectHeight = rect.height;
  63746. if (fill.type === 'linear') {
  63747. gradientType = 'gradient';
  63748. var transform = zrEl.transform;
  63749. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  63750. var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight];
  63751. if (transform) {
  63752. applyTransform(p0, p0, transform);
  63753. applyTransform(p1, p1, transform);
  63754. }
  63755. var dx = p1[0] - p0[0];
  63756. var dy = p1[1] - p0[1];
  63757. angle = Math.atan2(dx, dy) * 180 / Math.PI;
  63758. // The angle should be a non-negative number.
  63759. if (angle < 0) {
  63760. angle += 360;
  63761. }
  63762. // Very small angles produce an unexpected result because they are
  63763. // converted to a scientific notation string.
  63764. if (angle < 1e-6) {
  63765. angle = 0;
  63766. }
  63767. }
  63768. else {
  63769. gradientType = 'gradientradial';
  63770. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  63771. var transform = zrEl.transform;
  63772. var scale = zrEl.scale;
  63773. var width = rectWidth;
  63774. var height = rectHeight;
  63775. focus = [
  63776. // Percent in bounding rect
  63777. (p0[0] - rect.x) / width,
  63778. (p0[1] - rect.y) / height
  63779. ];
  63780. if (transform) {
  63781. applyTransform(p0, p0, transform);
  63782. }
  63783. width /= scale[0] * Z;
  63784. height /= scale[1] * Z;
  63785. var dimension = mathMax(width, height);
  63786. shift = 2 * 0 / dimension;
  63787. expansion = 2 * fill.r / dimension - shift;
  63788. }
  63789. // We need to sort the color stops in ascending order by offset,
  63790. // otherwise IE won't interpret it correctly.
  63791. var stops = fill.colorStops.slice();
  63792. stops.sort(function(cs1, cs2) {
  63793. return cs1.offset - cs2.offset;
  63794. });
  63795. var length = stops.length;
  63796. // Color and alpha list of first and last stop
  63797. var colorAndAlphaList = [];
  63798. var colors = [];
  63799. for (var i = 0; i < length; i++) {
  63800. var stop = stops[i];
  63801. var colorAndAlpha = getColorAndAlpha(stop.color);
  63802. colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]);
  63803. if (i === 0 || i === length - 1) {
  63804. colorAndAlphaList.push(colorAndAlpha);
  63805. }
  63806. }
  63807. if (length >= 2) {
  63808. var color1 = colorAndAlphaList[0][0];
  63809. var color2 = colorAndAlphaList[1][0];
  63810. var opacity1 = colorAndAlphaList[0][1] * style.opacity;
  63811. var opacity2 = colorAndAlphaList[1][1] * style.opacity;
  63812. el.type = gradientType;
  63813. el.method = 'none';
  63814. el.focus = '100%';
  63815. el.angle = angle;
  63816. el.color = color1;
  63817. el.color2 = color2;
  63818. el.colors = colors.join(',');
  63819. // When colors attribute is used, the meanings of opacity and o:opacity2
  63820. // are reversed.
  63821. el.opacity = opacity2;
  63822. // FIXME g_o_:opacity ?
  63823. el.opacity2 = opacity1;
  63824. }
  63825. if (gradientType === 'radial') {
  63826. el.focusposition = focus.join(',');
  63827. }
  63828. }
  63829. else {
  63830. // FIXME Change from Gradient fill to color fill
  63831. setColorAndOpacity(el, fill, style.opacity);
  63832. }
  63833. }
  63834. };
  63835. var updateStrokeNode = function (el, style) {
  63836. // if (style.lineJoin != null) {
  63837. // el.joinstyle = style.lineJoin;
  63838. // }
  63839. // if (style.miterLimit != null) {
  63840. // el.miterlimit = style.miterLimit * Z;
  63841. // }
  63842. // if (style.lineCap != null) {
  63843. // el.endcap = style.lineCap;
  63844. // }
  63845. if (style.lineDash != null) {
  63846. el.dashstyle = style.lineDash.join(' ');
  63847. }
  63848. if (style.stroke != null && !(style.stroke instanceof Gradient)) {
  63849. setColorAndOpacity(el, style.stroke, style.opacity);
  63850. }
  63851. };
  63852. var updateFillAndStroke = function (vmlEl, type, style, zrEl) {
  63853. var isFill = type == 'fill';
  63854. var el = vmlEl.getElementsByTagName(type)[0];
  63855. // Stroke must have lineWidth
  63856. if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) {
  63857. vmlEl[isFill ? 'filled' : 'stroked'] = 'true';
  63858. // FIXME Remove before updating, or set `colors` will throw error
  63859. if (style[type] instanceof Gradient) {
  63860. remove(vmlEl, el);
  63861. }
  63862. if (!el) {
  63863. el = vmlCore.createNode(type);
  63864. }
  63865. isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style);
  63866. append(vmlEl, el);
  63867. }
  63868. else {
  63869. vmlEl[isFill ? 'filled' : 'stroked'] = 'false';
  63870. remove(vmlEl, el);
  63871. }
  63872. };
  63873. var points = [[], [], []];
  63874. var pathDataToString = function (data, m) {
  63875. var M = CMD.M;
  63876. var C = CMD.C;
  63877. var L = CMD.L;
  63878. var A = CMD.A;
  63879. var Q = CMD.Q;
  63880. var str = [];
  63881. var nPoint;
  63882. var cmdStr;
  63883. var cmd;
  63884. var i;
  63885. var xi;
  63886. var yi;
  63887. for (i = 0; i < data.length;) {
  63888. cmd = data[i++];
  63889. cmdStr = '';
  63890. nPoint = 0;
  63891. switch (cmd) {
  63892. case M:
  63893. cmdStr = ' m ';
  63894. nPoint = 1;
  63895. xi = data[i++];
  63896. yi = data[i++];
  63897. points[0][0] = xi;
  63898. points[0][1] = yi;
  63899. break;
  63900. case L:
  63901. cmdStr = ' l ';
  63902. nPoint = 1;
  63903. xi = data[i++];
  63904. yi = data[i++];
  63905. points[0][0] = xi;
  63906. points[0][1] = yi;
  63907. break;
  63908. case Q:
  63909. case C:
  63910. cmdStr = ' c ';
  63911. nPoint = 3;
  63912. var x1 = data[i++];
  63913. var y1 = data[i++];
  63914. var x2 = data[i++];
  63915. var y2 = data[i++];
  63916. var x3;
  63917. var y3;
  63918. if (cmd === Q) {
  63919. // Convert quadratic to cubic using degree elevation
  63920. x3 = x2;
  63921. y3 = y2;
  63922. x2 = (x2 + 2 * x1) / 3;
  63923. y2 = (y2 + 2 * y1) / 3;
  63924. x1 = (xi + 2 * x1) / 3;
  63925. y1 = (yi + 2 * y1) / 3;
  63926. }
  63927. else {
  63928. x3 = data[i++];
  63929. y3 = data[i++];
  63930. }
  63931. points[0][0] = x1;
  63932. points[0][1] = y1;
  63933. points[1][0] = x2;
  63934. points[1][1] = y2;
  63935. points[2][0] = x3;
  63936. points[2][1] = y3;
  63937. xi = x3;
  63938. yi = y3;
  63939. break;
  63940. case A:
  63941. var x = 0;
  63942. var y = 0;
  63943. var sx = 1;
  63944. var sy = 1;
  63945. var angle = 0;
  63946. if (m) {
  63947. // Extract SRT from matrix
  63948. x = m[4];
  63949. y = m[5];
  63950. sx = sqrt(m[0] * m[0] + m[1] * m[1]);
  63951. sy = sqrt(m[2] * m[2] + m[3] * m[3]);
  63952. angle = Math.atan2(-m[1] / sy, m[0] / sx);
  63953. }
  63954. var cx = data[i++];
  63955. var cy = data[i++];
  63956. var rx = data[i++];
  63957. var ry = data[i++];
  63958. var startAngle = data[i++] + angle;
  63959. var endAngle = data[i++] + startAngle + angle;
  63960. // FIXME
  63961. // var psi = data[i++];
  63962. i++;
  63963. var clockwise = data[i++];
  63964. var x0 = cx + cos(startAngle) * rx;
  63965. var y0 = cy + sin(startAngle) * ry;
  63966. var x1 = cx + cos(endAngle) * rx;
  63967. var y1 = cy + sin(endAngle) * ry;
  63968. var type = clockwise ? ' wa ' : ' at ';
  63969. if (Math.abs(x0 - x1) < 1e-4) {
  63970. // IE won't render arches drawn counter clockwise if x0 == x1.
  63971. if (Math.abs(endAngle - startAngle) > 1e-2) {
  63972. // Offset x0 by 1/80 of a pixel. Use something
  63973. // that can be represented in binary
  63974. if (clockwise) {
  63975. x0 += 270 / Z;
  63976. }
  63977. }
  63978. else {
  63979. // Avoid case draw full circle
  63980. if (Math.abs(y0 - cy) < 1e-4) {
  63981. if ((clockwise && x0 < cx) || (!clockwise && x0 > cx)) {
  63982. y1 -= 270 / Z;
  63983. }
  63984. else {
  63985. y1 += 270 / Z;
  63986. }
  63987. }
  63988. else if ((clockwise && y0 < cy) || (!clockwise && y0 > cy)) {
  63989. x1 += 270 / Z;
  63990. }
  63991. else {
  63992. x1 -= 270 / Z;
  63993. }
  63994. }
  63995. }
  63996. str.push(
  63997. type,
  63998. round(((cx - rx) * sx + x) * Z - Z2), comma,
  63999. round(((cy - ry) * sy + y) * Z - Z2), comma,
  64000. round(((cx + rx) * sx + x) * Z - Z2), comma,
  64001. round(((cy + ry) * sy + y) * Z - Z2), comma,
  64002. round((x0 * sx + x) * Z - Z2), comma,
  64003. round((y0 * sy + y) * Z - Z2), comma,
  64004. round((x1 * sx + x) * Z - Z2), comma,
  64005. round((y1 * sy + y) * Z - Z2)
  64006. );
  64007. xi = x1;
  64008. yi = y1;
  64009. break;
  64010. case CMD.R:
  64011. var p0 = points[0];
  64012. var p1 = points[1];
  64013. // x0, y0
  64014. p0[0] = data[i++];
  64015. p0[1] = data[i++];
  64016. // x1, y1
  64017. p1[0] = p0[0] + data[i++];
  64018. p1[1] = p0[1] + data[i++];
  64019. if (m) {
  64020. applyTransform(p0, p0, m);
  64021. applyTransform(p1, p1, m);
  64022. }
  64023. p0[0] = round(p0[0] * Z - Z2);
  64024. p1[0] = round(p1[0] * Z - Z2);
  64025. p0[1] = round(p0[1] * Z - Z2);
  64026. p1[1] = round(p1[1] * Z - Z2);
  64027. str.push(
  64028. // x0, y0
  64029. ' m ', p0[0], comma, p0[1],
  64030. // x1, y0
  64031. ' l ', p1[0], comma, p0[1],
  64032. // x1, y1
  64033. ' l ', p1[0], comma, p1[1],
  64034. // x0, y1
  64035. ' l ', p0[0], comma, p1[1]
  64036. );
  64037. break;
  64038. case CMD.Z:
  64039. // FIXME Update xi, yi
  64040. str.push(' x ');
  64041. }
  64042. if (nPoint > 0) {
  64043. str.push(cmdStr);
  64044. for (var k = 0; k < nPoint; k++) {
  64045. var p = points[k];
  64046. m && applyTransform(p, p, m);
  64047. // 不 round 会非常慢
  64048. str.push(
  64049. round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2),
  64050. k < nPoint - 1 ? comma : ''
  64051. );
  64052. }
  64053. }
  64054. }
  64055. return str.join('');
  64056. };
  64057. // Rewrite the original path method
  64058. Path.prototype.brushVML = function (vmlRoot) {
  64059. var style = this.style;
  64060. var vmlEl = this._vmlEl;
  64061. if (!vmlEl) {
  64062. vmlEl = vmlCore.createNode('shape');
  64063. initRootElStyle(vmlEl);
  64064. this._vmlEl = vmlEl;
  64065. }
  64066. updateFillAndStroke(vmlEl, 'fill', style, this);
  64067. updateFillAndStroke(vmlEl, 'stroke', style, this);
  64068. var m = this.transform;
  64069. var needTransform = m != null;
  64070. var strokeEl = vmlEl.getElementsByTagName('stroke')[0];
  64071. if (strokeEl) {
  64072. var lineWidth = style.lineWidth;
  64073. // Get the line scale.
  64074. // Determinant of this.m_ means how much the area is enlarged by the
  64075. // transformation. So its square root can be used as a scale factor
  64076. // for width.
  64077. if (needTransform && !style.strokeNoScale) {
  64078. var det = m[0] * m[3] - m[1] * m[2];
  64079. lineWidth *= sqrt(abs(det));
  64080. }
  64081. strokeEl.weight = lineWidth + 'px';
  64082. }
  64083. var path = this.path || (this.path = new PathProxy());
  64084. if (this.__dirtyPath) {
  64085. path.beginPath();
  64086. this.buildPath(path, this.shape);
  64087. path.toStatic();
  64088. this.__dirtyPath = false;
  64089. }
  64090. vmlEl.path = pathDataToString(path.data, this.transform);
  64091. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  64092. // Append to root
  64093. append(vmlRoot, vmlEl);
  64094. // Text
  64095. if (style.text != null) {
  64096. this.drawRectText(vmlRoot, this.getBoundingRect());
  64097. }
  64098. else {
  64099. this.removeRectText(vmlRoot);
  64100. }
  64101. };
  64102. Path.prototype.onRemove = function (vmlRoot) {
  64103. remove(vmlRoot, this._vmlEl);
  64104. this.removeRectText(vmlRoot);
  64105. };
  64106. Path.prototype.onAdd = function (vmlRoot) {
  64107. append(vmlRoot, this._vmlEl);
  64108. this.appendRectText(vmlRoot);
  64109. };
  64110. /***************************************************
  64111. * IMAGE
  64112. **************************************************/
  64113. var isImage = function (img) {
  64114. // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错
  64115. return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG';
  64116. // return img instanceof Image;
  64117. };
  64118. // Rewrite the original path method
  64119. ZImage.prototype.brushVML = function (vmlRoot) {
  64120. var style = this.style;
  64121. var image = style.image;
  64122. // Image original width, height
  64123. var ow;
  64124. var oh;
  64125. if (isImage(image)) {
  64126. var src = image.src;
  64127. if (src === this._imageSrc) {
  64128. ow = this._imageWidth;
  64129. oh = this._imageHeight;
  64130. }
  64131. else {
  64132. var imageRuntimeStyle = image.runtimeStyle;
  64133. var oldRuntimeWidth = imageRuntimeStyle.width;
  64134. var oldRuntimeHeight = imageRuntimeStyle.height;
  64135. imageRuntimeStyle.width = 'auto';
  64136. imageRuntimeStyle.height = 'auto';
  64137. // get the original size
  64138. ow = image.width;
  64139. oh = image.height;
  64140. // and remove overides
  64141. imageRuntimeStyle.width = oldRuntimeWidth;
  64142. imageRuntimeStyle.height = oldRuntimeHeight;
  64143. // Caching image original width, height and src
  64144. this._imageSrc = src;
  64145. this._imageWidth = ow;
  64146. this._imageHeight = oh;
  64147. }
  64148. image = src;
  64149. }
  64150. else {
  64151. if (image === this._imageSrc) {
  64152. ow = this._imageWidth;
  64153. oh = this._imageHeight;
  64154. }
  64155. }
  64156. if (!image) {
  64157. return;
  64158. }
  64159. var x = style.x || 0;
  64160. var y = style.y || 0;
  64161. var dw = style.width;
  64162. var dh = style.height;
  64163. var sw = style.sWidth;
  64164. var sh = style.sHeight;
  64165. var sx = style.sx || 0;
  64166. var sy = style.sy || 0;
  64167. var hasCrop = sw && sh;
  64168. var vmlEl = this._vmlEl;
  64169. if (!vmlEl) {
  64170. // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。
  64171. // vmlEl = vmlCore.createNode('group');
  64172. vmlEl = vmlCore.doc.createElement('div');
  64173. initRootElStyle(vmlEl);
  64174. this._vmlEl = vmlEl;
  64175. }
  64176. var vmlElStyle = vmlEl.style;
  64177. var hasRotation = false;
  64178. var m;
  64179. var scaleX = 1;
  64180. var scaleY = 1;
  64181. if (this.transform) {
  64182. m = this.transform;
  64183. scaleX = sqrt(m[0] * m[0] + m[1] * m[1]);
  64184. scaleY = sqrt(m[2] * m[2] + m[3] * m[3]);
  64185. hasRotation = m[1] || m[2];
  64186. }
  64187. if (hasRotation) {
  64188. // If filters are necessary (rotation exists), create them
  64189. // filters are bog-slow, so only create them if abbsolutely necessary
  64190. // The following check doesn't account for skews (which don't exist
  64191. // in the canvas spec (yet) anyway.
  64192. // From excanvas
  64193. var p0 = [x, y];
  64194. var p1 = [x + dw, y];
  64195. var p2 = [x, y + dh];
  64196. var p3 = [x + dw, y + dh];
  64197. applyTransform(p0, p0, m);
  64198. applyTransform(p1, p1, m);
  64199. applyTransform(p2, p2, m);
  64200. applyTransform(p3, p3, m);
  64201. var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]);
  64202. var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]);
  64203. var transformFilter = [];
  64204. transformFilter.push('M11=', m[0] / scaleX, comma,
  64205. 'M12=', m[2] / scaleY, comma,
  64206. 'M21=', m[1] / scaleX, comma,
  64207. 'M22=', m[3] / scaleY, comma,
  64208. 'Dx=', round(x * scaleX + m[4]), comma,
  64209. 'Dy=', round(y * scaleY + m[5]));
  64210. vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0';
  64211. // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用
  64212. vmlElStyle.filter = imageTransformPrefix + '.Matrix('
  64213. + transformFilter.join('') + ', SizingMethod=clip)';
  64214. }
  64215. else {
  64216. if (m) {
  64217. x = x * scaleX + m[4];
  64218. y = y * scaleY + m[5];
  64219. }
  64220. vmlElStyle.filter = '';
  64221. vmlElStyle.left = round(x) + 'px';
  64222. vmlElStyle.top = round(y) + 'px';
  64223. }
  64224. var imageEl = this._imageEl;
  64225. var cropEl = this._cropEl;
  64226. if (!imageEl) {
  64227. imageEl = vmlCore.doc.createElement('div');
  64228. this._imageEl = imageEl;
  64229. }
  64230. var imageELStyle = imageEl.style;
  64231. if (hasCrop) {
  64232. // Needs know image original width and height
  64233. if (! (ow && oh)) {
  64234. var tmpImage = new Image();
  64235. var self = this;
  64236. tmpImage.onload = function () {
  64237. tmpImage.onload = null;
  64238. ow = tmpImage.width;
  64239. oh = tmpImage.height;
  64240. // Adjust image width and height to fit the ratio destinationSize / sourceSize
  64241. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  64242. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  64243. // Caching image original width, height and src
  64244. self._imageWidth = ow;
  64245. self._imageHeight = oh;
  64246. self._imageSrc = image;
  64247. };
  64248. tmpImage.src = image;
  64249. }
  64250. else {
  64251. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  64252. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  64253. }
  64254. if (! cropEl) {
  64255. cropEl = vmlCore.doc.createElement('div');
  64256. cropEl.style.overflow = 'hidden';
  64257. this._cropEl = cropEl;
  64258. }
  64259. var cropElStyle = cropEl.style;
  64260. cropElStyle.width = round((dw + sx * dw / sw) * scaleX);
  64261. cropElStyle.height = round((dh + sy * dh / sh) * scaleY);
  64262. cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx='
  64263. + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')';
  64264. if (! cropEl.parentNode) {
  64265. vmlEl.appendChild(cropEl);
  64266. }
  64267. if (imageEl.parentNode != cropEl) {
  64268. cropEl.appendChild(imageEl);
  64269. }
  64270. }
  64271. else {
  64272. imageELStyle.width = round(scaleX * dw) + 'px';
  64273. imageELStyle.height = round(scaleY * dh) + 'px';
  64274. vmlEl.appendChild(imageEl);
  64275. if (cropEl && cropEl.parentNode) {
  64276. vmlEl.removeChild(cropEl);
  64277. this._cropEl = null;
  64278. }
  64279. }
  64280. var filterStr = '';
  64281. var alpha = style.opacity;
  64282. if (alpha < 1) {
  64283. filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') ';
  64284. }
  64285. filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)';
  64286. imageELStyle.filter = filterStr;
  64287. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  64288. // Append to root
  64289. append(vmlRoot, vmlEl);
  64290. // Text
  64291. if (style.text != null) {
  64292. this.drawRectText(vmlRoot, this.getBoundingRect());
  64293. }
  64294. };
  64295. ZImage.prototype.onRemove = function (vmlRoot) {
  64296. remove(vmlRoot, this._vmlEl);
  64297. this._vmlEl = null;
  64298. this._cropEl = null;
  64299. this._imageEl = null;
  64300. this.removeRectText(vmlRoot);
  64301. };
  64302. ZImage.prototype.onAdd = function (vmlRoot) {
  64303. append(vmlRoot, this._vmlEl);
  64304. this.appendRectText(vmlRoot);
  64305. };
  64306. /***************************************************
  64307. * TEXT
  64308. **************************************************/
  64309. var DEFAULT_STYLE_NORMAL = 'normal';
  64310. var fontStyleCache = {};
  64311. var fontStyleCacheCount = 0;
  64312. var MAX_FONT_CACHE_SIZE = 100;
  64313. var fontEl = document.createElement('div');
  64314. var getFontStyle = function (fontString) {
  64315. var fontStyle = fontStyleCache[fontString];
  64316. if (!fontStyle) {
  64317. // Clear cache
  64318. if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) {
  64319. fontStyleCacheCount = 0;
  64320. fontStyleCache = {};
  64321. }
  64322. var style = fontEl.style;
  64323. var fontFamily;
  64324. try {
  64325. style.font = fontString;
  64326. fontFamily = style.fontFamily.split(',')[0];
  64327. }
  64328. catch (e) {
  64329. }
  64330. fontStyle = {
  64331. style: style.fontStyle || DEFAULT_STYLE_NORMAL,
  64332. variant: style.fontVariant || DEFAULT_STYLE_NORMAL,
  64333. weight: style.fontWeight || DEFAULT_STYLE_NORMAL,
  64334. size: parseFloat(style.fontSize || 12) | 0,
  64335. family: fontFamily || 'Microsoft YaHei'
  64336. };
  64337. fontStyleCache[fontString] = fontStyle;
  64338. fontStyleCacheCount++;
  64339. }
  64340. return fontStyle;
  64341. };
  64342. var textMeasureEl;
  64343. // Overwrite measure text method
  64344. textContain.measureText = function (text, textFont) {
  64345. var doc = vmlCore.doc;
  64346. if (!textMeasureEl) {
  64347. textMeasureEl = doc.createElement('div');
  64348. textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;'
  64349. + 'padding:0;margin:0;border:none;white-space:pre;';
  64350. vmlCore.doc.body.appendChild(textMeasureEl);
  64351. }
  64352. try {
  64353. textMeasureEl.style.font = textFont;
  64354. } catch (ex) {
  64355. // Ignore failures to set to invalid font.
  64356. }
  64357. textMeasureEl.innerHTML = '';
  64358. // Don't use innerHTML or innerText because they allow markup/whitespace.
  64359. textMeasureEl.appendChild(doc.createTextNode(text));
  64360. return {
  64361. width: textMeasureEl.offsetWidth
  64362. };
  64363. };
  64364. var tmpRect = new BoundingRect();
  64365. var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) {
  64366. var style = this.style;
  64367. // Optimize, avoid normalize every time.
  64368. this.__dirty && textHelper.normalizeTextStyle(style, true);
  64369. var text = style.text;
  64370. // Convert to string
  64371. text != null && (text += '');
  64372. if (!text) {
  64373. return;
  64374. }
  64375. // Convert rich text to plain text. Rich text is not supported in
  64376. // IE8-, but tags in rich text template will be removed.
  64377. if (style.rich) {
  64378. var contentBlock = textContain.parseRichText(text, style);
  64379. text = [];
  64380. for (var i = 0; i < contentBlock.lines.length; i++) {
  64381. var tokens = contentBlock.lines[i].tokens;
  64382. var textLine = [];
  64383. for (var j = 0; j < tokens.length; j++) {
  64384. textLine.push(tokens[j].text);
  64385. }
  64386. text.push(textLine.join(''));
  64387. }
  64388. text = text.join('\n');
  64389. }
  64390. var x;
  64391. var y;
  64392. var align = style.textAlign;
  64393. var verticalAlign = style.textVerticalAlign;
  64394. var fontStyle = getFontStyle(style.font);
  64395. // FIXME encodeHtmlAttribute ?
  64396. var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' '
  64397. + fontStyle.size + 'px "' + fontStyle.family + '"';
  64398. textRect = textRect || textContain.getBoundingRect(text, font, align, verticalAlign);
  64399. // Transform rect to view space
  64400. var m = this.transform;
  64401. // Ignore transform for text in other element
  64402. if (m && !fromTextEl) {
  64403. tmpRect.copy(rect);
  64404. tmpRect.applyTransform(m);
  64405. rect = tmpRect;
  64406. }
  64407. if (!fromTextEl) {
  64408. var textPosition = style.textPosition;
  64409. var distance = style.textDistance;
  64410. // Text position represented by coord
  64411. if (textPosition instanceof Array) {
  64412. x = rect.x + parsePercent(textPosition[0], rect.width);
  64413. y = rect.y + parsePercent(textPosition[1], rect.height);
  64414. align = align || 'left';
  64415. }
  64416. else {
  64417. var res = textContain.adjustTextPositionOnRect(
  64418. textPosition, rect, distance
  64419. );
  64420. x = res.x;
  64421. y = res.y;
  64422. // Default align and baseline when has textPosition
  64423. align = align || res.textAlign;
  64424. verticalAlign = verticalAlign || res.textVerticalAlign;
  64425. }
  64426. }
  64427. else {
  64428. x = rect.x;
  64429. y = rect.y;
  64430. }
  64431. x = textContain.adjustTextX(x, textRect.width, align);
  64432. y = textContain.adjustTextY(y, textRect.height, verticalAlign);
  64433. // Force baseline 'middle'
  64434. y += textRect.height / 2;
  64435. // var fontSize = fontStyle.size;
  64436. // 1.75 is an arbitrary number, as there is no info about the text baseline
  64437. // switch (baseline) {
  64438. // case 'hanging':
  64439. // case 'top':
  64440. // y += fontSize / 1.75;
  64441. // break;
  64442. // case 'middle':
  64443. // break;
  64444. // default:
  64445. // // case null:
  64446. // // case 'alphabetic':
  64447. // // case 'ideographic':
  64448. // // case 'bottom':
  64449. // y -= fontSize / 2.25;
  64450. // break;
  64451. // }
  64452. // switch (align) {
  64453. // case 'left':
  64454. // break;
  64455. // case 'center':
  64456. // x -= textRect.width / 2;
  64457. // break;
  64458. // case 'right':
  64459. // x -= textRect.width;
  64460. // break;
  64461. // case 'end':
  64462. // align = elementStyle.direction == 'ltr' ? 'right' : 'left';
  64463. // break;
  64464. // case 'start':
  64465. // align = elementStyle.direction == 'rtl' ? 'right' : 'left';
  64466. // break;
  64467. // default:
  64468. // align = 'left';
  64469. // }
  64470. var createNode = vmlCore.createNode;
  64471. var textVmlEl = this._textVmlEl;
  64472. var pathEl;
  64473. var textPathEl;
  64474. var skewEl;
  64475. if (!textVmlEl) {
  64476. textVmlEl = createNode('line');
  64477. pathEl = createNode('path');
  64478. textPathEl = createNode('textpath');
  64479. skewEl = createNode('skew');
  64480. // FIXME Why here is not cammel case
  64481. // Align 'center' seems wrong
  64482. textPathEl.style['v-text-align'] = 'left';
  64483. initRootElStyle(textVmlEl);
  64484. pathEl.textpathok = true;
  64485. textPathEl.on = true;
  64486. textVmlEl.from = '0 0';
  64487. textVmlEl.to = '1000 0.05';
  64488. append(textVmlEl, skewEl);
  64489. append(textVmlEl, pathEl);
  64490. append(textVmlEl, textPathEl);
  64491. this._textVmlEl = textVmlEl;
  64492. }
  64493. else {
  64494. // 这里是在前面 appendChild 保证顺序的前提下
  64495. skewEl = textVmlEl.firstChild;
  64496. pathEl = skewEl.nextSibling;
  64497. textPathEl = pathEl.nextSibling;
  64498. }
  64499. var coords = [x, y];
  64500. var textVmlElStyle = textVmlEl.style;
  64501. // Ignore transform for text in other element
  64502. if (m && fromTextEl) {
  64503. applyTransform(coords, coords, m);
  64504. skewEl.on = true;
  64505. skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma +
  64506. m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0';
  64507. // Text position
  64508. skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0);
  64509. // Left top point as origin
  64510. skewEl.origin = '0 0';
  64511. textVmlElStyle.left = '0px';
  64512. textVmlElStyle.top = '0px';
  64513. }
  64514. else {
  64515. skewEl.on = false;
  64516. textVmlElStyle.left = round(x) + 'px';
  64517. textVmlElStyle.top = round(y) + 'px';
  64518. }
  64519. textPathEl.string = encodeHtmlAttribute(text);
  64520. // TODO
  64521. try {
  64522. textPathEl.style.font = font;
  64523. }
  64524. // Error font format
  64525. catch (e) {}
  64526. updateFillAndStroke(textVmlEl, 'fill', {
  64527. fill: style.textFill,
  64528. opacity: style.opacity
  64529. }, this);
  64530. updateFillAndStroke(textVmlEl, 'stroke', {
  64531. stroke: style.textStroke,
  64532. opacity: style.opacity,
  64533. lineDash: style.lineDash
  64534. }, this);
  64535. textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  64536. // Attached to root
  64537. append(vmlRoot, textVmlEl);
  64538. };
  64539. var removeRectText = function (vmlRoot) {
  64540. remove(vmlRoot, this._textVmlEl);
  64541. this._textVmlEl = null;
  64542. };
  64543. var appendRectText = function (vmlRoot) {
  64544. append(vmlRoot, this._textVmlEl);
  64545. };
  64546. var list = [RectText, Displayable, ZImage, Path, Text];
  64547. // In case Displayable has been mixed in RectText
  64548. for (var i = 0; i < list.length; i++) {
  64549. var proto = list[i].prototype;
  64550. proto.drawRectText = drawRectText;
  64551. proto.removeRectText = removeRectText;
  64552. proto.appendRectText = appendRectText;
  64553. }
  64554. Text.prototype.brushVML = function (vmlRoot) {
  64555. var style = this.style;
  64556. if (style.text != null) {
  64557. this.drawRectText(vmlRoot, {
  64558. x: style.x || 0, y: style.y || 0,
  64559. width: 0, height: 0
  64560. }, this.getBoundingRect(), true);
  64561. }
  64562. else {
  64563. this.removeRectText(vmlRoot);
  64564. }
  64565. };
  64566. Text.prototype.onRemove = function (vmlRoot) {
  64567. this.removeRectText(vmlRoot);
  64568. };
  64569. Text.prototype.onAdd = function (vmlRoot) {
  64570. this.appendRectText(vmlRoot);
  64571. };
  64572. }
  64573. /***/ }),
  64574. /* 434 */
  64575. /***/ (function(module, exports, __webpack_require__) {
  64576. if (!__webpack_require__(2).canvasSupported) {
  64577. var urn = 'urn:schemas-microsoft-com:vml';
  64578. var createNode;
  64579. var win = window;
  64580. var doc = win.document;
  64581. var vmlInited = false;
  64582. try {
  64583. !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn);
  64584. createNode = function (tagName) {
  64585. return doc.createElement('<zrvml:' + tagName + ' class="zrvml">');
  64586. };
  64587. }
  64588. catch (e) {
  64589. createNode = function (tagName) {
  64590. return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">');
  64591. };
  64592. }
  64593. // From raphael
  64594. var initVML = function () {
  64595. if (vmlInited) {
  64596. return;
  64597. }
  64598. vmlInited = true;
  64599. var styleSheets = doc.styleSheets;
  64600. if (styleSheets.length < 31) {
  64601. doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)');
  64602. }
  64603. else {
  64604. // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx
  64605. styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)');
  64606. }
  64607. };
  64608. // Not useing return to avoid error when converting to CommonJS module
  64609. module.exports = {
  64610. doc: doc,
  64611. initVML: initVML,
  64612. createNode: createNode
  64613. };
  64614. }
  64615. /***/ }),
  64616. /* 435 */
  64617. /***/ (function(module, exports, __webpack_require__) {
  64618. /**
  64619. * VML Painter.
  64620. *
  64621. * @module zrender/vml/Painter
  64622. */
  64623. var zrLog = __webpack_require__(34);
  64624. var vmlCore = __webpack_require__(434);
  64625. function parseInt10(val) {
  64626. return parseInt(val, 10);
  64627. }
  64628. /**
  64629. * @alias module:zrender/vml/Painter
  64630. */
  64631. function VMLPainter(root, storage) {
  64632. vmlCore.initVML();
  64633. this.root = root;
  64634. this.storage = storage;
  64635. var vmlViewport = document.createElement('div');
  64636. var vmlRoot = document.createElement('div');
  64637. vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;';
  64638. vmlRoot.style.cssText = 'position:absolute;left:0;top:0;';
  64639. root.appendChild(vmlViewport);
  64640. this._vmlRoot = vmlRoot;
  64641. this._vmlViewport = vmlViewport;
  64642. this.resize();
  64643. // Modify storage
  64644. var oldDelFromStorage = storage.delFromStorage;
  64645. var oldAddToStorage = storage.addToStorage;
  64646. storage.delFromStorage = function (el) {
  64647. oldDelFromStorage.call(storage, el);
  64648. if (el) {
  64649. el.onRemove && el.onRemove(vmlRoot);
  64650. }
  64651. };
  64652. storage.addToStorage = function (el) {
  64653. // Displayable already has a vml node
  64654. el.onAdd && el.onAdd(vmlRoot);
  64655. oldAddToStorage.call(storage, el);
  64656. };
  64657. this._firstPaint = true;
  64658. }
  64659. VMLPainter.prototype = {
  64660. constructor: VMLPainter,
  64661. getType: function () {
  64662. return 'vml';
  64663. },
  64664. /**
  64665. * @return {HTMLDivElement}
  64666. */
  64667. getViewportRoot: function () {
  64668. return this._vmlViewport;
  64669. },
  64670. getViewportRootOffset: function () {
  64671. var viewportRoot = this.getViewportRoot();
  64672. if (viewportRoot) {
  64673. return {
  64674. offsetLeft: viewportRoot.offsetLeft || 0,
  64675. offsetTop: viewportRoot.offsetTop || 0
  64676. };
  64677. }
  64678. },
  64679. /**
  64680. * 刷新
  64681. */
  64682. refresh: function () {
  64683. var list = this.storage.getDisplayList(true, true);
  64684. this._paintList(list);
  64685. },
  64686. _paintList: function (list) {
  64687. var vmlRoot = this._vmlRoot;
  64688. for (var i = 0; i < list.length; i++) {
  64689. var el = list[i];
  64690. if (el.invisible || el.ignore) {
  64691. if (!el.__alreadyNotVisible) {
  64692. el.onRemove(vmlRoot);
  64693. }
  64694. // Set as already invisible
  64695. el.__alreadyNotVisible = true;
  64696. }
  64697. else {
  64698. if (el.__alreadyNotVisible) {
  64699. el.onAdd(vmlRoot);
  64700. }
  64701. el.__alreadyNotVisible = false;
  64702. if (el.__dirty) {
  64703. el.beforeBrush && el.beforeBrush();
  64704. (el.brushVML || el.brush).call(el, vmlRoot);
  64705. el.afterBrush && el.afterBrush();
  64706. }
  64707. }
  64708. el.__dirty = false;
  64709. }
  64710. if (this._firstPaint) {
  64711. // Detached from document at first time
  64712. // to avoid page refreshing too many times
  64713. // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变
  64714. this._vmlViewport.appendChild(vmlRoot);
  64715. this._firstPaint = false;
  64716. }
  64717. },
  64718. resize: function (width, height) {
  64719. var width = width == null ? this._getWidth() : width;
  64720. var height = height == null ? this._getHeight() : height;
  64721. if (this._width != width || this._height != height) {
  64722. this._width = width;
  64723. this._height = height;
  64724. var vmlViewportStyle = this._vmlViewport.style;
  64725. vmlViewportStyle.width = width + 'px';
  64726. vmlViewportStyle.height = height + 'px';
  64727. }
  64728. },
  64729. dispose: function () {
  64730. this.root.innerHTML = '';
  64731. this._vmlRoot =
  64732. this._vmlViewport =
  64733. this.storage = null;
  64734. },
  64735. getWidth: function () {
  64736. return this._width;
  64737. },
  64738. getHeight: function () {
  64739. return this._height;
  64740. },
  64741. clear: function () {
  64742. if (this._vmlViewport) {
  64743. this.root.removeChild(this._vmlViewport);
  64744. }
  64745. },
  64746. _getWidth: function () {
  64747. var root = this.root;
  64748. var stl = root.currentStyle;
  64749. return ((root.clientWidth || parseInt10(stl.width))
  64750. - parseInt10(stl.paddingLeft)
  64751. - parseInt10(stl.paddingRight)) | 0;
  64752. },
  64753. _getHeight: function () {
  64754. var root = this.root;
  64755. var stl = root.currentStyle;
  64756. return ((root.clientHeight || parseInt10(stl.height))
  64757. - parseInt10(stl.paddingTop)
  64758. - parseInt10(stl.paddingBottom)) | 0;
  64759. }
  64760. };
  64761. // Not supported methods
  64762. function createMethodNotSupport(method) {
  64763. return function () {
  64764. zrLog('In IE8.0 VML mode painter not support method "' + method + '"');
  64765. };
  64766. }
  64767. var notSupportedMethods = [
  64768. 'getLayer', 'insertLayer', 'eachLayer', 'eachBuiltinLayer', 'eachOtherLayer', 'getLayers',
  64769. 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage'
  64770. ];
  64771. for (var i = 0; i < notSupportedMethods.length; i++) {
  64772. var name = notSupportedMethods[i];
  64773. VMLPainter.prototype[name] = createMethodNotSupport(name);
  64774. }
  64775. module.exports = VMLPainter;
  64776. /***/ })
  64777. /******/ ])
  64778. });
  64779. ;