echarts.js 2.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108
  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__(113);
  51. __webpack_require__(139);
  52. __webpack_require__(146);
  53. __webpack_require__(155);
  54. __webpack_require__(159);
  55. __webpack_require__(169);
  56. __webpack_require__(193);
  57. __webpack_require__(205);
  58. __webpack_require__(226);
  59. __webpack_require__(230);
  60. __webpack_require__(234);
  61. __webpack_require__(251);
  62. __webpack_require__(257);
  63. __webpack_require__(264);
  64. __webpack_require__(270);
  65. __webpack_require__(274);
  66. __webpack_require__(283);
  67. __webpack_require__(287);
  68. __webpack_require__(290);
  69. __webpack_require__(313);
  70. __webpack_require__(319);
  71. __webpack_require__(320);
  72. __webpack_require__(321);
  73. __webpack_require__(327);
  74. __webpack_require__(298);
  75. __webpack_require__(331);
  76. __webpack_require__(344);
  77. __webpack_require__(235);
  78. __webpack_require__(291);
  79. __webpack_require__(347);
  80. __webpack_require__(358);
  81. __webpack_require__(362);
  82. __webpack_require__(363);
  83. __webpack_require__(376);
  84. __webpack_require__(391);
  85. __webpack_require__(397);
  86. __webpack_require__(400);
  87. __webpack_require__(403);
  88. __webpack_require__(412);
  89. __webpack_require__(424);
  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__(75);
  121. var CoordinateSystemManager = __webpack_require__(76);
  122. var OptionManager = __webpack_require__(77);
  123. var ComponentModel = __webpack_require__(69);
  124. var SeriesModel = __webpack_require__(78);
  125. var ComponentView = __webpack_require__(79);
  126. var ChartView = __webpack_require__(80);
  127. var graphic = __webpack_require__(18);
  128. var modelUtil = __webpack_require__(5);
  129. var throttle = __webpack_require__(81);
  130. var zrender = __webpack_require__(82);
  131. var zrUtil = __webpack_require__(4);
  132. var colorTool = __webpack_require__(31);
  133. var Eventful = __webpack_require__(25);
  134. var timsort = __webpack_require__(86);
  135. var each = zrUtil.each;
  136. var parseClassType = ComponentModel.parseClassType;
  137. var PRIORITY_PROCESSOR_FILTER = 1000;
  138. var PRIORITY_PROCESSOR_STATISTIC = 5000;
  139. var PRIORITY_VISUAL_LAYOUT = 1000;
  140. var PRIORITY_VISUAL_GLOBAL = 2000;
  141. var PRIORITY_VISUAL_CHART = 3000;
  142. var PRIORITY_VISUAL_COMPONENT = 4000;
  143. // FIXME
  144. // necessary?
  145. var PRIORITY_VISUAL_BRUSH = 5000;
  146. // Main process have three entries: `setOption`, `dispatchAction` and `resize`,
  147. // where they must not be invoked nestedly, except the only case: invoke
  148. // dispatchAction with updateMethod "none" in main process.
  149. // This flag is used to carry out this rule.
  150. // All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]).
  151. var IN_MAIN_PROCESS = '__flagInMainProcess';
  152. var HAS_GRADIENT_OR_PATTERN_BG = '__hasGradientOrPatternBg';
  153. var OPTION_UPDATED = '__optionUpdated';
  154. var ACTION_REG = /^[a-zA-Z0-9_]+$/;
  155. function createRegisterEventWithLowercaseName(method) {
  156. return function (eventName, handler, context) {
  157. // Event name is all lowercase
  158. eventName = eventName && eventName.toLowerCase();
  159. Eventful.prototype[method].call(this, eventName, handler, context);
  160. };
  161. }
  162. /**
  163. * @module echarts~MessageCenter
  164. */
  165. function MessageCenter() {
  166. Eventful.call(this);
  167. }
  168. MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on');
  169. MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off');
  170. MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one');
  171. zrUtil.mixin(MessageCenter, Eventful);
  172. /**
  173. * @module echarts~ECharts
  174. */
  175. function ECharts(dom, theme, opts) {
  176. opts = opts || {};
  177. // Get theme by name
  178. if (typeof theme === 'string') {
  179. theme = themeStorage[theme];
  180. }
  181. /**
  182. * @type {string}
  183. */
  184. this.id;
  185. /**
  186. * Group id
  187. * @type {string}
  188. */
  189. this.group;
  190. /**
  191. * @type {HTMLDomElement}
  192. * @private
  193. */
  194. this._dom = dom;
  195. /**
  196. * @type {module:zrender/ZRender}
  197. * @private
  198. */
  199. var zr = this._zr = zrender.init(dom, {
  200. renderer: opts.renderer || 'canvas',
  201. devicePixelRatio: opts.devicePixelRatio,
  202. width: opts.width,
  203. height: opts.height
  204. });
  205. /**
  206. * Expect 60 pfs.
  207. * @type {Function}
  208. * @private
  209. */
  210. this._throttledZrFlush = throttle.throttle(zrUtil.bind(zr.flush, zr), 17);
  211. /**
  212. * @type {Object}
  213. * @private
  214. */
  215. this._theme = zrUtil.clone(theme);
  216. /**
  217. * @type {Array.<module:echarts/view/Chart>}
  218. * @private
  219. */
  220. this._chartsViews = [];
  221. /**
  222. * @type {Object.<string, module:echarts/view/Chart>}
  223. * @private
  224. */
  225. this._chartsMap = {};
  226. /**
  227. * @type {Array.<module:echarts/view/Component>}
  228. * @private
  229. */
  230. this._componentsViews = [];
  231. /**
  232. * @type {Object.<string, module:echarts/view/Component>}
  233. * @private
  234. */
  235. this._componentsMap = {};
  236. /**
  237. * @type {module:echarts/CoordinateSystem}
  238. * @private
  239. */
  240. this._coordSysMgr = new CoordinateSystemManager();
  241. /**
  242. * @type {module:echarts/ExtensionAPI}
  243. * @private
  244. */
  245. this._api = createExtensionAPI(this);
  246. Eventful.call(this);
  247. /**
  248. * @type {module:echarts~MessageCenter}
  249. * @private
  250. */
  251. this._messageCenter = new MessageCenter();
  252. // Init mouse events
  253. this._initEvents();
  254. // In case some people write `window.onresize = chart.resize`
  255. this.resize = zrUtil.bind(this.resize, this);
  256. // Can't dispatch action during rendering procedure
  257. this._pendingActions = [];
  258. // Sort on demand
  259. function prioritySortFunc(a, b) {
  260. return a.prio - b.prio;
  261. }
  262. timsort(visualFuncs, prioritySortFunc);
  263. timsort(dataProcessorFuncs, prioritySortFunc);
  264. zr.animation.on('frame', this._onframe, this);
  265. // ECharts instance can be used as value.
  266. zrUtil.setAsPrimitive(this);
  267. }
  268. var echartsProto = ECharts.prototype;
  269. echartsProto._onframe = function () {
  270. // Lazy update
  271. if (this[OPTION_UPDATED]) {
  272. var silent = this[OPTION_UPDATED].silent;
  273. this[IN_MAIN_PROCESS] = true;
  274. updateMethods.prepareAndUpdate.call(this);
  275. this[IN_MAIN_PROCESS] = false;
  276. this[OPTION_UPDATED] = false;
  277. flushPendingActions.call(this, silent);
  278. triggerUpdatedEvent.call(this, silent);
  279. }
  280. };
  281. /**
  282. * @return {HTMLDomElement}
  283. */
  284. echartsProto.getDom = function () {
  285. return this._dom;
  286. };
  287. /**
  288. * @return {module:zrender~ZRender}
  289. */
  290. echartsProto.getZr = function () {
  291. return this._zr;
  292. };
  293. /**
  294. * Usage:
  295. * chart.setOption(option, notMerge, lazyUpdate);
  296. * chart.setOption(option, {
  297. * notMerge: ...,
  298. * lazyUpdate: ...,
  299. * silent: ...
  300. * });
  301. *
  302. * @param {Object} option
  303. * @param {Object|boolean} [opts] opts or notMerge.
  304. * @param {boolean} [opts.notMerge=false]
  305. * @param {boolean} [opts.lazyUpdate=false] Useful when setOption frequently.
  306. */
  307. echartsProto.setOption = function (option, notMerge, lazyUpdate) {
  308. if (true) {
  309. zrUtil.assert(!this[IN_MAIN_PROCESS], '`setOption` should not be called during main process.');
  310. }
  311. var silent;
  312. if (zrUtil.isObject(notMerge)) {
  313. lazyUpdate = notMerge.lazyUpdate;
  314. silent = notMerge.silent;
  315. notMerge = notMerge.notMerge;
  316. }
  317. this[IN_MAIN_PROCESS] = true;
  318. if (!this._model || notMerge) {
  319. var optionManager = new OptionManager(this._api);
  320. var theme = this._theme;
  321. var ecModel = this._model = new GlobalModel(null, null, theme, optionManager);
  322. ecModel.init(null, null, theme, optionManager);
  323. }
  324. this._model.setOption(option, optionPreprocessorFuncs);
  325. if (lazyUpdate) {
  326. this[OPTION_UPDATED] = {silent: silent};
  327. this[IN_MAIN_PROCESS] = false;
  328. }
  329. else {
  330. updateMethods.prepareAndUpdate.call(this);
  331. // Ensure zr refresh sychronously, and then pixel in canvas can be
  332. // fetched after `setOption`.
  333. this._zr.flush();
  334. this[OPTION_UPDATED] = false;
  335. this[IN_MAIN_PROCESS] = false;
  336. flushPendingActions.call(this, silent);
  337. triggerUpdatedEvent.call(this, silent);
  338. }
  339. };
  340. /**
  341. * @DEPRECATED
  342. */
  343. echartsProto.setTheme = function () {
  344. console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0');
  345. };
  346. /**
  347. * @return {module:echarts/model/Global}
  348. */
  349. echartsProto.getModel = function () {
  350. return this._model;
  351. };
  352. /**
  353. * @return {Object}
  354. */
  355. echartsProto.getOption = function () {
  356. return this._model && this._model.getOption();
  357. };
  358. /**
  359. * @return {number}
  360. */
  361. echartsProto.getWidth = function () {
  362. return this._zr.getWidth();
  363. };
  364. /**
  365. * @return {number}
  366. */
  367. echartsProto.getHeight = function () {
  368. return this._zr.getHeight();
  369. };
  370. /**
  371. * @return {number}
  372. */
  373. echartsProto.getDevicePixelRatio = function () {
  374. return this._zr.painter.dpr || window.devicePixelRatio || 1;
  375. };
  376. /**
  377. * Get canvas which has all thing rendered
  378. * @param {Object} opts
  379. * @param {string} [opts.backgroundColor]
  380. */
  381. echartsProto.getRenderedCanvas = function (opts) {
  382. if (!env.canvasSupported) {
  383. return;
  384. }
  385. opts = opts || {};
  386. opts.pixelRatio = opts.pixelRatio || 1;
  387. opts.backgroundColor = opts.backgroundColor
  388. || this._model.get('backgroundColor');
  389. var zr = this._zr;
  390. var list = zr.storage.getDisplayList();
  391. // Stop animations
  392. zrUtil.each(list, function (el) {
  393. el.stopAnimation(true);
  394. });
  395. return zr.painter.getRenderedCanvas(opts);
  396. };
  397. /**
  398. * @return {string}
  399. * @param {Object} opts
  400. * @param {string} [opts.type='png']
  401. * @param {string} [opts.pixelRatio=1]
  402. * @param {string} [opts.backgroundColor]
  403. * @param {string} [opts.excludeComponents]
  404. */
  405. echartsProto.getDataURL = function (opts) {
  406. opts = opts || {};
  407. var excludeComponents = opts.excludeComponents;
  408. var ecModel = this._model;
  409. var excludesComponentViews = [];
  410. var self = this;
  411. each(excludeComponents, function (componentType) {
  412. ecModel.eachComponent({
  413. mainType: componentType
  414. }, function (component) {
  415. var view = self._componentsMap[component.__viewId];
  416. if (!view.group.ignore) {
  417. excludesComponentViews.push(view);
  418. view.group.ignore = true;
  419. }
  420. });
  421. });
  422. var url = this.getRenderedCanvas(opts).toDataURL(
  423. 'image/' + (opts && opts.type || 'png')
  424. );
  425. each(excludesComponentViews, function (view) {
  426. view.group.ignore = false;
  427. });
  428. return url;
  429. };
  430. /**
  431. * @return {string}
  432. * @param {Object} opts
  433. * @param {string} [opts.type='png']
  434. * @param {string} [opts.pixelRatio=1]
  435. * @param {string} [opts.backgroundColor]
  436. */
  437. echartsProto.getConnectedDataURL = function (opts) {
  438. if (!env.canvasSupported) {
  439. return;
  440. }
  441. var groupId = this.group;
  442. var mathMin = Math.min;
  443. var mathMax = Math.max;
  444. var MAX_NUMBER = Infinity;
  445. if (connectedGroups[groupId]) {
  446. var left = MAX_NUMBER;
  447. var top = MAX_NUMBER;
  448. var right = -MAX_NUMBER;
  449. var bottom = -MAX_NUMBER;
  450. var canvasList = [];
  451. var dpr = (opts && opts.pixelRatio) || 1;
  452. zrUtil.each(instances, function (chart, id) {
  453. if (chart.group === groupId) {
  454. var canvas = chart.getRenderedCanvas(
  455. zrUtil.clone(opts)
  456. );
  457. var boundingRect = chart.getDom().getBoundingClientRect();
  458. left = mathMin(boundingRect.left, left);
  459. top = mathMin(boundingRect.top, top);
  460. right = mathMax(boundingRect.right, right);
  461. bottom = mathMax(boundingRect.bottom, bottom);
  462. canvasList.push({
  463. dom: canvas,
  464. left: boundingRect.left,
  465. top: boundingRect.top
  466. });
  467. }
  468. });
  469. left *= dpr;
  470. top *= dpr;
  471. right *= dpr;
  472. bottom *= dpr;
  473. var width = right - left;
  474. var height = bottom - top;
  475. var targetCanvas = zrUtil.createCanvas();
  476. targetCanvas.width = width;
  477. targetCanvas.height = height;
  478. var zr = zrender.init(targetCanvas);
  479. each(canvasList, function (item) {
  480. var img = new graphic.Image({
  481. style: {
  482. x: item.left * dpr - left,
  483. y: item.top * dpr - top,
  484. image: item.dom
  485. }
  486. });
  487. zr.add(img);
  488. });
  489. zr.refreshImmediately();
  490. return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));
  491. }
  492. else {
  493. return this.getDataURL(opts);
  494. }
  495. };
  496. /**
  497. * Convert from logical coordinate system to pixel coordinate system.
  498. * See CoordinateSystem#convertToPixel.
  499. * @param {string|Object} finder
  500. * If string, e.g., 'geo', means {geoIndex: 0}.
  501. * If Object, could contain some of these properties below:
  502. * {
  503. * seriesIndex / seriesId / seriesName,
  504. * geoIndex / geoId, geoName,
  505. * bmapIndex / bmapId / bmapName,
  506. * xAxisIndex / xAxisId / xAxisName,
  507. * yAxisIndex / yAxisId / yAxisName,
  508. * gridIndex / gridId / gridName,
  509. * ... (can be extended)
  510. * }
  511. * @param {Array|number} value
  512. * @return {Array|number} result
  513. */
  514. echartsProto.convertToPixel = zrUtil.curry(doConvertPixel, 'convertToPixel');
  515. /**
  516. * Convert from pixel coordinate system to logical coordinate system.
  517. * See CoordinateSystem#convertFromPixel.
  518. * @param {string|Object} finder
  519. * If string, e.g., 'geo', means {geoIndex: 0}.
  520. * If Object, could contain some of these properties below:
  521. * {
  522. * seriesIndex / seriesId / seriesName,
  523. * geoIndex / geoId / geoName,
  524. * bmapIndex / bmapId / bmapName,
  525. * xAxisIndex / xAxisId / xAxisName,
  526. * yAxisIndex / yAxisId / yAxisName
  527. * gridIndex / gridId / gridName,
  528. * ... (can be extended)
  529. * }
  530. * @param {Array|number} value
  531. * @return {Array|number} result
  532. */
  533. echartsProto.convertFromPixel = zrUtil.curry(doConvertPixel, 'convertFromPixel');
  534. function doConvertPixel(methodName, finder, value) {
  535. var ecModel = this._model;
  536. var coordSysList = this._coordSysMgr.getCoordinateSystems();
  537. var result;
  538. finder = modelUtil.parseFinder(ecModel, finder);
  539. for (var i = 0; i < coordSysList.length; i++) {
  540. var coordSys = coordSysList[i];
  541. if (coordSys[methodName]
  542. && (result = coordSys[methodName](ecModel, finder, value)) != null
  543. ) {
  544. return result;
  545. }
  546. }
  547. if (true) {
  548. console.warn(
  549. 'No coordinate system that supports ' + methodName + ' found by the given finder.'
  550. );
  551. }
  552. }
  553. /**
  554. * Is the specified coordinate systems or components contain the given pixel point.
  555. * @param {string|Object} finder
  556. * If string, e.g., 'geo', means {geoIndex: 0}.
  557. * If Object, could contain some of these properties below:
  558. * {
  559. * seriesIndex / seriesId / seriesName,
  560. * geoIndex / geoId / geoName,
  561. * bmapIndex / bmapId / bmapName,
  562. * xAxisIndex / xAxisId / xAxisName,
  563. * yAxisIndex / yAxisId / yAxisName,
  564. * gridIndex / gridId / gridName,
  565. * ... (can be extended)
  566. * }
  567. * @param {Array|number} value
  568. * @return {boolean} result
  569. */
  570. echartsProto.containPixel = function (finder, value) {
  571. var ecModel = this._model;
  572. var result;
  573. finder = modelUtil.parseFinder(ecModel, finder);
  574. zrUtil.each(finder, function (models, key) {
  575. key.indexOf('Models') >= 0 && zrUtil.each(models, function (model) {
  576. var coordSys = model.coordinateSystem;
  577. if (coordSys && coordSys.containPoint) {
  578. result |= !!coordSys.containPoint(value);
  579. }
  580. else if (key === 'seriesModels') {
  581. var view = this._chartsMap[model.__viewId];
  582. if (view && view.containPoint) {
  583. result |= view.containPoint(value, model);
  584. }
  585. else {
  586. if (true) {
  587. console.warn(key + ': ' + (view
  588. ? 'The found component do not support containPoint.'
  589. : 'No view mapping to the found component.'
  590. ));
  591. }
  592. }
  593. }
  594. else {
  595. if (true) {
  596. console.warn(key + ': containPoint is not supported');
  597. }
  598. }
  599. }, this);
  600. }, this);
  601. return !!result;
  602. };
  603. /**
  604. * Get visual from series or data.
  605. * @param {string|Object} finder
  606. * If string, e.g., 'series', means {seriesIndex: 0}.
  607. * If Object, could contain some of these properties below:
  608. * {
  609. * seriesIndex / seriesId / seriesName,
  610. * dataIndex / dataIndexInside
  611. * }
  612. * If dataIndex is not specified, series visual will be fetched,
  613. * but not data item visual.
  614. * If all of seriesIndex, seriesId, seriesName are not specified,
  615. * visual will be fetched from first series.
  616. * @param {string} visualType 'color', 'symbol', 'symbolSize'
  617. */
  618. echartsProto.getVisual = function (finder, visualType) {
  619. var ecModel = this._model;
  620. finder = modelUtil.parseFinder(ecModel, finder, {defaultMainType: 'series'});
  621. var seriesModel = finder.seriesModel;
  622. if (true) {
  623. if (!seriesModel) {
  624. console.warn('There is no specified seires model');
  625. }
  626. }
  627. var data = seriesModel.getData();
  628. var dataIndexInside = finder.hasOwnProperty('dataIndexInside')
  629. ? finder.dataIndexInside
  630. : finder.hasOwnProperty('dataIndex')
  631. ? data.indexOfRawIndex(finder.dataIndex)
  632. : null;
  633. return dataIndexInside != null
  634. ? data.getItemVisual(dataIndexInside, visualType)
  635. : data.getVisual(visualType);
  636. };
  637. /**
  638. * Get view of corresponding component model
  639. * @param {module:echarts/model/Component} componentModel
  640. * @return {module:echarts/view/Component}
  641. */
  642. echartsProto.getViewOfComponentModel = function (componentModel) {
  643. return this._componentsMap[componentModel.__viewId];
  644. };
  645. /**
  646. * Get view of corresponding series model
  647. * @param {module:echarts/model/Series} seriesModel
  648. * @return {module:echarts/view/Chart}
  649. */
  650. echartsProto.getViewOfSeriesModel = function (seriesModel) {
  651. return this._chartsMap[seriesModel.__viewId];
  652. };
  653. var updateMethods = {
  654. /**
  655. * @param {Object} payload
  656. * @private
  657. */
  658. update: function (payload) {
  659. // console.profile && console.profile('update');
  660. var ecModel = this._model;
  661. var api = this._api;
  662. var coordSysMgr = this._coordSysMgr;
  663. var zr = this._zr;
  664. // update before setOption
  665. if (!ecModel) {
  666. return;
  667. }
  668. // Fixme First time update ?
  669. ecModel.restoreData();
  670. // TODO
  671. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  672. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  673. // Create new coordinate system each update
  674. // In LineView may save the old coordinate system and use it to get the orignal point
  675. coordSysMgr.create(this._model, this._api);
  676. processData.call(this, ecModel, api);
  677. stackSeriesData.call(this, ecModel);
  678. coordSysMgr.update(ecModel, api);
  679. doVisualEncoding.call(this, ecModel, payload);
  680. doRender.call(this, ecModel, payload);
  681. // Set background
  682. var backgroundColor = ecModel.get('backgroundColor') || 'transparent';
  683. var painter = zr.painter;
  684. // TODO all use clearColor ?
  685. if (painter.isSingleCanvas && painter.isSingleCanvas()) {
  686. zr.configLayer(0, {
  687. clearColor: backgroundColor
  688. });
  689. }
  690. else {
  691. // In IE8
  692. if (!env.canvasSupported) {
  693. var colorArr = colorTool.parse(backgroundColor);
  694. backgroundColor = colorTool.stringify(colorArr, 'rgb');
  695. if (colorArr[3] === 0) {
  696. backgroundColor = 'transparent';
  697. }
  698. }
  699. if (backgroundColor.colorStops || backgroundColor.image) {
  700. // Gradient background
  701. // FIXME Fixed layer?
  702. zr.configLayer(0, {
  703. clearColor: backgroundColor
  704. });
  705. this[HAS_GRADIENT_OR_PATTERN_BG] = true;
  706. this._dom.style.background = 'transparent';
  707. }
  708. else {
  709. if (this[HAS_GRADIENT_OR_PATTERN_BG]) {
  710. zr.configLayer(0, {
  711. clearColor: null
  712. });
  713. }
  714. this[HAS_GRADIENT_OR_PATTERN_BG] = false;
  715. this._dom.style.background = backgroundColor;
  716. }
  717. }
  718. each(postUpdateFuncs, function (func) {
  719. func(ecModel, api);
  720. });
  721. // console.profile && console.profileEnd('update');
  722. },
  723. /**
  724. * @param {Object} payload
  725. * @private
  726. */
  727. updateView: function (payload) {
  728. var ecModel = this._model;
  729. // update before setOption
  730. if (!ecModel) {
  731. return;
  732. }
  733. ecModel.eachSeries(function (seriesModel) {
  734. seriesModel.getData().clearAllVisual();
  735. });
  736. doVisualEncoding.call(this, ecModel, payload);
  737. invokeUpdateMethod.call(this, 'updateView', ecModel, payload);
  738. },
  739. /**
  740. * @param {Object} payload
  741. * @private
  742. */
  743. updateVisual: function (payload) {
  744. var ecModel = this._model;
  745. // update before setOption
  746. if (!ecModel) {
  747. return;
  748. }
  749. ecModel.eachSeries(function (seriesModel) {
  750. seriesModel.getData().clearAllVisual();
  751. });
  752. doVisualEncoding.call(this, ecModel, payload, true);
  753. invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload);
  754. },
  755. /**
  756. * @param {Object} payload
  757. * @private
  758. */
  759. updateLayout: function (payload) {
  760. var ecModel = this._model;
  761. // update before setOption
  762. if (!ecModel) {
  763. return;
  764. }
  765. doLayout.call(this, ecModel, payload);
  766. invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload);
  767. },
  768. /**
  769. * @param {Object} payload
  770. * @private
  771. */
  772. prepareAndUpdate: function (payload) {
  773. var ecModel = this._model;
  774. prepareView.call(this, 'component', ecModel);
  775. prepareView.call(this, 'chart', ecModel);
  776. updateMethods.update.call(this, payload);
  777. }
  778. };
  779. /**
  780. * @private
  781. */
  782. function updateDirectly(ecIns, method, payload, mainType, subType) {
  783. var ecModel = ecIns._model;
  784. // broadcast
  785. if (!mainType) {
  786. each(ecIns._componentsViews.concat(ecIns._chartsViews), callView);
  787. return;
  788. }
  789. var query = {};
  790. query[mainType + 'Id'] = payload[mainType + 'Id'];
  791. query[mainType + 'Index'] = payload[mainType + 'Index'];
  792. query[mainType + 'Name'] = payload[mainType + 'Name'];
  793. var condition = {mainType: mainType, query: query};
  794. subType && (condition.subType = subType); // subType may be '' by parseClassType;
  795. // If dispatchAction before setOption, do nothing.
  796. ecModel && ecModel.eachComponent(condition, function (model, index) {
  797. callView(ecIns[
  798. mainType === 'series' ? '_chartsMap' : '_componentsMap'
  799. ][model.__viewId]);
  800. }, ecIns);
  801. function callView(view) {
  802. view && view.__alive && view[method] && view[method](
  803. view.__model, ecModel, ecIns._api, payload
  804. );
  805. }
  806. }
  807. /**
  808. * Resize the chart
  809. * @param {Object} opts
  810. * @param {number} [opts.width] Can be 'auto' (the same as null/undefined)
  811. * @param {number} [opts.height] Can be 'auto' (the same as null/undefined)
  812. * @param {boolean} [opts.silent=false]
  813. */
  814. echartsProto.resize = function (opts) {
  815. if (true) {
  816. zrUtil.assert(!this[IN_MAIN_PROCESS], '`resize` should not be called during main process.');
  817. }
  818. this[IN_MAIN_PROCESS] = true;
  819. this._zr.resize(opts);
  820. var optionChanged = this._model && this._model.resetOption('media');
  821. var updateMethod = optionChanged ? 'prepareAndUpdate' : 'update';
  822. updateMethods[updateMethod].call(this);
  823. // Resize loading effect
  824. this._loadingFX && this._loadingFX.resize();
  825. this[IN_MAIN_PROCESS] = false;
  826. var silent = opts && opts.silent;
  827. flushPendingActions.call(this, silent);
  828. triggerUpdatedEvent.call(this, silent);
  829. };
  830. /**
  831. * Show loading effect
  832. * @param {string} [name='default']
  833. * @param {Object} [cfg]
  834. */
  835. echartsProto.showLoading = function (name, cfg) {
  836. if (zrUtil.isObject(name)) {
  837. cfg = name;
  838. name = '';
  839. }
  840. name = name || 'default';
  841. this.hideLoading();
  842. if (!loadingEffects[name]) {
  843. if (true) {
  844. console.warn('Loading effects ' + name + ' not exists.');
  845. }
  846. return;
  847. }
  848. var el = loadingEffects[name](this._api, cfg);
  849. var zr = this._zr;
  850. this._loadingFX = el;
  851. zr.add(el);
  852. };
  853. /**
  854. * Hide loading effect
  855. */
  856. echartsProto.hideLoading = function () {
  857. this._loadingFX && this._zr.remove(this._loadingFX);
  858. this._loadingFX = null;
  859. };
  860. /**
  861. * @param {Object} eventObj
  862. * @return {Object}
  863. */
  864. echartsProto.makeActionFromEvent = function (eventObj) {
  865. var payload = zrUtil.extend({}, eventObj);
  866. payload.type = eventActionMap[eventObj.type];
  867. return payload;
  868. };
  869. /**
  870. * @pubilc
  871. * @param {Object} payload
  872. * @param {string} [payload.type] Action type
  873. * @param {Object|boolean} [opt] If pass boolean, means opt.silent
  874. * @param {boolean} [opt.silent=false] Whether trigger events.
  875. * @param {boolean} [opt.flush=undefined]
  876. * true: Flush immediately, and then pixel in canvas can be fetched
  877. * immediately. Caution: it might affect performance.
  878. * false: Not not flush.
  879. * undefined: Auto decide whether perform flush.
  880. */
  881. echartsProto.dispatchAction = function (payload, opt) {
  882. if (!zrUtil.isObject(opt)) {
  883. opt = {silent: !!opt};
  884. }
  885. if (!actions[payload.type]) {
  886. return;
  887. }
  888. // May dispatchAction in rendering procedure
  889. if (this[IN_MAIN_PROCESS]) {
  890. this._pendingActions.push(payload);
  891. return;
  892. }
  893. doDispatchAction.call(this, payload, opt.silent);
  894. if (opt.flush) {
  895. this._zr.flush(true);
  896. }
  897. else if (opt.flush !== false && env.browser.weChat) {
  898. // In WeChat embeded browser, `requestAnimationFrame` and `setInterval`
  899. // hang when sliding page (on touch event), which cause that zr does not
  900. // refresh util user interaction finished, which is not expected.
  901. // But `dispatchAction` may be called too frequently when pan on touch
  902. // screen, which impacts performance if do not throttle them.
  903. this._throttledZrFlush();
  904. }
  905. flushPendingActions.call(this, opt.silent);
  906. triggerUpdatedEvent.call(this, opt.silent);
  907. };
  908. function doDispatchAction(payload, silent) {
  909. var payloadType = payload.type;
  910. var escapeConnect = payload.escapeConnect;
  911. var actionWrap = actions[payloadType];
  912. var actionInfo = actionWrap.actionInfo;
  913. var cptType = (actionInfo.update || 'update').split(':');
  914. var updateMethod = cptType.pop();
  915. cptType = cptType[0] != null && parseClassType(cptType[0]);
  916. this[IN_MAIN_PROCESS] = true;
  917. var payloads = [payload];
  918. var batched = false;
  919. // Batch action
  920. if (payload.batch) {
  921. batched = true;
  922. payloads = zrUtil.map(payload.batch, function (item) {
  923. item = zrUtil.defaults(zrUtil.extend({}, item), payload);
  924. item.batch = null;
  925. return item;
  926. });
  927. }
  928. var eventObjBatch = [];
  929. var eventObj;
  930. var isHighDown = payloadType === 'highlight' || payloadType === 'downplay';
  931. each(payloads, function (batchItem) {
  932. // Action can specify the event by return it.
  933. eventObj = actionWrap.action(batchItem, this._model, this._api);
  934. // Emit event outside
  935. eventObj = eventObj || zrUtil.extend({}, batchItem);
  936. // Convert type to eventType
  937. eventObj.type = actionInfo.event || eventObj.type;
  938. eventObjBatch.push(eventObj);
  939. // light update does not perform data process, layout and visual.
  940. if (isHighDown) {
  941. // method, payload, mainType, subType
  942. updateDirectly(this, updateMethod, batchItem, 'series');
  943. }
  944. else if (cptType) {
  945. updateDirectly(this, updateMethod, batchItem, cptType.main, cptType.sub);
  946. }
  947. }, this);
  948. if (updateMethod !== 'none' && !isHighDown && !cptType) {
  949. // Still dirty
  950. if (this[OPTION_UPDATED]) {
  951. // FIXME Pass payload ?
  952. updateMethods.prepareAndUpdate.call(this, payload);
  953. this[OPTION_UPDATED] = false;
  954. }
  955. else {
  956. updateMethods[updateMethod].call(this, payload);
  957. }
  958. }
  959. // Follow the rule of action batch
  960. if (batched) {
  961. eventObj = {
  962. type: actionInfo.event || payloadType,
  963. escapeConnect: escapeConnect,
  964. batch: eventObjBatch
  965. };
  966. }
  967. else {
  968. eventObj = eventObjBatch[0];
  969. }
  970. this[IN_MAIN_PROCESS] = false;
  971. !silent && this._messageCenter.trigger(eventObj.type, eventObj);
  972. }
  973. function flushPendingActions(silent) {
  974. var pendingActions = this._pendingActions;
  975. while (pendingActions.length) {
  976. var payload = pendingActions.shift();
  977. doDispatchAction.call(this, payload, silent);
  978. }
  979. }
  980. function triggerUpdatedEvent(silent) {
  981. !silent && this.trigger('updated');
  982. }
  983. /**
  984. * Register event
  985. * @method
  986. */
  987. echartsProto.on = createRegisterEventWithLowercaseName('on');
  988. echartsProto.off = createRegisterEventWithLowercaseName('off');
  989. echartsProto.one = createRegisterEventWithLowercaseName('one');
  990. /**
  991. * @param {string} methodName
  992. * @private
  993. */
  994. function invokeUpdateMethod(methodName, ecModel, payload) {
  995. var api = this._api;
  996. // Update all components
  997. each(this._componentsViews, function (component) {
  998. var componentModel = component.__model;
  999. component[methodName](componentModel, ecModel, api, payload);
  1000. updateZ(componentModel, component);
  1001. }, this);
  1002. // Upate all charts
  1003. ecModel.eachSeries(function (seriesModel, idx) {
  1004. var chart = this._chartsMap[seriesModel.__viewId];
  1005. chart[methodName](seriesModel, ecModel, api, payload);
  1006. updateZ(seriesModel, chart);
  1007. updateProgressiveAndBlend(seriesModel, chart);
  1008. }, this);
  1009. // If use hover layer
  1010. updateHoverLayerStatus(this._zr, ecModel);
  1011. // Post render
  1012. each(postUpdateFuncs, function (func) {
  1013. func(ecModel, api);
  1014. });
  1015. }
  1016. /**
  1017. * Prepare view instances of charts and components
  1018. * @param {module:echarts/model/Global} ecModel
  1019. * @private
  1020. */
  1021. function prepareView(type, ecModel) {
  1022. var isComponent = type === 'component';
  1023. var viewList = isComponent ? this._componentsViews : this._chartsViews;
  1024. var viewMap = isComponent ? this._componentsMap : this._chartsMap;
  1025. var zr = this._zr;
  1026. for (var i = 0; i < viewList.length; i++) {
  1027. viewList[i].__alive = false;
  1028. }
  1029. ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) {
  1030. if (isComponent) {
  1031. if (componentType === 'series') {
  1032. return;
  1033. }
  1034. }
  1035. else {
  1036. model = componentType;
  1037. }
  1038. // Consider: id same and type changed.
  1039. var viewId = '_ec_' + model.id + '_' + model.type;
  1040. var view = viewMap[viewId];
  1041. if (!view) {
  1042. var classType = parseClassType(model.type);
  1043. var Clazz = isComponent
  1044. ? ComponentView.getClass(classType.main, classType.sub)
  1045. : ChartView.getClass(classType.sub);
  1046. if (Clazz) {
  1047. view = new Clazz();
  1048. view.init(ecModel, this._api);
  1049. viewMap[viewId] = view;
  1050. viewList.push(view);
  1051. zr.add(view.group);
  1052. }
  1053. else {
  1054. // Error
  1055. return;
  1056. }
  1057. }
  1058. model.__viewId = view.__id = viewId;
  1059. view.__alive = true;
  1060. view.__model = model;
  1061. view.group.__ecComponentInfo = {
  1062. mainType: model.mainType,
  1063. index: model.componentIndex
  1064. };
  1065. }, this);
  1066. for (var i = 0; i < viewList.length;) {
  1067. var view = viewList[i];
  1068. if (!view.__alive) {
  1069. zr.remove(view.group);
  1070. view.dispose(ecModel, this._api);
  1071. viewList.splice(i, 1);
  1072. delete viewMap[view.__id];
  1073. view.__id = view.group.__ecComponentInfo = null;
  1074. }
  1075. else {
  1076. i++;
  1077. }
  1078. }
  1079. }
  1080. /**
  1081. * Processor data in each series
  1082. *
  1083. * @param {module:echarts/model/Global} ecModel
  1084. * @private
  1085. */
  1086. function processData(ecModel, api) {
  1087. each(dataProcessorFuncs, function (process) {
  1088. process.func(ecModel, api);
  1089. });
  1090. }
  1091. /**
  1092. * @private
  1093. */
  1094. function stackSeriesData(ecModel) {
  1095. var stackedDataMap = {};
  1096. ecModel.eachSeries(function (series) {
  1097. var stack = series.get('stack');
  1098. var data = series.getData();
  1099. if (stack && data.type === 'list') {
  1100. var previousStack = stackedDataMap[stack];
  1101. // Avoid conflict with Object.prototype
  1102. if (stackedDataMap.hasOwnProperty(stack) && previousStack) {
  1103. data.stackedOn = previousStack;
  1104. }
  1105. stackedDataMap[stack] = data;
  1106. }
  1107. });
  1108. }
  1109. /**
  1110. * Layout before each chart render there series, special visual encoding stage
  1111. *
  1112. * @param {module:echarts/model/Global} ecModel
  1113. * @private
  1114. */
  1115. function doLayout(ecModel, payload) {
  1116. var api = this._api;
  1117. each(visualFuncs, function (visual) {
  1118. if (visual.isLayout) {
  1119. visual.func(ecModel, api, payload);
  1120. }
  1121. });
  1122. }
  1123. /**
  1124. * Encode visual infomation from data after data processing
  1125. *
  1126. * @param {module:echarts/model/Global} ecModel
  1127. * @param {object} layout
  1128. * @param {boolean} [excludesLayout]
  1129. * @private
  1130. */
  1131. function doVisualEncoding(ecModel, payload, excludesLayout) {
  1132. var api = this._api;
  1133. ecModel.clearColorPalette();
  1134. ecModel.eachSeries(function (seriesModel) {
  1135. seriesModel.clearColorPalette();
  1136. });
  1137. each(visualFuncs, function (visual) {
  1138. (!excludesLayout || !visual.isLayout)
  1139. && visual.func(ecModel, api, payload);
  1140. });
  1141. }
  1142. /**
  1143. * Render each chart and component
  1144. * @private
  1145. */
  1146. function doRender(ecModel, payload) {
  1147. var api = this._api;
  1148. // Render all components
  1149. each(this._componentsViews, function (componentView) {
  1150. var componentModel = componentView.__model;
  1151. componentView.render(componentModel, ecModel, api, payload);
  1152. updateZ(componentModel, componentView);
  1153. }, this);
  1154. each(this._chartsViews, function (chart) {
  1155. chart.__alive = false;
  1156. }, this);
  1157. // Render all charts
  1158. ecModel.eachSeries(function (seriesModel, idx) {
  1159. var chartView = this._chartsMap[seriesModel.__viewId];
  1160. chartView.__alive = true;
  1161. chartView.render(seriesModel, ecModel, api, payload);
  1162. chartView.group.silent = !!seriesModel.get('silent');
  1163. updateZ(seriesModel, chartView);
  1164. updateProgressiveAndBlend(seriesModel, chartView);
  1165. }, this);
  1166. // If use hover layer
  1167. updateHoverLayerStatus(this._zr, ecModel);
  1168. // Remove groups of unrendered charts
  1169. each(this._chartsViews, function (chart) {
  1170. if (!chart.__alive) {
  1171. chart.remove(ecModel, api);
  1172. }
  1173. }, this);
  1174. }
  1175. var MOUSE_EVENT_NAMES = [
  1176. 'click', 'dblclick', 'mouseover', 'mouseout', 'mousemove',
  1177. 'mousedown', 'mouseup', 'globalout', 'contextmenu'
  1178. ];
  1179. /**
  1180. * @private
  1181. */
  1182. echartsProto._initEvents = function () {
  1183. each(MOUSE_EVENT_NAMES, function (eveName) {
  1184. this._zr.on(eveName, function (e) {
  1185. var ecModel = this.getModel();
  1186. var el = e.target;
  1187. var params;
  1188. // no e.target when 'globalout'.
  1189. if (eveName === 'globalout') {
  1190. params = {};
  1191. }
  1192. else if (el && el.dataIndex != null) {
  1193. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  1194. params = dataModel && dataModel.getDataParams(el.dataIndex, el.dataType) || {};
  1195. }
  1196. // If element has custom eventData of components
  1197. else if (el && el.eventData) {
  1198. params = zrUtil.extend({}, el.eventData);
  1199. }
  1200. if (params) {
  1201. params.event = e;
  1202. params.type = eveName;
  1203. this.trigger(eveName, params);
  1204. }
  1205. }, this);
  1206. }, this);
  1207. each(eventActionMap, function (actionType, eventType) {
  1208. this._messageCenter.on(eventType, function (event) {
  1209. this.trigger(eventType, event);
  1210. }, this);
  1211. }, this);
  1212. };
  1213. /**
  1214. * @return {boolean}
  1215. */
  1216. echartsProto.isDisposed = function () {
  1217. return this._disposed;
  1218. };
  1219. /**
  1220. * Clear
  1221. */
  1222. echartsProto.clear = function () {
  1223. this.setOption({ series: [] }, true);
  1224. };
  1225. /**
  1226. * Dispose instance
  1227. */
  1228. echartsProto.dispose = function () {
  1229. if (this._disposed) {
  1230. if (true) {
  1231. console.warn('Instance ' + this.id + ' has been disposed');
  1232. }
  1233. return;
  1234. }
  1235. this._disposed = true;
  1236. var api = this._api;
  1237. var ecModel = this._model;
  1238. each(this._componentsViews, function (component) {
  1239. component.dispose(ecModel, api);
  1240. });
  1241. each(this._chartsViews, function (chart) {
  1242. chart.dispose(ecModel, api);
  1243. });
  1244. // Dispose after all views disposed
  1245. this._zr.dispose();
  1246. delete instances[this.id];
  1247. };
  1248. zrUtil.mixin(ECharts, Eventful);
  1249. function updateHoverLayerStatus(zr, ecModel) {
  1250. var storage = zr.storage;
  1251. var elCount = 0;
  1252. storage.traverse(function (el) {
  1253. if (!el.isGroup) {
  1254. elCount++;
  1255. }
  1256. });
  1257. if (elCount > ecModel.get('hoverLayerThreshold') && !env.node) {
  1258. storage.traverse(function (el) {
  1259. if (!el.isGroup) {
  1260. el.useHoverLayer = true;
  1261. }
  1262. });
  1263. }
  1264. }
  1265. /**
  1266. * Update chart progressive and blend.
  1267. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  1268. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  1269. */
  1270. function updateProgressiveAndBlend(seriesModel, chartView) {
  1271. // Progressive configuration
  1272. var elCount = 0;
  1273. chartView.group.traverse(function (el) {
  1274. if (el.type !== 'group' && !el.ignore) {
  1275. elCount++;
  1276. }
  1277. });
  1278. var frameDrawNum = +seriesModel.get('progressive');
  1279. var needProgressive = elCount > seriesModel.get('progressiveThreshold') && frameDrawNum && !env.node;
  1280. if (needProgressive) {
  1281. chartView.group.traverse(function (el) {
  1282. // FIXME marker and other components
  1283. if (!el.isGroup) {
  1284. el.progressive = needProgressive ?
  1285. Math.floor(elCount++ / frameDrawNum) : -1;
  1286. if (needProgressive) {
  1287. el.stopAnimation(true);
  1288. }
  1289. }
  1290. });
  1291. }
  1292. // Blend configration
  1293. var blendMode = seriesModel.get('blendMode') || null;
  1294. if (true) {
  1295. if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {
  1296. console.warn('Only canvas support blendMode');
  1297. }
  1298. }
  1299. chartView.group.traverse(function (el) {
  1300. // FIXME marker and other components
  1301. if (!el.isGroup) {
  1302. el.setStyle('blend', blendMode);
  1303. }
  1304. });
  1305. }
  1306. /**
  1307. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  1308. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  1309. */
  1310. function updateZ(model, view) {
  1311. var z = model.get('z');
  1312. var zlevel = model.get('zlevel');
  1313. // Set z and zlevel
  1314. view.group.traverse(function (el) {
  1315. if (el.type !== 'group') {
  1316. z != null && (el.z = z);
  1317. zlevel != null && (el.zlevel = zlevel);
  1318. }
  1319. });
  1320. }
  1321. function createExtensionAPI(ecInstance) {
  1322. var coordSysMgr = ecInstance._coordSysMgr;
  1323. return zrUtil.extend(new ExtensionAPI(ecInstance), {
  1324. // Inject methods
  1325. getCoordinateSystems: zrUtil.bind(
  1326. coordSysMgr.getCoordinateSystems, coordSysMgr
  1327. ),
  1328. getComponentByElement: function (el) {
  1329. while (el) {
  1330. var modelInfo = el.__ecComponentInfo;
  1331. if (modelInfo != null) {
  1332. return ecInstance._model.getComponent(modelInfo.mainType, modelInfo.index);
  1333. }
  1334. el = el.parent;
  1335. }
  1336. }
  1337. });
  1338. }
  1339. /**
  1340. * @type {Object} key: actionType.
  1341. * @inner
  1342. */
  1343. var actions = {};
  1344. /**
  1345. * Map eventType to actionType
  1346. * @type {Object}
  1347. */
  1348. var eventActionMap = {};
  1349. /**
  1350. * Data processor functions of each stage
  1351. * @type {Array.<Object.<string, Function>>}
  1352. * @inner
  1353. */
  1354. var dataProcessorFuncs = [];
  1355. /**
  1356. * @type {Array.<Function>}
  1357. * @inner
  1358. */
  1359. var optionPreprocessorFuncs = [];
  1360. /**
  1361. * @type {Array.<Function>}
  1362. * @inner
  1363. */
  1364. var postUpdateFuncs = [];
  1365. /**
  1366. * Visual encoding functions of each stage
  1367. * @type {Array.<Object.<string, Function>>}
  1368. * @inner
  1369. */
  1370. var visualFuncs = [];
  1371. /**
  1372. * Theme storage
  1373. * @type {Object.<key, Object>}
  1374. */
  1375. var themeStorage = {};
  1376. /**
  1377. * Loading effects
  1378. */
  1379. var loadingEffects = {};
  1380. var instances = {};
  1381. var connectedGroups = {};
  1382. var idBase = new Date() - 0;
  1383. var groupIdBase = new Date() - 0;
  1384. var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
  1385. /**
  1386. * @alias module:echarts
  1387. */
  1388. var echarts = {
  1389. /**
  1390. * @type {number}
  1391. */
  1392. version: '3.6.2',
  1393. dependencies: {
  1394. zrender: '3.5.2'
  1395. }
  1396. };
  1397. function enableConnect(chart) {
  1398. var STATUS_PENDING = 0;
  1399. var STATUS_UPDATING = 1;
  1400. var STATUS_UPDATED = 2;
  1401. var STATUS_KEY = '__connectUpdateStatus';
  1402. function updateConnectedChartsStatus(charts, status) {
  1403. for (var i = 0; i < charts.length; i++) {
  1404. var otherChart = charts[i];
  1405. otherChart[STATUS_KEY] = status;
  1406. }
  1407. }
  1408. zrUtil.each(eventActionMap, function (actionType, eventType) {
  1409. chart._messageCenter.on(eventType, function (event) {
  1410. if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) {
  1411. if (event && event.escapeConnect) {
  1412. return;
  1413. }
  1414. var action = chart.makeActionFromEvent(event);
  1415. var otherCharts = [];
  1416. zrUtil.each(instances, function (otherChart) {
  1417. if (otherChart !== chart && otherChart.group === chart.group) {
  1418. otherCharts.push(otherChart);
  1419. }
  1420. });
  1421. updateConnectedChartsStatus(otherCharts, STATUS_PENDING);
  1422. each(otherCharts, function (otherChart) {
  1423. if (otherChart[STATUS_KEY] !== STATUS_UPDATING) {
  1424. otherChart.dispatchAction(action);
  1425. }
  1426. });
  1427. updateConnectedChartsStatus(otherCharts, STATUS_UPDATED);
  1428. }
  1429. });
  1430. });
  1431. }
  1432. /**
  1433. * @param {HTMLDomElement} dom
  1434. * @param {Object} [theme]
  1435. * @param {Object} opts
  1436. * @param {number} [opts.devicePixelRatio] Use window.devicePixelRatio by default
  1437. * @param {string} [opts.renderer] Currently only 'canvas' is supported.
  1438. * @param {number} [opts.width] Use clientWidth of the input `dom` by default.
  1439. * Can be 'auto' (the same as null/undefined)
  1440. * @param {number} [opts.height] Use clientHeight of the input `dom` by default.
  1441. * Can be 'auto' (the same as null/undefined)
  1442. */
  1443. echarts.init = function (dom, theme, opts) {
  1444. if (true) {
  1445. // Check version
  1446. if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) {
  1447. throw new Error(
  1448. 'ZRender ' + zrender.version
  1449. + ' is too old for ECharts ' + echarts.version
  1450. + '. Current version need ZRender '
  1451. + echarts.dependencies.zrender + '+'
  1452. );
  1453. }
  1454. if (!dom) {
  1455. throw new Error('Initialize failed: invalid dom.');
  1456. }
  1457. }
  1458. var existInstance = echarts.getInstanceByDom(dom);
  1459. if (existInstance) {
  1460. if (true) {
  1461. console.warn('There is a chart instance already initialized on the dom.');
  1462. }
  1463. return existInstance;
  1464. }
  1465. if (true) {
  1466. if (zrUtil.isDom(dom)
  1467. && dom.nodeName.toUpperCase() !== 'CANVAS'
  1468. && (
  1469. (!dom.clientWidth && (!opts || opts.width == null))
  1470. || (!dom.clientHeight && (!opts || opts.height == null))
  1471. )
  1472. ) {
  1473. console.warn('Can\'t get dom width or height');
  1474. }
  1475. }
  1476. var chart = new ECharts(dom, theme, opts);
  1477. chart.id = 'ec_' + idBase++;
  1478. instances[chart.id] = chart;
  1479. if (dom.setAttribute) {
  1480. dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
  1481. }
  1482. else {
  1483. dom[DOM_ATTRIBUTE_KEY] = chart.id;
  1484. }
  1485. enableConnect(chart);
  1486. return chart;
  1487. };
  1488. /**
  1489. * @return {string|Array.<module:echarts~ECharts>} groupId
  1490. */
  1491. echarts.connect = function (groupId) {
  1492. // Is array of charts
  1493. if (zrUtil.isArray(groupId)) {
  1494. var charts = groupId;
  1495. groupId = null;
  1496. // If any chart has group
  1497. zrUtil.each(charts, function (chart) {
  1498. if (chart.group != null) {
  1499. groupId = chart.group;
  1500. }
  1501. });
  1502. groupId = groupId || ('g_' + groupIdBase++);
  1503. zrUtil.each(charts, function (chart) {
  1504. chart.group = groupId;
  1505. });
  1506. }
  1507. connectedGroups[groupId] = true;
  1508. return groupId;
  1509. };
  1510. /**
  1511. * @DEPRECATED
  1512. * @return {string} groupId
  1513. */
  1514. echarts.disConnect = function (groupId) {
  1515. connectedGroups[groupId] = false;
  1516. };
  1517. /**
  1518. * @return {string} groupId
  1519. */
  1520. echarts.disconnect = echarts.disConnect;
  1521. /**
  1522. * Dispose a chart instance
  1523. * @param {module:echarts~ECharts|HTMLDomElement|string} chart
  1524. */
  1525. echarts.dispose = function (chart) {
  1526. if (typeof chart === 'string') {
  1527. chart = instances[chart];
  1528. }
  1529. else if (!(chart instanceof ECharts)){
  1530. // Try to treat as dom
  1531. chart = echarts.getInstanceByDom(chart);
  1532. }
  1533. if ((chart instanceof ECharts) && !chart.isDisposed()) {
  1534. chart.dispose();
  1535. }
  1536. };
  1537. /**
  1538. * @param {HTMLDomElement} dom
  1539. * @return {echarts~ECharts}
  1540. */
  1541. echarts.getInstanceByDom = function (dom) {
  1542. var key;
  1543. if (dom.getAttribute) {
  1544. key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
  1545. }
  1546. else {
  1547. key = dom[DOM_ATTRIBUTE_KEY];
  1548. }
  1549. return instances[key];
  1550. };
  1551. /**
  1552. * @param {string} key
  1553. * @return {echarts~ECharts}
  1554. */
  1555. echarts.getInstanceById = function (key) {
  1556. return instances[key];
  1557. };
  1558. /**
  1559. * Register theme
  1560. */
  1561. echarts.registerTheme = function (name, theme) {
  1562. themeStorage[name] = theme;
  1563. };
  1564. /**
  1565. * Register option preprocessor
  1566. * @param {Function} preprocessorFunc
  1567. */
  1568. echarts.registerPreprocessor = function (preprocessorFunc) {
  1569. optionPreprocessorFuncs.push(preprocessorFunc);
  1570. };
  1571. /**
  1572. * @param {number} [priority=1000]
  1573. * @param {Function} processorFunc
  1574. */
  1575. echarts.registerProcessor = function (priority, processorFunc) {
  1576. if (typeof priority === 'function') {
  1577. processorFunc = priority;
  1578. priority = PRIORITY_PROCESSOR_FILTER;
  1579. }
  1580. if (true) {
  1581. if (isNaN(priority)) {
  1582. throw new Error('Unkown processor priority');
  1583. }
  1584. }
  1585. dataProcessorFuncs.push({
  1586. prio: priority,
  1587. func: processorFunc
  1588. });
  1589. };
  1590. /**
  1591. * Register postUpdater
  1592. * @param {Function} postUpdateFunc
  1593. */
  1594. echarts.registerPostUpdate = function (postUpdateFunc) {
  1595. postUpdateFuncs.push(postUpdateFunc);
  1596. };
  1597. /**
  1598. * Usage:
  1599. * registerAction('someAction', 'someEvent', function () { ... });
  1600. * registerAction('someAction', function () { ... });
  1601. * registerAction(
  1602. * {type: 'someAction', event: 'someEvent', update: 'updateView'},
  1603. * function () { ... }
  1604. * );
  1605. *
  1606. * @param {(string|Object)} actionInfo
  1607. * @param {string} actionInfo.type
  1608. * @param {string} [actionInfo.event]
  1609. * @param {string} [actionInfo.update]
  1610. * @param {string} [eventName]
  1611. * @param {Function} action
  1612. */
  1613. echarts.registerAction = function (actionInfo, eventName, action) {
  1614. if (typeof eventName === 'function') {
  1615. action = eventName;
  1616. eventName = '';
  1617. }
  1618. var actionType = zrUtil.isObject(actionInfo)
  1619. ? actionInfo.type
  1620. : ([actionInfo, actionInfo = {
  1621. event: eventName
  1622. }][0]);
  1623. // Event name is all lowercase
  1624. actionInfo.event = (actionInfo.event || actionType).toLowerCase();
  1625. eventName = actionInfo.event;
  1626. // Validate action type and event name.
  1627. zrUtil.assert(ACTION_REG.test(actionType) && ACTION_REG.test(eventName));
  1628. if (!actions[actionType]) {
  1629. actions[actionType] = {action: action, actionInfo: actionInfo};
  1630. }
  1631. eventActionMap[eventName] = actionType;
  1632. };
  1633. /**
  1634. * @param {string} type
  1635. * @param {*} CoordinateSystem
  1636. */
  1637. echarts.registerCoordinateSystem = function (type, CoordinateSystem) {
  1638. CoordinateSystemManager.register(type, CoordinateSystem);
  1639. };
  1640. /**
  1641. * Get dimensions of specified coordinate system.
  1642. * @param {string} type
  1643. * @return {Array.<string|Object>}
  1644. */
  1645. echarts.getCoordinateSystemDimensions = function (type) {
  1646. var coordSysCreator = CoordinateSystemManager.get(type);
  1647. if (coordSysCreator) {
  1648. return coordSysCreator.getDimensionsInfo
  1649. ? coordSysCreator.getDimensionsInfo()
  1650. : coordSysCreator.dimensions.slice();
  1651. }
  1652. };
  1653. /**
  1654. * Layout is a special stage of visual encoding
  1655. * Most visual encoding like color are common for different chart
  1656. * But each chart has it's own layout algorithm
  1657. *
  1658. * @param {number} [priority=1000]
  1659. * @param {Function} layoutFunc
  1660. */
  1661. echarts.registerLayout = function (priority, layoutFunc) {
  1662. if (typeof priority === 'function') {
  1663. layoutFunc = priority;
  1664. priority = PRIORITY_VISUAL_LAYOUT;
  1665. }
  1666. if (true) {
  1667. if (isNaN(priority)) {
  1668. throw new Error('Unkown layout priority');
  1669. }
  1670. }
  1671. visualFuncs.push({
  1672. prio: priority,
  1673. func: layoutFunc,
  1674. isLayout: true
  1675. });
  1676. };
  1677. /**
  1678. * @param {number} [priority=3000]
  1679. * @param {Function} visualFunc
  1680. */
  1681. echarts.registerVisual = function (priority, visualFunc) {
  1682. if (typeof priority === 'function') {
  1683. visualFunc = priority;
  1684. priority = PRIORITY_VISUAL_CHART;
  1685. }
  1686. if (true) {
  1687. if (isNaN(priority)) {
  1688. throw new Error('Unkown visual priority');
  1689. }
  1690. }
  1691. visualFuncs.push({
  1692. prio: priority,
  1693. func: visualFunc
  1694. });
  1695. };
  1696. /**
  1697. * @param {string} name
  1698. */
  1699. echarts.registerLoading = function (name, loadingFx) {
  1700. loadingEffects[name] = loadingFx;
  1701. };
  1702. /**
  1703. * @param {Object} opts
  1704. * @param {string} [superClass]
  1705. */
  1706. echarts.extendComponentModel = function (opts/*, superClass*/) {
  1707. // var Clazz = ComponentModel;
  1708. // if (superClass) {
  1709. // var classType = parseClassType(superClass);
  1710. // Clazz = ComponentModel.getClass(classType.main, classType.sub, true);
  1711. // }
  1712. return ComponentModel.extend(opts);
  1713. };
  1714. /**
  1715. * @param {Object} opts
  1716. * @param {string} [superClass]
  1717. */
  1718. echarts.extendComponentView = function (opts/*, superClass*/) {
  1719. // var Clazz = ComponentView;
  1720. // if (superClass) {
  1721. // var classType = parseClassType(superClass);
  1722. // Clazz = ComponentView.getClass(classType.main, classType.sub, true);
  1723. // }
  1724. return ComponentView.extend(opts);
  1725. };
  1726. /**
  1727. * @param {Object} opts
  1728. * @param {string} [superClass]
  1729. */
  1730. echarts.extendSeriesModel = function (opts/*, superClass*/) {
  1731. // var Clazz = SeriesModel;
  1732. // if (superClass) {
  1733. // superClass = 'series.' + superClass.replace('series.', '');
  1734. // var classType = parseClassType(superClass);
  1735. // Clazz = ComponentModel.getClass(classType.main, classType.sub, true);
  1736. // }
  1737. return SeriesModel.extend(opts);
  1738. };
  1739. /**
  1740. * @param {Object} opts
  1741. * @param {string} [superClass]
  1742. */
  1743. echarts.extendChartView = function (opts/*, superClass*/) {
  1744. // var Clazz = ChartView;
  1745. // if (superClass) {
  1746. // superClass = superClass.replace('series.', '');
  1747. // var classType = parseClassType(superClass);
  1748. // Clazz = ChartView.getClass(classType.main, true);
  1749. // }
  1750. return ChartView.extend(opts);
  1751. };
  1752. /**
  1753. * ZRender need a canvas context to do measureText.
  1754. * But in node environment canvas may be created by node-canvas.
  1755. * So we need to specify how to create a canvas instead of using document.createElement('canvas')
  1756. *
  1757. * Be careful of using it in the browser.
  1758. *
  1759. * @param {Function} creator
  1760. * @example
  1761. * var Canvas = require('canvas');
  1762. * var echarts = require('echarts');
  1763. * echarts.setCanvasCreator(function () {
  1764. * // Small size is enough.
  1765. * return new Canvas(32, 32);
  1766. * });
  1767. */
  1768. echarts.setCanvasCreator = function (creator) {
  1769. zrUtil.createCanvas = creator;
  1770. };
  1771. echarts.registerVisual(PRIORITY_VISUAL_GLOBAL, __webpack_require__(94));
  1772. echarts.registerPreprocessor(__webpack_require__(95));
  1773. echarts.registerLoading('default', __webpack_require__(97));
  1774. // Default action
  1775. echarts.registerAction({
  1776. type: 'highlight',
  1777. event: 'highlight',
  1778. update: 'highlight'
  1779. }, zrUtil.noop);
  1780. echarts.registerAction({
  1781. type: 'downplay',
  1782. event: 'downplay',
  1783. update: 'downplay'
  1784. }, zrUtil.noop);
  1785. // --------
  1786. // Exports
  1787. // --------
  1788. echarts.zrender = zrender;
  1789. echarts.List = __webpack_require__(98);
  1790. echarts.Model = __webpack_require__(12);
  1791. echarts.Axis = __webpack_require__(100);
  1792. echarts.graphic = __webpack_require__(18);
  1793. echarts.number = __webpack_require__(7);
  1794. echarts.format = __webpack_require__(6);
  1795. echarts.throttle = throttle.throttle;
  1796. echarts.matrix = __webpack_require__(11);
  1797. echarts.vector = __webpack_require__(10);
  1798. echarts.color = __webpack_require__(31);
  1799. echarts.util = {};
  1800. each([
  1801. 'map', 'each', 'filter', 'indexOf', 'inherits', 'reduce', 'filter',
  1802. 'bind', 'curry', 'isArray', 'isString', 'isObject', 'isFunction',
  1803. 'extend', 'defaults', 'clone', 'merge'
  1804. ],
  1805. function (name) {
  1806. echarts.util[name] = zrUtil[name];
  1807. }
  1808. );
  1809. echarts.helper = __webpack_require__(108);
  1810. // PRIORITY
  1811. echarts.PRIORITY = {
  1812. PROCESSOR: {
  1813. FILTER: PRIORITY_PROCESSOR_FILTER,
  1814. STATISTIC: PRIORITY_PROCESSOR_STATISTIC
  1815. },
  1816. VISUAL: {
  1817. LAYOUT: PRIORITY_VISUAL_LAYOUT,
  1818. GLOBAL: PRIORITY_VISUAL_GLOBAL,
  1819. CHART: PRIORITY_VISUAL_CHART,
  1820. COMPONENT: PRIORITY_VISUAL_COMPONENT,
  1821. BRUSH: PRIORITY_VISUAL_BRUSH
  1822. }
  1823. };
  1824. module.exports = echarts;
  1825. /***/ },
  1826. /* 2 */
  1827. /***/ function(module, exports) {
  1828. /**
  1829. * echarts设备环境识别
  1830. *
  1831. * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
  1832. * @author firede[firede@firede.us]
  1833. * @desc thanks zepto.
  1834. */
  1835. var env = {};
  1836. if (typeof navigator === 'undefined') {
  1837. // In node
  1838. env = {
  1839. browser: {},
  1840. os: {},
  1841. node: true,
  1842. // Assume canvas is supported
  1843. canvasSupported: true
  1844. };
  1845. }
  1846. else {
  1847. env = detect(navigator.userAgent);
  1848. }
  1849. module.exports = env;
  1850. // Zepto.js
  1851. // (c) 2010-2013 Thomas Fuchs
  1852. // Zepto.js may be freely distributed under the MIT license.
  1853. function detect(ua) {
  1854. var os = {};
  1855. var browser = {};
  1856. // var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
  1857. // var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  1858. // var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  1859. // var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  1860. // var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  1861. // var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
  1862. // var touchpad = webos && ua.match(/TouchPad/);
  1863. // var kindle = ua.match(/Kindle\/([\d.]+)/);
  1864. // var silk = ua.match(/Silk\/([\d._]+)/);
  1865. // var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  1866. // var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  1867. // var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  1868. // var playbook = ua.match(/PlayBook/);
  1869. // var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  1870. var firefox = ua.match(/Firefox\/([\d.]+)/);
  1871. // var safari = webkit && ua.match(/Mobile\//) && !chrome;
  1872. // var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
  1873. var ie = ua.match(/MSIE\s([\d.]+)/)
  1874. // IE 11 Trident/7.0; rv:11.0
  1875. || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  1876. var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
  1877. var weChat = (/micromessenger/i).test(ua);
  1878. // Todo: clean this up with a better OS/browser seperation:
  1879. // - discern (more) between multiple browsers on android
  1880. // - decide if kindle fire in silk mode is android or not
  1881. // - Firefox on Android doesn't specify the Android version
  1882. // - possibly devide in os, device and browser hashes
  1883. // if (browser.webkit = !!webkit) browser.version = webkit[1];
  1884. // if (android) os.android = true, os.version = android[2];
  1885. // if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
  1886. // if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
  1887. // if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  1888. // if (webos) os.webos = true, os.version = webos[2];
  1889. // if (touchpad) os.touchpad = true;
  1890. // if (blackberry) os.blackberry = true, os.version = blackberry[2];
  1891. // if (bb10) os.bb10 = true, os.version = bb10[2];
  1892. // if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
  1893. // if (playbook) browser.playbook = true;
  1894. // if (kindle) os.kindle = true, os.version = kindle[1];
  1895. // if (silk) browser.silk = true, browser.version = silk[1];
  1896. // if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
  1897. // if (chrome) browser.chrome = true, browser.version = chrome[1];
  1898. if (firefox) {
  1899. browser.firefox = true;
  1900. browser.version = firefox[1];
  1901. }
  1902. // if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
  1903. // if (webview) browser.webview = true;
  1904. if (ie) {
  1905. browser.ie = true;
  1906. browser.version = ie[1];
  1907. }
  1908. if (edge) {
  1909. browser.edge = true;
  1910. browser.version = edge[1];
  1911. }
  1912. // It is difficult to detect WeChat in Win Phone precisely, because ua can
  1913. // not be set on win phone. So we do not consider Win Phone.
  1914. if (weChat) {
  1915. browser.weChat = true;
  1916. }
  1917. // os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
  1918. // (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
  1919. // os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos ||
  1920. // (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
  1921. // (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
  1922. return {
  1923. browser: browser,
  1924. os: os,
  1925. node: false,
  1926. // 原生canvas支持,改极端点了
  1927. // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
  1928. canvasSupported : document.createElement('canvas').getContext ? true : false,
  1929. // @see <http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript>
  1930. // works on most browsers
  1931. // IE10/11 does not support touch event, and MS Edge supports them but not by
  1932. // default, so we dont check navigator.maxTouchPoints for them here.
  1933. touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
  1934. // <http://caniuse.com/#search=pointer%20event>.
  1935. pointerEventsSupported: 'onpointerdown' in window
  1936. // Firefox supports pointer but not by default, only MS browsers are reliable on pointer
  1937. // events currently. So we dont use that on other browsers unless tested sufficiently.
  1938. // Although IE 10 supports pointer event, it use old style and is different from the
  1939. // standard. So we exclude that. (IE 10 is hardly used on touch device)
  1940. && (browser.edge || (browser.ie && browser.version >= 11))
  1941. };
  1942. }
  1943. /***/ },
  1944. /* 3 */
  1945. /***/ function(module, exports, __webpack_require__) {
  1946. /**
  1947. * ECharts global model
  1948. *
  1949. * @module {echarts/model/Global}
  1950. */
  1951. /**
  1952. * Caution: If the mechanism should be changed some day, these cases
  1953. * should be considered:
  1954. *
  1955. * (1) In `merge option` mode, if using the same option to call `setOption`
  1956. * many times, the result should be the same (try our best to ensure that).
  1957. * (2) In `merge option` mode, if a component has no id/name specified, it
  1958. * will be merged by index, and the result sequence of the components is
  1959. * consistent to the original sequence.
  1960. * (3) `reset` feature (in toolbox). Find detailed info in comments about
  1961. * `mergeOption` in module:echarts/model/OptionManager.
  1962. */
  1963. var zrUtil = __webpack_require__(4);
  1964. var modelUtil = __webpack_require__(5);
  1965. var Model = __webpack_require__(12);
  1966. var each = zrUtil.each;
  1967. var filter = zrUtil.filter;
  1968. var map = zrUtil.map;
  1969. var isArray = zrUtil.isArray;
  1970. var indexOf = zrUtil.indexOf;
  1971. var isObject = zrUtil.isObject;
  1972. var ComponentModel = __webpack_require__(69);
  1973. var globalDefault = __webpack_require__(73);
  1974. var OPTION_INNER_KEY = '\0_ec_inner';
  1975. /**
  1976. * @alias module:echarts/model/Global
  1977. *
  1978. * @param {Object} option
  1979. * @param {module:echarts/model/Model} parentModel
  1980. * @param {Object} theme
  1981. */
  1982. var GlobalModel = Model.extend({
  1983. constructor: GlobalModel,
  1984. init: function (option, parentModel, theme, optionManager) {
  1985. theme = theme || {};
  1986. this.option = null; // Mark as not initialized.
  1987. /**
  1988. * @type {module:echarts/model/Model}
  1989. * @private
  1990. */
  1991. this._theme = new Model(theme);
  1992. /**
  1993. * @type {module:echarts/model/OptionManager}
  1994. */
  1995. this._optionManager = optionManager;
  1996. },
  1997. setOption: function (option, optionPreprocessorFuncs) {
  1998. zrUtil.assert(
  1999. !(OPTION_INNER_KEY in option),
  2000. 'please use chart.getOption()'
  2001. );
  2002. this._optionManager.setOption(option, optionPreprocessorFuncs);
  2003. this.resetOption(null);
  2004. },
  2005. /**
  2006. * @param {string} type null/undefined: reset all.
  2007. * 'recreate': force recreate all.
  2008. * 'timeline': only reset timeline option
  2009. * 'media': only reset media query option
  2010. * @return {boolean} Whether option changed.
  2011. */
  2012. resetOption: function (type) {
  2013. var optionChanged = false;
  2014. var optionManager = this._optionManager;
  2015. if (!type || type === 'recreate') {
  2016. var baseOption = optionManager.mountOption(type === 'recreate');
  2017. if (!this.option || type === 'recreate') {
  2018. initBase.call(this, baseOption);
  2019. }
  2020. else {
  2021. this.restoreData();
  2022. this.mergeOption(baseOption);
  2023. }
  2024. optionChanged = true;
  2025. }
  2026. if (type === 'timeline' || type === 'media') {
  2027. this.restoreData();
  2028. }
  2029. if (!type || type === 'recreate' || type === 'timeline') {
  2030. var timelineOption = optionManager.getTimelineOption(this);
  2031. timelineOption && (this.mergeOption(timelineOption), optionChanged = true);
  2032. }
  2033. if (!type || type === 'recreate' || type === 'media') {
  2034. var mediaOptions = optionManager.getMediaOption(this, this._api);
  2035. if (mediaOptions.length) {
  2036. each(mediaOptions, function (mediaOption) {
  2037. this.mergeOption(mediaOption, optionChanged = true);
  2038. }, this);
  2039. }
  2040. }
  2041. return optionChanged;
  2042. },
  2043. /**
  2044. * @protected
  2045. */
  2046. mergeOption: function (newOption) {
  2047. var option = this.option;
  2048. var componentsMap = this._componentsMap;
  2049. var newCptTypes = [];
  2050. // 如果不存在对应的 component model 则直接 merge
  2051. each(newOption, function (componentOption, mainType) {
  2052. if (componentOption == null) {
  2053. return;
  2054. }
  2055. if (!ComponentModel.hasClass(mainType)) {
  2056. option[mainType] = option[mainType] == null
  2057. ? zrUtil.clone(componentOption)
  2058. : zrUtil.merge(option[mainType], componentOption, true);
  2059. }
  2060. else {
  2061. newCptTypes.push(mainType);
  2062. }
  2063. });
  2064. // FIXME OPTION 同步是否要改回原来的
  2065. ComponentModel.topologicalTravel(
  2066. newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this
  2067. );
  2068. this._seriesIndices = this._seriesIndices || [];
  2069. function visitComponent(mainType, dependencies) {
  2070. var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
  2071. var mapResult = modelUtil.mappingToExists(
  2072. componentsMap.get(mainType), newCptOptionList
  2073. );
  2074. modelUtil.makeIdAndName(mapResult);
  2075. // Set mainType and complete subType.
  2076. each(mapResult, function (item, index) {
  2077. var opt = item.option;
  2078. if (isObject(opt)) {
  2079. item.keyInfo.mainType = mainType;
  2080. item.keyInfo.subType = determineSubType(mainType, opt, item.exist);
  2081. }
  2082. });
  2083. var dependentModels = getComponentsByTypes(
  2084. componentsMap, dependencies
  2085. );
  2086. option[mainType] = [];
  2087. componentsMap.set(mainType, []);
  2088. each(mapResult, function (resultItem, index) {
  2089. var componentModel = resultItem.exist;
  2090. var newCptOption = resultItem.option;
  2091. zrUtil.assert(
  2092. isObject(newCptOption) || componentModel,
  2093. 'Empty component definition'
  2094. );
  2095. // Consider where is no new option and should be merged using {},
  2096. // see removeEdgeAndAdd in topologicalTravel and
  2097. // ComponentModel.getAllClassMainTypes.
  2098. if (!newCptOption) {
  2099. componentModel.mergeOption({}, this);
  2100. componentModel.optionUpdated({}, false);
  2101. }
  2102. else {
  2103. var ComponentModelClass = ComponentModel.getClass(
  2104. mainType, resultItem.keyInfo.subType, true
  2105. );
  2106. if (componentModel && componentModel instanceof ComponentModelClass) {
  2107. componentModel.name = resultItem.keyInfo.name;
  2108. componentModel.mergeOption(newCptOption, this);
  2109. componentModel.optionUpdated(newCptOption, false);
  2110. }
  2111. else {
  2112. // PENDING Global as parent ?
  2113. var extraOpt = zrUtil.extend(
  2114. {
  2115. dependentModels: dependentModels,
  2116. componentIndex: index
  2117. },
  2118. resultItem.keyInfo
  2119. );
  2120. componentModel = new ComponentModelClass(
  2121. newCptOption, this, this, extraOpt
  2122. );
  2123. zrUtil.extend(componentModel, extraOpt);
  2124. componentModel.init(newCptOption, this, this, extraOpt);
  2125. // Call optionUpdated after init.
  2126. // newCptOption has been used as componentModel.option
  2127. // and may be merged with theme and default, so pass null
  2128. // to avoid confusion.
  2129. componentModel.optionUpdated(null, true);
  2130. }
  2131. }
  2132. componentsMap.get(mainType)[index] = componentModel;
  2133. option[mainType][index] = componentModel.option;
  2134. }, this);
  2135. // Backup series for filtering.
  2136. if (mainType === 'series') {
  2137. this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
  2138. }
  2139. }
  2140. },
  2141. /**
  2142. * Get option for output (cloned option and inner info removed)
  2143. * @public
  2144. * @return {Object}
  2145. */
  2146. getOption: function () {
  2147. var option = zrUtil.clone(this.option);
  2148. each(option, function (opts, mainType) {
  2149. if (ComponentModel.hasClass(mainType)) {
  2150. var opts = modelUtil.normalizeToArray(opts);
  2151. for (var i = opts.length - 1; i >= 0; i--) {
  2152. // Remove options with inner id.
  2153. if (modelUtil.isIdInner(opts[i])) {
  2154. opts.splice(i, 1);
  2155. }
  2156. }
  2157. option[mainType] = opts;
  2158. }
  2159. });
  2160. delete option[OPTION_INNER_KEY];
  2161. return option;
  2162. },
  2163. /**
  2164. * @return {module:echarts/model/Model}
  2165. */
  2166. getTheme: function () {
  2167. return this._theme;
  2168. },
  2169. /**
  2170. * @param {string} mainType
  2171. * @param {number} [idx=0]
  2172. * @return {module:echarts/model/Component}
  2173. */
  2174. getComponent: function (mainType, idx) {
  2175. var list = this._componentsMap.get(mainType);
  2176. if (list) {
  2177. return list[idx || 0];
  2178. }
  2179. },
  2180. /**
  2181. * If none of index and id and name used, return all components with mainType.
  2182. * @param {Object} condition
  2183. * @param {string} condition.mainType
  2184. * @param {string} [condition.subType] If ignore, only query by mainType
  2185. * @param {number|Array.<number>} [condition.index] Either input index or id or name.
  2186. * @param {string|Array.<string>} [condition.id] Either input index or id or name.
  2187. * @param {string|Array.<string>} [condition.name] Either input index or id or name.
  2188. * @return {Array.<module:echarts/model/Component>}
  2189. */
  2190. queryComponents: function (condition) {
  2191. var mainType = condition.mainType;
  2192. if (!mainType) {
  2193. return [];
  2194. }
  2195. var index = condition.index;
  2196. var id = condition.id;
  2197. var name = condition.name;
  2198. var cpts = this._componentsMap.get(mainType);
  2199. if (!cpts || !cpts.length) {
  2200. return [];
  2201. }
  2202. var result;
  2203. if (index != null) {
  2204. if (!isArray(index)) {
  2205. index = [index];
  2206. }
  2207. result = filter(map(index, function (idx) {
  2208. return cpts[idx];
  2209. }), function (val) {
  2210. return !!val;
  2211. });
  2212. }
  2213. else if (id != null) {
  2214. var isIdArray = isArray(id);
  2215. result = filter(cpts, function (cpt) {
  2216. return (isIdArray && indexOf(id, cpt.id) >= 0)
  2217. || (!isIdArray && cpt.id === id);
  2218. });
  2219. }
  2220. else if (name != null) {
  2221. var isNameArray = isArray(name);
  2222. result = filter(cpts, function (cpt) {
  2223. return (isNameArray && indexOf(name, cpt.name) >= 0)
  2224. || (!isNameArray && cpt.name === name);
  2225. });
  2226. }
  2227. else {
  2228. // Return all components with mainType
  2229. result = cpts.slice();
  2230. }
  2231. return filterBySubType(result, condition);
  2232. },
  2233. /**
  2234. * The interface is different from queryComponents,
  2235. * which is convenient for inner usage.
  2236. *
  2237. * @usage
  2238. * var result = findComponents(
  2239. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  2240. * );
  2241. * var result = findComponents(
  2242. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  2243. * );
  2244. * var result = findComponents(
  2245. * {mainType: 'series'},
  2246. * function (model, index) {...}
  2247. * );
  2248. * // result like [component0, componnet1, ...]
  2249. *
  2250. * @param {Object} condition
  2251. * @param {string} condition.mainType Mandatory.
  2252. * @param {string} [condition.subType] Optional.
  2253. * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName},
  2254. * where xxx is mainType.
  2255. * If query attribute is null/undefined or has no index/id/name,
  2256. * do not filtering by query conditions, which is convenient for
  2257. * no-payload situations or when target of action is global.
  2258. * @param {Function} [condition.filter] parameter: component, return boolean.
  2259. * @return {Array.<module:echarts/model/Component>}
  2260. */
  2261. findComponents: function (condition) {
  2262. var query = condition.query;
  2263. var mainType = condition.mainType;
  2264. var queryCond = getQueryCond(query);
  2265. var result = queryCond
  2266. ? this.queryComponents(queryCond)
  2267. : this._componentsMap.get(mainType);
  2268. return doFilter(filterBySubType(result, condition));
  2269. function getQueryCond(q) {
  2270. var indexAttr = mainType + 'Index';
  2271. var idAttr = mainType + 'Id';
  2272. var nameAttr = mainType + 'Name';
  2273. return q && (
  2274. q[indexAttr] != null
  2275. || q[idAttr] != null
  2276. || q[nameAttr] != null
  2277. )
  2278. ? {
  2279. mainType: mainType,
  2280. // subType will be filtered finally.
  2281. index: q[indexAttr],
  2282. id: q[idAttr],
  2283. name: q[nameAttr]
  2284. }
  2285. : null;
  2286. }
  2287. function doFilter(res) {
  2288. return condition.filter
  2289. ? filter(res, condition.filter)
  2290. : res;
  2291. }
  2292. },
  2293. /**
  2294. * @usage
  2295. * eachComponent('legend', function (legendModel, index) {
  2296. * ...
  2297. * });
  2298. * eachComponent(function (componentType, model, index) {
  2299. * // componentType does not include subType
  2300. * // (componentType is 'xxx' but not 'xxx.aa')
  2301. * });
  2302. * eachComponent(
  2303. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
  2304. * function (model, index) {...}
  2305. * );
  2306. * eachComponent(
  2307. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
  2308. * function (model, index) {...}
  2309. * );
  2310. *
  2311. * @param {string|Object=} mainType When mainType is object, the definition
  2312. * is the same as the method 'findComponents'.
  2313. * @param {Function} cb
  2314. * @param {*} context
  2315. */
  2316. eachComponent: function (mainType, cb, context) {
  2317. var componentsMap = this._componentsMap;
  2318. if (typeof mainType === 'function') {
  2319. context = cb;
  2320. cb = mainType;
  2321. componentsMap.each(function (components, componentType) {
  2322. each(components, function (component, index) {
  2323. cb.call(context, componentType, component, index);
  2324. });
  2325. });
  2326. }
  2327. else if (zrUtil.isString(mainType)) {
  2328. each(componentsMap.get(mainType), cb, context);
  2329. }
  2330. else if (isObject(mainType)) {
  2331. var queryResult = this.findComponents(mainType);
  2332. each(queryResult, cb, context);
  2333. }
  2334. },
  2335. /**
  2336. * @param {string} name
  2337. * @return {Array.<module:echarts/model/Series>}
  2338. */
  2339. getSeriesByName: function (name) {
  2340. var series = this._componentsMap.get('series');
  2341. return filter(series, function (oneSeries) {
  2342. return oneSeries.name === name;
  2343. });
  2344. },
  2345. /**
  2346. * @param {number} seriesIndex
  2347. * @return {module:echarts/model/Series}
  2348. */
  2349. getSeriesByIndex: function (seriesIndex) {
  2350. return this._componentsMap.get('series')[seriesIndex];
  2351. },
  2352. /**
  2353. * @param {string} subType
  2354. * @return {Array.<module:echarts/model/Series>}
  2355. */
  2356. getSeriesByType: function (subType) {
  2357. var series = this._componentsMap.get('series');
  2358. return filter(series, function (oneSeries) {
  2359. return oneSeries.subType === subType;
  2360. });
  2361. },
  2362. /**
  2363. * @return {Array.<module:echarts/model/Series>}
  2364. */
  2365. getSeries: function () {
  2366. return this._componentsMap.get('series').slice();
  2367. },
  2368. /**
  2369. * After filtering, series may be different
  2370. * frome raw series.
  2371. *
  2372. * @param {Function} cb
  2373. * @param {*} context
  2374. */
  2375. eachSeries: function (cb, context) {
  2376. assertSeriesInitialized(this);
  2377. each(this._seriesIndices, function (rawSeriesIndex) {
  2378. var series = this._componentsMap.get('series')[rawSeriesIndex];
  2379. cb.call(context, series, rawSeriesIndex);
  2380. }, this);
  2381. },
  2382. /**
  2383. * Iterate raw series before filtered.
  2384. *
  2385. * @param {Function} cb
  2386. * @param {*} context
  2387. */
  2388. eachRawSeries: function (cb, context) {
  2389. each(this._componentsMap.get('series'), cb, context);
  2390. },
  2391. /**
  2392. * After filtering, series may be different.
  2393. * frome raw series.
  2394. *
  2395. * @parma {string} subType
  2396. * @param {Function} cb
  2397. * @param {*} context
  2398. */
  2399. eachSeriesByType: function (subType, cb, context) {
  2400. assertSeriesInitialized(this);
  2401. each(this._seriesIndices, function (rawSeriesIndex) {
  2402. var series = this._componentsMap.get('series')[rawSeriesIndex];
  2403. if (series.subType === subType) {
  2404. cb.call(context, series, rawSeriesIndex);
  2405. }
  2406. }, this);
  2407. },
  2408. /**
  2409. * Iterate raw series before filtered of given type.
  2410. *
  2411. * @parma {string} subType
  2412. * @param {Function} cb
  2413. * @param {*} context
  2414. */
  2415. eachRawSeriesByType: function (subType, cb, context) {
  2416. return each(this.getSeriesByType(subType), cb, context);
  2417. },
  2418. /**
  2419. * @param {module:echarts/model/Series} seriesModel
  2420. */
  2421. isSeriesFiltered: function (seriesModel) {
  2422. assertSeriesInitialized(this);
  2423. return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
  2424. },
  2425. /**
  2426. * @return {Array.<number>}
  2427. */
  2428. getCurrentSeriesIndices: function () {
  2429. return (this._seriesIndices || []).slice();
  2430. },
  2431. /**
  2432. * @param {Function} cb
  2433. * @param {*} context
  2434. */
  2435. filterSeries: function (cb, context) {
  2436. assertSeriesInitialized(this);
  2437. var filteredSeries = filter(
  2438. this._componentsMap.get('series'), cb, context
  2439. );
  2440. this._seriesIndices = createSeriesIndices(filteredSeries);
  2441. },
  2442. restoreData: function () {
  2443. var componentsMap = this._componentsMap;
  2444. this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
  2445. var componentTypes = [];
  2446. componentsMap.each(function (components, componentType) {
  2447. componentTypes.push(componentType);
  2448. });
  2449. ComponentModel.topologicalTravel(
  2450. componentTypes,
  2451. ComponentModel.getAllClassMainTypes(),
  2452. function (componentType, dependencies) {
  2453. each(componentsMap.get(componentType), function (component) {
  2454. component.restoreData();
  2455. });
  2456. }
  2457. );
  2458. }
  2459. });
  2460. /**
  2461. * @inner
  2462. */
  2463. function mergeTheme(option, theme) {
  2464. zrUtil.each(theme, function (themeItem, name) {
  2465. // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理
  2466. if (!ComponentModel.hasClass(name)) {
  2467. if (typeof themeItem === 'object') {
  2468. option[name] = !option[name]
  2469. ? zrUtil.clone(themeItem)
  2470. : zrUtil.merge(option[name], themeItem, false);
  2471. }
  2472. else {
  2473. if (option[name] == null) {
  2474. option[name] = themeItem;
  2475. }
  2476. }
  2477. }
  2478. });
  2479. }
  2480. function initBase(baseOption) {
  2481. baseOption = baseOption;
  2482. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  2483. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  2484. this.option = {};
  2485. this.option[OPTION_INNER_KEY] = 1;
  2486. /**
  2487. * Init with series: [], in case of calling findSeries method
  2488. * before series initialized.
  2489. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  2490. * @private
  2491. */
  2492. this._componentsMap = zrUtil.createHashMap({series: []});
  2493. /**
  2494. * Mapping between filtered series list and raw series list.
  2495. * key: filtered series indices, value: raw series indices.
  2496. * @type {Array.<nubmer>}
  2497. * @private
  2498. */
  2499. this._seriesIndices = null;
  2500. mergeTheme(baseOption, this._theme.option);
  2501. // TODO Needs clone when merging to the unexisted property
  2502. zrUtil.merge(baseOption, globalDefault, false);
  2503. this.mergeOption(baseOption);
  2504. }
  2505. /**
  2506. * @inner
  2507. * @param {Array.<string>|string} types model types
  2508. * @return {Object} key: {string} type, value: {Array.<Object>} models
  2509. */
  2510. function getComponentsByTypes(componentsMap, types) {
  2511. if (!zrUtil.isArray(types)) {
  2512. types = types ? [types] : [];
  2513. }
  2514. var ret = {};
  2515. each(types, function (type) {
  2516. ret[type] = (componentsMap.get(type) || []).slice();
  2517. });
  2518. return ret;
  2519. }
  2520. /**
  2521. * @inner
  2522. */
  2523. function determineSubType(mainType, newCptOption, existComponent) {
  2524. var subType = newCptOption.type
  2525. ? newCptOption.type
  2526. : existComponent
  2527. ? existComponent.subType
  2528. // Use determineSubType only when there is no existComponent.
  2529. : ComponentModel.determineSubType(mainType, newCptOption);
  2530. // tooltip, markline, markpoint may always has no subType
  2531. return subType;
  2532. }
  2533. /**
  2534. * @inner
  2535. */
  2536. function createSeriesIndices(seriesModels) {
  2537. return map(seriesModels, function (series) {
  2538. return series.componentIndex;
  2539. }) || [];
  2540. }
  2541. /**
  2542. * @inner
  2543. */
  2544. function filterBySubType(components, condition) {
  2545. // Using hasOwnProperty for restrict. Consider
  2546. // subType is undefined in user payload.
  2547. return condition.hasOwnProperty('subType')
  2548. ? filter(components, function (cpt) {
  2549. return cpt.subType === condition.subType;
  2550. })
  2551. : components;
  2552. }
  2553. /**
  2554. * @inner
  2555. */
  2556. function assertSeriesInitialized(ecModel) {
  2557. // Components that use _seriesIndices should depends on series component,
  2558. // which make sure that their initialization is after series.
  2559. if (true) {
  2560. if (!ecModel._seriesIndices) {
  2561. throw new Error('Option should contains series.');
  2562. }
  2563. }
  2564. }
  2565. zrUtil.mixin(GlobalModel, __webpack_require__(74));
  2566. module.exports = GlobalModel;
  2567. /***/ },
  2568. /* 4 */
  2569. /***/ function(module, exports) {
  2570. /**
  2571. * @module zrender/core/util
  2572. */
  2573. // 用于处理merge时无法遍历Date等对象的问题
  2574. var BUILTIN_OBJECT = {
  2575. '[object Function]': 1,
  2576. '[object RegExp]': 1,
  2577. '[object Date]': 1,
  2578. '[object Error]': 1,
  2579. '[object CanvasGradient]': 1,
  2580. '[object CanvasPattern]': 1,
  2581. // For node-canvas
  2582. '[object Image]': 1,
  2583. '[object Canvas]': 1
  2584. };
  2585. var TYPED_ARRAY = {
  2586. '[object Int8Array]': 1,
  2587. '[object Uint8Array]': 1,
  2588. '[object Uint8ClampedArray]': 1,
  2589. '[object Int16Array]': 1,
  2590. '[object Uint16Array]': 1,
  2591. '[object Int32Array]': 1,
  2592. '[object Uint32Array]': 1,
  2593. '[object Float32Array]': 1,
  2594. '[object Float64Array]': 1
  2595. };
  2596. var objToString = Object.prototype.toString;
  2597. var arrayProto = Array.prototype;
  2598. var nativeForEach = arrayProto.forEach;
  2599. var nativeFilter = arrayProto.filter;
  2600. var nativeSlice = arrayProto.slice;
  2601. var nativeMap = arrayProto.map;
  2602. var nativeReduce = arrayProto.reduce;
  2603. /**
  2604. * Those data types can be cloned:
  2605. * Plain object, Array, TypedArray, number, string, null, undefined.
  2606. * Those data types will be assgined using the orginal data:
  2607. * BUILTIN_OBJECT
  2608. * Instance of user defined class will be cloned to a plain object, without
  2609. * properties in prototype.
  2610. * Other data types is not supported (not sure what will happen).
  2611. *
  2612. * Caution: do not support clone Date, for performance consideration.
  2613. * (There might be a large number of date in `series.data`).
  2614. * So date should not be modified in and out of echarts.
  2615. *
  2616. * @param {*} source
  2617. * @return {*} new
  2618. */
  2619. function clone(source) {
  2620. if (source == null || typeof source != 'object') {
  2621. return source;
  2622. }
  2623. var result = source;
  2624. var typeStr = objToString.call(source);
  2625. if (typeStr === '[object Array]') {
  2626. result = [];
  2627. for (var i = 0, len = source.length; i < len; i++) {
  2628. result[i] = clone(source[i]);
  2629. }
  2630. }
  2631. else if (TYPED_ARRAY[typeStr]) {
  2632. result = source.constructor.from(source);
  2633. }
  2634. else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
  2635. result = {};
  2636. for (var key in source) {
  2637. if (source.hasOwnProperty(key)) {
  2638. result[key] = clone(source[key]);
  2639. }
  2640. }
  2641. }
  2642. return result;
  2643. }
  2644. /**
  2645. * @memberOf module:zrender/core/util
  2646. * @param {*} target
  2647. * @param {*} source
  2648. * @param {boolean} [overwrite=false]
  2649. */
  2650. function merge(target, source, overwrite) {
  2651. // We should escapse that source is string
  2652. // and enter for ... in ...
  2653. if (!isObject(source) || !isObject(target)) {
  2654. return overwrite ? clone(source) : target;
  2655. }
  2656. for (var key in source) {
  2657. if (source.hasOwnProperty(key)) {
  2658. var targetProp = target[key];
  2659. var sourceProp = source[key];
  2660. if (isObject(sourceProp)
  2661. && isObject(targetProp)
  2662. && !isArray(sourceProp)
  2663. && !isArray(targetProp)
  2664. && !isDom(sourceProp)
  2665. && !isDom(targetProp)
  2666. && !isBuiltInObject(sourceProp)
  2667. && !isBuiltInObject(targetProp)
  2668. && !isPrimitive(sourceProp)
  2669. && !isPrimitive(targetProp)
  2670. ) {
  2671. // 如果需要递归覆盖,就递归调用merge
  2672. merge(targetProp, sourceProp, overwrite);
  2673. }
  2674. else if (overwrite || !(key in target)) {
  2675. // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
  2676. // NOTE,在 target[key] 不存在的时候也是直接覆盖
  2677. target[key] = clone(source[key], true);
  2678. }
  2679. }
  2680. }
  2681. return target;
  2682. }
  2683. /**
  2684. * @param {Array} targetAndSources The first item is target, and the rests are source.
  2685. * @param {boolean} [overwrite=false]
  2686. * @return {*} target
  2687. */
  2688. function mergeAll(targetAndSources, overwrite) {
  2689. var result = targetAndSources[0];
  2690. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  2691. result = merge(result, targetAndSources[i], overwrite);
  2692. }
  2693. return result;
  2694. }
  2695. /**
  2696. * @param {*} target
  2697. * @param {*} source
  2698. * @memberOf module:zrender/core/util
  2699. */
  2700. function extend(target, source) {
  2701. for (var key in source) {
  2702. if (source.hasOwnProperty(key)) {
  2703. target[key] = source[key];
  2704. }
  2705. }
  2706. return target;
  2707. }
  2708. /**
  2709. * @param {*} target
  2710. * @param {*} source
  2711. * @param {boolen} [overlay=false]
  2712. * @memberOf module:zrender/core/util
  2713. */
  2714. function defaults(target, source, overlay) {
  2715. for (var key in source) {
  2716. if (source.hasOwnProperty(key)
  2717. && (overlay ? source[key] != null : target[key] == null)
  2718. ) {
  2719. target[key] = source[key];
  2720. }
  2721. }
  2722. return target;
  2723. }
  2724. function createCanvas() {
  2725. return document.createElement('canvas');
  2726. }
  2727. // FIXME
  2728. var _ctx;
  2729. function getContext() {
  2730. if (!_ctx) {
  2731. // Use util.createCanvas instead of createCanvas
  2732. // because createCanvas may be overwritten in different environment
  2733. _ctx = util.createCanvas().getContext('2d');
  2734. }
  2735. return _ctx;
  2736. }
  2737. /**
  2738. * 查询数组中元素的index
  2739. * @memberOf module:zrender/core/util
  2740. */
  2741. function indexOf(array, value) {
  2742. if (array) {
  2743. if (array.indexOf) {
  2744. return array.indexOf(value);
  2745. }
  2746. for (var i = 0, len = array.length; i < len; i++) {
  2747. if (array[i] === value) {
  2748. return i;
  2749. }
  2750. }
  2751. }
  2752. return -1;
  2753. }
  2754. /**
  2755. * 构造类继承关系
  2756. *
  2757. * @memberOf module:zrender/core/util
  2758. * @param {Function} clazz 源类
  2759. * @param {Function} baseClazz 基类
  2760. */
  2761. function inherits(clazz, baseClazz) {
  2762. var clazzPrototype = clazz.prototype;
  2763. function F() {}
  2764. F.prototype = baseClazz.prototype;
  2765. clazz.prototype = new F();
  2766. for (var prop in clazzPrototype) {
  2767. clazz.prototype[prop] = clazzPrototype[prop];
  2768. }
  2769. clazz.prototype.constructor = clazz;
  2770. clazz.superClass = baseClazz;
  2771. }
  2772. /**
  2773. * @memberOf module:zrender/core/util
  2774. * @param {Object|Function} target
  2775. * @param {Object|Function} sorce
  2776. * @param {boolean} overlay
  2777. */
  2778. function mixin(target, source, overlay) {
  2779. target = 'prototype' in target ? target.prototype : target;
  2780. source = 'prototype' in source ? source.prototype : source;
  2781. defaults(target, source, overlay);
  2782. }
  2783. /**
  2784. * Consider typed array.
  2785. * @param {Array|TypedArray} data
  2786. */
  2787. function isArrayLike(data) {
  2788. if (! data) {
  2789. return;
  2790. }
  2791. if (typeof data == 'string') {
  2792. return false;
  2793. }
  2794. return typeof data.length == 'number';
  2795. }
  2796. /**
  2797. * 数组或对象遍历
  2798. * @memberOf module:zrender/core/util
  2799. * @param {Object|Array} obj
  2800. * @param {Function} cb
  2801. * @param {*} [context]
  2802. */
  2803. function each(obj, cb, context) {
  2804. if (!(obj && cb)) {
  2805. return;
  2806. }
  2807. if (obj.forEach && obj.forEach === nativeForEach) {
  2808. obj.forEach(cb, context);
  2809. }
  2810. else if (obj.length === +obj.length) {
  2811. for (var i = 0, len = obj.length; i < len; i++) {
  2812. cb.call(context, obj[i], i, obj);
  2813. }
  2814. }
  2815. else {
  2816. for (var key in obj) {
  2817. if (obj.hasOwnProperty(key)) {
  2818. cb.call(context, obj[key], key, obj);
  2819. }
  2820. }
  2821. }
  2822. }
  2823. /**
  2824. * 数组映射
  2825. * @memberOf module:zrender/core/util
  2826. * @param {Array} obj
  2827. * @param {Function} cb
  2828. * @param {*} [context]
  2829. * @return {Array}
  2830. */
  2831. function map(obj, cb, context) {
  2832. if (!(obj && cb)) {
  2833. return;
  2834. }
  2835. if (obj.map && obj.map === nativeMap) {
  2836. return obj.map(cb, context);
  2837. }
  2838. else {
  2839. var result = [];
  2840. for (var i = 0, len = obj.length; i < len; i++) {
  2841. result.push(cb.call(context, obj[i], i, obj));
  2842. }
  2843. return result;
  2844. }
  2845. }
  2846. /**
  2847. * @memberOf module:zrender/core/util
  2848. * @param {Array} obj
  2849. * @param {Function} cb
  2850. * @param {Object} [memo]
  2851. * @param {*} [context]
  2852. * @return {Array}
  2853. */
  2854. function reduce(obj, cb, memo, context) {
  2855. if (!(obj && cb)) {
  2856. return;
  2857. }
  2858. if (obj.reduce && obj.reduce === nativeReduce) {
  2859. return obj.reduce(cb, memo, context);
  2860. }
  2861. else {
  2862. for (var i = 0, len = obj.length; i < len; i++) {
  2863. memo = cb.call(context, memo, obj[i], i, obj);
  2864. }
  2865. return memo;
  2866. }
  2867. }
  2868. /**
  2869. * 数组过滤
  2870. * @memberOf module:zrender/core/util
  2871. * @param {Array} obj
  2872. * @param {Function} cb
  2873. * @param {*} [context]
  2874. * @return {Array}
  2875. */
  2876. function filter(obj, cb, context) {
  2877. if (!(obj && cb)) {
  2878. return;
  2879. }
  2880. if (obj.filter && obj.filter === nativeFilter) {
  2881. return obj.filter(cb, context);
  2882. }
  2883. else {
  2884. var result = [];
  2885. for (var i = 0, len = obj.length; i < len; i++) {
  2886. if (cb.call(context, obj[i], i, obj)) {
  2887. result.push(obj[i]);
  2888. }
  2889. }
  2890. return result;
  2891. }
  2892. }
  2893. /**
  2894. * 数组项查找
  2895. * @memberOf module:zrender/core/util
  2896. * @param {Array} obj
  2897. * @param {Function} cb
  2898. * @param {*} [context]
  2899. * @return {Array}
  2900. */
  2901. function find(obj, cb, context) {
  2902. if (!(obj && cb)) {
  2903. return;
  2904. }
  2905. for (var i = 0, len = obj.length; i < len; i++) {
  2906. if (cb.call(context, obj[i], i, obj)) {
  2907. return obj[i];
  2908. }
  2909. }
  2910. }
  2911. /**
  2912. * @memberOf module:zrender/core/util
  2913. * @param {Function} func
  2914. * @param {*} context
  2915. * @return {Function}
  2916. */
  2917. function bind(func, context) {
  2918. var args = nativeSlice.call(arguments, 2);
  2919. return function () {
  2920. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  2921. };
  2922. }
  2923. /**
  2924. * @memberOf module:zrender/core/util
  2925. * @param {Function} func
  2926. * @return {Function}
  2927. */
  2928. function curry(func) {
  2929. var args = nativeSlice.call(arguments, 1);
  2930. return function () {
  2931. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  2932. };
  2933. }
  2934. /**
  2935. * @memberOf module:zrender/core/util
  2936. * @param {*} value
  2937. * @return {boolean}
  2938. */
  2939. function isArray(value) {
  2940. return objToString.call(value) === '[object Array]';
  2941. }
  2942. /**
  2943. * @memberOf module:zrender/core/util
  2944. * @param {*} value
  2945. * @return {boolean}
  2946. */
  2947. function isFunction(value) {
  2948. return typeof value === 'function';
  2949. }
  2950. /**
  2951. * @memberOf module:zrender/core/util
  2952. * @param {*} value
  2953. * @return {boolean}
  2954. */
  2955. function isString(value) {
  2956. return objToString.call(value) === '[object String]';
  2957. }
  2958. /**
  2959. * @memberOf module:zrender/core/util
  2960. * @param {*} value
  2961. * @return {boolean}
  2962. */
  2963. function isObject(value) {
  2964. // Avoid a V8 JIT bug in Chrome 19-20.
  2965. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  2966. var type = typeof value;
  2967. return type === 'function' || (!!value && type == 'object');
  2968. }
  2969. /**
  2970. * @memberOf module:zrender/core/util
  2971. * @param {*} value
  2972. * @return {boolean}
  2973. */
  2974. function isBuiltInObject(value) {
  2975. return !!BUILTIN_OBJECT[objToString.call(value)];
  2976. }
  2977. /**
  2978. * @memberOf module:zrender/core/util
  2979. * @param {*} value
  2980. * @return {boolean}
  2981. */
  2982. function isDom(value) {
  2983. return typeof value === 'object'
  2984. && typeof value.nodeType === 'number'
  2985. && typeof value.ownerDocument === 'object';
  2986. }
  2987. /**
  2988. * Whether is exactly NaN. Notice isNaN('a') returns true.
  2989. * @param {*} value
  2990. * @return {boolean}
  2991. */
  2992. function eqNaN(value) {
  2993. return value !== value;
  2994. }
  2995. /**
  2996. * If value1 is not null, then return value1, otherwise judget rest of values.
  2997. * @memberOf module:zrender/core/util
  2998. * @return {*} Final value
  2999. */
  3000. function retrieve(values) {
  3001. for (var i = 0, len = arguments.length; i < len; i++) {
  3002. if (arguments[i] != null) {
  3003. return arguments[i];
  3004. }
  3005. }
  3006. }
  3007. /**
  3008. * @memberOf module:zrender/core/util
  3009. * @param {Array} arr
  3010. * @param {number} startIndex
  3011. * @param {number} endIndex
  3012. * @return {Array}
  3013. */
  3014. function slice() {
  3015. return Function.call.apply(nativeSlice, arguments);
  3016. }
  3017. /**
  3018. * @memberOf module:zrender/core/util
  3019. * @param {boolean} condition
  3020. * @param {string} message
  3021. */
  3022. function assert(condition, message) {
  3023. if (!condition) {
  3024. throw new Error(message);
  3025. }
  3026. }
  3027. var primitiveKey = '__ec_primitive__';
  3028. /**
  3029. * Set an object as primitive to be ignored traversing children in clone or merge
  3030. */
  3031. function setAsPrimitive(obj) {
  3032. obj[primitiveKey] = true;
  3033. }
  3034. function isPrimitive(obj) {
  3035. return obj[primitiveKey];
  3036. }
  3037. /**
  3038. * @constructor
  3039. * @param {Object} obj Only apply `ownProperty`.
  3040. */
  3041. function HashMap(obj) {
  3042. obj && each(obj, function (value, key) {
  3043. this.set(key, value);
  3044. }, this);
  3045. }
  3046. // Add prefix to avoid conflict with Object.prototype.
  3047. var HASH_MAP_PREFIX = '_ec_';
  3048. var HASH_MAP_PREFIX_LENGTH = 4;
  3049. HashMap.prototype = {
  3050. constructor: HashMap,
  3051. // Do not provide `has` method to avoid defining what is `has`.
  3052. // (We usually treat `null` and `undefined` as the same, different
  3053. // from ES6 Map).
  3054. get: function (key) {
  3055. return this[HASH_MAP_PREFIX + key];
  3056. },
  3057. set: function (key, value) {
  3058. this[HASH_MAP_PREFIX + key] = value;
  3059. // Comparing with invocation chaining, `return value` is more commonly
  3060. // used in this case: `var someVal = map.set('a', genVal());`
  3061. return value;
  3062. },
  3063. // Although util.each can be performed on this hashMap directly, user
  3064. // should not use the exposed keys, who are prefixed.
  3065. each: function (cb, context) {
  3066. context !== void 0 && (cb = bind(cb, context));
  3067. for (var prefixedKey in this) {
  3068. this.hasOwnProperty(prefixedKey)
  3069. && cb(this[prefixedKey], prefixedKey.slice(HASH_MAP_PREFIX_LENGTH));
  3070. }
  3071. },
  3072. // Do not use this method if performance sensitive.
  3073. removeKey: function (key) {
  3074. delete this[key];
  3075. }
  3076. };
  3077. function createHashMap(obj) {
  3078. return new HashMap(obj);
  3079. }
  3080. var util = {
  3081. inherits: inherits,
  3082. mixin: mixin,
  3083. clone: clone,
  3084. merge: merge,
  3085. mergeAll: mergeAll,
  3086. extend: extend,
  3087. defaults: defaults,
  3088. getContext: getContext,
  3089. createCanvas: createCanvas,
  3090. indexOf: indexOf,
  3091. slice: slice,
  3092. find: find,
  3093. isArrayLike: isArrayLike,
  3094. each: each,
  3095. map: map,
  3096. reduce: reduce,
  3097. filter: filter,
  3098. bind: bind,
  3099. curry: curry,
  3100. isArray: isArray,
  3101. isString: isString,
  3102. isObject: isObject,
  3103. isFunction: isFunction,
  3104. isBuiltInObject: isBuiltInObject,
  3105. isDom: isDom,
  3106. eqNaN: eqNaN,
  3107. retrieve: retrieve,
  3108. assert: assert,
  3109. setAsPrimitive: setAsPrimitive,
  3110. createHashMap: createHashMap,
  3111. noop: function () {}
  3112. };
  3113. module.exports = util;
  3114. /***/ },
  3115. /* 5 */
  3116. /***/ function(module, exports, __webpack_require__) {
  3117. var formatUtil = __webpack_require__(6);
  3118. var nubmerUtil = __webpack_require__(7);
  3119. var Model = __webpack_require__(12);
  3120. var zrUtil = __webpack_require__(4);
  3121. var each = zrUtil.each;
  3122. var isObject = zrUtil.isObject;
  3123. var modelUtil = {};
  3124. /**
  3125. * If value is not array, then translate it to array.
  3126. * @param {*} value
  3127. * @return {Array} [value] or value
  3128. */
  3129. modelUtil.normalizeToArray = function (value) {
  3130. return value instanceof Array
  3131. ? value
  3132. : value == null
  3133. ? []
  3134. : [value];
  3135. };
  3136. /**
  3137. * Sync default option between normal and emphasis like `position` and `show`
  3138. * In case some one will write code like
  3139. * label: {
  3140. * normal: {
  3141. * show: false,
  3142. * position: 'outside',
  3143. * textStyle: {
  3144. * fontSize: 18
  3145. * }
  3146. * },
  3147. * emphasis: {
  3148. * show: true
  3149. * }
  3150. * }
  3151. * @param {Object} opt
  3152. * @param {Array.<string>} subOpts
  3153. */
  3154. modelUtil.defaultEmphasis = function (opt, subOpts) {
  3155. if (opt) {
  3156. var emphasisOpt = opt.emphasis = opt.emphasis || {};
  3157. var normalOpt = opt.normal = opt.normal || {};
  3158. // Default emphasis option from normal
  3159. each(subOpts, function (subOptName) {
  3160. var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]);
  3161. if (val != null) {
  3162. emphasisOpt[subOptName] = val;
  3163. }
  3164. });
  3165. }
  3166. };
  3167. modelUtil.LABEL_OPTIONS = ['position', 'offset', 'show', 'textStyle', 'distance', 'formatter'];
  3168. /**
  3169. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  3170. * This helper method retieves value from data.
  3171. * @param {string|number|Date|Array|Object} dataItem
  3172. * @return {number|string|Date|Array.<number|string|Date>}
  3173. */
  3174. modelUtil.getDataItemValue = function (dataItem) {
  3175. // Performance sensitive.
  3176. return dataItem && (dataItem.value == null ? dataItem : dataItem.value);
  3177. };
  3178. /**
  3179. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  3180. * This helper method determine if dataItem has extra option besides value
  3181. * @param {string|number|Date|Array|Object} dataItem
  3182. */
  3183. modelUtil.isDataItemOption = function (dataItem) {
  3184. return isObject(dataItem)
  3185. && !(dataItem instanceof Array);
  3186. // // markLine data can be array
  3187. // && !(dataItem[0] && isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
  3188. };
  3189. /**
  3190. * This helper method convert value in data.
  3191. * @param {string|number|Date} value
  3192. * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'.
  3193. */
  3194. modelUtil.converDataValue = function (value, dimInfo) {
  3195. // Performance sensitive.
  3196. var dimType = dimInfo && dimInfo.type;
  3197. if (dimType === 'ordinal') {
  3198. return value;
  3199. }
  3200. if (dimType === 'time'
  3201. // spead up when using timestamp
  3202. && typeof value !== 'number'
  3203. && value != null
  3204. && value !== '-'
  3205. ) {
  3206. value = +nubmerUtil.parseDate(value);
  3207. }
  3208. // dimType defaults 'number'.
  3209. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  3210. // parse to NaN.
  3211. return (value == null || value === '')
  3212. ? NaN : +value; // If string (like '-'), using '+' parse to NaN
  3213. };
  3214. /**
  3215. * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data.
  3216. * @param {module:echarts/data/List} data
  3217. * @param {Object} opt
  3218. * @param {string} [opt.seriesIndex]
  3219. * @param {Object} [opt.name]
  3220. * @param {Object} [opt.mainType]
  3221. * @param {Object} [opt.subType]
  3222. */
  3223. modelUtil.createDataFormatModel = function (data, opt) {
  3224. var model = new Model();
  3225. zrUtil.mixin(model, modelUtil.dataFormatMixin);
  3226. model.seriesIndex = opt.seriesIndex;
  3227. model.name = opt.name || '';
  3228. model.mainType = opt.mainType;
  3229. model.subType = opt.subType;
  3230. model.getData = function () {
  3231. return data;
  3232. };
  3233. return model;
  3234. };
  3235. // PENDING A little ugly
  3236. modelUtil.dataFormatMixin = {
  3237. /**
  3238. * Get params for formatter
  3239. * @param {number} dataIndex
  3240. * @param {string} [dataType]
  3241. * @return {Object}
  3242. */
  3243. getDataParams: function (dataIndex, dataType) {
  3244. var data = this.getData(dataType);
  3245. var rawValue = this.getRawValue(dataIndex, dataType);
  3246. var rawDataIndex = data.getRawIndex(dataIndex);
  3247. var name = data.getName(dataIndex, true);
  3248. var itemOpt = data.getRawDataItem(dataIndex);
  3249. var color = data.getItemVisual(dataIndex, 'color');
  3250. return {
  3251. componentType: this.mainType,
  3252. componentSubType: this.subType,
  3253. seriesType: this.mainType === 'series' ? this.subType : null,
  3254. seriesIndex: this.seriesIndex,
  3255. seriesId: this.id,
  3256. seriesName: this.name,
  3257. name: name,
  3258. dataIndex: rawDataIndex,
  3259. data: itemOpt,
  3260. dataType: dataType,
  3261. value: rawValue,
  3262. color: color,
  3263. marker: formatUtil.getTooltipMarker(color),
  3264. // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  3265. $vars: ['seriesName', 'name', 'value']
  3266. };
  3267. },
  3268. /**
  3269. * Format label
  3270. * @param {number} dataIndex
  3271. * @param {string} [status='normal'] 'normal' or 'emphasis'
  3272. * @param {string} [dataType]
  3273. * @param {number} [dimIndex]
  3274. * @param {string} [labelProp='label']
  3275. * @return {string}
  3276. */
  3277. getFormattedLabel: function (dataIndex, status, dataType, dimIndex, labelProp) {
  3278. status = status || 'normal';
  3279. var data = this.getData(dataType);
  3280. var itemModel = data.getItemModel(dataIndex);
  3281. var params = this.getDataParams(dataIndex, dataType);
  3282. if (dimIndex != null && (params.value instanceof Array)) {
  3283. params.value = params.value[dimIndex];
  3284. }
  3285. var formatter = itemModel.get([labelProp || 'label', status, 'formatter']);
  3286. if (typeof formatter === 'function') {
  3287. params.status = status;
  3288. return formatter(params);
  3289. }
  3290. else if (typeof formatter === 'string') {
  3291. return formatUtil.formatTpl(formatter, params);
  3292. }
  3293. },
  3294. /**
  3295. * Get raw value in option
  3296. * @param {number} idx
  3297. * @param {string} [dataType]
  3298. * @return {Object}
  3299. */
  3300. getRawValue: function (idx, dataType) {
  3301. var data = this.getData(dataType);
  3302. var dataItem = data.getRawDataItem(idx);
  3303. if (dataItem != null) {
  3304. return (isObject(dataItem) && !(dataItem instanceof Array))
  3305. ? dataItem.value : dataItem;
  3306. }
  3307. },
  3308. /**
  3309. * Should be implemented.
  3310. * @param {number} dataIndex
  3311. * @param {boolean} [multipleSeries=false]
  3312. * @param {number} [dataType]
  3313. * @return {string} tooltip string
  3314. */
  3315. formatTooltip: zrUtil.noop
  3316. };
  3317. /**
  3318. * Mapping to exists for merge.
  3319. *
  3320. * @public
  3321. * @param {Array.<Object>|Array.<module:echarts/model/Component>} exists
  3322. * @param {Object|Array.<Object>} newCptOptions
  3323. * @return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3324. * index of which is the same as exists.
  3325. */
  3326. modelUtil.mappingToExists = function (exists, newCptOptions) {
  3327. // Mapping by the order by original option (but not order of
  3328. // new option) in merge mode. Because we should ensure
  3329. // some specified index (like xAxisIndex) is consistent with
  3330. // original option, which is easy to understand, espatially in
  3331. // media query. And in most case, merge option is used to
  3332. // update partial option but not be expected to change order.
  3333. newCptOptions = (newCptOptions || []).slice();
  3334. var result = zrUtil.map(exists || [], function (obj, index) {
  3335. return {exist: obj};
  3336. });
  3337. // Mapping by id or name if specified.
  3338. each(newCptOptions, function (cptOption, index) {
  3339. if (!isObject(cptOption)) {
  3340. return;
  3341. }
  3342. // id has highest priority.
  3343. for (var i = 0; i < result.length; i++) {
  3344. if (!result[i].option // Consider name: two map to one.
  3345. && cptOption.id != null
  3346. && result[i].exist.id === cptOption.id + ''
  3347. ) {
  3348. result[i].option = cptOption;
  3349. newCptOptions[index] = null;
  3350. return;
  3351. }
  3352. }
  3353. for (var i = 0; i < result.length; i++) {
  3354. var exist = result[i].exist;
  3355. if (!result[i].option // Consider name: two map to one.
  3356. // Can not match when both ids exist but different.
  3357. && (exist.id == null || cptOption.id == null)
  3358. && cptOption.name != null
  3359. && !modelUtil.isIdInner(cptOption)
  3360. && !modelUtil.isIdInner(exist)
  3361. && exist.name === cptOption.name + ''
  3362. ) {
  3363. result[i].option = cptOption;
  3364. newCptOptions[index] = null;
  3365. return;
  3366. }
  3367. }
  3368. });
  3369. // Otherwise mapping by index.
  3370. each(newCptOptions, function (cptOption, index) {
  3371. if (!isObject(cptOption)) {
  3372. return;
  3373. }
  3374. var i = 0;
  3375. for (; i < result.length; i++) {
  3376. var exist = result[i].exist;
  3377. if (!result[i].option
  3378. // Existing model that already has id should be able to
  3379. // mapped to (because after mapping performed model may
  3380. // be assigned with a id, whish should not affect next
  3381. // mapping), except those has inner id.
  3382. && !modelUtil.isIdInner(exist)
  3383. // Caution:
  3384. // Do not overwrite id. But name can be overwritten,
  3385. // because axis use name as 'show label text'.
  3386. // 'exist' always has id and name and we dont
  3387. // need to check it.
  3388. && cptOption.id == null
  3389. ) {
  3390. result[i].option = cptOption;
  3391. break;
  3392. }
  3393. }
  3394. if (i >= result.length) {
  3395. result.push({option: cptOption});
  3396. }
  3397. });
  3398. return result;
  3399. };
  3400. /**
  3401. * Make id and name for mapping result (result of mappingToExists)
  3402. * into `keyInfo` field.
  3403. *
  3404. * @public
  3405. * @param {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3406. * which order is the same as exists.
  3407. * @return {Array.<Object>} The input.
  3408. */
  3409. modelUtil.makeIdAndName = function (mapResult) {
  3410. // We use this id to hash component models and view instances
  3411. // in echarts. id can be specified by user, or auto generated.
  3412. // The id generation rule ensures new view instance are able
  3413. // to mapped to old instance when setOption are called in
  3414. // no-merge mode. So we generate model id by name and plus
  3415. // type in view id.
  3416. // name can be duplicated among components, which is convenient
  3417. // to specify multi components (like series) by one name.
  3418. // Ensure that each id is distinct.
  3419. var idMap = zrUtil.createHashMap();
  3420. each(mapResult, function (item, index) {
  3421. var existCpt = item.exist;
  3422. existCpt && idMap.set(existCpt.id, item);
  3423. });
  3424. each(mapResult, function (item, index) {
  3425. var opt = item.option;
  3426. zrUtil.assert(
  3427. !opt || opt.id == null || !idMap.get(opt.id) || idMap.get(opt.id) === item,
  3428. 'id duplicates: ' + (opt && opt.id)
  3429. );
  3430. opt && opt.id != null && idMap.set(opt.id, item);
  3431. !item.keyInfo && (item.keyInfo = {});
  3432. });
  3433. // Make name and id.
  3434. each(mapResult, function (item, index) {
  3435. var existCpt = item.exist;
  3436. var opt = item.option;
  3437. var keyInfo = item.keyInfo;
  3438. if (!isObject(opt)) {
  3439. return;
  3440. }
  3441. // name can be overwitten. Consider case: axis.name = '20km'.
  3442. // But id generated by name will not be changed, which affect
  3443. // only in that case: setOption with 'not merge mode' and view
  3444. // instance will be recreated, which can be accepted.
  3445. keyInfo.name = opt.name != null
  3446. ? opt.name + ''
  3447. : existCpt
  3448. ? existCpt.name
  3449. : '\0-'; // name may be displayed on screen, so use '-'.
  3450. if (existCpt) {
  3451. keyInfo.id = existCpt.id;
  3452. }
  3453. else if (opt.id != null) {
  3454. keyInfo.id = opt.id + '';
  3455. }
  3456. else {
  3457. // Consider this situatoin:
  3458. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  3459. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  3460. // Series with the same name between optionA and optionB
  3461. // should be mapped.
  3462. var idNum = 0;
  3463. do {
  3464. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  3465. }
  3466. while (idMap.get(keyInfo.id));
  3467. }
  3468. idMap.set(keyInfo.id, item);
  3469. });
  3470. };
  3471. /**
  3472. * @public
  3473. * @param {Object} cptOption
  3474. * @return {boolean}
  3475. */
  3476. modelUtil.isIdInner = function (cptOption) {
  3477. return isObject(cptOption)
  3478. && cptOption.id
  3479. && (cptOption.id + '').indexOf('\0_ec_\0') === 0;
  3480. };
  3481. /**
  3482. * A helper for removing duplicate items between batchA and batchB,
  3483. * and in themselves, and categorize by series.
  3484. *
  3485. * @param {Array.<Object>} batchA Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3486. * @param {Array.<Object>} batchB Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3487. * @return {Array.<Array.<Object>, Array.<Object>>} result: [resultBatchA, resultBatchB]
  3488. */
  3489. modelUtil.compressBatches = function (batchA, batchB) {
  3490. var mapA = {};
  3491. var mapB = {};
  3492. makeMap(batchA || [], mapA);
  3493. makeMap(batchB || [], mapB, mapA);
  3494. return [mapToArray(mapA), mapToArray(mapB)];
  3495. function makeMap(sourceBatch, map, otherMap) {
  3496. for (var i = 0, len = sourceBatch.length; i < len; i++) {
  3497. var seriesId = sourceBatch[i].seriesId;
  3498. var dataIndices = modelUtil.normalizeToArray(sourceBatch[i].dataIndex);
  3499. var otherDataIndices = otherMap && otherMap[seriesId];
  3500. for (var j = 0, lenj = dataIndices.length; j < lenj; j++) {
  3501. var dataIndex = dataIndices[j];
  3502. if (otherDataIndices && otherDataIndices[dataIndex]) {
  3503. otherDataIndices[dataIndex] = null;
  3504. }
  3505. else {
  3506. (map[seriesId] || (map[seriesId] = {}))[dataIndex] = 1;
  3507. }
  3508. }
  3509. }
  3510. }
  3511. function mapToArray(map, isData) {
  3512. var result = [];
  3513. for (var i in map) {
  3514. if (map.hasOwnProperty(i) && map[i] != null) {
  3515. if (isData) {
  3516. result.push(+i);
  3517. }
  3518. else {
  3519. var dataIndices = mapToArray(map[i], true);
  3520. dataIndices.length && result.push({seriesId: i, dataIndex: dataIndices});
  3521. }
  3522. }
  3523. }
  3524. return result;
  3525. }
  3526. };
  3527. /**
  3528. * @param {module:echarts/data/List} data
  3529. * @param {Object} payload Contains dataIndex (means rawIndex) / dataIndexInside / name
  3530. * each of which can be Array or primary type.
  3531. * @return {number|Array.<number>} dataIndex If not found, return undefined/null.
  3532. */
  3533. modelUtil.queryDataIndex = function (data, payload) {
  3534. if (payload.dataIndexInside != null) {
  3535. return payload.dataIndexInside;
  3536. }
  3537. else if (payload.dataIndex != null) {
  3538. return zrUtil.isArray(payload.dataIndex)
  3539. ? zrUtil.map(payload.dataIndex, function (value) {
  3540. return data.indexOfRawIndex(value);
  3541. })
  3542. : data.indexOfRawIndex(payload.dataIndex);
  3543. }
  3544. else if (payload.name != null) {
  3545. return zrUtil.isArray(payload.name)
  3546. ? zrUtil.map(payload.name, function (value) {
  3547. return data.indexOfName(value);
  3548. })
  3549. : data.indexOfName(payload.name);
  3550. }
  3551. };
  3552. /**
  3553. * Enable property storage to any host object.
  3554. * Notice: Serialization is not supported.
  3555. *
  3556. * For example:
  3557. * var get = modelUitl.makeGetter();
  3558. *
  3559. * function some(hostObj) {
  3560. * get(hostObj)._someProperty = 1212;
  3561. * ...
  3562. * }
  3563. *
  3564. * @return {Function}
  3565. */
  3566. modelUtil.makeGetter = (function () {
  3567. var index = 0;
  3568. return function () {
  3569. var key = '\0__ec_prop_getter_' + index++;
  3570. return function (hostObj) {
  3571. return hostObj[key] || (hostObj[key] = {});
  3572. };
  3573. };
  3574. })();
  3575. /**
  3576. * @param {module:echarts/model/Global} ecModel
  3577. * @param {string|Object} finder
  3578. * If string, e.g., 'geo', means {geoIndex: 0}.
  3579. * If Object, could contain some of these properties below:
  3580. * {
  3581. * seriesIndex, seriesId, seriesName,
  3582. * geoIndex, geoId, geoName,
  3583. * bmapIndex, bmapId, bmapName,
  3584. * xAxisIndex, xAxisId, xAxisName,
  3585. * yAxisIndex, yAxisId, yAxisName,
  3586. * gridIndex, gridId, gridName,
  3587. * ... (can be extended)
  3588. * }
  3589. * Each properties can be number|string|Array.<number>|Array.<string>
  3590. * For example, a finder could be
  3591. * {
  3592. * seriesIndex: 3,
  3593. * geoId: ['aa', 'cc'],
  3594. * gridName: ['xx', 'rr']
  3595. * }
  3596. * xxxIndex can be set as 'all' (means all xxx) or 'none' (means not specify)
  3597. * If nothing or null/undefined specified, return nothing.
  3598. * @param {Object} [opt]
  3599. * @param {string} [opt.defaultMainType]
  3600. * @param {Array.<string>} [opt.includeMainTypes]
  3601. * @return {Object} result like:
  3602. * {
  3603. * seriesModels: [seriesModel1, seriesModel2],
  3604. * seriesModel: seriesModel1, // The first model
  3605. * geoModels: [geoModel1, geoModel2],
  3606. * geoModel: geoModel1, // The first model
  3607. * ...
  3608. * }
  3609. */
  3610. modelUtil.parseFinder = function (ecModel, finder, opt) {
  3611. if (zrUtil.isString(finder)) {
  3612. var obj = {};
  3613. obj[finder + 'Index'] = 0;
  3614. finder = obj;
  3615. }
  3616. var defaultMainType = opt && opt.defaultMainType;
  3617. if (defaultMainType
  3618. && !has(finder, defaultMainType + 'Index')
  3619. && !has(finder, defaultMainType + 'Id')
  3620. && !has(finder, defaultMainType + 'Name')
  3621. ) {
  3622. finder[defaultMainType + 'Index'] = 0;
  3623. }
  3624. var result = {};
  3625. each(finder, function (value, key) {
  3626. var value = finder[key];
  3627. // Exclude 'dataIndex' and other illgal keys.
  3628. if (key === 'dataIndex' || key === 'dataIndexInside') {
  3629. result[key] = value;
  3630. return;
  3631. }
  3632. var parsedKey = key.match(/^(\w+)(Index|Id|Name)$/) || [];
  3633. var mainType = parsedKey[1];
  3634. var queryType = (parsedKey[2] || '').toLowerCase();
  3635. if (!mainType
  3636. || !queryType
  3637. || value == null
  3638. || (queryType === 'index' && value === 'none')
  3639. || (opt && opt.includeMainTypes && zrUtil.indexOf(opt.includeMainTypes, mainType) < 0)
  3640. ) {
  3641. return;
  3642. }
  3643. var queryParam = {mainType: mainType};
  3644. if (queryType !== 'index' || value !== 'all') {
  3645. queryParam[queryType] = value;
  3646. }
  3647. var models = ecModel.queryComponents(queryParam);
  3648. result[mainType + 'Models'] = models;
  3649. result[mainType + 'Model'] = models[0];
  3650. });
  3651. return result;
  3652. };
  3653. /**
  3654. * @see {module:echarts/data/helper/completeDimensions}
  3655. * @param {module:echarts/data/List} data
  3656. * @param {string|number} dataDim
  3657. * @return {string}
  3658. */
  3659. modelUtil.dataDimToCoordDim = function (data, dataDim) {
  3660. var dimensions = data.dimensions;
  3661. dataDim = data.getDimension(dataDim);
  3662. for (var i = 0; i < dimensions.length; i++) {
  3663. var dimItem = data.getDimensionInfo(dimensions[i]);
  3664. if (dimItem.name === dataDim) {
  3665. return dimItem.coordDim;
  3666. }
  3667. }
  3668. };
  3669. /**
  3670. * @see {module:echarts/data/helper/completeDimensions}
  3671. * @param {module:echarts/data/List} data
  3672. * @param {string} coordDim
  3673. * @return {Array.<string>} data dimensions on the coordDim.
  3674. */
  3675. modelUtil.coordDimToDataDim = function (data, coordDim) {
  3676. var dataDim = [];
  3677. each(data.dimensions, function (dimName) {
  3678. var dimItem = data.getDimensionInfo(dimName);
  3679. if (dimItem.coordDim === coordDim) {
  3680. dataDim[dimItem.coordDimIndex] = dimItem.name;
  3681. }
  3682. });
  3683. return dataDim;
  3684. };
  3685. /**
  3686. * @see {module:echarts/data/helper/completeDimensions}
  3687. * @param {module:echarts/data/List} data
  3688. * @param {string} otherDim Can be `otherDims`
  3689. * like 'label' or 'tooltip'.
  3690. * @return {Array.<string>} data dimensions on the otherDim.
  3691. */
  3692. modelUtil.otherDimToDataDim = function (data, otherDim) {
  3693. var dataDim = [];
  3694. each(data.dimensions, function (dimName) {
  3695. var dimItem = data.getDimensionInfo(dimName);
  3696. var otherDims = dimItem.otherDims;
  3697. var dimIndex = otherDims[otherDim];
  3698. if (dimIndex != null && dimIndex !== false) {
  3699. dataDim[dimIndex] = dimItem.name;
  3700. }
  3701. });
  3702. return dataDim;
  3703. };
  3704. function has(obj, prop) {
  3705. return obj && obj.hasOwnProperty(prop);
  3706. }
  3707. module.exports = modelUtil;
  3708. /***/ },
  3709. /* 6 */
  3710. /***/ function(module, exports, __webpack_require__) {
  3711. var zrUtil = __webpack_require__(4);
  3712. var numberUtil = __webpack_require__(7);
  3713. var textContain = __webpack_require__(8);
  3714. var formatUtil = {};
  3715. /**
  3716. * 每三位默认加,格式化
  3717. * @param {string|number} x
  3718. * @return {string}
  3719. */
  3720. formatUtil.addCommas = function (x) {
  3721. if (isNaN(x)) {
  3722. return '-';
  3723. }
  3724. x = (x + '').split('.');
  3725. return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,')
  3726. + (x.length > 1 ? ('.' + x[1]) : '');
  3727. };
  3728. /**
  3729. * @param {string} str
  3730. * @param {boolean} [upperCaseFirst=false]
  3731. * @return {string} str
  3732. */
  3733. formatUtil.toCamelCase = function (str, upperCaseFirst) {
  3734. str = (str || '').toLowerCase().replace(/-(.)/g, function(match, group1) {
  3735. return group1.toUpperCase();
  3736. });
  3737. if (upperCaseFirst && str) {
  3738. str = str.charAt(0).toUpperCase() + str.slice(1);
  3739. }
  3740. return str;
  3741. };
  3742. /**
  3743. * Normalize css liked array configuration
  3744. * e.g.
  3745. * 3 => [3, 3, 3, 3]
  3746. * [4, 2] => [4, 2, 4, 2]
  3747. * [4, 3, 2] => [4, 3, 2, 3]
  3748. * @param {number|Array.<number>} val
  3749. */
  3750. formatUtil.normalizeCssArray = function (val) {
  3751. var len = val.length;
  3752. if (typeof (val) === 'number') {
  3753. return [val, val, val, val];
  3754. }
  3755. else if (len === 2) {
  3756. // vertical | horizontal
  3757. return [val[0], val[1], val[0], val[1]];
  3758. }
  3759. else if (len === 3) {
  3760. // top | horizontal | bottom
  3761. return [val[0], val[1], val[2], val[1]];
  3762. }
  3763. return val;
  3764. };
  3765. var encodeHTML = formatUtil.encodeHTML = function (source) {
  3766. return String(source)
  3767. .replace(/&/g, '&amp;')
  3768. .replace(/</g, '&lt;')
  3769. .replace(/>/g, '&gt;')
  3770. .replace(/"/g, '&quot;')
  3771. .replace(/'/g, '&#39;');
  3772. };
  3773. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
  3774. var wrapVar = function (varName, seriesIdx) {
  3775. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
  3776. };
  3777. /**
  3778. * Template formatter
  3779. * @param {string} tpl
  3780. * @param {Array.<Object>|Object} paramsList
  3781. * @param {boolean} [encode=false]
  3782. * @return {string}
  3783. */
  3784. formatUtil.formatTpl = function (tpl, paramsList, encode) {
  3785. if (!zrUtil.isArray(paramsList)) {
  3786. paramsList = [paramsList];
  3787. }
  3788. var seriesLen = paramsList.length;
  3789. if (!seriesLen) {
  3790. return '';
  3791. }
  3792. var $vars = paramsList[0].$vars || [];
  3793. for (var i = 0; i < $vars.length; i++) {
  3794. var alias = TPL_VAR_ALIAS[i];
  3795. var val = wrapVar(alias, 0);
  3796. tpl = tpl.replace(wrapVar(alias), encode ? encodeHTML(val) : val);
  3797. }
  3798. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  3799. for (var k = 0; k < $vars.length; k++) {
  3800. var val = paramsList[seriesIdx][$vars[k]];
  3801. tpl = tpl.replace(
  3802. wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
  3803. encode ? encodeHTML(val) : val
  3804. );
  3805. }
  3806. }
  3807. return tpl;
  3808. };
  3809. /**
  3810. * simple Template formatter
  3811. *
  3812. * @param {string} tpl
  3813. * @param {Object} param
  3814. * @param {boolean} [encode=false]
  3815. * @return {string}
  3816. */
  3817. formatUtil.formatTplSimple = function (tpl, param, encode) {
  3818. zrUtil.each(param, function (value, key) {
  3819. tpl = tpl.replace(
  3820. '{' + key + '}',
  3821. encode ? encodeHTML(value) : value
  3822. );
  3823. });
  3824. return tpl;
  3825. };
  3826. /**
  3827. * @param {string} color
  3828. * @param {string} [extraCssText]
  3829. * @return {string}
  3830. */
  3831. formatUtil.getTooltipMarker = function (color, extraCssText) {
  3832. return color
  3833. ? '<span style="display:inline-block;margin-right:5px;'
  3834. + 'border-radius:10px;width:9px;height:9px;background-color:'
  3835. + formatUtil.encodeHTML(color) + ';' + (extraCssText || '') + '"></span>'
  3836. : '';
  3837. };
  3838. /**
  3839. * @param {string} str
  3840. * @return {string}
  3841. * @inner
  3842. */
  3843. var s2d = function (str) {
  3844. return str < 10 ? ('0' + str) : str;
  3845. };
  3846. /**
  3847. * ISO Date format
  3848. * @param {string} tpl
  3849. * @param {number} value
  3850. * @param {boolean} [isUTC=false] Default in local time.
  3851. * see `module:echarts/scale/Time`
  3852. * and `module:echarts/util/number#parseDate`.
  3853. * @inner
  3854. */
  3855. formatUtil.formatTime = function (tpl, value, isUTC) {
  3856. if (tpl === 'week'
  3857. || tpl === 'month'
  3858. || tpl === 'quarter'
  3859. || tpl === 'half-year'
  3860. || tpl === 'year'
  3861. ) {
  3862. tpl = 'MM-dd\nyyyy';
  3863. }
  3864. var date = numberUtil.parseDate(value);
  3865. var utc = isUTC ? 'UTC' : '';
  3866. var y = date['get' + utc + 'FullYear']();
  3867. var M = date['get' + utc + 'Month']() + 1;
  3868. var d = date['get' + utc + 'Date']();
  3869. var h = date['get' + utc + 'Hours']();
  3870. var m = date['get' + utc + 'Minutes']();
  3871. var s = date['get' + utc + 'Seconds']();
  3872. tpl = tpl.replace('MM', s2d(M))
  3873. .toLowerCase()
  3874. .replace('yyyy', y)
  3875. .replace('yy', y % 100)
  3876. .replace('dd', s2d(d))
  3877. .replace('d', d)
  3878. .replace('hh', s2d(h))
  3879. .replace('h', h)
  3880. .replace('mm', s2d(m))
  3881. .replace('m', m)
  3882. .replace('ss', s2d(s))
  3883. .replace('s', s);
  3884. return tpl;
  3885. };
  3886. /**
  3887. * Capital first
  3888. * @param {string} str
  3889. * @return {string}
  3890. */
  3891. formatUtil.capitalFirst = function (str) {
  3892. return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
  3893. };
  3894. formatUtil.truncateText = textContain.truncateText;
  3895. module.exports = formatUtil;
  3896. /***/ },
  3897. /* 7 */
  3898. /***/ function(module, exports, __webpack_require__) {
  3899. /**
  3900. * 数值处理模块
  3901. * @module echarts/util/number
  3902. */
  3903. var zrUtil = __webpack_require__(4);
  3904. var number = {};
  3905. var RADIAN_EPSILON = 1e-4;
  3906. function _trim(str) {
  3907. return str.replace(/^\s+/, '').replace(/\s+$/, '');
  3908. }
  3909. /**
  3910. * Linear mapping a value from domain to range
  3911. * @memberOf module:echarts/util/number
  3912. * @param {(number|Array.<number>)} val
  3913. * @param {Array.<number>} domain Domain extent domain[0] can be bigger than domain[1]
  3914. * @param {Array.<number>} range Range extent range[0] can be bigger than range[1]
  3915. * @param {boolean} clamp
  3916. * @return {(number|Array.<number>}
  3917. */
  3918. number.linearMap = function (val, domain, range, clamp) {
  3919. var subDomain = domain[1] - domain[0];
  3920. var subRange = range[1] - range[0];
  3921. if (subDomain === 0) {
  3922. return subRange === 0
  3923. ? range[0]
  3924. : (range[0] + range[1]) / 2;
  3925. }
  3926. // Avoid accuracy problem in edge, such as
  3927. // 146.39 - 62.83 === 83.55999999999999.
  3928. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  3929. // It is a little verbose for efficiency considering this method
  3930. // is a hotspot.
  3931. if (clamp) {
  3932. if (subDomain > 0) {
  3933. if (val <= domain[0]) {
  3934. return range[0];
  3935. }
  3936. else if (val >= domain[1]) {
  3937. return range[1];
  3938. }
  3939. }
  3940. else {
  3941. if (val >= domain[0]) {
  3942. return range[0];
  3943. }
  3944. else if (val <= domain[1]) {
  3945. return range[1];
  3946. }
  3947. }
  3948. }
  3949. else {
  3950. if (val === domain[0]) {
  3951. return range[0];
  3952. }
  3953. if (val === domain[1]) {
  3954. return range[1];
  3955. }
  3956. }
  3957. return (val - domain[0]) / subDomain * subRange + range[0];
  3958. };
  3959. /**
  3960. * Convert a percent string to absolute number.
  3961. * Returns NaN if percent is not a valid string or number
  3962. * @memberOf module:echarts/util/number
  3963. * @param {string|number} percent
  3964. * @param {number} all
  3965. * @return {number}
  3966. */
  3967. number.parsePercent = function(percent, all) {
  3968. switch (percent) {
  3969. case 'center':
  3970. case 'middle':
  3971. percent = '50%';
  3972. break;
  3973. case 'left':
  3974. case 'top':
  3975. percent = '0%';
  3976. break;
  3977. case 'right':
  3978. case 'bottom':
  3979. percent = '100%';
  3980. break;
  3981. }
  3982. if (typeof percent === 'string') {
  3983. if (_trim(percent).match(/%$/)) {
  3984. return parseFloat(percent) / 100 * all;
  3985. }
  3986. return parseFloat(percent);
  3987. }
  3988. return percent == null ? NaN : +percent;
  3989. };
  3990. /**
  3991. * (1) Fix rounding error of float numbers.
  3992. * (2) Support return string to avoid scientific notation like '3.5e-7'.
  3993. *
  3994. * @param {number} x
  3995. * @param {number} [precision]
  3996. * @param {boolean} [returnStr]
  3997. * @return {number|string}
  3998. */
  3999. number.round = function (x, precision, returnStr) {
  4000. if (precision == null) {
  4001. precision = 10;
  4002. }
  4003. // Avoid range error
  4004. precision = Math.min(Math.max(0, precision), 20);
  4005. x = (+x).toFixed(precision);
  4006. return returnStr ? x : +x;
  4007. };
  4008. number.asc = function (arr) {
  4009. arr.sort(function (a, b) {
  4010. return a - b;
  4011. });
  4012. return arr;
  4013. };
  4014. /**
  4015. * Get precision
  4016. * @param {number} val
  4017. */
  4018. number.getPrecision = function (val) {
  4019. val = +val;
  4020. if (isNaN(val)) {
  4021. return 0;
  4022. }
  4023. // It is much faster than methods converting number to string as follows
  4024. // var tmp = val.toString();
  4025. // return tmp.length - 1 - tmp.indexOf('.');
  4026. // especially when precision is low
  4027. var e = 1;
  4028. var count = 0;
  4029. while (Math.round(val * e) / e !== val) {
  4030. e *= 10;
  4031. count++;
  4032. }
  4033. return count;
  4034. };
  4035. /**
  4036. * @param {string|number} val
  4037. * @return {number}
  4038. */
  4039. number.getPrecisionSafe = function (val) {
  4040. var str = val.toString();
  4041. // Consider scientific notation: '3.4e-12' '3.4e+12'
  4042. var eIndex = str.indexOf('e');
  4043. if (eIndex > 0) {
  4044. var precision = +str.slice(eIndex + 1);
  4045. return precision < 0 ? -precision : 0;
  4046. }
  4047. else {
  4048. var dotIndex = str.indexOf('.');
  4049. return dotIndex < 0 ? 0 : str.length - 1 - dotIndex;
  4050. }
  4051. };
  4052. /**
  4053. * Minimal dicernible data precisioin according to a single pixel.
  4054. *
  4055. * @param {Array.<number>} dataExtent
  4056. * @param {Array.<number>} pixelExtent
  4057. * @return {number} precision
  4058. */
  4059. number.getPixelPrecision = function (dataExtent, pixelExtent) {
  4060. var log = Math.log;
  4061. var LN10 = Math.LN10;
  4062. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  4063. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
  4064. // toFixed() digits argument must be between 0 and 20.
  4065. var precision = Math.min(Math.max(-dataQuantity + sizeQuantity, 0), 20);
  4066. return !isFinite(precision) ? 20 : precision;
  4067. };
  4068. /**
  4069. * Get a data of given precision, assuring the sum of percentages
  4070. * in valueList is 1.
  4071. * The largest remainer method is used.
  4072. * https://en.wikipedia.org/wiki/Largest_remainder_method
  4073. *
  4074. * @param {Array.<number>} valueList a list of all data
  4075. * @param {number} idx index of the data to be processed in valueList
  4076. * @param {number} precision integer number showing digits of precision
  4077. * @return {number} percent ranging from 0 to 100
  4078. */
  4079. number.getPercentWithPrecision = function (valueList, idx, precision) {
  4080. if (!valueList[idx]) {
  4081. return 0;
  4082. }
  4083. var sum = zrUtil.reduce(valueList, function (acc, val) {
  4084. return acc + (isNaN(val) ? 0 : val);
  4085. }, 0);
  4086. if (sum === 0) {
  4087. return 0;
  4088. }
  4089. var digits = Math.pow(10, precision);
  4090. var votesPerQuota = zrUtil.map(valueList, function (val) {
  4091. return (isNaN(val) ? 0 : val) / sum * digits * 100;
  4092. });
  4093. var targetSeats = digits * 100;
  4094. var seats = zrUtil.map(votesPerQuota, function (votes) {
  4095. // Assign automatic seats.
  4096. return Math.floor(votes);
  4097. });
  4098. var currentSum = zrUtil.reduce(seats, function (acc, val) {
  4099. return acc + val;
  4100. }, 0);
  4101. var remainder = zrUtil.map(votesPerQuota, function (votes, idx) {
  4102. return votes - seats[idx];
  4103. });
  4104. // Has remainding votes.
  4105. while (currentSum < targetSeats) {
  4106. // Find next largest remainder.
  4107. var max = Number.NEGATIVE_INFINITY;
  4108. var maxId = null;
  4109. for (var i = 0, len = remainder.length; i < len; ++i) {
  4110. if (remainder[i] > max) {
  4111. max = remainder[i];
  4112. maxId = i;
  4113. }
  4114. }
  4115. // Add a vote to max remainder.
  4116. ++seats[maxId];
  4117. remainder[maxId] = 0;
  4118. ++currentSum;
  4119. }
  4120. return seats[idx] / digits;
  4121. };
  4122. // Number.MAX_SAFE_INTEGER, ie do not support.
  4123. number.MAX_SAFE_INTEGER = 9007199254740991;
  4124. /**
  4125. * To 0 - 2 * PI, considering negative radian.
  4126. * @param {number} radian
  4127. * @return {number}
  4128. */
  4129. number.remRadian = function (radian) {
  4130. var pi2 = Math.PI * 2;
  4131. return (radian % pi2 + pi2) % pi2;
  4132. };
  4133. /**
  4134. * @param {type} radian
  4135. * @return {boolean}
  4136. */
  4137. number.isRadianAroundZero = function (val) {
  4138. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  4139. };
  4140. 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
  4141. /**
  4142. * @return {number} in minutes
  4143. */
  4144. number.getTimezoneOffset = function () {
  4145. return (new Date()).getTimezoneOffset();
  4146. };
  4147. /**
  4148. * @param {string|Date|number} value These values can be accepted:
  4149. * + An instance of Date, represent a time in its own time zone.
  4150. * + Or string in a subset of ISO 8601, only including:
  4151. * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
  4152. * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
  4153. * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
  4154. * all of which will be treated as local time if time zone is not specified
  4155. * (see <https://momentjs.com/>).
  4156. * + Or other string format, including (all of which will be treated as loacal time):
  4157. * '2012', '2012-3-1', '2012/3/1', '2012/03/01',
  4158. * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
  4159. * + a timestamp, which represent a time in UTC.
  4160. * @return {Date} date
  4161. */
  4162. number.parseDate = function (value) {
  4163. if (value instanceof Date) {
  4164. return value;
  4165. }
  4166. else if (typeof value === 'string') {
  4167. // Different browsers parse date in different way, so we parse it manually.
  4168. // Some other issues:
  4169. // new Date('1970-01-01') is UTC,
  4170. // new Date('1970/01/01') and new Date('1970-1-01') is local.
  4171. // See issue #3623
  4172. var match = TIME_REG.exec(value);
  4173. if (!match) {
  4174. // return Invalid Date.
  4175. return new Date(NaN);
  4176. }
  4177. var timezoneOffset = number.getTimezoneOffset();
  4178. var timeOffset = !match[8]
  4179. ? 0
  4180. : match[8].toUpperCase() === 'Z'
  4181. ? timezoneOffset
  4182. : +match[8].slice(0, 3) * 60 + timezoneOffset;
  4183. // match[n] can only be string or undefined.
  4184. // But take care of '12' + 1 => '121'.
  4185. return new Date(
  4186. +match[1],
  4187. +(match[2] || 1) - 1,
  4188. +match[3] || 1,
  4189. +match[4] || 0,
  4190. +(match[5] || 0) - timeOffset,
  4191. +match[6] || 0,
  4192. +match[7] || 0
  4193. );
  4194. }
  4195. else if (value == null) {
  4196. return new Date(NaN);
  4197. }
  4198. return new Date(Math.round(value));
  4199. };
  4200. /**
  4201. * Quantity of a number. e.g. 0.1, 1, 10, 100
  4202. *
  4203. * @param {number} val
  4204. * @return {number}
  4205. */
  4206. number.quantity = function (val) {
  4207. return Math.pow(10, quantityExponent(val));
  4208. };
  4209. function quantityExponent(val) {
  4210. return Math.floor(Math.log(val) / Math.LN10);
  4211. }
  4212. /**
  4213. * find a “nice” number approximately equal to x. Round the number if round = true,
  4214. * take ceiling if round = false. The primary observation is that the “nicest”
  4215. * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  4216. *
  4217. * See "Nice Numbers for Graph Labels" of Graphic Gems.
  4218. *
  4219. * @param {number} val Non-negative value.
  4220. * @param {boolean} round
  4221. * @return {number}
  4222. */
  4223. number.nice = function (val, round) {
  4224. var exponent = quantityExponent(val);
  4225. var exp10 = Math.pow(10, exponent);
  4226. var f = val / exp10; // 1 <= f < 10
  4227. var nf;
  4228. if (round) {
  4229. if (f < 1.5) { nf = 1; }
  4230. else if (f < 2.5) { nf = 2; }
  4231. else if (f < 4) { nf = 3; }
  4232. else if (f < 7) { nf = 5; }
  4233. else { nf = 10; }
  4234. }
  4235. else {
  4236. if (f < 1) { nf = 1; }
  4237. else if (f < 2) { nf = 2; }
  4238. else if (f < 3) { nf = 3; }
  4239. else if (f < 5) { nf = 5; }
  4240. else { nf = 10; }
  4241. }
  4242. val = nf * exp10;
  4243. // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754).
  4244. // 20 is the uppper bound of toFixed.
  4245. return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
  4246. };
  4247. /**
  4248. * Order intervals asc, and split them when overlap.
  4249. * expect(numberUtil.reformIntervals([
  4250. * {interval: [18, 62], close: [1, 1]},
  4251. * {interval: [-Infinity, -70], close: [0, 0]},
  4252. * {interval: [-70, -26], close: [1, 1]},
  4253. * {interval: [-26, 18], close: [1, 1]},
  4254. * {interval: [62, 150], close: [1, 1]},
  4255. * {interval: [106, 150], close: [1, 1]},
  4256. * {interval: [150, Infinity], close: [0, 0]}
  4257. * ])).toEqual([
  4258. * {interval: [-Infinity, -70], close: [0, 0]},
  4259. * {interval: [-70, -26], close: [1, 1]},
  4260. * {interval: [-26, 18], close: [0, 1]},
  4261. * {interval: [18, 62], close: [0, 1]},
  4262. * {interval: [62, 150], close: [0, 1]},
  4263. * {interval: [150, Infinity], close: [0, 0]}
  4264. * ]);
  4265. * @param {Array.<Object>} list, where `close` mean open or close
  4266. * of the interval, and Infinity can be used.
  4267. * @return {Array.<Object>} The origin list, which has been reformed.
  4268. */
  4269. number.reformIntervals = function (list) {
  4270. list.sort(function (a, b) {
  4271. return littleThan(a, b, 0) ? -1 : 1;
  4272. });
  4273. var curr = -Infinity;
  4274. var currClose = 1;
  4275. for (var i = 0; i < list.length;) {
  4276. var interval = list[i].interval;
  4277. var close = list[i].close;
  4278. for (var lg = 0; lg < 2; lg++) {
  4279. if (interval[lg] <= curr) {
  4280. interval[lg] = curr;
  4281. close[lg] = !lg ? 1 - currClose : 1;
  4282. }
  4283. curr = interval[lg];
  4284. currClose = close[lg];
  4285. }
  4286. if (interval[0] === interval[1] && close[0] * close[1] !== 1) {
  4287. list.splice(i, 1);
  4288. }
  4289. else {
  4290. i++;
  4291. }
  4292. }
  4293. return list;
  4294. function littleThan(a, b, lg) {
  4295. return a.interval[lg] < b.interval[lg]
  4296. || (
  4297. a.interval[lg] === b.interval[lg]
  4298. && (
  4299. (a.close[lg] - b.close[lg] === (!lg ? 1 : -1))
  4300. || (!lg && littleThan(a, b, 1))
  4301. )
  4302. );
  4303. }
  4304. };
  4305. /**
  4306. * parseFloat NaNs numeric-cast false positives (null|true|false|"")
  4307. * ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  4308. * subtraction forces infinities to NaN
  4309. *
  4310. * @param {*} v
  4311. * @return {boolean}
  4312. */
  4313. number.isNumeric = function (v) {
  4314. return v - parseFloat(v) >= 0;
  4315. };
  4316. module.exports = number;
  4317. /***/ },
  4318. /* 8 */
  4319. /***/ function(module, exports, __webpack_require__) {
  4320. var textWidthCache = {};
  4321. var textWidthCacheCounter = 0;
  4322. var TEXT_CACHE_MAX = 5000;
  4323. var util = __webpack_require__(4);
  4324. var BoundingRect = __webpack_require__(9);
  4325. var retrieve = util.retrieve;
  4326. function getTextWidth(text, textFont) {
  4327. var key = text + ':' + textFont;
  4328. if (textWidthCache[key]) {
  4329. return textWidthCache[key];
  4330. }
  4331. var textLines = (text + '').split('\n');
  4332. var width = 0;
  4333. for (var i = 0, l = textLines.length; i < l; i++) {
  4334. // measureText 可以被覆盖以兼容不支持 Canvas 的环境
  4335. width = Math.max(textContain.measureText(textLines[i], textFont).width, width);
  4336. }
  4337. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  4338. textWidthCacheCounter = 0;
  4339. textWidthCache = {};
  4340. }
  4341. textWidthCacheCounter++;
  4342. textWidthCache[key] = width;
  4343. return width;
  4344. }
  4345. function getTextRect(text, textFont, textAlign, textBaseline) {
  4346. var textLineLen = ((text || '') + '').split('\n').length;
  4347. var width = getTextWidth(text, textFont);
  4348. // FIXME 高度计算比较粗暴
  4349. var lineHeight = getTextWidth('国', textFont);
  4350. var height = textLineLen * lineHeight;
  4351. var rect = new BoundingRect(0, 0, width, height);
  4352. // Text has a special line height property
  4353. rect.lineHeight = lineHeight;
  4354. switch (textBaseline) {
  4355. case 'bottom':
  4356. case 'alphabetic':
  4357. rect.y -= lineHeight;
  4358. break;
  4359. case 'middle':
  4360. rect.y -= lineHeight / 2;
  4361. break;
  4362. // case 'hanging':
  4363. // case 'top':
  4364. }
  4365. // FIXME Right to left language
  4366. switch (textAlign) {
  4367. case 'end':
  4368. case 'right':
  4369. rect.x -= rect.width;
  4370. break;
  4371. case 'center':
  4372. rect.x -= rect.width / 2;
  4373. break;
  4374. // case 'start':
  4375. // case 'left':
  4376. }
  4377. return rect;
  4378. }
  4379. function adjustTextPositionOnRect(textPosition, rect, textRect, distance) {
  4380. var x = rect.x;
  4381. var y = rect.y;
  4382. var height = rect.height;
  4383. var width = rect.width;
  4384. var textHeight = textRect.height;
  4385. var lineHeight = textRect.lineHeight;
  4386. var halfHeight = height / 2 - textHeight / 2 + lineHeight;
  4387. var textAlign = 'left';
  4388. switch (textPosition) {
  4389. case 'left':
  4390. x -= distance;
  4391. y += halfHeight;
  4392. textAlign = 'right';
  4393. break;
  4394. case 'right':
  4395. x += distance + width;
  4396. y += halfHeight;
  4397. textAlign = 'left';
  4398. break;
  4399. case 'top':
  4400. x += width / 2;
  4401. y -= distance + textHeight - lineHeight;
  4402. textAlign = 'center';
  4403. break;
  4404. case 'bottom':
  4405. x += width / 2;
  4406. y += height + distance + lineHeight;
  4407. textAlign = 'center';
  4408. break;
  4409. case 'inside':
  4410. x += width / 2;
  4411. y += halfHeight;
  4412. textAlign = 'center';
  4413. break;
  4414. case 'insideLeft':
  4415. x += distance;
  4416. y += halfHeight;
  4417. textAlign = 'left';
  4418. break;
  4419. case 'insideRight':
  4420. x += width - distance;
  4421. y += halfHeight;
  4422. textAlign = 'right';
  4423. break;
  4424. case 'insideTop':
  4425. x += width / 2;
  4426. y += distance + lineHeight;
  4427. textAlign = 'center';
  4428. break;
  4429. case 'insideBottom':
  4430. x += width / 2;
  4431. y += height - textHeight - distance + lineHeight;
  4432. textAlign = 'center';
  4433. break;
  4434. case 'insideTopLeft':
  4435. x += distance;
  4436. y += distance + lineHeight;
  4437. textAlign = 'left';
  4438. break;
  4439. case 'insideTopRight':
  4440. x += width - distance;
  4441. y += distance + lineHeight;
  4442. textAlign = 'right';
  4443. break;
  4444. case 'insideBottomLeft':
  4445. x += distance;
  4446. y += height - textHeight - distance + lineHeight;
  4447. break;
  4448. case 'insideBottomRight':
  4449. x += width - distance;
  4450. y += height - textHeight - distance + lineHeight;
  4451. textAlign = 'right';
  4452. break;
  4453. }
  4454. return {
  4455. x: x,
  4456. y: y,
  4457. textAlign: textAlign,
  4458. textBaseline: 'alphabetic'
  4459. };
  4460. }
  4461. /**
  4462. * Show ellipsis if overflow.
  4463. *
  4464. * @param {string} text
  4465. * @param {string} containerWidth
  4466. * @param {string} textFont
  4467. * @param {number} [ellipsis='...']
  4468. * @param {Object} [options]
  4469. * @param {number} [options.maxIterations=3]
  4470. * @param {number} [options.minChar=0] If truncate result are less
  4471. * then minChar, ellipsis will not show, which is
  4472. * better for user hint in some cases.
  4473. * @param {number} [options.placeholder=''] When all truncated, use the placeholder.
  4474. * @return {string}
  4475. */
  4476. function truncateText(text, containerWidth, textFont, ellipsis, options) {
  4477. if (!containerWidth) {
  4478. return '';
  4479. }
  4480. options = options || {};
  4481. ellipsis = retrieve(ellipsis, '...');
  4482. var maxIterations = retrieve(options.maxIterations, 2);
  4483. var minChar = retrieve(options.minChar, 0);
  4484. // FIXME
  4485. // Other languages?
  4486. var cnCharWidth = getTextWidth('国', textFont);
  4487. // FIXME
  4488. // Consider proportional font?
  4489. var ascCharWidth = getTextWidth('a', textFont);
  4490. var placeholder = retrieve(options.placeholder, '');
  4491. // Example 1: minChar: 3, text: 'asdfzxcv', truncate result: 'asdf', but not: 'a...'.
  4492. // Example 2: minChar: 3, text: '维度', truncate result: '维', but not: '...'.
  4493. var contentWidth = containerWidth = Math.max(0, containerWidth - 1); // Reserve some gap.
  4494. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  4495. contentWidth -= ascCharWidth;
  4496. }
  4497. var ellipsisWidth = getTextWidth(ellipsis);
  4498. if (ellipsisWidth > contentWidth) {
  4499. ellipsis = '';
  4500. ellipsisWidth = 0;
  4501. }
  4502. contentWidth = containerWidth - ellipsisWidth;
  4503. var textLines = (text + '').split('\n');
  4504. for (var i = 0, len = textLines.length; i < len; i++) {
  4505. var textLine = textLines[i];
  4506. var lineWidth = getTextWidth(textLine, textFont);
  4507. if (lineWidth <= containerWidth) {
  4508. continue;
  4509. }
  4510. for (var j = 0;; j++) {
  4511. if (lineWidth <= contentWidth || j >= maxIterations) {
  4512. textLine += ellipsis;
  4513. break;
  4514. }
  4515. var subLength = j === 0
  4516. ? estimateLength(textLine, contentWidth, ascCharWidth, cnCharWidth)
  4517. : lineWidth > 0
  4518. ? Math.floor(textLine.length * contentWidth / lineWidth)
  4519. : 0;
  4520. textLine = textLine.substr(0, subLength);
  4521. lineWidth = getTextWidth(textLine, textFont);
  4522. }
  4523. if (textLine === '') {
  4524. textLine = placeholder;
  4525. }
  4526. textLines[i] = textLine;
  4527. }
  4528. return textLines.join('\n');
  4529. }
  4530. function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
  4531. var width = 0;
  4532. var i = 0;
  4533. for (var len = text.length; i < len && width < contentWidth; i++) {
  4534. var charCode = text.charCodeAt(i);
  4535. width += (0 <= charCode && charCode <= 127) ? ascCharWidth : cnCharWidth;
  4536. }
  4537. return i;
  4538. }
  4539. var textContain = {
  4540. getWidth: getTextWidth,
  4541. getBoundingRect: getTextRect,
  4542. adjustTextPositionOnRect: adjustTextPositionOnRect,
  4543. truncateText: truncateText,
  4544. measureText: function (text, textFont) {
  4545. var ctx = util.getContext();
  4546. ctx.font = textFont || '12px sans-serif';
  4547. return ctx.measureText(text);
  4548. }
  4549. };
  4550. module.exports = textContain;
  4551. /***/ },
  4552. /* 9 */
  4553. /***/ function(module, exports, __webpack_require__) {
  4554. 'use strict';
  4555. /**
  4556. * @module echarts/core/BoundingRect
  4557. */
  4558. var vec2 = __webpack_require__(10);
  4559. var matrix = __webpack_require__(11);
  4560. var v2ApplyTransform = vec2.applyTransform;
  4561. var mathMin = Math.min;
  4562. var mathMax = Math.max;
  4563. /**
  4564. * @alias module:echarts/core/BoundingRect
  4565. */
  4566. function BoundingRect(x, y, width, height) {
  4567. if (width < 0) {
  4568. x = x + width;
  4569. width = -width;
  4570. }
  4571. if (height < 0) {
  4572. y = y + height;
  4573. height = -height;
  4574. }
  4575. /**
  4576. * @type {number}
  4577. */
  4578. this.x = x;
  4579. /**
  4580. * @type {number}
  4581. */
  4582. this.y = y;
  4583. /**
  4584. * @type {number}
  4585. */
  4586. this.width = width;
  4587. /**
  4588. * @type {number}
  4589. */
  4590. this.height = height;
  4591. }
  4592. BoundingRect.prototype = {
  4593. constructor: BoundingRect,
  4594. /**
  4595. * @param {module:echarts/core/BoundingRect} other
  4596. */
  4597. union: function (other) {
  4598. var x = mathMin(other.x, this.x);
  4599. var y = mathMin(other.y, this.y);
  4600. this.width = mathMax(
  4601. other.x + other.width,
  4602. this.x + this.width
  4603. ) - x;
  4604. this.height = mathMax(
  4605. other.y + other.height,
  4606. this.y + this.height
  4607. ) - y;
  4608. this.x = x;
  4609. this.y = y;
  4610. },
  4611. /**
  4612. * @param {Array.<number>} m
  4613. * @methods
  4614. */
  4615. applyTransform: (function () {
  4616. var lt = [];
  4617. var rb = [];
  4618. var lb = [];
  4619. var rt = [];
  4620. return function (m) {
  4621. // In case usage like this
  4622. // el.getBoundingRect().applyTransform(el.transform)
  4623. // And element has no transform
  4624. if (!m) {
  4625. return;
  4626. }
  4627. lt[0] = lb[0] = this.x;
  4628. lt[1] = rt[1] = this.y;
  4629. rb[0] = rt[0] = this.x + this.width;
  4630. rb[1] = lb[1] = this.y + this.height;
  4631. v2ApplyTransform(lt, lt, m);
  4632. v2ApplyTransform(rb, rb, m);
  4633. v2ApplyTransform(lb, lb, m);
  4634. v2ApplyTransform(rt, rt, m);
  4635. this.x = mathMin(lt[0], rb[0], lb[0], rt[0]);
  4636. this.y = mathMin(lt[1], rb[1], lb[1], rt[1]);
  4637. var maxX = mathMax(lt[0], rb[0], lb[0], rt[0]);
  4638. var maxY = mathMax(lt[1], rb[1], lb[1], rt[1]);
  4639. this.width = maxX - this.x;
  4640. this.height = maxY - this.y;
  4641. };
  4642. })(),
  4643. /**
  4644. * Calculate matrix of transforming from self to target rect
  4645. * @param {module:zrender/core/BoundingRect} b
  4646. * @return {Array.<number>}
  4647. */
  4648. calculateTransform: function (b) {
  4649. var a = this;
  4650. var sx = b.width / a.width;
  4651. var sy = b.height / a.height;
  4652. var m = matrix.create();
  4653. // 矩阵右乘
  4654. matrix.translate(m, m, [-a.x, -a.y]);
  4655. matrix.scale(m, m, [sx, sy]);
  4656. matrix.translate(m, m, [b.x, b.y]);
  4657. return m;
  4658. },
  4659. /**
  4660. * @param {(module:echarts/core/BoundingRect|Object)} b
  4661. * @return {boolean}
  4662. */
  4663. intersect: function (b) {
  4664. if (!b) {
  4665. return false;
  4666. }
  4667. if (!(b instanceof BoundingRect)) {
  4668. // Normalize negative width/height.
  4669. b = BoundingRect.create(b);
  4670. }
  4671. var a = this;
  4672. var ax0 = a.x;
  4673. var ax1 = a.x + a.width;
  4674. var ay0 = a.y;
  4675. var ay1 = a.y + a.height;
  4676. var bx0 = b.x;
  4677. var bx1 = b.x + b.width;
  4678. var by0 = b.y;
  4679. var by1 = b.y + b.height;
  4680. return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  4681. },
  4682. contain: function (x, y) {
  4683. var rect = this;
  4684. return x >= rect.x
  4685. && x <= (rect.x + rect.width)
  4686. && y >= rect.y
  4687. && y <= (rect.y + rect.height);
  4688. },
  4689. /**
  4690. * @return {module:echarts/core/BoundingRect}
  4691. */
  4692. clone: function () {
  4693. return new BoundingRect(this.x, this.y, this.width, this.height);
  4694. },
  4695. /**
  4696. * Copy from another rect
  4697. */
  4698. copy: function (other) {
  4699. this.x = other.x;
  4700. this.y = other.y;
  4701. this.width = other.width;
  4702. this.height = other.height;
  4703. },
  4704. plain: function () {
  4705. return {
  4706. x: this.x,
  4707. y: this.y,
  4708. width: this.width,
  4709. height: this.height
  4710. };
  4711. }
  4712. };
  4713. /**
  4714. * @param {Object|module:zrender/core/BoundingRect} rect
  4715. * @param {number} rect.x
  4716. * @param {number} rect.y
  4717. * @param {number} rect.width
  4718. * @param {number} rect.height
  4719. * @return {module:zrender/core/BoundingRect}
  4720. */
  4721. BoundingRect.create = function (rect) {
  4722. return new BoundingRect(rect.x, rect.y, rect.width, rect.height);
  4723. };
  4724. module.exports = BoundingRect;
  4725. /***/ },
  4726. /* 10 */
  4727. /***/ function(module, exports) {
  4728. var ArrayCtor = typeof Float32Array === 'undefined'
  4729. ? Array
  4730. : Float32Array;
  4731. /**
  4732. * @typedef {Float32Array|Array.<number>} Vector2
  4733. */
  4734. /**
  4735. * 二维向量类
  4736. * @exports zrender/tool/vector
  4737. */
  4738. var vector = {
  4739. /**
  4740. * 创建一个向量
  4741. * @param {number} [x=0]
  4742. * @param {number} [y=0]
  4743. * @return {Vector2}
  4744. */
  4745. create: function (x, y) {
  4746. var out = new ArrayCtor(2);
  4747. if (x == null) {
  4748. x = 0;
  4749. }
  4750. if (y == null) {
  4751. y = 0;
  4752. }
  4753. out[0] = x;
  4754. out[1] = y;
  4755. return out;
  4756. },
  4757. /**
  4758. * 复制向量数据
  4759. * @param {Vector2} out
  4760. * @param {Vector2} v
  4761. * @return {Vector2}
  4762. */
  4763. copy: function (out, v) {
  4764. out[0] = v[0];
  4765. out[1] = v[1];
  4766. return out;
  4767. },
  4768. /**
  4769. * 克隆一个向量
  4770. * @param {Vector2} v
  4771. * @return {Vector2}
  4772. */
  4773. clone: function (v) {
  4774. var out = new ArrayCtor(2);
  4775. out[0] = v[0];
  4776. out[1] = v[1];
  4777. return out;
  4778. },
  4779. /**
  4780. * 设置向量的两个项
  4781. * @param {Vector2} out
  4782. * @param {number} a
  4783. * @param {number} b
  4784. * @return {Vector2} 结果
  4785. */
  4786. set: function (out, a, b) {
  4787. out[0] = a;
  4788. out[1] = b;
  4789. return out;
  4790. },
  4791. /**
  4792. * 向量相加
  4793. * @param {Vector2} out
  4794. * @param {Vector2} v1
  4795. * @param {Vector2} v2
  4796. */
  4797. add: function (out, v1, v2) {
  4798. out[0] = v1[0] + v2[0];
  4799. out[1] = v1[1] + v2[1];
  4800. return out;
  4801. },
  4802. /**
  4803. * 向量缩放后相加
  4804. * @param {Vector2} out
  4805. * @param {Vector2} v1
  4806. * @param {Vector2} v2
  4807. * @param {number} a
  4808. */
  4809. scaleAndAdd: function (out, v1, v2, a) {
  4810. out[0] = v1[0] + v2[0] * a;
  4811. out[1] = v1[1] + v2[1] * a;
  4812. return out;
  4813. },
  4814. /**
  4815. * 向量相减
  4816. * @param {Vector2} out
  4817. * @param {Vector2} v1
  4818. * @param {Vector2} v2
  4819. */
  4820. sub: function (out, v1, v2) {
  4821. out[0] = v1[0] - v2[0];
  4822. out[1] = v1[1] - v2[1];
  4823. return out;
  4824. },
  4825. /**
  4826. * 向量长度
  4827. * @param {Vector2} v
  4828. * @return {number}
  4829. */
  4830. len: function (v) {
  4831. return Math.sqrt(this.lenSquare(v));
  4832. },
  4833. /**
  4834. * 向量长度平方
  4835. * @param {Vector2} v
  4836. * @return {number}
  4837. */
  4838. lenSquare: function (v) {
  4839. return v[0] * v[0] + v[1] * v[1];
  4840. },
  4841. /**
  4842. * 向量乘法
  4843. * @param {Vector2} out
  4844. * @param {Vector2} v1
  4845. * @param {Vector2} v2
  4846. */
  4847. mul: function (out, v1, v2) {
  4848. out[0] = v1[0] * v2[0];
  4849. out[1] = v1[1] * v2[1];
  4850. return out;
  4851. },
  4852. /**
  4853. * 向量除法
  4854. * @param {Vector2} out
  4855. * @param {Vector2} v1
  4856. * @param {Vector2} v2
  4857. */
  4858. div: function (out, v1, v2) {
  4859. out[0] = v1[0] / v2[0];
  4860. out[1] = v1[1] / v2[1];
  4861. return out;
  4862. },
  4863. /**
  4864. * 向量点乘
  4865. * @param {Vector2} v1
  4866. * @param {Vector2} v2
  4867. * @return {number}
  4868. */
  4869. dot: function (v1, v2) {
  4870. return v1[0] * v2[0] + v1[1] * v2[1];
  4871. },
  4872. /**
  4873. * 向量缩放
  4874. * @param {Vector2} out
  4875. * @param {Vector2} v
  4876. * @param {number} s
  4877. */
  4878. scale: function (out, v, s) {
  4879. out[0] = v[0] * s;
  4880. out[1] = v[1] * s;
  4881. return out;
  4882. },
  4883. /**
  4884. * 向量归一化
  4885. * @param {Vector2} out
  4886. * @param {Vector2} v
  4887. */
  4888. normalize: function (out, v) {
  4889. var d = vector.len(v);
  4890. if (d === 0) {
  4891. out[0] = 0;
  4892. out[1] = 0;
  4893. }
  4894. else {
  4895. out[0] = v[0] / d;
  4896. out[1] = v[1] / d;
  4897. }
  4898. return out;
  4899. },
  4900. /**
  4901. * 计算向量间距离
  4902. * @param {Vector2} v1
  4903. * @param {Vector2} v2
  4904. * @return {number}
  4905. */
  4906. distance: function (v1, v2) {
  4907. return Math.sqrt(
  4908. (v1[0] - v2[0]) * (v1[0] - v2[0])
  4909. + (v1[1] - v2[1]) * (v1[1] - v2[1])
  4910. );
  4911. },
  4912. /**
  4913. * 向量距离平方
  4914. * @param {Vector2} v1
  4915. * @param {Vector2} v2
  4916. * @return {number}
  4917. */
  4918. distanceSquare: function (v1, v2) {
  4919. return (v1[0] - v2[0]) * (v1[0] - v2[0])
  4920. + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  4921. },
  4922. /**
  4923. * 求负向量
  4924. * @param {Vector2} out
  4925. * @param {Vector2} v
  4926. */
  4927. negate: function (out, v) {
  4928. out[0] = -v[0];
  4929. out[1] = -v[1];
  4930. return out;
  4931. },
  4932. /**
  4933. * 插值两个点
  4934. * @param {Vector2} out
  4935. * @param {Vector2} v1
  4936. * @param {Vector2} v2
  4937. * @param {number} t
  4938. */
  4939. lerp: function (out, v1, v2, t) {
  4940. out[0] = v1[0] + t * (v2[0] - v1[0]);
  4941. out[1] = v1[1] + t * (v2[1] - v1[1]);
  4942. return out;
  4943. },
  4944. /**
  4945. * 矩阵左乘向量
  4946. * @param {Vector2} out
  4947. * @param {Vector2} v
  4948. * @param {Vector2} m
  4949. */
  4950. applyTransform: function (out, v, m) {
  4951. var x = v[0];
  4952. var y = v[1];
  4953. out[0] = m[0] * x + m[2] * y + m[4];
  4954. out[1] = m[1] * x + m[3] * y + m[5];
  4955. return out;
  4956. },
  4957. /**
  4958. * 求两个向量最小值
  4959. * @param {Vector2} out
  4960. * @param {Vector2} v1
  4961. * @param {Vector2} v2
  4962. */
  4963. min: function (out, v1, v2) {
  4964. out[0] = Math.min(v1[0], v2[0]);
  4965. out[1] = Math.min(v1[1], v2[1]);
  4966. return out;
  4967. },
  4968. /**
  4969. * 求两个向量最大值
  4970. * @param {Vector2} out
  4971. * @param {Vector2} v1
  4972. * @param {Vector2} v2
  4973. */
  4974. max: function (out, v1, v2) {
  4975. out[0] = Math.max(v1[0], v2[0]);
  4976. out[1] = Math.max(v1[1], v2[1]);
  4977. return out;
  4978. }
  4979. };
  4980. vector.length = vector.len;
  4981. vector.lengthSquare = vector.lenSquare;
  4982. vector.dist = vector.distance;
  4983. vector.distSquare = vector.distanceSquare;
  4984. module.exports = vector;
  4985. /***/ },
  4986. /* 11 */
  4987. /***/ function(module, exports) {
  4988. var ArrayCtor = typeof Float32Array === 'undefined'
  4989. ? Array
  4990. : Float32Array;
  4991. /**
  4992. * 3x2矩阵操作类
  4993. * @exports zrender/tool/matrix
  4994. */
  4995. var matrix = {
  4996. /**
  4997. * 创建一个单位矩阵
  4998. * @return {Float32Array|Array.<number>}
  4999. */
  5000. create : function() {
  5001. var out = new ArrayCtor(6);
  5002. matrix.identity(out);
  5003. return out;
  5004. },
  5005. /**
  5006. * 设置矩阵为单位矩阵
  5007. * @param {Float32Array|Array.<number>} out
  5008. */
  5009. identity : function(out) {
  5010. out[0] = 1;
  5011. out[1] = 0;
  5012. out[2] = 0;
  5013. out[3] = 1;
  5014. out[4] = 0;
  5015. out[5] = 0;
  5016. return out;
  5017. },
  5018. /**
  5019. * 复制矩阵
  5020. * @param {Float32Array|Array.<number>} out
  5021. * @param {Float32Array|Array.<number>} m
  5022. */
  5023. copy: function(out, m) {
  5024. out[0] = m[0];
  5025. out[1] = m[1];
  5026. out[2] = m[2];
  5027. out[3] = m[3];
  5028. out[4] = m[4];
  5029. out[5] = m[5];
  5030. return out;
  5031. },
  5032. /**
  5033. * 矩阵相乘
  5034. * @param {Float32Array|Array.<number>} out
  5035. * @param {Float32Array|Array.<number>} m1
  5036. * @param {Float32Array|Array.<number>} m2
  5037. */
  5038. mul : function (out, m1, m2) {
  5039. // Consider matrix.mul(m, m2, m);
  5040. // where out is the same as m2.
  5041. // So use temp variable to escape error.
  5042. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  5043. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  5044. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  5045. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  5046. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  5047. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  5048. out[0] = out0;
  5049. out[1] = out1;
  5050. out[2] = out2;
  5051. out[3] = out3;
  5052. out[4] = out4;
  5053. out[5] = out5;
  5054. return out;
  5055. },
  5056. /**
  5057. * 平移变换
  5058. * @param {Float32Array|Array.<number>} out
  5059. * @param {Float32Array|Array.<number>} a
  5060. * @param {Float32Array|Array.<number>} v
  5061. */
  5062. translate : function(out, a, v) {
  5063. out[0] = a[0];
  5064. out[1] = a[1];
  5065. out[2] = a[2];
  5066. out[3] = a[3];
  5067. out[4] = a[4] + v[0];
  5068. out[5] = a[5] + v[1];
  5069. return out;
  5070. },
  5071. /**
  5072. * 旋转变换
  5073. * @param {Float32Array|Array.<number>} out
  5074. * @param {Float32Array|Array.<number>} a
  5075. * @param {number} rad
  5076. */
  5077. rotate : function(out, a, rad) {
  5078. var aa = a[0];
  5079. var ac = a[2];
  5080. var atx = a[4];
  5081. var ab = a[1];
  5082. var ad = a[3];
  5083. var aty = a[5];
  5084. var st = Math.sin(rad);
  5085. var ct = Math.cos(rad);
  5086. out[0] = aa * ct + ab * st;
  5087. out[1] = -aa * st + ab * ct;
  5088. out[2] = ac * ct + ad * st;
  5089. out[3] = -ac * st + ct * ad;
  5090. out[4] = ct * atx + st * aty;
  5091. out[5] = ct * aty - st * atx;
  5092. return out;
  5093. },
  5094. /**
  5095. * 缩放变换
  5096. * @param {Float32Array|Array.<number>} out
  5097. * @param {Float32Array|Array.<number>} a
  5098. * @param {Float32Array|Array.<number>} v
  5099. */
  5100. scale : function(out, a, v) {
  5101. var vx = v[0];
  5102. var vy = v[1];
  5103. out[0] = a[0] * vx;
  5104. out[1] = a[1] * vy;
  5105. out[2] = a[2] * vx;
  5106. out[3] = a[3] * vy;
  5107. out[4] = a[4] * vx;
  5108. out[5] = a[5] * vy;
  5109. return out;
  5110. },
  5111. /**
  5112. * 求逆矩阵
  5113. * @param {Float32Array|Array.<number>} out
  5114. * @param {Float32Array|Array.<number>} a
  5115. */
  5116. invert : function(out, a) {
  5117. var aa = a[0];
  5118. var ac = a[2];
  5119. var atx = a[4];
  5120. var ab = a[1];
  5121. var ad = a[3];
  5122. var aty = a[5];
  5123. var det = aa * ad - ab * ac;
  5124. if (!det) {
  5125. return null;
  5126. }
  5127. det = 1.0 / det;
  5128. out[0] = ad * det;
  5129. out[1] = -ab * det;
  5130. out[2] = -ac * det;
  5131. out[3] = aa * det;
  5132. out[4] = (ac * aty - ad * atx) * det;
  5133. out[5] = (ab * atx - aa * aty) * det;
  5134. return out;
  5135. }
  5136. };
  5137. module.exports = matrix;
  5138. /***/ },
  5139. /* 12 */
  5140. /***/ function(module, exports, __webpack_require__) {
  5141. /**
  5142. * @module echarts/model/Model
  5143. */
  5144. var zrUtil = __webpack_require__(4);
  5145. var clazzUtil = __webpack_require__(13);
  5146. var env = __webpack_require__(2);
  5147. /**
  5148. * @alias module:echarts/model/Model
  5149. * @constructor
  5150. * @param {Object} option
  5151. * @param {module:echarts/model/Model} [parentModel]
  5152. * @param {module:echarts/model/Global} [ecModel]
  5153. */
  5154. function Model(option, parentModel, ecModel) {
  5155. /**
  5156. * @type {module:echarts/model/Model}
  5157. * @readOnly
  5158. */
  5159. this.parentModel = parentModel;
  5160. /**
  5161. * @type {module:echarts/model/Global}
  5162. * @readOnly
  5163. */
  5164. this.ecModel = ecModel;
  5165. /**
  5166. * @type {Object}
  5167. * @protected
  5168. */
  5169. this.option = option;
  5170. // Simple optimization
  5171. // if (this.init) {
  5172. // if (arguments.length <= 4) {
  5173. // this.init(option, parentModel, ecModel, extraOpt);
  5174. // }
  5175. // else {
  5176. // this.init.apply(this, arguments);
  5177. // }
  5178. // }
  5179. }
  5180. Model.prototype = {
  5181. constructor: Model,
  5182. /**
  5183. * Model 的初始化函数
  5184. * @param {Object} option
  5185. */
  5186. init: null,
  5187. /**
  5188. * 从新的 Option merge
  5189. */
  5190. mergeOption: function (option) {
  5191. zrUtil.merge(this.option, option, true);
  5192. },
  5193. /**
  5194. * @param {string|Array.<string>} path
  5195. * @param {boolean} [ignoreParent=false]
  5196. * @return {*}
  5197. */
  5198. get: function (path, ignoreParent) {
  5199. if (path == null) {
  5200. return this.option;
  5201. }
  5202. return doGet(
  5203. this.option,
  5204. this.parsePath(path),
  5205. !ignoreParent && getParent(this, path)
  5206. );
  5207. },
  5208. /**
  5209. * @param {string} key
  5210. * @param {boolean} [ignoreParent=false]
  5211. * @return {*}
  5212. */
  5213. getShallow: function (key, ignoreParent) {
  5214. var option = this.option;
  5215. var val = option == null ? option : option[key];
  5216. var parentModel = !ignoreParent && getParent(this, key);
  5217. if (val == null && parentModel) {
  5218. val = parentModel.getShallow(key);
  5219. }
  5220. return val;
  5221. },
  5222. /**
  5223. * @param {string|Array.<string>} [path]
  5224. * @param {module:echarts/model/Model} [parentModel]
  5225. * @return {module:echarts/model/Model}
  5226. */
  5227. getModel: function (path, parentModel) {
  5228. var obj = path == null
  5229. ? this.option
  5230. : doGet(this.option, path = this.parsePath(path));
  5231. var thisParentModel;
  5232. parentModel = parentModel || (
  5233. (thisParentModel = getParent(this, path))
  5234. && thisParentModel.getModel(path)
  5235. );
  5236. return new Model(obj, parentModel, this.ecModel);
  5237. },
  5238. /**
  5239. * If model has option
  5240. */
  5241. isEmpty: function () {
  5242. return this.option == null;
  5243. },
  5244. restoreData: function () {},
  5245. // Pending
  5246. clone: function () {
  5247. var Ctor = this.constructor;
  5248. return new Ctor(zrUtil.clone(this.option));
  5249. },
  5250. setReadOnly: function (properties) {
  5251. clazzUtil.setReadOnly(this, properties);
  5252. },
  5253. // If path is null/undefined, return null/undefined.
  5254. parsePath: function(path) {
  5255. if (typeof path === 'string') {
  5256. path = path.split('.');
  5257. }
  5258. return path;
  5259. },
  5260. /**
  5261. * @param {Function} getParentMethod
  5262. * param {Array.<string>|string} path
  5263. * return {module:echarts/model/Model}
  5264. */
  5265. customizeGetParent: function (getParentMethod) {
  5266. clazzUtil.set(this, 'getParent', getParentMethod);
  5267. },
  5268. isAnimationEnabled: function () {
  5269. if (!env.node) {
  5270. if (this.option.animation != null) {
  5271. return !!this.option.animation;
  5272. }
  5273. else if (this.parentModel) {
  5274. return this.parentModel.isAnimationEnabled();
  5275. }
  5276. }
  5277. }
  5278. };
  5279. function doGet(obj, pathArr, parentModel) {
  5280. for (var i = 0; i < pathArr.length; i++) {
  5281. // Ignore empty
  5282. if (!pathArr[i]) {
  5283. continue;
  5284. }
  5285. // obj could be number/string/... (like 0)
  5286. obj = (obj && typeof obj === 'object') ? obj[pathArr[i]] : null;
  5287. if (obj == null) {
  5288. break;
  5289. }
  5290. }
  5291. if (obj == null && parentModel) {
  5292. obj = parentModel.get(pathArr);
  5293. }
  5294. return obj;
  5295. }
  5296. // `path` can be null/undefined
  5297. function getParent(model, path) {
  5298. var getParentMethod = clazzUtil.get(model, 'getParent');
  5299. return getParentMethod ? getParentMethod.call(model, path) : model.parentModel;
  5300. }
  5301. // Enable Model.extend.
  5302. clazzUtil.enableClassExtend(Model);
  5303. var mixin = zrUtil.mixin;
  5304. mixin(Model, __webpack_require__(14));
  5305. mixin(Model, __webpack_require__(16));
  5306. mixin(Model, __webpack_require__(17));
  5307. mixin(Model, __webpack_require__(68));
  5308. module.exports = Model;
  5309. /***/ },
  5310. /* 13 */
  5311. /***/ function(module, exports, __webpack_require__) {
  5312. var zrUtil = __webpack_require__(4);
  5313. var clazz = {};
  5314. var TYPE_DELIMITER = '.';
  5315. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  5316. var MEMBER_PRIFIX = '\0ec_\0';
  5317. /**
  5318. * Hide private class member.
  5319. * The same behavior as `host[name] = value;` (can be right-value)
  5320. * @public
  5321. */
  5322. clazz.set = function (host, name, value) {
  5323. return (host[MEMBER_PRIFIX + name] = value);
  5324. };
  5325. /**
  5326. * Hide private class member.
  5327. * The same behavior as `host[name];`
  5328. * @public
  5329. */
  5330. clazz.get = function (host, name) {
  5331. return host[MEMBER_PRIFIX + name];
  5332. };
  5333. /**
  5334. * For hidden private class member.
  5335. * The same behavior as `host.hasOwnProperty(name);`
  5336. * @public
  5337. */
  5338. clazz.hasOwn = function (host, name) {
  5339. return host.hasOwnProperty(MEMBER_PRIFIX + name);
  5340. };
  5341. /**
  5342. * Notice, parseClassType('') should returns {main: '', sub: ''}
  5343. * @public
  5344. */
  5345. var parseClassType = clazz.parseClassType = function (componentType) {
  5346. var ret = {main: '', sub: ''};
  5347. if (componentType) {
  5348. componentType = componentType.split(TYPE_DELIMITER);
  5349. ret.main = componentType[0] || '';
  5350. ret.sub = componentType[1] || '';
  5351. }
  5352. return ret;
  5353. };
  5354. /**
  5355. * @public
  5356. */
  5357. function checkClassType(componentType) {
  5358. zrUtil.assert(
  5359. /^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType),
  5360. 'componentType "' + componentType + '" illegal'
  5361. );
  5362. }
  5363. /**
  5364. * @public
  5365. */
  5366. clazz.enableClassExtend = function (RootClass, mandatoryMethods) {
  5367. RootClass.$constructor = RootClass;
  5368. RootClass.extend = function (proto) {
  5369. if (true) {
  5370. zrUtil.each(mandatoryMethods, function (method) {
  5371. if (!proto[method]) {
  5372. console.warn(
  5373. 'Method `' + method + '` should be implemented'
  5374. + (proto.type ? ' in ' + proto.type : '') + '.'
  5375. );
  5376. }
  5377. });
  5378. }
  5379. var superClass = this;
  5380. var ExtendedClass = function () {
  5381. if (!proto.$constructor) {
  5382. superClass.apply(this, arguments);
  5383. }
  5384. else {
  5385. proto.$constructor.apply(this, arguments);
  5386. }
  5387. };
  5388. zrUtil.extend(ExtendedClass.prototype, proto);
  5389. ExtendedClass.extend = this.extend;
  5390. ExtendedClass.superCall = superCall;
  5391. ExtendedClass.superApply = superApply;
  5392. zrUtil.inherits(ExtendedClass, this);
  5393. ExtendedClass.superClass = superClass;
  5394. return ExtendedClass;
  5395. };
  5396. };
  5397. // superCall should have class info, which can not be fetch from 'this'.
  5398. // Consider this case:
  5399. // class A has method f,
  5400. // class B inherits class A, overrides method f, f call superApply('f'),
  5401. // class C inherits class B, do not overrides method f,
  5402. // then when method of class C is called, dead loop occured.
  5403. function superCall(context, methodName) {
  5404. var args = zrUtil.slice(arguments, 2);
  5405. return this.superClass.prototype[methodName].apply(context, args);
  5406. }
  5407. function superApply(context, methodName, args) {
  5408. return this.superClass.prototype[methodName].apply(context, args);
  5409. }
  5410. /**
  5411. * @param {Object} entity
  5412. * @param {Object} options
  5413. * @param {boolean} [options.registerWhenExtend]
  5414. * @public
  5415. */
  5416. clazz.enableClassManagement = function (entity, options) {
  5417. options = options || {};
  5418. /**
  5419. * Component model classes
  5420. * key: componentType,
  5421. * value:
  5422. * componentClass, when componentType is 'xxx'
  5423. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  5424. * @type {Object}
  5425. */
  5426. var storage = {};
  5427. entity.registerClass = function (Clazz, componentType) {
  5428. if (componentType) {
  5429. checkClassType(componentType);
  5430. componentType = parseClassType(componentType);
  5431. if (!componentType.sub) {
  5432. if (true) {
  5433. if (storage[componentType.main]) {
  5434. console.warn(componentType.main + ' exists.');
  5435. }
  5436. }
  5437. storage[componentType.main] = Clazz;
  5438. }
  5439. else if (componentType.sub !== IS_CONTAINER) {
  5440. var container = makeContainer(componentType);
  5441. container[componentType.sub] = Clazz;
  5442. }
  5443. }
  5444. return Clazz;
  5445. };
  5446. entity.getClass = function (componentMainType, subType, throwWhenNotFound) {
  5447. var Clazz = storage[componentMainType];
  5448. if (Clazz && Clazz[IS_CONTAINER]) {
  5449. Clazz = subType ? Clazz[subType] : null;
  5450. }
  5451. if (throwWhenNotFound && !Clazz) {
  5452. throw new Error(
  5453. !subType
  5454. ? componentMainType + '.' + 'type should be specified.'
  5455. : 'Component ' + componentMainType + '.' + (subType || '') + ' not exists. Load it first.'
  5456. );
  5457. }
  5458. return Clazz;
  5459. };
  5460. entity.getClassesByMainType = function (componentType) {
  5461. componentType = parseClassType(componentType);
  5462. var result = [];
  5463. var obj = storage[componentType.main];
  5464. if (obj && obj[IS_CONTAINER]) {
  5465. zrUtil.each(obj, function (o, type) {
  5466. type !== IS_CONTAINER && result.push(o);
  5467. });
  5468. }
  5469. else {
  5470. result.push(obj);
  5471. }
  5472. return result;
  5473. };
  5474. entity.hasClass = function (componentType) {
  5475. // Just consider componentType.main.
  5476. componentType = parseClassType(componentType);
  5477. return !!storage[componentType.main];
  5478. };
  5479. /**
  5480. * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
  5481. */
  5482. entity.getAllClassMainTypes = function () {
  5483. var types = [];
  5484. zrUtil.each(storage, function (obj, type) {
  5485. types.push(type);
  5486. });
  5487. return types;
  5488. };
  5489. /**
  5490. * If a main type is container and has sub types
  5491. * @param {string} mainType
  5492. * @return {boolean}
  5493. */
  5494. entity.hasSubTypes = function (componentType) {
  5495. componentType = parseClassType(componentType);
  5496. var obj = storage[componentType.main];
  5497. return obj && obj[IS_CONTAINER];
  5498. };
  5499. entity.parseClassType = parseClassType;
  5500. function makeContainer(componentType) {
  5501. var container = storage[componentType.main];
  5502. if (!container || !container[IS_CONTAINER]) {
  5503. container = storage[componentType.main] = {};
  5504. container[IS_CONTAINER] = true;
  5505. }
  5506. return container;
  5507. }
  5508. if (options.registerWhenExtend) {
  5509. var originalExtend = entity.extend;
  5510. if (originalExtend) {
  5511. entity.extend = function (proto) {
  5512. var ExtendedClass = originalExtend.call(this, proto);
  5513. return entity.registerClass(ExtendedClass, proto.type);
  5514. };
  5515. }
  5516. }
  5517. return entity;
  5518. };
  5519. /**
  5520. * @param {string|Array.<string>} properties
  5521. */
  5522. clazz.setReadOnly = function (obj, properties) {
  5523. // FIXME It seems broken in IE8 simulation of IE11
  5524. // if (!zrUtil.isArray(properties)) {
  5525. // properties = properties != null ? [properties] : [];
  5526. // }
  5527. // zrUtil.each(properties, function (prop) {
  5528. // var value = obj[prop];
  5529. // Object.defineProperty
  5530. // && Object.defineProperty(obj, prop, {
  5531. // value: value, writable: false
  5532. // });
  5533. // zrUtil.isArray(obj[prop])
  5534. // && Object.freeze
  5535. // && Object.freeze(obj[prop]);
  5536. // });
  5537. };
  5538. module.exports = clazz;
  5539. /***/ },
  5540. /* 14 */
  5541. /***/ function(module, exports, __webpack_require__) {
  5542. var getLineStyle = __webpack_require__(15)(
  5543. [
  5544. ['lineWidth', 'width'],
  5545. ['stroke', 'color'],
  5546. ['opacity'],
  5547. ['shadowBlur'],
  5548. ['shadowOffsetX'],
  5549. ['shadowOffsetY'],
  5550. ['shadowColor']
  5551. ]
  5552. );
  5553. module.exports = {
  5554. getLineStyle: function (excludes) {
  5555. var style = getLineStyle.call(this, excludes);
  5556. var lineDash = this.getLineDash(style.lineWidth);
  5557. lineDash && (style.lineDash = lineDash);
  5558. return style;
  5559. },
  5560. getLineDash: function (lineWidth) {
  5561. if (lineWidth == null) {
  5562. lineWidth = 1;
  5563. }
  5564. var lineType = this.get('type');
  5565. var dotSize = Math.max(lineWidth, 2);
  5566. var dashSize = lineWidth * 4;
  5567. return (lineType === 'solid' || lineType == null) ? null
  5568. : (lineType === 'dashed' ? [dashSize, dashSize] : [dotSize, dotSize]);
  5569. }
  5570. };
  5571. /***/ },
  5572. /* 15 */
  5573. /***/ function(module, exports, __webpack_require__) {
  5574. // TODO Parse shadow style
  5575. // TODO Only shallow path support
  5576. var zrUtil = __webpack_require__(4);
  5577. module.exports = function (properties) {
  5578. // Normalize
  5579. for (var i = 0; i < properties.length; i++) {
  5580. if (!properties[i][1]) {
  5581. properties[i][1] = properties[i][0];
  5582. }
  5583. }
  5584. return function (excludes, includes) {
  5585. var style = {};
  5586. for (var i = 0; i < properties.length; i++) {
  5587. var propName = properties[i][1];
  5588. if ((excludes && zrUtil.indexOf(excludes, propName) >= 0)
  5589. || (includes && zrUtil.indexOf(includes, propName) < 0)
  5590. ) {
  5591. continue;
  5592. }
  5593. var val = this.getShallow(propName);
  5594. if (val != null) {
  5595. style[properties[i][0]] = val;
  5596. }
  5597. }
  5598. return style;
  5599. };
  5600. };
  5601. /***/ },
  5602. /* 16 */
  5603. /***/ function(module, exports, __webpack_require__) {
  5604. module.exports = {
  5605. getAreaStyle: __webpack_require__(15)(
  5606. [
  5607. ['fill', 'color'],
  5608. ['shadowBlur'],
  5609. ['shadowOffsetX'],
  5610. ['shadowOffsetY'],
  5611. ['opacity'],
  5612. ['shadowColor']
  5613. ]
  5614. )
  5615. };
  5616. /***/ },
  5617. /* 17 */
  5618. /***/ function(module, exports, __webpack_require__) {
  5619. var textContain = __webpack_require__(8);
  5620. var graphicUtil = __webpack_require__(18);
  5621. module.exports = {
  5622. /**
  5623. * Get color property or get color from option.textStyle.color
  5624. * @return {string}
  5625. */
  5626. getTextColor: function () {
  5627. var ecModel = this.ecModel;
  5628. return this.getShallow('color')
  5629. || (ecModel && ecModel.get('textStyle.color'));
  5630. },
  5631. /**
  5632. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  5633. * @return {string}
  5634. */
  5635. getFont: function () {
  5636. return graphicUtil.getFont({
  5637. fontStyle: this.getShallow('fontStyle'),
  5638. fontWeight: this.getShallow('fontWeight'),
  5639. fontSize: this.getShallow('fontSize'),
  5640. fontFamily: this.getShallow('fontFamily')
  5641. }, this.ecModel);
  5642. },
  5643. getTextRect: function (text) {
  5644. return textContain.getBoundingRect(
  5645. text,
  5646. this.getFont(),
  5647. this.getShallow('align'),
  5648. this.getShallow('baseline')
  5649. );
  5650. },
  5651. truncateText: function (text, containerWidth, ellipsis, options) {
  5652. return textContain.truncateText(
  5653. text, containerWidth, this.getFont(), ellipsis, options
  5654. );
  5655. }
  5656. };
  5657. /***/ },
  5658. /* 18 */
  5659. /***/ function(module, exports, __webpack_require__) {
  5660. 'use strict';
  5661. var zrUtil = __webpack_require__(4);
  5662. var pathTool = __webpack_require__(19);
  5663. var Path = __webpack_require__(20);
  5664. var colorTool = __webpack_require__(31);
  5665. var matrix = __webpack_require__(11);
  5666. var vector = __webpack_require__(10);
  5667. var Transformable = __webpack_require__(26);
  5668. var BoundingRect = __webpack_require__(9);
  5669. var round = Math.round;
  5670. var mathMax = Math.max;
  5671. var mathMin = Math.min;
  5672. var graphic = {};
  5673. graphic.Group = __webpack_require__(48);
  5674. graphic.Image = __webpack_require__(49);
  5675. graphic.Text = __webpack_require__(50);
  5676. graphic.Circle = __webpack_require__(51);
  5677. graphic.Sector = __webpack_require__(52);
  5678. graphic.Ring = __webpack_require__(53);
  5679. graphic.Polygon = __webpack_require__(54);
  5680. graphic.Polyline = __webpack_require__(58);
  5681. graphic.Rect = __webpack_require__(59);
  5682. graphic.Line = __webpack_require__(61);
  5683. graphic.BezierCurve = __webpack_require__(62);
  5684. graphic.Arc = __webpack_require__(63);
  5685. graphic.CompoundPath = __webpack_require__(64);
  5686. graphic.LinearGradient = __webpack_require__(65);
  5687. graphic.RadialGradient = __webpack_require__(67);
  5688. graphic.BoundingRect = BoundingRect;
  5689. /**
  5690. * Extend shape with parameters
  5691. */
  5692. graphic.extendShape = function (opts) {
  5693. return Path.extend(opts);
  5694. };
  5695. /**
  5696. * Extend path
  5697. */
  5698. graphic.extendPath = function (pathData, opts) {
  5699. return pathTool.extendFromString(pathData, opts);
  5700. };
  5701. /**
  5702. * Create a path element from path data string
  5703. * @param {string} pathData
  5704. * @param {Object} opts
  5705. * @param {module:zrender/core/BoundingRect} rect
  5706. * @param {string} [layout=cover] 'center' or 'cover'
  5707. */
  5708. graphic.makePath = function (pathData, opts, rect, layout) {
  5709. var path = pathTool.createFromString(pathData, opts);
  5710. var boundingRect = path.getBoundingRect();
  5711. if (rect) {
  5712. var aspect = boundingRect.width / boundingRect.height;
  5713. if (layout === 'center') {
  5714. // Set rect to center, keep width / height ratio.
  5715. var width = rect.height * aspect;
  5716. var height;
  5717. if (width <= rect.width) {
  5718. height = rect.height;
  5719. }
  5720. else {
  5721. width = rect.width;
  5722. height = width / aspect;
  5723. }
  5724. var cx = rect.x + rect.width / 2;
  5725. var cy = rect.y + rect.height / 2;
  5726. rect.x = cx - width / 2;
  5727. rect.y = cy - height / 2;
  5728. rect.width = width;
  5729. rect.height = height;
  5730. }
  5731. graphic.resizePath(path, rect);
  5732. }
  5733. return path;
  5734. };
  5735. graphic.mergePath = pathTool.mergePath,
  5736. /**
  5737. * Resize a path to fit the rect
  5738. * @param {module:zrender/graphic/Path} path
  5739. * @param {Object} rect
  5740. */
  5741. graphic.resizePath = function (path, rect) {
  5742. if (!path.applyTransform) {
  5743. return;
  5744. }
  5745. var pathRect = path.getBoundingRect();
  5746. var m = pathRect.calculateTransform(rect);
  5747. path.applyTransform(m);
  5748. };
  5749. /**
  5750. * Sub pixel optimize line for canvas
  5751. *
  5752. * @param {Object} param
  5753. * @param {Object} [param.shape]
  5754. * @param {number} [param.shape.x1]
  5755. * @param {number} [param.shape.y1]
  5756. * @param {number} [param.shape.x2]
  5757. * @param {number} [param.shape.y2]
  5758. * @param {Object} [param.style]
  5759. * @param {number} [param.style.lineWidth]
  5760. * @return {Object} Modified param
  5761. */
  5762. graphic.subPixelOptimizeLine = function (param) {
  5763. var subPixelOptimize = graphic.subPixelOptimize;
  5764. var shape = param.shape;
  5765. var lineWidth = param.style.lineWidth;
  5766. if (round(shape.x1 * 2) === round(shape.x2 * 2)) {
  5767. shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true);
  5768. }
  5769. if (round(shape.y1 * 2) === round(shape.y2 * 2)) {
  5770. shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true);
  5771. }
  5772. return param;
  5773. };
  5774. /**
  5775. * Sub pixel optimize rect for canvas
  5776. *
  5777. * @param {Object} param
  5778. * @param {Object} [param.shape]
  5779. * @param {number} [param.shape.x]
  5780. * @param {number} [param.shape.y]
  5781. * @param {number} [param.shape.width]
  5782. * @param {number} [param.shape.height]
  5783. * @param {Object} [param.style]
  5784. * @param {number} [param.style.lineWidth]
  5785. * @return {Object} Modified param
  5786. */
  5787. graphic.subPixelOptimizeRect = function (param) {
  5788. var subPixelOptimize = graphic.subPixelOptimize;
  5789. var shape = param.shape;
  5790. var lineWidth = param.style.lineWidth;
  5791. var originX = shape.x;
  5792. var originY = shape.y;
  5793. var originWidth = shape.width;
  5794. var originHeight = shape.height;
  5795. shape.x = subPixelOptimize(shape.x, lineWidth, true);
  5796. shape.y = subPixelOptimize(shape.y, lineWidth, true);
  5797. shape.width = Math.max(
  5798. subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x,
  5799. originWidth === 0 ? 0 : 1
  5800. );
  5801. shape.height = Math.max(
  5802. subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y,
  5803. originHeight === 0 ? 0 : 1
  5804. );
  5805. return param;
  5806. };
  5807. /**
  5808. * Sub pixel optimize for canvas
  5809. *
  5810. * @param {number} position Coordinate, such as x, y
  5811. * @param {number} lineWidth Should be nonnegative integer.
  5812. * @param {boolean=} positiveOrNegative Default false (negative).
  5813. * @return {number} Optimized position.
  5814. */
  5815. graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
  5816. // Assure that (position + lineWidth / 2) is near integer edge,
  5817. // otherwise line will be fuzzy in canvas.
  5818. var doubledPosition = round(position * 2);
  5819. return (doubledPosition + round(lineWidth)) % 2 === 0
  5820. ? doubledPosition / 2
  5821. : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  5822. };
  5823. function hasFillOrStroke(fillOrStroke) {
  5824. return fillOrStroke != null && fillOrStroke != 'none';
  5825. }
  5826. function liftColor(color) {
  5827. return typeof color === 'string' ? colorTool.lift(color, -0.1) : color;
  5828. }
  5829. /**
  5830. * @private
  5831. */
  5832. function cacheElementStl(el) {
  5833. if (el.__hoverStlDirty) {
  5834. var stroke = el.style.stroke;
  5835. var fill = el.style.fill;
  5836. // Create hoverStyle on mouseover
  5837. var hoverStyle = el.__hoverStl;
  5838. hoverStyle.fill = hoverStyle.fill
  5839. || (hasFillOrStroke(fill) ? liftColor(fill) : null);
  5840. hoverStyle.stroke = hoverStyle.stroke
  5841. || (hasFillOrStroke(stroke) ? liftColor(stroke) : null);
  5842. var normalStyle = {};
  5843. for (var name in hoverStyle) {
  5844. if (hoverStyle.hasOwnProperty(name)) {
  5845. normalStyle[name] = el.style[name];
  5846. }
  5847. }
  5848. el.__normalStl = normalStyle;
  5849. el.__hoverStlDirty = false;
  5850. }
  5851. }
  5852. /**
  5853. * @private
  5854. */
  5855. function doSingleEnterHover(el) {
  5856. if (el.__isHover) {
  5857. return;
  5858. }
  5859. cacheElementStl(el);
  5860. if (el.useHoverLayer) {
  5861. el.__zr && el.__zr.addHover(el, el.__hoverStl);
  5862. }
  5863. else {
  5864. el.setStyle(el.__hoverStl);
  5865. el.z2 += 1;
  5866. }
  5867. el.__isHover = true;
  5868. }
  5869. /**
  5870. * @inner
  5871. */
  5872. function doSingleLeaveHover(el) {
  5873. if (!el.__isHover) {
  5874. return;
  5875. }
  5876. var normalStl = el.__normalStl;
  5877. if (el.useHoverLayer) {
  5878. el.__zr && el.__zr.removeHover(el);
  5879. }
  5880. else {
  5881. normalStl && el.setStyle(normalStl);
  5882. el.z2 -= 1;
  5883. }
  5884. el.__isHover = false;
  5885. }
  5886. /**
  5887. * @inner
  5888. */
  5889. function doEnterHover(el) {
  5890. el.type === 'group'
  5891. ? el.traverse(function (child) {
  5892. if (child.type !== 'group') {
  5893. doSingleEnterHover(child);
  5894. }
  5895. })
  5896. : doSingleEnterHover(el);
  5897. }
  5898. function doLeaveHover(el) {
  5899. el.type === 'group'
  5900. ? el.traverse(function (child) {
  5901. if (child.type !== 'group') {
  5902. doSingleLeaveHover(child);
  5903. }
  5904. })
  5905. : doSingleLeaveHover(el);
  5906. }
  5907. /**
  5908. * @inner
  5909. */
  5910. function setElementHoverStl(el, hoverStl) {
  5911. // If element has sepcified hoverStyle, then use it instead of given hoverStyle
  5912. // Often used when item group has a label element and it's hoverStyle is different
  5913. el.__hoverStl = el.hoverStyle || hoverStl || {};
  5914. el.__hoverStlDirty = true;
  5915. if (el.__isHover) {
  5916. cacheElementStl(el);
  5917. }
  5918. }
  5919. /**
  5920. * @inner
  5921. */
  5922. function onElementMouseOver(e) {
  5923. if (this.__hoverSilentOnTouch && e.zrByTouch) {
  5924. return;
  5925. }
  5926. // Only if element is not in emphasis status
  5927. !this.__isEmphasis && doEnterHover(this);
  5928. }
  5929. /**
  5930. * @inner
  5931. */
  5932. function onElementMouseOut(e) {
  5933. if (this.__hoverSilentOnTouch && e.zrByTouch) {
  5934. return;
  5935. }
  5936. // Only if element is not in emphasis status
  5937. !this.__isEmphasis && doLeaveHover(this);
  5938. }
  5939. /**
  5940. * @inner
  5941. */
  5942. function enterEmphasis() {
  5943. this.__isEmphasis = true;
  5944. doEnterHover(this);
  5945. }
  5946. /**
  5947. * @inner
  5948. */
  5949. function leaveEmphasis() {
  5950. this.__isEmphasis = false;
  5951. doLeaveHover(this);
  5952. }
  5953. /**
  5954. * Set hover style of element.
  5955. * This method can be called repeatly without side-effects.
  5956. * @param {module:zrender/Element} el
  5957. * @param {Object} [hoverStyle]
  5958. * @param {Object} [opt]
  5959. * @param {boolean} [opt.hoverSilentOnTouch=false]
  5960. * In touch device, mouseover event will be trigger on touchstart event
  5961. * (see module:zrender/dom/HandlerProxy). By this mechanism, we can
  5962. * conviniently use hoverStyle when tap on touch screen without additional
  5963. * code for compatibility.
  5964. * But if the chart/component has select feature, which usually also use
  5965. * hoverStyle, there might be conflict between 'select-highlight' and
  5966. * 'hover-highlight' especially when roam is enabled (see geo for example).
  5967. * In this case, hoverSilentOnTouch should be used to disable hover-highlight
  5968. * on touch device.
  5969. */
  5970. graphic.setHoverStyle = function (el, hoverStyle, opt) {
  5971. el.__hoverSilentOnTouch = opt && opt.hoverSilentOnTouch;
  5972. el.type === 'group'
  5973. ? el.traverse(function (child) {
  5974. if (child.type !== 'group') {
  5975. setElementHoverStl(child, hoverStyle);
  5976. }
  5977. })
  5978. : setElementHoverStl(el, hoverStyle);
  5979. // Duplicated function will be auto-ignored, see Eventful.js.
  5980. el.on('mouseover', onElementMouseOver)
  5981. .on('mouseout', onElementMouseOut);
  5982. // Emphasis, normal can be triggered manually
  5983. el.on('emphasis', enterEmphasis)
  5984. .on('normal', leaveEmphasis);
  5985. };
  5986. /**
  5987. * Set text option in the style
  5988. * @param {Object} textStyle
  5989. * @param {module:echarts/model/Model} labelModel
  5990. * @param {string} color
  5991. */
  5992. graphic.setText = function (textStyle, labelModel, color) {
  5993. var labelPosition = labelModel.getShallow('position') || 'inside';
  5994. var labelOffset = labelModel.getShallow('offset');
  5995. var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
  5996. var textStyleModel = labelModel.getModel('textStyle');
  5997. zrUtil.extend(textStyle, {
  5998. textDistance: labelModel.getShallow('distance') || 5,
  5999. textFont: textStyleModel.getFont(),
  6000. textPosition: labelPosition,
  6001. textOffset: labelOffset,
  6002. textFill: textStyleModel.getTextColor() || labelColor
  6003. });
  6004. };
  6005. graphic.getFont = function (opt, ecModel) {
  6006. var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
  6007. return [
  6008. // FIXME in node-canvas fontWeight is before fontStyle
  6009. opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
  6010. opt.fontWeight || gTextStyleModel && gTextStyleModel.getShallow('fontWeight') || '',
  6011. (opt.fontSize || gTextStyleModel && gTextStyleModel.getShallow('fontSize') || 12) + 'px',
  6012. opt.fontFamily || gTextStyleModel && gTextStyleModel.getShallow('fontFamily') || 'sans-serif'
  6013. ].join(' ');
  6014. };
  6015. function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
  6016. if (typeof dataIndex === 'function') {
  6017. cb = dataIndex;
  6018. dataIndex = null;
  6019. }
  6020. // Do not check 'animation' property directly here. Consider this case:
  6021. // animation model is an `itemModel`, whose does not have `isAnimationEnabled`
  6022. // but its parent model (`seriesModel`) does.
  6023. var animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
  6024. if (animationEnabled) {
  6025. var postfix = isUpdate ? 'Update' : '';
  6026. var duration = animatableModel.getShallow('animationDuration' + postfix);
  6027. var animationEasing = animatableModel.getShallow('animationEasing' + postfix);
  6028. var animationDelay = animatableModel.getShallow('animationDelay' + postfix);
  6029. if (typeof animationDelay === 'function') {
  6030. animationDelay = animationDelay(
  6031. dataIndex,
  6032. animatableModel.getAnimationDelayParams
  6033. ? animatableModel.getAnimationDelayParams(el, dataIndex)
  6034. : null
  6035. );
  6036. }
  6037. if (typeof duration === 'function') {
  6038. duration = duration(dataIndex);
  6039. }
  6040. duration > 0
  6041. ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
  6042. : (el.stopAnimation(), el.attr(props), cb && cb());
  6043. }
  6044. else {
  6045. el.stopAnimation();
  6046. el.attr(props);
  6047. cb && cb();
  6048. }
  6049. }
  6050. /**
  6051. * Update graphic element properties with or without animation according to the configuration in series
  6052. * @param {module:zrender/Element} el
  6053. * @param {Object} props
  6054. * @param {module:echarts/model/Model} [animatableModel]
  6055. * @param {number} [dataIndex]
  6056. * @param {Function} [cb]
  6057. * @example
  6058. * graphic.updateProps(el, {
  6059. * position: [100, 100]
  6060. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  6061. * // Or
  6062. * graphic.updateProps(el, {
  6063. * position: [100, 100]
  6064. * }, seriesModel, function () { console.log('Animation done!'); });
  6065. */
  6066. graphic.updateProps = function (el, props, animatableModel, dataIndex, cb) {
  6067. animateOrSetProps(true, el, props, animatableModel, dataIndex, cb);
  6068. };
  6069. /**
  6070. * Init graphic element properties with or without animation according to the configuration in series
  6071. * @param {module:zrender/Element} el
  6072. * @param {Object} props
  6073. * @param {module:echarts/model/Model} [animatableModel]
  6074. * @param {number} [dataIndex]
  6075. * @param {Function} cb
  6076. */
  6077. graphic.initProps = function (el, props, animatableModel, dataIndex, cb) {
  6078. animateOrSetProps(false, el, props, animatableModel, dataIndex, cb);
  6079. };
  6080. /**
  6081. * Get transform matrix of target (param target),
  6082. * in coordinate of its ancestor (param ancestor)
  6083. *
  6084. * @param {module:zrender/mixin/Transformable} target
  6085. * @param {module:zrender/mixin/Transformable} [ancestor]
  6086. */
  6087. graphic.getTransform = function (target, ancestor) {
  6088. var mat = matrix.identity([]);
  6089. while (target && target !== ancestor) {
  6090. matrix.mul(mat, target.getLocalTransform(), mat);
  6091. target = target.parent;
  6092. }
  6093. return mat;
  6094. };
  6095. /**
  6096. * Apply transform to an vertex.
  6097. * @param {Array.<number>} target [x, y]
  6098. * @param {Array.<number>|TypedArray.<number>|Object} transform Can be:
  6099. * + Transform matrix: like [1, 0, 0, 1, 0, 0]
  6100. * + {position, rotation, scale}, the same as `zrender/Transformable`.
  6101. * @param {boolean=} invert Whether use invert matrix.
  6102. * @return {Array.<number>} [x, y]
  6103. */
  6104. graphic.applyTransform = function (target, transform, invert) {
  6105. if (transform && !zrUtil.isArrayLike(transform)) {
  6106. transform = Transformable.getLocalTransform(transform);
  6107. }
  6108. if (invert) {
  6109. transform = matrix.invert([], transform);
  6110. }
  6111. return vector.applyTransform([], target, transform);
  6112. };
  6113. /**
  6114. * @param {string} direction 'left' 'right' 'top' 'bottom'
  6115. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  6116. * @param {boolean=} invert Whether use invert matrix.
  6117. * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom'
  6118. */
  6119. graphic.transformDirection = function (direction, transform, invert) {
  6120. // Pick a base, ensure that transform result will not be (0, 0).
  6121. var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0)
  6122. ? 1 : Math.abs(2 * transform[4] / transform[0]);
  6123. var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0)
  6124. ? 1 : Math.abs(2 * transform[4] / transform[2]);
  6125. var vertex = [
  6126. direction === 'left' ? -hBase : direction === 'right' ? hBase : 0,
  6127. direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0
  6128. ];
  6129. vertex = graphic.applyTransform(vertex, transform, invert);
  6130. return Math.abs(vertex[0]) > Math.abs(vertex[1])
  6131. ? (vertex[0] > 0 ? 'right' : 'left')
  6132. : (vertex[1] > 0 ? 'bottom' : 'top');
  6133. };
  6134. /**
  6135. * Apply group transition animation from g1 to g2.
  6136. * If no animatableModel, no animation.
  6137. */
  6138. graphic.groupTransition = function (g1, g2, animatableModel, cb) {
  6139. if (!g1 || !g2) {
  6140. return;
  6141. }
  6142. function getElMap(g) {
  6143. var elMap = {};
  6144. g.traverse(function (el) {
  6145. if (!el.isGroup && el.anid) {
  6146. elMap[el.anid] = el;
  6147. }
  6148. });
  6149. return elMap;
  6150. }
  6151. function getAnimatableProps(el) {
  6152. var obj = {
  6153. position: vector.clone(el.position),
  6154. rotation: el.rotation
  6155. };
  6156. if (el.shape) {
  6157. obj.shape = zrUtil.extend({}, el.shape);
  6158. }
  6159. return obj;
  6160. }
  6161. var elMap1 = getElMap(g1);
  6162. g2.traverse(function (el) {
  6163. if (!el.isGroup && el.anid) {
  6164. var oldEl = elMap1[el.anid];
  6165. if (oldEl) {
  6166. var newProp = getAnimatableProps(el);
  6167. el.attr(getAnimatableProps(oldEl));
  6168. graphic.updateProps(el, newProp, animatableModel, el.dataIndex);
  6169. }
  6170. // else {
  6171. // if (el.previousProps) {
  6172. // graphic.updateProps
  6173. // }
  6174. // }
  6175. }
  6176. });
  6177. };
  6178. /**
  6179. * @param {Array.<Array.<number>>} points Like: [[23, 44], [53, 66], ...]
  6180. * @param {Object} rect {x, y, width, height}
  6181. * @return {Array.<Array.<number>>} A new clipped points.
  6182. */
  6183. graphic.clipPointsByRect = function (points, rect) {
  6184. return zrUtil.map(points, function (point) {
  6185. var x = point[0];
  6186. x = mathMax(x, rect.x);
  6187. x = mathMin(x, rect.x + rect.width);
  6188. var y = point[1];
  6189. y = mathMax(y, rect.y);
  6190. y = mathMin(y, rect.y + rect.height);
  6191. return [x, y];
  6192. });
  6193. };
  6194. /**
  6195. * @param {Object} targetRect {x, y, width, height}
  6196. * @param {Object} rect {x, y, width, height}
  6197. * @return {Object} A new clipped rect. If rect size are negative, return undefined.
  6198. */
  6199. graphic.clipRectByRect = function (targetRect, rect) {
  6200. var x = mathMax(targetRect.x, rect.x);
  6201. var x2 = mathMin(targetRect.x + targetRect.width, rect.x + rect.width);
  6202. var y = mathMax(targetRect.y, rect.y);
  6203. var y2 = mathMin(targetRect.y + targetRect.height, rect.y + rect.height);
  6204. if (x2 >= x && y2 >= y) {
  6205. return {
  6206. x: x,
  6207. y: y,
  6208. width: x2 - x,
  6209. height: y2 - y
  6210. };
  6211. }
  6212. };
  6213. module.exports = graphic;
  6214. /***/ },
  6215. /* 19 */
  6216. /***/ function(module, exports, __webpack_require__) {
  6217. var Path = __webpack_require__(20);
  6218. var PathProxy = __webpack_require__(36);
  6219. var transformPath = __webpack_require__(47);
  6220. // command chars
  6221. var cc = [
  6222. 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',
  6223. 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'
  6224. ];
  6225. var mathSqrt = Math.sqrt;
  6226. var mathSin = Math.sin;
  6227. var mathCos = Math.cos;
  6228. var PI = Math.PI;
  6229. var vMag = function(v) {
  6230. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  6231. };
  6232. var vRatio = function(u, v) {
  6233. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  6234. };
  6235. var vAngle = function(u, v) {
  6236. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)
  6237. * Math.acos(vRatio(u, v));
  6238. };
  6239. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  6240. var psi = psiDeg * (PI / 180.0);
  6241. var xp = mathCos(psi) * (x1 - x2) / 2.0
  6242. + mathSin(psi) * (y1 - y2) / 2.0;
  6243. var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
  6244. + mathCos(psi) * (y1 - y2) / 2.0;
  6245. var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
  6246. if (lambda > 1) {
  6247. rx *= mathSqrt(lambda);
  6248. ry *= mathSqrt(lambda);
  6249. }
  6250. var f = (fa === fs ? -1 : 1)
  6251. * mathSqrt((((rx * rx) * (ry * ry))
  6252. - ((rx * rx) * (yp * yp))
  6253. - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
  6254. + (ry * ry) * (xp * xp))
  6255. ) || 0;
  6256. var cxp = f * rx * yp / ry;
  6257. var cyp = f * -ry * xp / rx;
  6258. var cx = (x1 + x2) / 2.0
  6259. + mathCos(psi) * cxp
  6260. - mathSin(psi) * cyp;
  6261. var cy = (y1 + y2) / 2.0
  6262. + mathSin(psi) * cxp
  6263. + mathCos(psi) * cyp;
  6264. var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);
  6265. var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];
  6266. var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];
  6267. var dTheta = vAngle(u, v);
  6268. if (vRatio(u, v) <= -1) {
  6269. dTheta = PI;
  6270. }
  6271. if (vRatio(u, v) >= 1) {
  6272. dTheta = 0;
  6273. }
  6274. if (fs === 0 && dTheta > 0) {
  6275. dTheta = dTheta - 2 * PI;
  6276. }
  6277. if (fs === 1 && dTheta < 0) {
  6278. dTheta = dTheta + 2 * PI;
  6279. }
  6280. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  6281. }
  6282. function createPathProxyFromString(data) {
  6283. if (!data) {
  6284. return [];
  6285. }
  6286. // command string
  6287. var cs = data.replace(/-/g, ' -')
  6288. .replace(/ /g, ' ')
  6289. .replace(/ /g, ',')
  6290. .replace(/,,/g, ',');
  6291. var n;
  6292. // create pipes so that we can split the data
  6293. for (n = 0; n < cc.length; n++) {
  6294. cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
  6295. }
  6296. // create array
  6297. var arr = cs.split('|');
  6298. // init context point
  6299. var cpx = 0;
  6300. var cpy = 0;
  6301. var path = new PathProxy();
  6302. var CMD = PathProxy.CMD;
  6303. var prevCmd;
  6304. for (n = 1; n < arr.length; n++) {
  6305. var str = arr[n];
  6306. var c = str.charAt(0);
  6307. var off = 0;
  6308. var p = str.slice(1).replace(/e,-/g, 'e-').split(',');
  6309. var cmd;
  6310. if (p.length > 0 && p[0] === '') {
  6311. p.shift();
  6312. }
  6313. for (var i = 0; i < p.length; i++) {
  6314. p[i] = parseFloat(p[i]);
  6315. }
  6316. while (off < p.length && !isNaN(p[off])) {
  6317. if (isNaN(p[0])) {
  6318. break;
  6319. }
  6320. var ctlPtx;
  6321. var ctlPty;
  6322. var rx;
  6323. var ry;
  6324. var psi;
  6325. var fa;
  6326. var fs;
  6327. var x1 = cpx;
  6328. var y1 = cpy;
  6329. // convert l, H, h, V, and v to L
  6330. switch (c) {
  6331. case 'l':
  6332. cpx += p[off++];
  6333. cpy += p[off++];
  6334. cmd = CMD.L;
  6335. path.addData(cmd, cpx, cpy);
  6336. break;
  6337. case 'L':
  6338. cpx = p[off++];
  6339. cpy = p[off++];
  6340. cmd = CMD.L;
  6341. path.addData(cmd, cpx, cpy);
  6342. break;
  6343. case 'm':
  6344. cpx += p[off++];
  6345. cpy += p[off++];
  6346. cmd = CMD.M;
  6347. path.addData(cmd, cpx, cpy);
  6348. c = 'l';
  6349. break;
  6350. case 'M':
  6351. cpx = p[off++];
  6352. cpy = p[off++];
  6353. cmd = CMD.M;
  6354. path.addData(cmd, cpx, cpy);
  6355. c = 'L';
  6356. break;
  6357. case 'h':
  6358. cpx += p[off++];
  6359. cmd = CMD.L;
  6360. path.addData(cmd, cpx, cpy);
  6361. break;
  6362. case 'H':
  6363. cpx = p[off++];
  6364. cmd = CMD.L;
  6365. path.addData(cmd, cpx, cpy);
  6366. break;
  6367. case 'v':
  6368. cpy += p[off++];
  6369. cmd = CMD.L;
  6370. path.addData(cmd, cpx, cpy);
  6371. break;
  6372. case 'V':
  6373. cpy = p[off++];
  6374. cmd = CMD.L;
  6375. path.addData(cmd, cpx, cpy);
  6376. break;
  6377. case 'C':
  6378. cmd = CMD.C;
  6379. path.addData(
  6380. cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
  6381. );
  6382. cpx = p[off - 2];
  6383. cpy = p[off - 1];
  6384. break;
  6385. case 'c':
  6386. cmd = CMD.C;
  6387. path.addData(
  6388. cmd,
  6389. p[off++] + cpx, p[off++] + cpy,
  6390. p[off++] + cpx, p[off++] + cpy,
  6391. p[off++] + cpx, p[off++] + cpy
  6392. );
  6393. cpx += p[off - 2];
  6394. cpy += p[off - 1];
  6395. break;
  6396. case 'S':
  6397. ctlPtx = cpx;
  6398. ctlPty = cpy;
  6399. var len = path.len();
  6400. var pathData = path.data;
  6401. if (prevCmd === CMD.C) {
  6402. ctlPtx += cpx - pathData[len - 4];
  6403. ctlPty += cpy - pathData[len - 3];
  6404. }
  6405. cmd = CMD.C;
  6406. x1 = p[off++];
  6407. y1 = p[off++];
  6408. cpx = p[off++];
  6409. cpy = p[off++];
  6410. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  6411. break;
  6412. case 's':
  6413. ctlPtx = cpx;
  6414. ctlPty = cpy;
  6415. var len = path.len();
  6416. var pathData = path.data;
  6417. if (prevCmd === CMD.C) {
  6418. ctlPtx += cpx - pathData[len - 4];
  6419. ctlPty += cpy - pathData[len - 3];
  6420. }
  6421. cmd = CMD.C;
  6422. x1 = cpx + p[off++];
  6423. y1 = cpy + p[off++];
  6424. cpx += p[off++];
  6425. cpy += p[off++];
  6426. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  6427. break;
  6428. case 'Q':
  6429. x1 = p[off++];
  6430. y1 = p[off++];
  6431. cpx = p[off++];
  6432. cpy = p[off++];
  6433. cmd = CMD.Q;
  6434. path.addData(cmd, x1, y1, cpx, cpy);
  6435. break;
  6436. case 'q':
  6437. x1 = p[off++] + cpx;
  6438. y1 = p[off++] + cpy;
  6439. cpx += p[off++];
  6440. cpy += p[off++];
  6441. cmd = CMD.Q;
  6442. path.addData(cmd, x1, y1, cpx, cpy);
  6443. break;
  6444. case 'T':
  6445. ctlPtx = cpx;
  6446. ctlPty = cpy;
  6447. var len = path.len();
  6448. var pathData = path.data;
  6449. if (prevCmd === CMD.Q) {
  6450. ctlPtx += cpx - pathData[len - 4];
  6451. ctlPty += cpy - pathData[len - 3];
  6452. }
  6453. cpx = p[off++];
  6454. cpy = p[off++];
  6455. cmd = CMD.Q;
  6456. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  6457. break;
  6458. case 't':
  6459. ctlPtx = cpx;
  6460. ctlPty = cpy;
  6461. var len = path.len();
  6462. var pathData = path.data;
  6463. if (prevCmd === CMD.Q) {
  6464. ctlPtx += cpx - pathData[len - 4];
  6465. ctlPty += cpy - pathData[len - 3];
  6466. }
  6467. cpx += p[off++];
  6468. cpy += p[off++];
  6469. cmd = CMD.Q;
  6470. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  6471. break;
  6472. case 'A':
  6473. rx = p[off++];
  6474. ry = p[off++];
  6475. psi = p[off++];
  6476. fa = p[off++];
  6477. fs = p[off++];
  6478. x1 = cpx, y1 = cpy;
  6479. cpx = p[off++];
  6480. cpy = p[off++];
  6481. cmd = CMD.A;
  6482. processArc(
  6483. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  6484. );
  6485. break;
  6486. case 'a':
  6487. rx = p[off++];
  6488. ry = p[off++];
  6489. psi = p[off++];
  6490. fa = p[off++];
  6491. fs = p[off++];
  6492. x1 = cpx, y1 = cpy;
  6493. cpx += p[off++];
  6494. cpy += p[off++];
  6495. cmd = CMD.A;
  6496. processArc(
  6497. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  6498. );
  6499. break;
  6500. }
  6501. }
  6502. if (c === 'z' || c === 'Z') {
  6503. cmd = CMD.Z;
  6504. path.addData(cmd);
  6505. }
  6506. prevCmd = cmd;
  6507. }
  6508. path.toStatic();
  6509. return path;
  6510. }
  6511. // TODO Optimize double memory cost problem
  6512. function createPathOptions(str, opts) {
  6513. var pathProxy = createPathProxyFromString(str);
  6514. opts = opts || {};
  6515. opts.buildPath = function (path) {
  6516. if (path.setData) {
  6517. path.setData(pathProxy.data);
  6518. // Svg and vml renderer don't have context
  6519. var ctx = path.getContext();
  6520. if (ctx) {
  6521. path.rebuildPath(ctx);
  6522. }
  6523. }
  6524. else {
  6525. var ctx = path;
  6526. pathProxy.rebuildPath(ctx);
  6527. }
  6528. };
  6529. opts.applyTransform = function (m) {
  6530. transformPath(pathProxy, m);
  6531. this.dirty(true);
  6532. };
  6533. return opts;
  6534. }
  6535. module.exports = {
  6536. /**
  6537. * Create a Path object from path string data
  6538. * http://www.w3.org/TR/SVG/paths.html#PathData
  6539. * @param {Object} opts Other options
  6540. */
  6541. createFromString: function (str, opts) {
  6542. return new Path(createPathOptions(str, opts));
  6543. },
  6544. /**
  6545. * Create a Path class from path string data
  6546. * @param {string} str
  6547. * @param {Object} opts Other options
  6548. */
  6549. extendFromString: function (str, opts) {
  6550. return Path.extend(createPathOptions(str, opts));
  6551. },
  6552. /**
  6553. * Merge multiple paths
  6554. */
  6555. // TODO Apply transform
  6556. // TODO stroke dash
  6557. // TODO Optimize double memory cost problem
  6558. mergePath: function (pathEls, opts) {
  6559. var pathList = [];
  6560. var len = pathEls.length;
  6561. for (var i = 0; i < len; i++) {
  6562. var pathEl = pathEls[i];
  6563. if (!pathEl.path) {
  6564. pathEl.createPathProxy();
  6565. }
  6566. if (pathEl.__dirtyPath) {
  6567. pathEl.buildPath(pathEl.path, pathEl.shape, true);
  6568. }
  6569. pathList.push(pathEl.path);
  6570. }
  6571. var pathBundle = new Path(opts);
  6572. // Need path proxy.
  6573. pathBundle.createPathProxy();
  6574. pathBundle.buildPath = function (path) {
  6575. path.appendPath(pathList);
  6576. // Svg and vml renderer don't have context
  6577. var ctx = path.getContext();
  6578. if (ctx) {
  6579. path.rebuildPath(ctx);
  6580. }
  6581. };
  6582. return pathBundle;
  6583. }
  6584. };
  6585. /***/ },
  6586. /* 20 */
  6587. /***/ function(module, exports, __webpack_require__) {
  6588. /**
  6589. * Path element
  6590. * @module zrender/graphic/Path
  6591. */
  6592. var Displayable = __webpack_require__(21);
  6593. var zrUtil = __webpack_require__(4);
  6594. var PathProxy = __webpack_require__(36);
  6595. var pathContain = __webpack_require__(39);
  6596. var Pattern = __webpack_require__(46);
  6597. var getCanvasPattern = Pattern.prototype.getCanvasPattern;
  6598. var abs = Math.abs;
  6599. var pathProxyForDraw = new PathProxy(true);
  6600. /**
  6601. * @alias module:zrender/graphic/Path
  6602. * @extends module:zrender/graphic/Displayable
  6603. * @constructor
  6604. * @param {Object} opts
  6605. */
  6606. function Path(opts) {
  6607. Displayable.call(this, opts);
  6608. /**
  6609. * @type {module:zrender/core/PathProxy}
  6610. * @readOnly
  6611. */
  6612. this.path = null;
  6613. }
  6614. Path.prototype = {
  6615. constructor: Path,
  6616. type: 'path',
  6617. __dirtyPath: true,
  6618. strokeContainThreshold: 5,
  6619. brush: function (ctx, prevEl) {
  6620. var style = this.style;
  6621. var path = this.path || pathProxyForDraw;
  6622. var hasStroke = style.hasStroke();
  6623. var hasFill = style.hasFill();
  6624. var fill = style.fill;
  6625. var stroke = style.stroke;
  6626. var hasFillGradient = hasFill && !!(fill.colorStops);
  6627. var hasStrokeGradient = hasStroke && !!(stroke.colorStops);
  6628. var hasFillPattern = hasFill && !!(fill.image);
  6629. var hasStrokePattern = hasStroke && !!(stroke.image);
  6630. style.bind(ctx, this, prevEl);
  6631. this.setTransform(ctx);
  6632. if (this.__dirty) {
  6633. var rect;
  6634. // Update gradient because bounding rect may changed
  6635. if (hasFillGradient) {
  6636. rect = rect || this.getBoundingRect();
  6637. this._fillGradient = style.getGradient(ctx, fill, rect);
  6638. }
  6639. if (hasStrokeGradient) {
  6640. rect = rect || this.getBoundingRect();
  6641. this._strokeGradient = style.getGradient(ctx, stroke, rect);
  6642. }
  6643. }
  6644. // Use the gradient or pattern
  6645. if (hasFillGradient) {
  6646. // PENDING If may have affect the state
  6647. ctx.fillStyle = this._fillGradient;
  6648. }
  6649. else if (hasFillPattern) {
  6650. ctx.fillStyle = getCanvasPattern.call(fill, ctx);
  6651. }
  6652. if (hasStrokeGradient) {
  6653. ctx.strokeStyle = this._strokeGradient;
  6654. }
  6655. else if (hasStrokePattern) {
  6656. ctx.strokeStyle = getCanvasPattern.call(stroke, ctx);
  6657. }
  6658. var lineDash = style.lineDash;
  6659. var lineDashOffset = style.lineDashOffset;
  6660. var ctxLineDash = !!ctx.setLineDash;
  6661. // Update path sx, sy
  6662. var scale = this.getGlobalScale();
  6663. path.setScale(scale[0], scale[1]);
  6664. // Proxy context
  6665. // Rebuild path in following 2 cases
  6666. // 1. Path is dirty
  6667. // 2. Path needs javascript implemented lineDash stroking.
  6668. // In this case, lineDash information will not be saved in PathProxy
  6669. if (this.__dirtyPath
  6670. || (lineDash && !ctxLineDash && hasStroke)
  6671. ) {
  6672. path.beginPath(ctx);
  6673. // Setting line dash before build path
  6674. if (lineDash && !ctxLineDash) {
  6675. path.setLineDash(lineDash);
  6676. path.setLineDashOffset(lineDashOffset);
  6677. }
  6678. this.buildPath(path, this.shape, false);
  6679. // Clear path dirty flag
  6680. if (this.path) {
  6681. this.__dirtyPath = false;
  6682. }
  6683. }
  6684. else {
  6685. // Replay path building
  6686. ctx.beginPath();
  6687. this.path.rebuildPath(ctx);
  6688. }
  6689. hasFill && path.fill(ctx);
  6690. if (lineDash && ctxLineDash) {
  6691. ctx.setLineDash(lineDash);
  6692. ctx.lineDashOffset = lineDashOffset;
  6693. }
  6694. hasStroke && path.stroke(ctx);
  6695. if (lineDash && ctxLineDash) {
  6696. // PENDING
  6697. // Remove lineDash
  6698. ctx.setLineDash([]);
  6699. }
  6700. this.restoreTransform(ctx);
  6701. // Draw rect text
  6702. if (style.text != null) {
  6703. this.drawRectText(ctx, this.getBoundingRect());
  6704. }
  6705. },
  6706. // When bundling path, some shape may decide if use moveTo to begin a new subpath or closePath
  6707. // Like in circle
  6708. buildPath: function (ctx, shapeCfg, inBundle) {},
  6709. createPathProxy: function () {
  6710. this.path = new PathProxy();
  6711. },
  6712. getBoundingRect: function () {
  6713. var rect = this._rect;
  6714. var style = this.style;
  6715. var needsUpdateRect = !rect;
  6716. if (needsUpdateRect) {
  6717. var path = this.path;
  6718. if (!path) {
  6719. // Create path on demand.
  6720. path = this.path = new PathProxy();
  6721. }
  6722. if (this.__dirtyPath) {
  6723. path.beginPath();
  6724. this.buildPath(path, this.shape, false);
  6725. }
  6726. rect = path.getBoundingRect();
  6727. }
  6728. this._rect = rect;
  6729. if (style.hasStroke()) {
  6730. // Needs update rect with stroke lineWidth when
  6731. // 1. Element changes scale or lineWidth
  6732. // 2. Shape is changed
  6733. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  6734. if (this.__dirty || needsUpdateRect) {
  6735. rectWithStroke.copy(rect);
  6736. // FIXME Must after updateTransform
  6737. var w = style.lineWidth;
  6738. // PENDING, Min line width is needed when line is horizontal or vertical
  6739. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  6740. // Only add extra hover lineWidth when there are no fill
  6741. if (!style.hasFill()) {
  6742. w = Math.max(w, this.strokeContainThreshold || 4);
  6743. }
  6744. // Consider line width
  6745. // Line scale can't be 0;
  6746. if (lineScale > 1e-10) {
  6747. rectWithStroke.width += w / lineScale;
  6748. rectWithStroke.height += w / lineScale;
  6749. rectWithStroke.x -= w / lineScale / 2;
  6750. rectWithStroke.y -= w / lineScale / 2;
  6751. }
  6752. }
  6753. // Return rect with stroke
  6754. return rectWithStroke;
  6755. }
  6756. return rect;
  6757. },
  6758. contain: function (x, y) {
  6759. var localPos = this.transformCoordToLocal(x, y);
  6760. var rect = this.getBoundingRect();
  6761. var style = this.style;
  6762. x = localPos[0];
  6763. y = localPos[1];
  6764. if (rect.contain(x, y)) {
  6765. var pathData = this.path.data;
  6766. if (style.hasStroke()) {
  6767. var lineWidth = style.lineWidth;
  6768. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  6769. // Line scale can't be 0;
  6770. if (lineScale > 1e-10) {
  6771. // Only add extra hover lineWidth when there are no fill
  6772. if (!style.hasFill()) {
  6773. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  6774. }
  6775. if (pathContain.containStroke(
  6776. pathData, lineWidth / lineScale, x, y
  6777. )) {
  6778. return true;
  6779. }
  6780. }
  6781. }
  6782. if (style.hasFill()) {
  6783. return pathContain.contain(pathData, x, y);
  6784. }
  6785. }
  6786. return false;
  6787. },
  6788. /**
  6789. * @param {boolean} dirtyPath
  6790. */
  6791. dirty: function (dirtyPath) {
  6792. if (dirtyPath == null) {
  6793. dirtyPath = true;
  6794. }
  6795. // Only mark dirty, not mark clean
  6796. if (dirtyPath) {
  6797. this.__dirtyPath = dirtyPath;
  6798. this._rect = null;
  6799. }
  6800. this.__dirty = true;
  6801. this.__zr && this.__zr.refresh();
  6802. // Used as a clipping path
  6803. if (this.__clipTarget) {
  6804. this.__clipTarget.dirty();
  6805. }
  6806. },
  6807. /**
  6808. * Alias for animate('shape')
  6809. * @param {boolean} loop
  6810. */
  6811. animateShape: function (loop) {
  6812. return this.animate('shape', loop);
  6813. },
  6814. // Overwrite attrKV
  6815. attrKV: function (key, value) {
  6816. // FIXME
  6817. if (key === 'shape') {
  6818. this.setShape(value);
  6819. this.__dirtyPath = true;
  6820. this._rect = null;
  6821. }
  6822. else {
  6823. Displayable.prototype.attrKV.call(this, key, value);
  6824. }
  6825. },
  6826. /**
  6827. * @param {Object|string} key
  6828. * @param {*} value
  6829. */
  6830. setShape: function (key, value) {
  6831. var shape = this.shape;
  6832. // Path from string may not have shape
  6833. if (shape) {
  6834. if (zrUtil.isObject(key)) {
  6835. for (var name in key) {
  6836. if (key.hasOwnProperty(name)) {
  6837. shape[name] = key[name];
  6838. }
  6839. }
  6840. }
  6841. else {
  6842. shape[key] = value;
  6843. }
  6844. this.dirty(true);
  6845. }
  6846. return this;
  6847. },
  6848. getLineScale: function () {
  6849. var m = this.transform;
  6850. // Get the line scale.
  6851. // Determinant of `m` means how much the area is enlarged by the
  6852. // transformation. So its square root can be used as a scale factor
  6853. // for width.
  6854. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10
  6855. ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1]))
  6856. : 1;
  6857. }
  6858. };
  6859. /**
  6860. * 扩展一个 Path element, 比如星形,圆等。
  6861. * Extend a path element
  6862. * @param {Object} props
  6863. * @param {string} props.type Path type
  6864. * @param {Function} props.init Initialize
  6865. * @param {Function} props.buildPath Overwrite buildPath method
  6866. * @param {Object} [props.style] Extended default style config
  6867. * @param {Object} [props.shape] Extended default shape config
  6868. */
  6869. Path.extend = function (defaults) {
  6870. var Sub = function (opts) {
  6871. Path.call(this, opts);
  6872. if (defaults.style) {
  6873. // Extend default style
  6874. this.style.extendFrom(defaults.style, false);
  6875. }
  6876. // Extend default shape
  6877. var defaultShape = defaults.shape;
  6878. if (defaultShape) {
  6879. this.shape = this.shape || {};
  6880. var thisShape = this.shape;
  6881. for (var name in defaultShape) {
  6882. if (
  6883. ! thisShape.hasOwnProperty(name)
  6884. && defaultShape.hasOwnProperty(name)
  6885. ) {
  6886. thisShape[name] = defaultShape[name];
  6887. }
  6888. }
  6889. }
  6890. defaults.init && defaults.init.call(this, opts);
  6891. };
  6892. zrUtil.inherits(Sub, Path);
  6893. // FIXME 不能 extend position, rotation 等引用对象
  6894. for (var name in defaults) {
  6895. // Extending prototype values and methods
  6896. if (name !== 'style' && name !== 'shape') {
  6897. Sub.prototype[name] = defaults[name];
  6898. }
  6899. }
  6900. return Sub;
  6901. };
  6902. zrUtil.inherits(Path, Displayable);
  6903. module.exports = Path;
  6904. /***/ },
  6905. /* 21 */
  6906. /***/ function(module, exports, __webpack_require__) {
  6907. /**
  6908. * 可绘制的图形基类
  6909. * Base class of all displayable graphic objects
  6910. * @module zrender/graphic/Displayable
  6911. */
  6912. var zrUtil = __webpack_require__(4);
  6913. var Style = __webpack_require__(22);
  6914. var Element = __webpack_require__(23);
  6915. var RectText = __webpack_require__(35);
  6916. // var Stateful = require('./mixin/Stateful');
  6917. /**
  6918. * @alias module:zrender/graphic/Displayable
  6919. * @extends module:zrender/Element
  6920. * @extends module:zrender/graphic/mixin/RectText
  6921. */
  6922. function Displayable(opts) {
  6923. opts = opts || {};
  6924. Element.call(this, opts);
  6925. // Extend properties
  6926. for (var name in opts) {
  6927. if (
  6928. opts.hasOwnProperty(name) &&
  6929. name !== 'style'
  6930. ) {
  6931. this[name] = opts[name];
  6932. }
  6933. }
  6934. /**
  6935. * @type {module:zrender/graphic/Style}
  6936. */
  6937. this.style = new Style(opts.style);
  6938. this._rect = null;
  6939. // Shapes for cascade clipping.
  6940. this.__clipPaths = [];
  6941. // FIXME Stateful must be mixined after style is setted
  6942. // Stateful.call(this, opts);
  6943. }
  6944. Displayable.prototype = {
  6945. constructor: Displayable,
  6946. type: 'displayable',
  6947. /**
  6948. * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制
  6949. * Dirty flag. From which painter will determine if this displayable object needs brush
  6950. * @name module:zrender/graphic/Displayable#__dirty
  6951. * @type {boolean}
  6952. */
  6953. __dirty: true,
  6954. /**
  6955. * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件
  6956. * If ignore drawing of the displayable object. Mouse event will still be triggered
  6957. * @name module:/zrender/graphic/Displayable#invisible
  6958. * @type {boolean}
  6959. * @default false
  6960. */
  6961. invisible: false,
  6962. /**
  6963. * @name module:/zrender/graphic/Displayable#z
  6964. * @type {number}
  6965. * @default 0
  6966. */
  6967. z: 0,
  6968. /**
  6969. * @name module:/zrender/graphic/Displayable#z
  6970. * @type {number}
  6971. * @default 0
  6972. */
  6973. z2: 0,
  6974. /**
  6975. * z层level,决定绘画在哪层canvas中
  6976. * @name module:/zrender/graphic/Displayable#zlevel
  6977. * @type {number}
  6978. * @default 0
  6979. */
  6980. zlevel: 0,
  6981. /**
  6982. * 是否可拖拽
  6983. * @name module:/zrender/graphic/Displayable#draggable
  6984. * @type {boolean}
  6985. * @default false
  6986. */
  6987. draggable: false,
  6988. /**
  6989. * 是否正在拖拽
  6990. * @name module:/zrender/graphic/Displayable#draggable
  6991. * @type {boolean}
  6992. * @default false
  6993. */
  6994. dragging: false,
  6995. /**
  6996. * 是否相应鼠标事件
  6997. * @name module:/zrender/graphic/Displayable#silent
  6998. * @type {boolean}
  6999. * @default false
  7000. */
  7001. silent: false,
  7002. /**
  7003. * If enable culling
  7004. * @type {boolean}
  7005. * @default false
  7006. */
  7007. culling: false,
  7008. /**
  7009. * Mouse cursor when hovered
  7010. * @name module:/zrender/graphic/Displayable#cursor
  7011. * @type {string}
  7012. */
  7013. cursor: 'pointer',
  7014. /**
  7015. * If hover area is bounding rect
  7016. * @name module:/zrender/graphic/Displayable#rectHover
  7017. * @type {string}
  7018. */
  7019. rectHover: false,
  7020. /**
  7021. * Render the element progressively when the value >= 0,
  7022. * usefull for large data.
  7023. * @type {number}
  7024. */
  7025. progressive: -1,
  7026. beforeBrush: function (ctx) {},
  7027. afterBrush: function (ctx) {},
  7028. /**
  7029. * 图形绘制方法
  7030. * @param {Canvas2DRenderingContext} ctx
  7031. */
  7032. // Interface
  7033. brush: function (ctx, prevEl) {},
  7034. /**
  7035. * 获取最小包围盒
  7036. * @return {module:zrender/core/BoundingRect}
  7037. */
  7038. // Interface
  7039. getBoundingRect: function () {},
  7040. /**
  7041. * 判断坐标 x, y 是否在图形上
  7042. * If displayable element contain coord x, y
  7043. * @param {number} x
  7044. * @param {number} y
  7045. * @return {boolean}
  7046. */
  7047. contain: function (x, y) {
  7048. return this.rectContain(x, y);
  7049. },
  7050. /**
  7051. * @param {Function} cb
  7052. * @param {} context
  7053. */
  7054. traverse: function (cb, context) {
  7055. cb.call(context, this);
  7056. },
  7057. /**
  7058. * 判断坐标 x, y 是否在图形的包围盒上
  7059. * If bounding rect of element contain coord x, y
  7060. * @param {number} x
  7061. * @param {number} y
  7062. * @return {boolean}
  7063. */
  7064. rectContain: function (x, y) {
  7065. var coord = this.transformCoordToLocal(x, y);
  7066. var rect = this.getBoundingRect();
  7067. return rect.contain(coord[0], coord[1]);
  7068. },
  7069. /**
  7070. * 标记图形元素为脏,并且在下一帧重绘
  7071. * Mark displayable element dirty and refresh next frame
  7072. */
  7073. dirty: function () {
  7074. this.__dirty = true;
  7075. this._rect = null;
  7076. this.__zr && this.__zr.refresh();
  7077. },
  7078. /**
  7079. * 图形是否会触发事件
  7080. * If displayable object binded any event
  7081. * @return {boolean}
  7082. */
  7083. // TODO, 通过 bind 绑定的事件
  7084. // isSilent: function () {
  7085. // return !(
  7086. // this.hoverable || this.draggable
  7087. // || this.onmousemove || this.onmouseover || this.onmouseout
  7088. // || this.onmousedown || this.onmouseup || this.onclick
  7089. // || this.ondragenter || this.ondragover || this.ondragleave
  7090. // || this.ondrop
  7091. // );
  7092. // },
  7093. /**
  7094. * Alias for animate('style')
  7095. * @param {boolean} loop
  7096. */
  7097. animateStyle: function (loop) {
  7098. return this.animate('style', loop);
  7099. },
  7100. attrKV: function (key, value) {
  7101. if (key !== 'style') {
  7102. Element.prototype.attrKV.call(this, key, value);
  7103. }
  7104. else {
  7105. this.style.set(value);
  7106. }
  7107. },
  7108. /**
  7109. * @param {Object|string} key
  7110. * @param {*} value
  7111. */
  7112. setStyle: function (key, value) {
  7113. this.style.set(key, value);
  7114. this.dirty(false);
  7115. return this;
  7116. },
  7117. /**
  7118. * Use given style object
  7119. * @param {Object} obj
  7120. */
  7121. useStyle: function (obj) {
  7122. this.style = new Style(obj);
  7123. this.dirty(false);
  7124. return this;
  7125. }
  7126. };
  7127. zrUtil.inherits(Displayable, Element);
  7128. zrUtil.mixin(Displayable, RectText);
  7129. // zrUtil.mixin(Displayable, Stateful);
  7130. module.exports = Displayable;
  7131. /***/ },
  7132. /* 22 */
  7133. /***/ function(module, exports) {
  7134. /**
  7135. * @module zrender/graphic/Style
  7136. */
  7137. var STYLE_COMMON_PROPS = [
  7138. ['shadowBlur', 0], ['shadowOffsetX', 0], ['shadowOffsetY', 0], ['shadowColor', '#000'],
  7139. ['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]
  7140. ];
  7141. // var SHADOW_PROPS = STYLE_COMMON_PROPS.slice(0, 4);
  7142. // var LINE_PROPS = STYLE_COMMON_PROPS.slice(4);
  7143. var Style = function (opts) {
  7144. this.extendFrom(opts);
  7145. };
  7146. function createLinearGradient(ctx, obj, rect) {
  7147. var x = obj.x == null ? 0 : obj.x;
  7148. var x2 = obj.x2 == null ? 1 : obj.x2;
  7149. var y = obj.y == null ? 0 : obj.y;
  7150. var y2 = obj.y2 == null ? 0 : obj.y2;
  7151. if (!obj.global) {
  7152. x = x * rect.width + rect.x;
  7153. x2 = x2 * rect.width + rect.x;
  7154. y = y * rect.height + rect.y;
  7155. y2 = y2 * rect.height + rect.y;
  7156. }
  7157. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  7158. return canvasGradient;
  7159. }
  7160. function createRadialGradient(ctx, obj, rect) {
  7161. var width = rect.width;
  7162. var height = rect.height;
  7163. var min = Math.min(width, height);
  7164. var x = obj.x == null ? 0.5 : obj.x;
  7165. var y = obj.y == null ? 0.5 : obj.y;
  7166. var r = obj.r == null ? 0.5 : obj.r;
  7167. if (!obj.global) {
  7168. x = x * width + rect.x;
  7169. y = y * height + rect.y;
  7170. r = r * min;
  7171. }
  7172. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  7173. return canvasGradient;
  7174. }
  7175. Style.prototype = {
  7176. constructor: Style,
  7177. /**
  7178. * @type {string}
  7179. */
  7180. fill: '#000000',
  7181. /**
  7182. * @type {string}
  7183. */
  7184. stroke: null,
  7185. /**
  7186. * @type {number}
  7187. */
  7188. opacity: 1,
  7189. /**
  7190. * @type {Array.<number>}
  7191. */
  7192. lineDash: null,
  7193. /**
  7194. * @type {number}
  7195. */
  7196. lineDashOffset: 0,
  7197. /**
  7198. * @type {number}
  7199. */
  7200. shadowBlur: 0,
  7201. /**
  7202. * @type {number}
  7203. */
  7204. shadowOffsetX: 0,
  7205. /**
  7206. * @type {number}
  7207. */
  7208. shadowOffsetY: 0,
  7209. /**
  7210. * @type {number}
  7211. */
  7212. lineWidth: 1,
  7213. /**
  7214. * If stroke ignore scale
  7215. * @type {Boolean}
  7216. */
  7217. strokeNoScale: false,
  7218. // Bounding rect text configuration
  7219. // Not affected by element transform
  7220. /**
  7221. * @type {string}
  7222. */
  7223. text: null,
  7224. /**
  7225. * @type {string}
  7226. */
  7227. textFill: '#000',
  7228. /**
  7229. * @type {string}
  7230. */
  7231. textStroke: null,
  7232. /**
  7233. * 'inside', 'left', 'right', 'top', 'bottom'
  7234. * [x, y]
  7235. * @type {string|Array.<number>}
  7236. * @default 'inside'
  7237. */
  7238. textPosition: 'inside',
  7239. /**
  7240. * If not specified, use the boundingRect of a `displayable`.
  7241. * @type {Object}
  7242. */
  7243. textPositionRect: null,
  7244. /**
  7245. * [x, y]
  7246. * @type {Array.<number>}
  7247. */
  7248. textOffset: null,
  7249. /**
  7250. * @type {string}
  7251. */
  7252. textBaseline: null,
  7253. /**
  7254. * @type {string}
  7255. */
  7256. textAlign: null,
  7257. /**
  7258. * @type {string}
  7259. */
  7260. textVerticalAlign: null,
  7261. /**
  7262. * Only useful in Path and Image element
  7263. * @type {number}
  7264. */
  7265. textDistance: 5,
  7266. /**
  7267. * Only useful in Path and Image element
  7268. * @type {number}
  7269. */
  7270. textShadowBlur: 0,
  7271. /**
  7272. * Only useful in Path and Image element
  7273. * @type {number}
  7274. */
  7275. textShadowOffsetX: 0,
  7276. /**
  7277. * Only useful in Path and Image element
  7278. * @type {number}
  7279. */
  7280. textShadowOffsetY: 0,
  7281. /**
  7282. * If transform text
  7283. * Only useful in Path and Image element
  7284. * @type {boolean}
  7285. */
  7286. textTransform: false,
  7287. /**
  7288. * Text rotate around position of Path or Image
  7289. * Only useful in Path and Image element and textTransform is false.
  7290. */
  7291. textRotation: 0,
  7292. /**
  7293. * @type {string}
  7294. * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  7295. */
  7296. blend: null,
  7297. /**
  7298. * @param {CanvasRenderingContext2D} ctx
  7299. */
  7300. bind: function (ctx, el, prevEl) {
  7301. var style = this;
  7302. var prevStyle = prevEl && prevEl.style;
  7303. var firstDraw = !prevStyle;
  7304. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  7305. var prop = STYLE_COMMON_PROPS[i];
  7306. var styleName = prop[0];
  7307. if (firstDraw || style[styleName] !== prevStyle[styleName]) {
  7308. // FIXME Invalid property value will cause style leak from previous element.
  7309. ctx[styleName] = style[styleName] || prop[1];
  7310. }
  7311. }
  7312. if ((firstDraw || style.fill !== prevStyle.fill)) {
  7313. ctx.fillStyle = style.fill;
  7314. }
  7315. if ((firstDraw || style.stroke !== prevStyle.stroke)) {
  7316. ctx.strokeStyle = style.stroke;
  7317. }
  7318. if ((firstDraw || style.opacity !== prevStyle.opacity)) {
  7319. ctx.globalAlpha = style.opacity == null ? 1 : style.opacity;
  7320. }
  7321. if ((firstDraw || style.blend !== prevStyle.blend)) {
  7322. ctx.globalCompositeOperation = style.blend || 'source-over';
  7323. }
  7324. if (this.hasStroke()) {
  7325. var lineWidth = style.lineWidth;
  7326. ctx.lineWidth = lineWidth / (
  7327. (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1
  7328. );
  7329. }
  7330. },
  7331. hasFill: function () {
  7332. var fill = this.fill;
  7333. return fill != null && fill !== 'none';
  7334. },
  7335. hasStroke: function () {
  7336. var stroke = this.stroke;
  7337. return stroke != null && stroke !== 'none' && this.lineWidth > 0;
  7338. },
  7339. /**
  7340. * Extend from other style
  7341. * @param {zrender/graphic/Style} otherStyle
  7342. * @param {boolean} overwrite
  7343. */
  7344. extendFrom: function (otherStyle, overwrite) {
  7345. if (otherStyle) {
  7346. var target = this;
  7347. for (var name in otherStyle) {
  7348. if (otherStyle.hasOwnProperty(name)
  7349. && (overwrite || ! target.hasOwnProperty(name))
  7350. ) {
  7351. target[name] = otherStyle[name];
  7352. }
  7353. }
  7354. }
  7355. },
  7356. /**
  7357. * Batch setting style with a given object
  7358. * @param {Object|string} obj
  7359. * @param {*} [obj]
  7360. */
  7361. set: function (obj, value) {
  7362. if (typeof obj === 'string') {
  7363. this[obj] = value;
  7364. }
  7365. else {
  7366. this.extendFrom(obj, true);
  7367. }
  7368. },
  7369. /**
  7370. * Clone
  7371. * @return {zrender/graphic/Style} [description]
  7372. */
  7373. clone: function () {
  7374. var newStyle = new this.constructor();
  7375. newStyle.extendFrom(this, true);
  7376. return newStyle;
  7377. },
  7378. getGradient: function (ctx, obj, rect) {
  7379. var method = obj.type === 'radial' ? createRadialGradient : createLinearGradient;
  7380. var canvasGradient = method(ctx, obj, rect);
  7381. var colorStops = obj.colorStops;
  7382. for (var i = 0; i < colorStops.length; i++) {
  7383. canvasGradient.addColorStop(
  7384. colorStops[i].offset, colorStops[i].color
  7385. );
  7386. }
  7387. return canvasGradient;
  7388. }
  7389. };
  7390. var styleProto = Style.prototype;
  7391. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  7392. var prop = STYLE_COMMON_PROPS[i];
  7393. if (!(prop[0] in styleProto)) {
  7394. styleProto[prop[0]] = prop[1];
  7395. }
  7396. }
  7397. // Provide for others
  7398. Style.getGradient = styleProto.getGradient;
  7399. module.exports = Style;
  7400. /***/ },
  7401. /* 23 */
  7402. /***/ function(module, exports, __webpack_require__) {
  7403. 'use strict';
  7404. /**
  7405. * @module zrender/Element
  7406. */
  7407. var guid = __webpack_require__(24);
  7408. var Eventful = __webpack_require__(25);
  7409. var Transformable = __webpack_require__(26);
  7410. var Animatable = __webpack_require__(27);
  7411. var zrUtil = __webpack_require__(4);
  7412. /**
  7413. * @alias module:zrender/Element
  7414. * @constructor
  7415. * @extends {module:zrender/mixin/Animatable}
  7416. * @extends {module:zrender/mixin/Transformable}
  7417. * @extends {module:zrender/mixin/Eventful}
  7418. */
  7419. var Element = function (opts) {
  7420. Transformable.call(this, opts);
  7421. Eventful.call(this, opts);
  7422. Animatable.call(this, opts);
  7423. /**
  7424. * 画布元素ID
  7425. * @type {string}
  7426. */
  7427. this.id = opts.id || guid();
  7428. };
  7429. Element.prototype = {
  7430. /**
  7431. * 元素类型
  7432. * Element type
  7433. * @type {string}
  7434. */
  7435. type: 'element',
  7436. /**
  7437. * 元素名字
  7438. * Element name
  7439. * @type {string}
  7440. */
  7441. name: '',
  7442. /**
  7443. * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值
  7444. * ZRender instance will be assigned when element is associated with zrender
  7445. * @name module:/zrender/Element#__zr
  7446. * @type {module:zrender/ZRender}
  7447. */
  7448. __zr: null,
  7449. /**
  7450. * 图形是否忽略,为true时忽略图形的绘制以及事件触发
  7451. * If ignore drawing and events of the element object
  7452. * @name module:/zrender/Element#ignore
  7453. * @type {boolean}
  7454. * @default false
  7455. */
  7456. ignore: false,
  7457. /**
  7458. * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪
  7459. * 该路径会继承被裁减对象的变换
  7460. * @type {module:zrender/graphic/Path}
  7461. * @see http://www.w3.org/TR/2dcontext/#clipping-region
  7462. * @readOnly
  7463. */
  7464. clipPath: null,
  7465. /**
  7466. * Drift element
  7467. * @param {number} dx dx on the global space
  7468. * @param {number} dy dy on the global space
  7469. */
  7470. drift: function (dx, dy) {
  7471. switch (this.draggable) {
  7472. case 'horizontal':
  7473. dy = 0;
  7474. break;
  7475. case 'vertical':
  7476. dx = 0;
  7477. break;
  7478. }
  7479. var m = this.transform;
  7480. if (!m) {
  7481. m = this.transform = [1, 0, 0, 1, 0, 0];
  7482. }
  7483. m[4] += dx;
  7484. m[5] += dy;
  7485. this.decomposeTransform();
  7486. this.dirty(false);
  7487. },
  7488. /**
  7489. * Hook before update
  7490. */
  7491. beforeUpdate: function () {},
  7492. /**
  7493. * Hook after update
  7494. */
  7495. afterUpdate: function () {},
  7496. /**
  7497. * Update each frame
  7498. */
  7499. update: function () {
  7500. this.updateTransform();
  7501. },
  7502. /**
  7503. * @param {Function} cb
  7504. * @param {} context
  7505. */
  7506. traverse: function (cb, context) {},
  7507. /**
  7508. * @protected
  7509. */
  7510. attrKV: function (key, value) {
  7511. if (key === 'position' || key === 'scale' || key === 'origin') {
  7512. // Copy the array
  7513. if (value) {
  7514. var target = this[key];
  7515. if (!target) {
  7516. target = this[key] = [];
  7517. }
  7518. target[0] = value[0];
  7519. target[1] = value[1];
  7520. }
  7521. }
  7522. else {
  7523. this[key] = value;
  7524. }
  7525. },
  7526. /**
  7527. * Hide the element
  7528. */
  7529. hide: function () {
  7530. this.ignore = true;
  7531. this.__zr && this.__zr.refresh();
  7532. },
  7533. /**
  7534. * Show the element
  7535. */
  7536. show: function () {
  7537. this.ignore = false;
  7538. this.__zr && this.__zr.refresh();
  7539. },
  7540. /**
  7541. * @param {string|Object} key
  7542. * @param {*} value
  7543. */
  7544. attr: function (key, value) {
  7545. if (typeof key === 'string') {
  7546. this.attrKV(key, value);
  7547. }
  7548. else if (zrUtil.isObject(key)) {
  7549. for (var name in key) {
  7550. if (key.hasOwnProperty(name)) {
  7551. this.attrKV(name, key[name]);
  7552. }
  7553. }
  7554. }
  7555. this.dirty(false);
  7556. return this;
  7557. },
  7558. /**
  7559. * @param {module:zrender/graphic/Path} clipPath
  7560. */
  7561. setClipPath: function (clipPath) {
  7562. var zr = this.__zr;
  7563. if (zr) {
  7564. clipPath.addSelfToZr(zr);
  7565. }
  7566. // Remove previous clip path
  7567. if (this.clipPath && this.clipPath !== clipPath) {
  7568. this.removeClipPath();
  7569. }
  7570. this.clipPath = clipPath;
  7571. clipPath.__zr = zr;
  7572. clipPath.__clipTarget = this;
  7573. this.dirty(false);
  7574. },
  7575. /**
  7576. */
  7577. removeClipPath: function () {
  7578. var clipPath = this.clipPath;
  7579. if (clipPath) {
  7580. if (clipPath.__zr) {
  7581. clipPath.removeSelfFromZr(clipPath.__zr);
  7582. }
  7583. clipPath.__zr = null;
  7584. clipPath.__clipTarget = null;
  7585. this.clipPath = null;
  7586. this.dirty(false);
  7587. }
  7588. },
  7589. /**
  7590. * Add self from zrender instance.
  7591. * Not recursively because it will be invoked when element added to storage.
  7592. * @param {module:zrender/ZRender} zr
  7593. */
  7594. addSelfToZr: function (zr) {
  7595. this.__zr = zr;
  7596. // 添加动画
  7597. var animators = this.animators;
  7598. if (animators) {
  7599. for (var i = 0; i < animators.length; i++) {
  7600. zr.animation.addAnimator(animators[i]);
  7601. }
  7602. }
  7603. if (this.clipPath) {
  7604. this.clipPath.addSelfToZr(zr);
  7605. }
  7606. },
  7607. /**
  7608. * Remove self from zrender instance.
  7609. * Not recursively because it will be invoked when element added to storage.
  7610. * @param {module:zrender/ZRender} zr
  7611. */
  7612. removeSelfFromZr: function (zr) {
  7613. this.__zr = null;
  7614. // 移除动画
  7615. var animators = this.animators;
  7616. if (animators) {
  7617. for (var i = 0; i < animators.length; i++) {
  7618. zr.animation.removeAnimator(animators[i]);
  7619. }
  7620. }
  7621. if (this.clipPath) {
  7622. this.clipPath.removeSelfFromZr(zr);
  7623. }
  7624. }
  7625. };
  7626. zrUtil.mixin(Element, Animatable);
  7627. zrUtil.mixin(Element, Transformable);
  7628. zrUtil.mixin(Element, Eventful);
  7629. module.exports = Element;
  7630. /***/ },
  7631. /* 24 */
  7632. /***/ function(module, exports) {
  7633. /**
  7634. * zrender: 生成唯一id
  7635. *
  7636. * @author errorrik (errorrik@gmail.com)
  7637. */
  7638. var idStart = 0x0907;
  7639. module.exports = function () {
  7640. return idStart++;
  7641. };
  7642. /***/ },
  7643. /* 25 */
  7644. /***/ function(module, exports) {
  7645. /**
  7646. * 事件扩展
  7647. * @module zrender/mixin/Eventful
  7648. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  7649. * pissang (https://www.github.com/pissang)
  7650. */
  7651. var arrySlice = Array.prototype.slice;
  7652. /**
  7653. * 事件分发器
  7654. * @alias module:zrender/mixin/Eventful
  7655. * @constructor
  7656. */
  7657. var Eventful = function () {
  7658. this._$handlers = {};
  7659. };
  7660. Eventful.prototype = {
  7661. constructor: Eventful,
  7662. /**
  7663. * 单次触发绑定,trigger后销毁
  7664. *
  7665. * @param {string} event 事件名
  7666. * @param {Function} handler 响应函数
  7667. * @param {Object} context
  7668. */
  7669. one: function (event, handler, context) {
  7670. var _h = this._$handlers;
  7671. if (!handler || !event) {
  7672. return this;
  7673. }
  7674. if (!_h[event]) {
  7675. _h[event] = [];
  7676. }
  7677. for (var i = 0; i < _h[event].length; i++) {
  7678. if (_h[event][i].h === handler) {
  7679. return this;
  7680. }
  7681. }
  7682. _h[event].push({
  7683. h: handler,
  7684. one: true,
  7685. ctx: context || this
  7686. });
  7687. return this;
  7688. },
  7689. /**
  7690. * 绑定事件
  7691. * @param {string} event 事件名
  7692. * @param {Function} handler 事件处理函数
  7693. * @param {Object} [context]
  7694. */
  7695. on: function (event, handler, context) {
  7696. var _h = this._$handlers;
  7697. if (!handler || !event) {
  7698. return this;
  7699. }
  7700. if (!_h[event]) {
  7701. _h[event] = [];
  7702. }
  7703. for (var i = 0; i < _h[event].length; i++) {
  7704. if (_h[event][i].h === handler) {
  7705. return this;
  7706. }
  7707. }
  7708. _h[event].push({
  7709. h: handler,
  7710. one: false,
  7711. ctx: context || this
  7712. });
  7713. return this;
  7714. },
  7715. /**
  7716. * 是否绑定了事件
  7717. * @param {string} event
  7718. * @return {boolean}
  7719. */
  7720. isSilent: function (event) {
  7721. var _h = this._$handlers;
  7722. return _h[event] && _h[event].length;
  7723. },
  7724. /**
  7725. * 解绑事件
  7726. * @param {string} event 事件名
  7727. * @param {Function} [handler] 事件处理函数
  7728. */
  7729. off: function (event, handler) {
  7730. var _h = this._$handlers;
  7731. if (!event) {
  7732. this._$handlers = {};
  7733. return this;
  7734. }
  7735. if (handler) {
  7736. if (_h[event]) {
  7737. var newList = [];
  7738. for (var i = 0, l = _h[event].length; i < l; i++) {
  7739. if (_h[event][i]['h'] != handler) {
  7740. newList.push(_h[event][i]);
  7741. }
  7742. }
  7743. _h[event] = newList;
  7744. }
  7745. if (_h[event] && _h[event].length === 0) {
  7746. delete _h[event];
  7747. }
  7748. }
  7749. else {
  7750. delete _h[event];
  7751. }
  7752. return this;
  7753. },
  7754. /**
  7755. * 事件分发
  7756. *
  7757. * @param {string} type 事件类型
  7758. */
  7759. trigger: function (type) {
  7760. if (this._$handlers[type]) {
  7761. var args = arguments;
  7762. var argLen = args.length;
  7763. if (argLen > 3) {
  7764. args = arrySlice.call(args, 1);
  7765. }
  7766. var _h = this._$handlers[type];
  7767. var len = _h.length;
  7768. for (var i = 0; i < len;) {
  7769. // Optimize advise from backbone
  7770. switch (argLen) {
  7771. case 1:
  7772. _h[i]['h'].call(_h[i]['ctx']);
  7773. break;
  7774. case 2:
  7775. _h[i]['h'].call(_h[i]['ctx'], args[1]);
  7776. break;
  7777. case 3:
  7778. _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]);
  7779. break;
  7780. default:
  7781. // have more than 2 given arguments
  7782. _h[i]['h'].apply(_h[i]['ctx'], args);
  7783. break;
  7784. }
  7785. if (_h[i]['one']) {
  7786. _h.splice(i, 1);
  7787. len--;
  7788. }
  7789. else {
  7790. i++;
  7791. }
  7792. }
  7793. }
  7794. return this;
  7795. },
  7796. /**
  7797. * 带有context的事件分发, 最后一个参数是事件回调的context
  7798. * @param {string} type 事件类型
  7799. */
  7800. triggerWithContext: function (type) {
  7801. if (this._$handlers[type]) {
  7802. var args = arguments;
  7803. var argLen = args.length;
  7804. if (argLen > 4) {
  7805. args = arrySlice.call(args, 1, args.length - 1);
  7806. }
  7807. var ctx = args[args.length - 1];
  7808. var _h = this._$handlers[type];
  7809. var len = _h.length;
  7810. for (var i = 0; i < len;) {
  7811. // Optimize advise from backbone
  7812. switch (argLen) {
  7813. case 1:
  7814. _h[i]['h'].call(ctx);
  7815. break;
  7816. case 2:
  7817. _h[i]['h'].call(ctx, args[1]);
  7818. break;
  7819. case 3:
  7820. _h[i]['h'].call(ctx, args[1], args[2]);
  7821. break;
  7822. default:
  7823. // have more than 2 given arguments
  7824. _h[i]['h'].apply(ctx, args);
  7825. break;
  7826. }
  7827. if (_h[i]['one']) {
  7828. _h.splice(i, 1);
  7829. len--;
  7830. }
  7831. else {
  7832. i++;
  7833. }
  7834. }
  7835. }
  7836. return this;
  7837. }
  7838. };
  7839. // 对象可以通过 onxxxx 绑定事件
  7840. /**
  7841. * @event module:zrender/mixin/Eventful#onclick
  7842. * @type {Function}
  7843. * @default null
  7844. */
  7845. /**
  7846. * @event module:zrender/mixin/Eventful#onmouseover
  7847. * @type {Function}
  7848. * @default null
  7849. */
  7850. /**
  7851. * @event module:zrender/mixin/Eventful#onmouseout
  7852. * @type {Function}
  7853. * @default null
  7854. */
  7855. /**
  7856. * @event module:zrender/mixin/Eventful#onmousemove
  7857. * @type {Function}
  7858. * @default null
  7859. */
  7860. /**
  7861. * @event module:zrender/mixin/Eventful#onmousewheel
  7862. * @type {Function}
  7863. * @default null
  7864. */
  7865. /**
  7866. * @event module:zrender/mixin/Eventful#onmousedown
  7867. * @type {Function}
  7868. * @default null
  7869. */
  7870. /**
  7871. * @event module:zrender/mixin/Eventful#onmouseup
  7872. * @type {Function}
  7873. * @default null
  7874. */
  7875. /**
  7876. * @event module:zrender/mixin/Eventful#ondrag
  7877. * @type {Function}
  7878. * @default null
  7879. */
  7880. /**
  7881. * @event module:zrender/mixin/Eventful#ondragstart
  7882. * @type {Function}
  7883. * @default null
  7884. */
  7885. /**
  7886. * @event module:zrender/mixin/Eventful#ondragend
  7887. * @type {Function}
  7888. * @default null
  7889. */
  7890. /**
  7891. * @event module:zrender/mixin/Eventful#ondragenter
  7892. * @type {Function}
  7893. * @default null
  7894. */
  7895. /**
  7896. * @event module:zrender/mixin/Eventful#ondragleave
  7897. * @type {Function}
  7898. * @default null
  7899. */
  7900. /**
  7901. * @event module:zrender/mixin/Eventful#ondragover
  7902. * @type {Function}
  7903. * @default null
  7904. */
  7905. /**
  7906. * @event module:zrender/mixin/Eventful#ondrop
  7907. * @type {Function}
  7908. * @default null
  7909. */
  7910. module.exports = Eventful;
  7911. /***/ },
  7912. /* 26 */
  7913. /***/ function(module, exports, __webpack_require__) {
  7914. 'use strict';
  7915. /**
  7916. * 提供变换扩展
  7917. * @module zrender/mixin/Transformable
  7918. * @author pissang (https://www.github.com/pissang)
  7919. */
  7920. var matrix = __webpack_require__(11);
  7921. var vector = __webpack_require__(10);
  7922. var mIdentity = matrix.identity;
  7923. var EPSILON = 5e-5;
  7924. function isNotAroundZero(val) {
  7925. return val > EPSILON || val < -EPSILON;
  7926. }
  7927. /**
  7928. * @alias module:zrender/mixin/Transformable
  7929. * @constructor
  7930. */
  7931. var Transformable = function (opts) {
  7932. opts = opts || {};
  7933. // If there are no given position, rotation, scale
  7934. if (!opts.position) {
  7935. /**
  7936. * 平移
  7937. * @type {Array.<number>}
  7938. * @default [0, 0]
  7939. */
  7940. this.position = [0, 0];
  7941. }
  7942. if (opts.rotation == null) {
  7943. /**
  7944. * 旋转
  7945. * @type {Array.<number>}
  7946. * @default 0
  7947. */
  7948. this.rotation = 0;
  7949. }
  7950. if (!opts.scale) {
  7951. /**
  7952. * 缩放
  7953. * @type {Array.<number>}
  7954. * @default [1, 1]
  7955. */
  7956. this.scale = [1, 1];
  7957. }
  7958. /**
  7959. * 旋转和缩放的原点
  7960. * @type {Array.<number>}
  7961. * @default null
  7962. */
  7963. this.origin = this.origin || null;
  7964. };
  7965. var transformableProto = Transformable.prototype;
  7966. transformableProto.transform = null;
  7967. /**
  7968. * 判断是否需要有坐标变换
  7969. * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
  7970. */
  7971. transformableProto.needLocalTransform = function () {
  7972. return isNotAroundZero(this.rotation)
  7973. || isNotAroundZero(this.position[0])
  7974. || isNotAroundZero(this.position[1])
  7975. || isNotAroundZero(this.scale[0] - 1)
  7976. || isNotAroundZero(this.scale[1] - 1);
  7977. };
  7978. transformableProto.updateTransform = function () {
  7979. var parent = this.parent;
  7980. var parentHasTransform = parent && parent.transform;
  7981. var needLocalTransform = this.needLocalTransform();
  7982. var m = this.transform;
  7983. if (!(needLocalTransform || parentHasTransform)) {
  7984. m && mIdentity(m);
  7985. return;
  7986. }
  7987. m = m || matrix.create();
  7988. if (needLocalTransform) {
  7989. this.getLocalTransform(m);
  7990. }
  7991. else {
  7992. mIdentity(m);
  7993. }
  7994. // 应用父节点变换
  7995. if (parentHasTransform) {
  7996. if (needLocalTransform) {
  7997. matrix.mul(m, parent.transform, m);
  7998. }
  7999. else {
  8000. matrix.copy(m, parent.transform);
  8001. }
  8002. }
  8003. // 保存这个变换矩阵
  8004. this.transform = m;
  8005. this.invTransform = this.invTransform || matrix.create();
  8006. matrix.invert(this.invTransform, m);
  8007. };
  8008. transformableProto.getLocalTransform = function (m) {
  8009. return Transformable.getLocalTransform(this, m);
  8010. };
  8011. /**
  8012. * 将自己的transform应用到context上
  8013. * @param {Context2D} ctx
  8014. */
  8015. transformableProto.setTransform = function (ctx) {
  8016. var m = this.transform;
  8017. var dpr = ctx.dpr || 1;
  8018. if (m) {
  8019. ctx.setTransform(dpr * m[0], dpr * m[1], dpr * m[2], dpr * m[3], dpr * m[4], dpr * m[5]);
  8020. }
  8021. else {
  8022. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  8023. }
  8024. };
  8025. transformableProto.restoreTransform = function (ctx) {
  8026. var dpr = ctx.dpr || 1;
  8027. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  8028. };
  8029. var tmpTransform = [];
  8030. /**
  8031. * 分解`transform`矩阵到`position`, `rotation`, `scale`
  8032. */
  8033. transformableProto.decomposeTransform = function () {
  8034. if (!this.transform) {
  8035. return;
  8036. }
  8037. var parent = this.parent;
  8038. var m = this.transform;
  8039. if (parent && parent.transform) {
  8040. // Get local transform and decompose them to position, scale, rotation
  8041. matrix.mul(tmpTransform, parent.invTransform, m);
  8042. m = tmpTransform;
  8043. }
  8044. var sx = m[0] * m[0] + m[1] * m[1];
  8045. var sy = m[2] * m[2] + m[3] * m[3];
  8046. var position = this.position;
  8047. var scale = this.scale;
  8048. if (isNotAroundZero(sx - 1)) {
  8049. sx = Math.sqrt(sx);
  8050. }
  8051. if (isNotAroundZero(sy - 1)) {
  8052. sy = Math.sqrt(sy);
  8053. }
  8054. if (m[0] < 0) {
  8055. sx = -sx;
  8056. }
  8057. if (m[3] < 0) {
  8058. sy = -sy;
  8059. }
  8060. position[0] = m[4];
  8061. position[1] = m[5];
  8062. scale[0] = sx;
  8063. scale[1] = sy;
  8064. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  8065. };
  8066. /**
  8067. * Get global scale
  8068. * @return {Array.<number>}
  8069. */
  8070. transformableProto.getGlobalScale = function () {
  8071. var m = this.transform;
  8072. if (!m) {
  8073. return [1, 1];
  8074. }
  8075. var sx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  8076. var sy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  8077. if (m[0] < 0) {
  8078. sx = -sx;
  8079. }
  8080. if (m[3] < 0) {
  8081. sy = -sy;
  8082. }
  8083. return [sx, sy];
  8084. };
  8085. /**
  8086. * 变换坐标位置到 shape 的局部坐标空间
  8087. * @method
  8088. * @param {number} x
  8089. * @param {number} y
  8090. * @return {Array.<number>}
  8091. */
  8092. transformableProto.transformCoordToLocal = function (x, y) {
  8093. var v2 = [x, y];
  8094. var invTransform = this.invTransform;
  8095. if (invTransform) {
  8096. vector.applyTransform(v2, v2, invTransform);
  8097. }
  8098. return v2;
  8099. };
  8100. /**
  8101. * 变换局部坐标位置到全局坐标空间
  8102. * @method
  8103. * @param {number} x
  8104. * @param {number} y
  8105. * @return {Array.<number>}
  8106. */
  8107. transformableProto.transformCoordToGlobal = function (x, y) {
  8108. var v2 = [x, y];
  8109. var transform = this.transform;
  8110. if (transform) {
  8111. vector.applyTransform(v2, v2, transform);
  8112. }
  8113. return v2;
  8114. };
  8115. /**
  8116. * @static
  8117. * @param {Object} target
  8118. * @param {Array.<number>} target.origin
  8119. * @param {number} target.rotation
  8120. * @param {Array.<number>} target.position
  8121. * @param {Array.<number>} [m]
  8122. */
  8123. Transformable.getLocalTransform = function (target, m) {
  8124. m = m || [];
  8125. mIdentity(m);
  8126. var origin = target.origin;
  8127. var scale = target.scale || [1, 1];
  8128. var rotation = target.rotation || 0;
  8129. var position = target.position || [0, 0];
  8130. if (origin) {
  8131. // Translate to origin
  8132. m[4] -= origin[0];
  8133. m[5] -= origin[1];
  8134. }
  8135. matrix.scale(m, m, scale);
  8136. if (rotation) {
  8137. matrix.rotate(m, m, rotation);
  8138. }
  8139. if (origin) {
  8140. // Translate back from origin
  8141. m[4] += origin[0];
  8142. m[5] += origin[1];
  8143. }
  8144. m[4] += position[0];
  8145. m[5] += position[1];
  8146. return m;
  8147. };
  8148. module.exports = Transformable;
  8149. /***/ },
  8150. /* 27 */
  8151. /***/ function(module, exports, __webpack_require__) {
  8152. 'use strict';
  8153. /**
  8154. * @module zrender/mixin/Animatable
  8155. */
  8156. var Animator = __webpack_require__(28);
  8157. var util = __webpack_require__(4);
  8158. var isString = util.isString;
  8159. var isFunction = util.isFunction;
  8160. var isObject = util.isObject;
  8161. var log = __webpack_require__(33);
  8162. /**
  8163. * @alias modue:zrender/mixin/Animatable
  8164. * @constructor
  8165. */
  8166. var Animatable = function () {
  8167. /**
  8168. * @type {Array.<module:zrender/animation/Animator>}
  8169. * @readOnly
  8170. */
  8171. this.animators = [];
  8172. };
  8173. Animatable.prototype = {
  8174. constructor: Animatable,
  8175. /**
  8176. * 动画
  8177. *
  8178. * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性
  8179. * @param {boolean} [loop] 动画是否循环
  8180. * @return {module:zrender/animation/Animator}
  8181. * @example:
  8182. * el.animate('style', false)
  8183. * .when(1000, {x: 10} )
  8184. * .done(function(){ // Animation done })
  8185. * .start()
  8186. */
  8187. animate: function (path, loop) {
  8188. var target;
  8189. var animatingShape = false;
  8190. var el = this;
  8191. var zr = this.__zr;
  8192. if (path) {
  8193. var pathSplitted = path.split('.');
  8194. var prop = el;
  8195. // If animating shape
  8196. animatingShape = pathSplitted[0] === 'shape';
  8197. for (var i = 0, l = pathSplitted.length; i < l; i++) {
  8198. if (!prop) {
  8199. continue;
  8200. }
  8201. prop = prop[pathSplitted[i]];
  8202. }
  8203. if (prop) {
  8204. target = prop;
  8205. }
  8206. }
  8207. else {
  8208. target = el;
  8209. }
  8210. if (!target) {
  8211. log(
  8212. 'Property "'
  8213. + path
  8214. + '" is not existed in element '
  8215. + el.id
  8216. );
  8217. return;
  8218. }
  8219. var animators = el.animators;
  8220. var animator = new Animator(target, loop);
  8221. animator.during(function (target) {
  8222. el.dirty(animatingShape);
  8223. })
  8224. .done(function () {
  8225. // FIXME Animator will not be removed if use `Animator#stop` to stop animation
  8226. animators.splice(util.indexOf(animators, animator), 1);
  8227. });
  8228. animators.push(animator);
  8229. // If animate after added to the zrender
  8230. if (zr) {
  8231. zr.animation.addAnimator(animator);
  8232. }
  8233. return animator;
  8234. },
  8235. /**
  8236. * 停止动画
  8237. * @param {boolean} forwardToLast If move to last frame before stop
  8238. */
  8239. stopAnimation: function (forwardToLast) {
  8240. var animators = this.animators;
  8241. var len = animators.length;
  8242. for (var i = 0; i < len; i++) {
  8243. animators[i].stop(forwardToLast);
  8244. }
  8245. animators.length = 0;
  8246. return this;
  8247. },
  8248. /**
  8249. * @param {Object} target
  8250. * @param {number} [time=500] Time in ms
  8251. * @param {string} [easing='linear']
  8252. * @param {number} [delay=0]
  8253. * @param {Function} [callback]
  8254. *
  8255. * @example
  8256. * // Animate position
  8257. * el.animateTo({
  8258. * position: [10, 10]
  8259. * }, function () { // done })
  8260. *
  8261. * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing
  8262. * el.animateTo({
  8263. * shape: {
  8264. * width: 500
  8265. * },
  8266. * style: {
  8267. * fill: 'red'
  8268. * }
  8269. * position: [10, 10]
  8270. * }, 100, 100, 'cubicOut', function () { // done })
  8271. */
  8272. // TODO Return animation key
  8273. animateTo: function (target, time, delay, easing, callback) {
  8274. // animateTo(target, time, easing, callback);
  8275. if (isString(delay)) {
  8276. callback = easing;
  8277. easing = delay;
  8278. delay = 0;
  8279. }
  8280. // animateTo(target, time, delay, callback);
  8281. else if (isFunction(easing)) {
  8282. callback = easing;
  8283. easing = 'linear';
  8284. delay = 0;
  8285. }
  8286. // animateTo(target, time, callback);
  8287. else if (isFunction(delay)) {
  8288. callback = delay;
  8289. delay = 0;
  8290. }
  8291. // animateTo(target, callback)
  8292. else if (isFunction(time)) {
  8293. callback = time;
  8294. time = 500;
  8295. }
  8296. // animateTo(target)
  8297. else if (!time) {
  8298. time = 500;
  8299. }
  8300. // Stop all previous animations
  8301. this.stopAnimation();
  8302. this._animateToShallow('', this, target, time, delay, easing, callback);
  8303. // Animators may be removed immediately after start
  8304. // if there is nothing to animate
  8305. var animators = this.animators.slice();
  8306. var count = animators.length;
  8307. function done() {
  8308. count--;
  8309. if (!count) {
  8310. callback && callback();
  8311. }
  8312. }
  8313. // No animators. This should be checked before animators[i].start(),
  8314. // because 'done' may be executed immediately if no need to animate.
  8315. if (!count) {
  8316. callback && callback();
  8317. }
  8318. // Start after all animators created
  8319. // Incase any animator is done immediately when all animation properties are not changed
  8320. for (var i = 0; i < animators.length; i++) {
  8321. animators[i]
  8322. .done(done)
  8323. .start(easing);
  8324. }
  8325. },
  8326. /**
  8327. * @private
  8328. * @param {string} path=''
  8329. * @param {Object} source=this
  8330. * @param {Object} target
  8331. * @param {number} [time=500]
  8332. * @param {number} [delay=0]
  8333. *
  8334. * @example
  8335. * // Animate position
  8336. * el._animateToShallow({
  8337. * position: [10, 10]
  8338. * })
  8339. *
  8340. * // Animate shape, style and position in 100ms, delayed 100ms
  8341. * el._animateToShallow({
  8342. * shape: {
  8343. * width: 500
  8344. * },
  8345. * style: {
  8346. * fill: 'red'
  8347. * }
  8348. * position: [10, 10]
  8349. * }, 100, 100)
  8350. */
  8351. _animateToShallow: function (path, source, target, time, delay) {
  8352. var objShallow = {};
  8353. var propertyCount = 0;
  8354. for (var name in target) {
  8355. if (!target.hasOwnProperty(name)) {
  8356. continue;
  8357. }
  8358. if (source[name] != null) {
  8359. if (isObject(target[name]) && !util.isArrayLike(target[name])) {
  8360. this._animateToShallow(
  8361. path ? path + '.' + name : name,
  8362. source[name],
  8363. target[name],
  8364. time,
  8365. delay
  8366. );
  8367. }
  8368. else {
  8369. objShallow[name] = target[name];
  8370. propertyCount++;
  8371. }
  8372. }
  8373. else if (target[name] != null) {
  8374. // Attr directly if not has property
  8375. // FIXME, if some property not needed for element ?
  8376. if (!path) {
  8377. this.attr(name, target[name]);
  8378. }
  8379. else { // Shape or style
  8380. var props = {};
  8381. props[path] = {};
  8382. props[path][name] = target[name];
  8383. this.attr(props);
  8384. }
  8385. }
  8386. }
  8387. if (propertyCount > 0) {
  8388. this.animate(path, false)
  8389. .when(time == null ? 500 : time, objShallow)
  8390. .delay(delay || 0);
  8391. }
  8392. return this;
  8393. }
  8394. };
  8395. module.exports = Animatable;
  8396. /***/ },
  8397. /* 28 */
  8398. /***/ function(module, exports, __webpack_require__) {
  8399. /**
  8400. * @module echarts/animation/Animator
  8401. */
  8402. var Clip = __webpack_require__(29);
  8403. var color = __webpack_require__(31);
  8404. var util = __webpack_require__(4);
  8405. var isArrayLike = util.isArrayLike;
  8406. var arraySlice = Array.prototype.slice;
  8407. function defaultGetter(target, key) {
  8408. return target[key];
  8409. }
  8410. function defaultSetter(target, key, value) {
  8411. target[key] = value;
  8412. }
  8413. /**
  8414. * @param {number} p0
  8415. * @param {number} p1
  8416. * @param {number} percent
  8417. * @return {number}
  8418. */
  8419. function interpolateNumber(p0, p1, percent) {
  8420. return (p1 - p0) * percent + p0;
  8421. }
  8422. /**
  8423. * @param {string} p0
  8424. * @param {string} p1
  8425. * @param {number} percent
  8426. * @return {string}
  8427. */
  8428. function interpolateString(p0, p1, percent) {
  8429. return percent > 0.5 ? p1 : p0;
  8430. }
  8431. /**
  8432. * @param {Array} p0
  8433. * @param {Array} p1
  8434. * @param {number} percent
  8435. * @param {Array} out
  8436. * @param {number} arrDim
  8437. */
  8438. function interpolateArray(p0, p1, percent, out, arrDim) {
  8439. var len = p0.length;
  8440. if (arrDim == 1) {
  8441. for (var i = 0; i < len; i++) {
  8442. out[i] = interpolateNumber(p0[i], p1[i], percent);
  8443. }
  8444. }
  8445. else {
  8446. var len2 = len && p0[0].length;
  8447. for (var i = 0; i < len; i++) {
  8448. for (var j = 0; j < len2; j++) {
  8449. out[i][j] = interpolateNumber(
  8450. p0[i][j], p1[i][j], percent
  8451. );
  8452. }
  8453. }
  8454. }
  8455. }
  8456. // arr0 is source array, arr1 is target array.
  8457. // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
  8458. function fillArr(arr0, arr1, arrDim) {
  8459. var arr0Len = arr0.length;
  8460. var arr1Len = arr1.length;
  8461. if (arr0Len !== arr1Len) {
  8462. // FIXME Not work for TypedArray
  8463. var isPreviousLarger = arr0Len > arr1Len;
  8464. if (isPreviousLarger) {
  8465. // Cut the previous
  8466. arr0.length = arr1Len;
  8467. }
  8468. else {
  8469. // Fill the previous
  8470. for (var i = arr0Len; i < arr1Len; i++) {
  8471. arr0.push(
  8472. arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i])
  8473. );
  8474. }
  8475. }
  8476. }
  8477. // Handling NaN value
  8478. var len2 = arr0[0] && arr0[0].length;
  8479. for (var i = 0; i < arr0.length; i++) {
  8480. if (arrDim === 1) {
  8481. if (isNaN(arr0[i])) {
  8482. arr0[i] = arr1[i];
  8483. }
  8484. }
  8485. else {
  8486. for (var j = 0; j < len2; j++) {
  8487. if (isNaN(arr0[i][j])) {
  8488. arr0[i][j] = arr1[i][j];
  8489. }
  8490. }
  8491. }
  8492. }
  8493. }
  8494. /**
  8495. * @param {Array} arr0
  8496. * @param {Array} arr1
  8497. * @param {number} arrDim
  8498. * @return {boolean}
  8499. */
  8500. function isArraySame(arr0, arr1, arrDim) {
  8501. if (arr0 === arr1) {
  8502. return true;
  8503. }
  8504. var len = arr0.length;
  8505. if (len !== arr1.length) {
  8506. return false;
  8507. }
  8508. if (arrDim === 1) {
  8509. for (var i = 0; i < len; i++) {
  8510. if (arr0[i] !== arr1[i]) {
  8511. return false;
  8512. }
  8513. }
  8514. }
  8515. else {
  8516. var len2 = arr0[0].length;
  8517. for (var i = 0; i < len; i++) {
  8518. for (var j = 0; j < len2; j++) {
  8519. if (arr0[i][j] !== arr1[i][j]) {
  8520. return false;
  8521. }
  8522. }
  8523. }
  8524. }
  8525. return true;
  8526. }
  8527. /**
  8528. * Catmull Rom interpolate array
  8529. * @param {Array} p0
  8530. * @param {Array} p1
  8531. * @param {Array} p2
  8532. * @param {Array} p3
  8533. * @param {number} t
  8534. * @param {number} t2
  8535. * @param {number} t3
  8536. * @param {Array} out
  8537. * @param {number} arrDim
  8538. */
  8539. function catmullRomInterpolateArray(
  8540. p0, p1, p2, p3, t, t2, t3, out, arrDim
  8541. ) {
  8542. var len = p0.length;
  8543. if (arrDim == 1) {
  8544. for (var i = 0; i < len; i++) {
  8545. out[i] = catmullRomInterpolate(
  8546. p0[i], p1[i], p2[i], p3[i], t, t2, t3
  8547. );
  8548. }
  8549. }
  8550. else {
  8551. var len2 = p0[0].length;
  8552. for (var i = 0; i < len; i++) {
  8553. for (var j = 0; j < len2; j++) {
  8554. out[i][j] = catmullRomInterpolate(
  8555. p0[i][j], p1[i][j], p2[i][j], p3[i][j],
  8556. t, t2, t3
  8557. );
  8558. }
  8559. }
  8560. }
  8561. }
  8562. /**
  8563. * Catmull Rom interpolate number
  8564. * @param {number} p0
  8565. * @param {number} p1
  8566. * @param {number} p2
  8567. * @param {number} p3
  8568. * @param {number} t
  8569. * @param {number} t2
  8570. * @param {number} t3
  8571. * @return {number}
  8572. */
  8573. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  8574. var v0 = (p2 - p0) * 0.5;
  8575. var v1 = (p3 - p1) * 0.5;
  8576. return (2 * (p1 - p2) + v0 + v1) * t3
  8577. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  8578. + v0 * t + p1;
  8579. }
  8580. function cloneValue(value) {
  8581. if (isArrayLike(value)) {
  8582. var len = value.length;
  8583. if (isArrayLike(value[0])) {
  8584. var ret = [];
  8585. for (var i = 0; i < len; i++) {
  8586. ret.push(arraySlice.call(value[i]));
  8587. }
  8588. return ret;
  8589. }
  8590. return arraySlice.call(value);
  8591. }
  8592. return value;
  8593. }
  8594. function rgba2String(rgba) {
  8595. rgba[0] = Math.floor(rgba[0]);
  8596. rgba[1] = Math.floor(rgba[1]);
  8597. rgba[2] = Math.floor(rgba[2]);
  8598. return 'rgba(' + rgba.join(',') + ')';
  8599. }
  8600. function getArrayDim(keyframes) {
  8601. var lastValue = keyframes[keyframes.length - 1].value;
  8602. return isArrayLike(lastValue && lastValue[0]) ? 2 : 1;
  8603. }
  8604. function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) {
  8605. var getter = animator._getter;
  8606. var setter = animator._setter;
  8607. var useSpline = easing === 'spline';
  8608. var trackLen = keyframes.length;
  8609. if (!trackLen) {
  8610. return;
  8611. }
  8612. // Guess data type
  8613. var firstVal = keyframes[0].value;
  8614. var isValueArray = isArrayLike(firstVal);
  8615. var isValueColor = false;
  8616. var isValueString = false;
  8617. // For vertices morphing
  8618. var arrDim = isValueArray ? getArrayDim(keyframes) : 0;
  8619. var trackMaxTime;
  8620. // Sort keyframe as ascending
  8621. keyframes.sort(function(a, b) {
  8622. return a.time - b.time;
  8623. });
  8624. trackMaxTime = keyframes[trackLen - 1].time;
  8625. // Percents of each keyframe
  8626. var kfPercents = [];
  8627. // Value of each keyframe
  8628. var kfValues = [];
  8629. var prevValue = keyframes[0].value;
  8630. var isAllValueEqual = true;
  8631. for (var i = 0; i < trackLen; i++) {
  8632. kfPercents.push(keyframes[i].time / trackMaxTime);
  8633. // Assume value is a color when it is a string
  8634. var value = keyframes[i].value;
  8635. // Check if value is equal, deep check if value is array
  8636. if (!((isValueArray && isArraySame(value, prevValue, arrDim))
  8637. || (!isValueArray && value === prevValue))) {
  8638. isAllValueEqual = false;
  8639. }
  8640. prevValue = value;
  8641. // Try converting a string to a color array
  8642. if (typeof value == 'string') {
  8643. var colorArray = color.parse(value);
  8644. if (colorArray) {
  8645. value = colorArray;
  8646. isValueColor = true;
  8647. }
  8648. else {
  8649. isValueString = true;
  8650. }
  8651. }
  8652. kfValues.push(value);
  8653. }
  8654. if (isAllValueEqual) {
  8655. return;
  8656. }
  8657. var lastValue = kfValues[trackLen - 1];
  8658. // Polyfill array and NaN value
  8659. for (var i = 0; i < trackLen - 1; i++) {
  8660. if (isValueArray) {
  8661. fillArr(kfValues[i], lastValue, arrDim);
  8662. }
  8663. else {
  8664. if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
  8665. kfValues[i] = lastValue;
  8666. }
  8667. }
  8668. }
  8669. isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim);
  8670. // Cache the key of last frame to speed up when
  8671. // animation playback is sequency
  8672. var lastFrame = 0;
  8673. var lastFramePercent = 0;
  8674. var start;
  8675. var w;
  8676. var p0;
  8677. var p1;
  8678. var p2;
  8679. var p3;
  8680. if (isValueColor) {
  8681. var rgba = [0, 0, 0, 0];
  8682. }
  8683. var onframe = function (target, percent) {
  8684. // Find the range keyframes
  8685. // kf1-----kf2---------current--------kf3
  8686. // find kf2 and kf3 and do interpolation
  8687. var frame;
  8688. // In the easing function like elasticOut, percent may less than 0
  8689. if (percent < 0) {
  8690. frame = 0;
  8691. }
  8692. else if (percent < lastFramePercent) {
  8693. // Start from next key
  8694. // PENDING start from lastFrame ?
  8695. start = Math.min(lastFrame + 1, trackLen - 1);
  8696. for (frame = start; frame >= 0; frame--) {
  8697. if (kfPercents[frame] <= percent) {
  8698. break;
  8699. }
  8700. }
  8701. // PENDING really need to do this ?
  8702. frame = Math.min(frame, trackLen - 2);
  8703. }
  8704. else {
  8705. for (frame = lastFrame; frame < trackLen; frame++) {
  8706. if (kfPercents[frame] > percent) {
  8707. break;
  8708. }
  8709. }
  8710. frame = Math.min(frame - 1, trackLen - 2);
  8711. }
  8712. lastFrame = frame;
  8713. lastFramePercent = percent;
  8714. var range = (kfPercents[frame + 1] - kfPercents[frame]);
  8715. if (range === 0) {
  8716. return;
  8717. }
  8718. else {
  8719. w = (percent - kfPercents[frame]) / range;
  8720. }
  8721. if (useSpline) {
  8722. p1 = kfValues[frame];
  8723. p0 = kfValues[frame === 0 ? frame : frame - 1];
  8724. p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
  8725. p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
  8726. if (isValueArray) {
  8727. catmullRomInterpolateArray(
  8728. p0, p1, p2, p3, w, w * w, w * w * w,
  8729. getter(target, propName),
  8730. arrDim
  8731. );
  8732. }
  8733. else {
  8734. var value;
  8735. if (isValueColor) {
  8736. value = catmullRomInterpolateArray(
  8737. p0, p1, p2, p3, w, w * w, w * w * w,
  8738. rgba, 1
  8739. );
  8740. value = rgba2String(rgba);
  8741. }
  8742. else if (isValueString) {
  8743. // String is step(0.5)
  8744. return interpolateString(p1, p2, w);
  8745. }
  8746. else {
  8747. value = catmullRomInterpolate(
  8748. p0, p1, p2, p3, w, w * w, w * w * w
  8749. );
  8750. }
  8751. setter(
  8752. target,
  8753. propName,
  8754. value
  8755. );
  8756. }
  8757. }
  8758. else {
  8759. if (isValueArray) {
  8760. interpolateArray(
  8761. kfValues[frame], kfValues[frame + 1], w,
  8762. getter(target, propName),
  8763. arrDim
  8764. );
  8765. }
  8766. else {
  8767. var value;
  8768. if (isValueColor) {
  8769. interpolateArray(
  8770. kfValues[frame], kfValues[frame + 1], w,
  8771. rgba, 1
  8772. );
  8773. value = rgba2String(rgba);
  8774. }
  8775. else if (isValueString) {
  8776. // String is step(0.5)
  8777. return interpolateString(kfValues[frame], kfValues[frame + 1], w);
  8778. }
  8779. else {
  8780. value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
  8781. }
  8782. setter(
  8783. target,
  8784. propName,
  8785. value
  8786. );
  8787. }
  8788. }
  8789. };
  8790. var clip = new Clip({
  8791. target: animator._target,
  8792. life: trackMaxTime,
  8793. loop: animator._loop,
  8794. delay: animator._delay,
  8795. onframe: onframe,
  8796. ondestroy: oneTrackDone
  8797. });
  8798. if (easing && easing !== 'spline') {
  8799. clip.easing = easing;
  8800. }
  8801. return clip;
  8802. }
  8803. /**
  8804. * @alias module:zrender/animation/Animator
  8805. * @constructor
  8806. * @param {Object} target
  8807. * @param {boolean} loop
  8808. * @param {Function} getter
  8809. * @param {Function} setter
  8810. */
  8811. var Animator = function(target, loop, getter, setter) {
  8812. this._tracks = {};
  8813. this._target = target;
  8814. this._loop = loop || false;
  8815. this._getter = getter || defaultGetter;
  8816. this._setter = setter || defaultSetter;
  8817. this._clipCount = 0;
  8818. this._delay = 0;
  8819. this._doneList = [];
  8820. this._onframeList = [];
  8821. this._clipList = [];
  8822. };
  8823. Animator.prototype = {
  8824. /**
  8825. * 设置动画关键帧
  8826. * @param {number} time 关键帧时间,单位是ms
  8827. * @param {Object} props 关键帧的属性值,key-value表示
  8828. * @return {module:zrender/animation/Animator}
  8829. */
  8830. when: function(time /* ms */, props) {
  8831. var tracks = this._tracks;
  8832. for (var propName in props) {
  8833. if (!props.hasOwnProperty(propName)) {
  8834. continue;
  8835. }
  8836. if (!tracks[propName]) {
  8837. tracks[propName] = [];
  8838. // Invalid value
  8839. var value = this._getter(this._target, propName);
  8840. if (value == null) {
  8841. // zrLog('Invalid property ' + propName);
  8842. continue;
  8843. }
  8844. // If time is 0
  8845. // Then props is given initialize value
  8846. // Else
  8847. // Initialize value from current prop value
  8848. if (time !== 0) {
  8849. tracks[propName].push({
  8850. time: 0,
  8851. value: cloneValue(value)
  8852. });
  8853. }
  8854. }
  8855. tracks[propName].push({
  8856. time: time,
  8857. value: props[propName]
  8858. });
  8859. }
  8860. return this;
  8861. },
  8862. /**
  8863. * 添加动画每一帧的回调函数
  8864. * @param {Function} callback
  8865. * @return {module:zrender/animation/Animator}
  8866. */
  8867. during: function (callback) {
  8868. this._onframeList.push(callback);
  8869. return this;
  8870. },
  8871. pause: function () {
  8872. for (var i = 0; i < this._clipList.length; i++) {
  8873. this._clipList[i].pause();
  8874. }
  8875. this._paused = true;
  8876. },
  8877. resume: function () {
  8878. for (var i = 0; i < this._clipList.length; i++) {
  8879. this._clipList[i].resume();
  8880. }
  8881. this._paused = false;
  8882. },
  8883. isPaused: function () {
  8884. return !!this._paused;
  8885. },
  8886. _doneCallback: function () {
  8887. // Clear all tracks
  8888. this._tracks = {};
  8889. // Clear all clips
  8890. this._clipList.length = 0;
  8891. var doneList = this._doneList;
  8892. var len = doneList.length;
  8893. for (var i = 0; i < len; i++) {
  8894. doneList[i].call(this);
  8895. }
  8896. },
  8897. /**
  8898. * 开始执行动画
  8899. * @param {string|Function} easing
  8900. * 动画缓动函数,详见{@link module:zrender/animation/easing}
  8901. * @return {module:zrender/animation/Animator}
  8902. */
  8903. start: function (easing) {
  8904. var self = this;
  8905. var clipCount = 0;
  8906. var oneTrackDone = function() {
  8907. clipCount--;
  8908. if (!clipCount) {
  8909. self._doneCallback();
  8910. }
  8911. };
  8912. var lastClip;
  8913. for (var propName in this._tracks) {
  8914. if (!this._tracks.hasOwnProperty(propName)) {
  8915. continue;
  8916. }
  8917. var clip = createTrackClip(
  8918. this, easing, oneTrackDone,
  8919. this._tracks[propName], propName
  8920. );
  8921. if (clip) {
  8922. this._clipList.push(clip);
  8923. clipCount++;
  8924. // If start after added to animation
  8925. if (this.animation) {
  8926. this.animation.addClip(clip);
  8927. }
  8928. lastClip = clip;
  8929. }
  8930. }
  8931. // Add during callback on the last clip
  8932. if (lastClip) {
  8933. var oldOnFrame = lastClip.onframe;
  8934. lastClip.onframe = function (target, percent) {
  8935. oldOnFrame(target, percent);
  8936. for (var i = 0; i < self._onframeList.length; i++) {
  8937. self._onframeList[i](target, percent);
  8938. }
  8939. };
  8940. }
  8941. if (!clipCount) {
  8942. this._doneCallback();
  8943. }
  8944. return this;
  8945. },
  8946. /**
  8947. * 停止动画
  8948. * @param {boolean} forwardToLast If move to last frame before stop
  8949. */
  8950. stop: function (forwardToLast) {
  8951. var clipList = this._clipList;
  8952. var animation = this.animation;
  8953. for (var i = 0; i < clipList.length; i++) {
  8954. var clip = clipList[i];
  8955. if (forwardToLast) {
  8956. // Move to last frame before stop
  8957. clip.onframe(this._target, 1);
  8958. }
  8959. animation && animation.removeClip(clip);
  8960. }
  8961. clipList.length = 0;
  8962. },
  8963. /**
  8964. * 设置动画延迟开始的时间
  8965. * @param {number} time 单位ms
  8966. * @return {module:zrender/animation/Animator}
  8967. */
  8968. delay: function (time) {
  8969. this._delay = time;
  8970. return this;
  8971. },
  8972. /**
  8973. * 添加动画结束的回调
  8974. * @param {Function} cb
  8975. * @return {module:zrender/animation/Animator}
  8976. */
  8977. done: function(cb) {
  8978. if (cb) {
  8979. this._doneList.push(cb);
  8980. }
  8981. return this;
  8982. },
  8983. /**
  8984. * @return {Array.<module:zrender/animation/Clip>}
  8985. */
  8986. getClips: function () {
  8987. return this._clipList;
  8988. }
  8989. };
  8990. module.exports = Animator;
  8991. /***/ },
  8992. /* 29 */
  8993. /***/ function(module, exports, __webpack_require__) {
  8994. /**
  8995. * 动画主控制器
  8996. * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件
  8997. * @config life(1000) 动画时长
  8998. * @config delay(0) 动画延迟时间
  8999. * @config loop(true)
  9000. * @config gap(0) 循环的间隔时间
  9001. * @config onframe
  9002. * @config easing(optional)
  9003. * @config ondestroy(optional)
  9004. * @config onrestart(optional)
  9005. *
  9006. * TODO pause
  9007. */
  9008. var easingFuncs = __webpack_require__(30);
  9009. function Clip(options) {
  9010. this._target = options.target;
  9011. // 生命周期
  9012. this._life = options.life || 1000;
  9013. // 延时
  9014. this._delay = options.delay || 0;
  9015. // 开始时间
  9016. // this._startTime = new Date().getTime() + this._delay;// 单位毫秒
  9017. this._initialized = false;
  9018. // 是否循环
  9019. this.loop = options.loop == null ? false : options.loop;
  9020. this.gap = options.gap || 0;
  9021. this.easing = options.easing || 'Linear';
  9022. this.onframe = options.onframe;
  9023. this.ondestroy = options.ondestroy;
  9024. this.onrestart = options.onrestart;
  9025. this._pausedTime = 0;
  9026. this._paused = false;
  9027. }
  9028. Clip.prototype = {
  9029. constructor: Clip,
  9030. step: function (globalTime, deltaTime) {
  9031. // Set startTime on first step, or _startTime may has milleseconds different between clips
  9032. // PENDING
  9033. if (!this._initialized) {
  9034. this._startTime = globalTime + this._delay;
  9035. this._initialized = true;
  9036. }
  9037. if (this._paused) {
  9038. this._pausedTime += deltaTime;
  9039. return;
  9040. }
  9041. var percent = (globalTime - this._startTime - this._pausedTime) / this._life;
  9042. // 还没开始
  9043. if (percent < 0) {
  9044. return;
  9045. }
  9046. percent = Math.min(percent, 1);
  9047. var easing = this.easing;
  9048. var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing;
  9049. var schedule = typeof easingFunc === 'function'
  9050. ? easingFunc(percent)
  9051. : percent;
  9052. this.fire('frame', schedule);
  9053. // 结束
  9054. if (percent == 1) {
  9055. if (this.loop) {
  9056. this.restart (globalTime);
  9057. // 重新开始周期
  9058. // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件
  9059. return 'restart';
  9060. }
  9061. // 动画完成将这个控制器标识为待删除
  9062. // 在Animation.update中进行批量删除
  9063. this._needsRemove = true;
  9064. return 'destroy';
  9065. }
  9066. return null;
  9067. },
  9068. restart: function (globalTime) {
  9069. var remainder = (globalTime - this._startTime - this._pausedTime) % this._life;
  9070. this._startTime = globalTime - remainder + this.gap;
  9071. this._pausedTime = 0;
  9072. this._needsRemove = false;
  9073. },
  9074. fire: function (eventType, arg) {
  9075. eventType = 'on' + eventType;
  9076. if (this[eventType]) {
  9077. this[eventType](this._target, arg);
  9078. }
  9079. },
  9080. pause: function () {
  9081. this._paused = true;
  9082. },
  9083. resume: function () {
  9084. this._paused = false;
  9085. }
  9086. };
  9087. module.exports = Clip;
  9088. /***/ },
  9089. /* 30 */
  9090. /***/ function(module, exports) {
  9091. /**
  9092. * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js
  9093. * @see http://sole.github.io/tween.js/examples/03_graphs.html
  9094. * @exports zrender/animation/easing
  9095. */
  9096. var easing = {
  9097. /**
  9098. * @param {number} k
  9099. * @return {number}
  9100. */
  9101. linear: function (k) {
  9102. return k;
  9103. },
  9104. /**
  9105. * @param {number} k
  9106. * @return {number}
  9107. */
  9108. quadraticIn: function (k) {
  9109. return k * k;
  9110. },
  9111. /**
  9112. * @param {number} k
  9113. * @return {number}
  9114. */
  9115. quadraticOut: function (k) {
  9116. return k * (2 - k);
  9117. },
  9118. /**
  9119. * @param {number} k
  9120. * @return {number}
  9121. */
  9122. quadraticInOut: function (k) {
  9123. if ((k *= 2) < 1) {
  9124. return 0.5 * k * k;
  9125. }
  9126. return -0.5 * (--k * (k - 2) - 1);
  9127. },
  9128. // 三次方的缓动(t^3)
  9129. /**
  9130. * @param {number} k
  9131. * @return {number}
  9132. */
  9133. cubicIn: function (k) {
  9134. return k * k * k;
  9135. },
  9136. /**
  9137. * @param {number} k
  9138. * @return {number}
  9139. */
  9140. cubicOut: function (k) {
  9141. return --k * k * k + 1;
  9142. },
  9143. /**
  9144. * @param {number} k
  9145. * @return {number}
  9146. */
  9147. cubicInOut: function (k) {
  9148. if ((k *= 2) < 1) {
  9149. return 0.5 * k * k * k;
  9150. }
  9151. return 0.5 * ((k -= 2) * k * k + 2);
  9152. },
  9153. // 四次方的缓动(t^4)
  9154. /**
  9155. * @param {number} k
  9156. * @return {number}
  9157. */
  9158. quarticIn: function (k) {
  9159. return k * k * k * k;
  9160. },
  9161. /**
  9162. * @param {number} k
  9163. * @return {number}
  9164. */
  9165. quarticOut: function (k) {
  9166. return 1 - (--k * k * k * k);
  9167. },
  9168. /**
  9169. * @param {number} k
  9170. * @return {number}
  9171. */
  9172. quarticInOut: function (k) {
  9173. if ((k *= 2) < 1) {
  9174. return 0.5 * k * k * k * k;
  9175. }
  9176. return -0.5 * ((k -= 2) * k * k * k - 2);
  9177. },
  9178. // 五次方的缓动(t^5)
  9179. /**
  9180. * @param {number} k
  9181. * @return {number}
  9182. */
  9183. quinticIn: function (k) {
  9184. return k * k * k * k * k;
  9185. },
  9186. /**
  9187. * @param {number} k
  9188. * @return {number}
  9189. */
  9190. quinticOut: function (k) {
  9191. return --k * k * k * k * k + 1;
  9192. },
  9193. /**
  9194. * @param {number} k
  9195. * @return {number}
  9196. */
  9197. quinticInOut: function (k) {
  9198. if ((k *= 2) < 1) {
  9199. return 0.5 * k * k * k * k * k;
  9200. }
  9201. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  9202. },
  9203. // 正弦曲线的缓动(sin(t))
  9204. /**
  9205. * @param {number} k
  9206. * @return {number}
  9207. */
  9208. sinusoidalIn: function (k) {
  9209. return 1 - Math.cos(k * Math.PI / 2);
  9210. },
  9211. /**
  9212. * @param {number} k
  9213. * @return {number}
  9214. */
  9215. sinusoidalOut: function (k) {
  9216. return Math.sin(k * Math.PI / 2);
  9217. },
  9218. /**
  9219. * @param {number} k
  9220. * @return {number}
  9221. */
  9222. sinusoidalInOut: function (k) {
  9223. return 0.5 * (1 - Math.cos(Math.PI * k));
  9224. },
  9225. // 指数曲线的缓动(2^t)
  9226. /**
  9227. * @param {number} k
  9228. * @return {number}
  9229. */
  9230. exponentialIn: function (k) {
  9231. return k === 0 ? 0 : Math.pow(1024, k - 1);
  9232. },
  9233. /**
  9234. * @param {number} k
  9235. * @return {number}
  9236. */
  9237. exponentialOut: function (k) {
  9238. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  9239. },
  9240. /**
  9241. * @param {number} k
  9242. * @return {number}
  9243. */
  9244. exponentialInOut: function (k) {
  9245. if (k === 0) {
  9246. return 0;
  9247. }
  9248. if (k === 1) {
  9249. return 1;
  9250. }
  9251. if ((k *= 2) < 1) {
  9252. return 0.5 * Math.pow(1024, k - 1);
  9253. }
  9254. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  9255. },
  9256. // 圆形曲线的缓动(sqrt(1-t^2))
  9257. /**
  9258. * @param {number} k
  9259. * @return {number}
  9260. */
  9261. circularIn: function (k) {
  9262. return 1 - Math.sqrt(1 - k * k);
  9263. },
  9264. /**
  9265. * @param {number} k
  9266. * @return {number}
  9267. */
  9268. circularOut: function (k) {
  9269. return Math.sqrt(1 - (--k * k));
  9270. },
  9271. /**
  9272. * @param {number} k
  9273. * @return {number}
  9274. */
  9275. circularInOut: function (k) {
  9276. if ((k *= 2) < 1) {
  9277. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  9278. }
  9279. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  9280. },
  9281. // 创建类似于弹簧在停止前来回振荡的动画
  9282. /**
  9283. * @param {number} k
  9284. * @return {number}
  9285. */
  9286. elasticIn: function (k) {
  9287. var s;
  9288. var a = 0.1;
  9289. var p = 0.4;
  9290. if (k === 0) {
  9291. return 0;
  9292. }
  9293. if (k === 1) {
  9294. return 1;
  9295. }
  9296. if (!a || a < 1) {
  9297. a = 1; s = p / 4;
  9298. }
  9299. else {
  9300. s = p * Math.asin(1 / a) / (2 * Math.PI);
  9301. }
  9302. return -(a * Math.pow(2, 10 * (k -= 1)) *
  9303. Math.sin((k - s) * (2 * Math.PI) / p));
  9304. },
  9305. /**
  9306. * @param {number} k
  9307. * @return {number}
  9308. */
  9309. elasticOut: function (k) {
  9310. var s;
  9311. var a = 0.1;
  9312. var p = 0.4;
  9313. if (k === 0) {
  9314. return 0;
  9315. }
  9316. if (k === 1) {
  9317. return 1;
  9318. }
  9319. if (!a || a < 1) {
  9320. a = 1; s = p / 4;
  9321. }
  9322. else {
  9323. s = p * Math.asin(1 / a) / (2 * Math.PI);
  9324. }
  9325. return (a * Math.pow(2, -10 * k) *
  9326. Math.sin((k - s) * (2 * Math.PI) / p) + 1);
  9327. },
  9328. /**
  9329. * @param {number} k
  9330. * @return {number}
  9331. */
  9332. elasticInOut: function (k) {
  9333. var s;
  9334. var a = 0.1;
  9335. var p = 0.4;
  9336. if (k === 0) {
  9337. return 0;
  9338. }
  9339. if (k === 1) {
  9340. return 1;
  9341. }
  9342. if (!a || a < 1) {
  9343. a = 1; s = p / 4;
  9344. }
  9345. else {
  9346. s = p * Math.asin(1 / a) / (2 * Math.PI);
  9347. }
  9348. if ((k *= 2) < 1) {
  9349. return -0.5 * (a * Math.pow(2, 10 * (k -= 1))
  9350. * Math.sin((k - s) * (2 * Math.PI) / p));
  9351. }
  9352. return a * Math.pow(2, -10 * (k -= 1))
  9353. * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  9354. },
  9355. // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动
  9356. /**
  9357. * @param {number} k
  9358. * @return {number}
  9359. */
  9360. backIn: function (k) {
  9361. var s = 1.70158;
  9362. return k * k * ((s + 1) * k - s);
  9363. },
  9364. /**
  9365. * @param {number} k
  9366. * @return {number}
  9367. */
  9368. backOut: function (k) {
  9369. var s = 1.70158;
  9370. return --k * k * ((s + 1) * k + s) + 1;
  9371. },
  9372. /**
  9373. * @param {number} k
  9374. * @return {number}
  9375. */
  9376. backInOut: function (k) {
  9377. var s = 1.70158 * 1.525;
  9378. if ((k *= 2) < 1) {
  9379. return 0.5 * (k * k * ((s + 1) * k - s));
  9380. }
  9381. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  9382. },
  9383. // 创建弹跳效果
  9384. /**
  9385. * @param {number} k
  9386. * @return {number}
  9387. */
  9388. bounceIn: function (k) {
  9389. return 1 - easing.bounceOut(1 - k);
  9390. },
  9391. /**
  9392. * @param {number} k
  9393. * @return {number}
  9394. */
  9395. bounceOut: function (k) {
  9396. if (k < (1 / 2.75)) {
  9397. return 7.5625 * k * k;
  9398. }
  9399. else if (k < (2 / 2.75)) {
  9400. return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
  9401. }
  9402. else if (k < (2.5 / 2.75)) {
  9403. return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
  9404. }
  9405. else {
  9406. return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
  9407. }
  9408. },
  9409. /**
  9410. * @param {number} k
  9411. * @return {number}
  9412. */
  9413. bounceInOut: function (k) {
  9414. if (k < 0.5) {
  9415. return easing.bounceIn(k * 2) * 0.5;
  9416. }
  9417. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  9418. }
  9419. };
  9420. module.exports = easing;
  9421. /***/ },
  9422. /* 31 */
  9423. /***/ function(module, exports, __webpack_require__) {
  9424. /**
  9425. * @module zrender/tool/color
  9426. */
  9427. var LRU = __webpack_require__(32);
  9428. var kCSSColorTable = {
  9429. 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1],
  9430. 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1],
  9431. 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1],
  9432. 'beige': [245,245,220,1], 'bisque': [255,228,196,1],
  9433. 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1],
  9434. 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1],
  9435. 'brown': [165,42,42,1], 'burlywood': [222,184,135,1],
  9436. 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1],
  9437. 'chocolate': [210,105,30,1], 'coral': [255,127,80,1],
  9438. 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1],
  9439. 'crimson': [220,20,60,1], 'cyan': [0,255,255,1],
  9440. 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1],
  9441. 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1],
  9442. 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1],
  9443. 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1],
  9444. 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1],
  9445. 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1],
  9446. 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1],
  9447. 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1],
  9448. 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1],
  9449. 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1],
  9450. 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1],
  9451. 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1],
  9452. 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1],
  9453. 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1],
  9454. 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1],
  9455. 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1],
  9456. 'gray': [128,128,128,1], 'green': [0,128,0,1],
  9457. 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1],
  9458. 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1],
  9459. 'indianred': [205,92,92,1], 'indigo': [75,0,130,1],
  9460. 'ivory': [255,255,240,1], 'khaki': [240,230,140,1],
  9461. 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1],
  9462. 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1],
  9463. 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1],
  9464. 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1],
  9465. 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1],
  9466. 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1],
  9467. 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1],
  9468. 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1],
  9469. 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1],
  9470. 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1],
  9471. 'limegreen': [50,205,50,1], 'linen': [250,240,230,1],
  9472. 'magenta': [255,0,255,1], 'maroon': [128,0,0,1],
  9473. 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1],
  9474. 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1],
  9475. 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1],
  9476. 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1],
  9477. 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1],
  9478. 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1],
  9479. 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1],
  9480. 'navy': [0,0,128,1], 'oldlace': [253,245,230,1],
  9481. 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1],
  9482. 'orange': [255,165,0,1], 'orangered': [255,69,0,1],
  9483. 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1],
  9484. 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1],
  9485. 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1],
  9486. 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1],
  9487. 'pink': [255,192,203,1], 'plum': [221,160,221,1],
  9488. 'powderblue': [176,224,230,1], 'purple': [128,0,128,1],
  9489. 'red': [255,0,0,1], 'rosybrown': [188,143,143,1],
  9490. 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1],
  9491. 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1],
  9492. 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1],
  9493. 'sienna': [160,82,45,1], 'silver': [192,192,192,1],
  9494. 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1],
  9495. 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1],
  9496. 'snow': [255,250,250,1], 'springgreen': [0,255,127,1],
  9497. 'steelblue': [70,130,180,1], 'tan': [210,180,140,1],
  9498. 'teal': [0,128,128,1], 'thistle': [216,191,216,1],
  9499. 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1],
  9500. 'violet': [238,130,238,1], 'wheat': [245,222,179,1],
  9501. 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1],
  9502. 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1]
  9503. };
  9504. function clampCssByte(i) { // Clamp to integer 0 .. 255.
  9505. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  9506. return i < 0 ? 0 : i > 255 ? 255 : i;
  9507. }
  9508. function clampCssAngle(i) { // Clamp to integer 0 .. 360.
  9509. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  9510. return i < 0 ? 0 : i > 360 ? 360 : i;
  9511. }
  9512. function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0.
  9513. return f < 0 ? 0 : f > 1 ? 1 : f;
  9514. }
  9515. function parseCssInt(str) { // int or percentage.
  9516. if (str.length && str.charAt(str.length - 1) === '%') {
  9517. return clampCssByte(parseFloat(str) / 100 * 255);
  9518. }
  9519. return clampCssByte(parseInt(str, 10));
  9520. }
  9521. function parseCssFloat(str) { // float or percentage.
  9522. if (str.length && str.charAt(str.length - 1) === '%') {
  9523. return clampCssFloat(parseFloat(str) / 100);
  9524. }
  9525. return clampCssFloat(parseFloat(str));
  9526. }
  9527. function cssHueToRgb(m1, m2, h) {
  9528. if (h < 0) {
  9529. h += 1;
  9530. }
  9531. else if (h > 1) {
  9532. h -= 1;
  9533. }
  9534. if (h * 6 < 1) {
  9535. return m1 + (m2 - m1) * h * 6;
  9536. }
  9537. if (h * 2 < 1) {
  9538. return m2;
  9539. }
  9540. if (h * 3 < 2) {
  9541. return m1 + (m2 - m1) * (2/3 - h) * 6;
  9542. }
  9543. return m1;
  9544. }
  9545. function lerp(a, b, p) {
  9546. return a + (b - a) * p;
  9547. }
  9548. function setRgba(out, r, g, b, a) {
  9549. out[0] = r; out[1] = g; out[2] = b; out[3] = a;
  9550. return out;
  9551. }
  9552. function copyRgba(out, a) {
  9553. out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3];
  9554. return out;
  9555. }
  9556. var colorCache = new LRU(20);
  9557. var lastRemovedArr = null;
  9558. function putToCache(colorStr, rgbaArr) {
  9559. // Reuse removed array
  9560. if (lastRemovedArr) {
  9561. copyRgba(lastRemovedArr, rgbaArr);
  9562. }
  9563. lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || (rgbaArr.slice()));
  9564. }
  9565. /**
  9566. * @param {string} colorStr
  9567. * @param {Array.<number>} out
  9568. * @return {Array.<number>}
  9569. * @memberOf module:zrender/util/color
  9570. */
  9571. function parse(colorStr, rgbaArr) {
  9572. if (!colorStr) {
  9573. return;
  9574. }
  9575. rgbaArr = rgbaArr || [];
  9576. var cached = colorCache.get(colorStr);
  9577. if (cached) {
  9578. return copyRgba(rgbaArr, cached);
  9579. }
  9580. // colorStr may be not string
  9581. colorStr = colorStr + '';
  9582. // Remove all whitespace, not compliant, but should just be more accepting.
  9583. var str = colorStr.replace(/ /g, '').toLowerCase();
  9584. // Color keywords (and transparent) lookup.
  9585. if (str in kCSSColorTable) {
  9586. copyRgba(rgbaArr, kCSSColorTable[str]);
  9587. putToCache(colorStr, rgbaArr);
  9588. return rgbaArr;
  9589. }
  9590. // #abc and #abc123 syntax.
  9591. if (str.charAt(0) === '#') {
  9592. if (str.length === 4) {
  9593. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  9594. if (!(iv >= 0 && iv <= 0xfff)) {
  9595. setRgba(rgbaArr, 0, 0, 0, 1);
  9596. return; // Covers NaN.
  9597. }
  9598. setRgba(rgbaArr,
  9599. ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
  9600. (iv & 0xf0) | ((iv & 0xf0) >> 4),
  9601. (iv & 0xf) | ((iv & 0xf) << 4),
  9602. 1
  9603. );
  9604. putToCache(colorStr, rgbaArr);
  9605. return rgbaArr;
  9606. }
  9607. else if (str.length === 7) {
  9608. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  9609. if (!(iv >= 0 && iv <= 0xffffff)) {
  9610. setRgba(rgbaArr, 0, 0, 0, 1);
  9611. return; // Covers NaN.
  9612. }
  9613. setRgba(rgbaArr,
  9614. (iv & 0xff0000) >> 16,
  9615. (iv & 0xff00) >> 8,
  9616. iv & 0xff,
  9617. 1
  9618. );
  9619. putToCache(colorStr, rgbaArr);
  9620. return rgbaArr;
  9621. }
  9622. return;
  9623. }
  9624. var op = str.indexOf('('), ep = str.indexOf(')');
  9625. if (op !== -1 && ep + 1 === str.length) {
  9626. var fname = str.substr(0, op);
  9627. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  9628. var alpha = 1; // To allow case fallthrough.
  9629. switch (fname) {
  9630. case 'rgba':
  9631. if (params.length !== 4) {
  9632. setRgba(rgbaArr, 0, 0, 0, 1);
  9633. return;
  9634. }
  9635. alpha = parseCssFloat(params.pop()); // jshint ignore:line
  9636. // Fall through.
  9637. case 'rgb':
  9638. if (params.length !== 3) {
  9639. setRgba(rgbaArr, 0, 0, 0, 1);
  9640. return;
  9641. }
  9642. setRgba(rgbaArr,
  9643. parseCssInt(params[0]),
  9644. parseCssInt(params[1]),
  9645. parseCssInt(params[2]),
  9646. alpha
  9647. );
  9648. putToCache(colorStr, rgbaArr);
  9649. return rgbaArr;
  9650. case 'hsla':
  9651. if (params.length !== 4) {
  9652. setRgba(rgbaArr, 0, 0, 0, 1);
  9653. return;
  9654. }
  9655. params[3] = parseCssFloat(params[3]);
  9656. hsla2rgba(params, rgbaArr);
  9657. putToCache(colorStr, rgbaArr);
  9658. return rgbaArr;
  9659. case 'hsl':
  9660. if (params.length !== 3) {
  9661. setRgba(rgbaArr, 0, 0, 0, 1);
  9662. return;
  9663. }
  9664. hsla2rgba(params, rgbaArr);
  9665. putToCache(colorStr, rgbaArr);
  9666. return rgbaArr;
  9667. default:
  9668. return;
  9669. }
  9670. }
  9671. setRgba(rgbaArr, 0, 0, 0, 1);
  9672. return;
  9673. }
  9674. /**
  9675. * @param {Array.<number>} hsla
  9676. * @param {Array.<number>} rgba
  9677. * @return {Array.<number>} rgba
  9678. */
  9679. function hsla2rgba(hsla, rgba) {
  9680. var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1
  9681. // NOTE(deanm): According to the CSS spec s/l should only be
  9682. // percentages, but we don't bother and let float or percentage.
  9683. var s = parseCssFloat(hsla[1]);
  9684. var l = parseCssFloat(hsla[2]);
  9685. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  9686. var m1 = l * 2 - m2;
  9687. rgba = rgba || [];
  9688. setRgba(rgba,
  9689. clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
  9690. clampCssByte(cssHueToRgb(m1, m2, h) * 255),
  9691. clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255),
  9692. 1
  9693. );
  9694. if (hsla.length === 4) {
  9695. rgba[3] = hsla[3];
  9696. }
  9697. return rgba;
  9698. }
  9699. /**
  9700. * @param {Array.<number>} rgba
  9701. * @return {Array.<number>} hsla
  9702. */
  9703. function rgba2hsla(rgba) {
  9704. if (!rgba) {
  9705. return;
  9706. }
  9707. // RGB from 0 to 255
  9708. var R = rgba[0] / 255;
  9709. var G = rgba[1] / 255;
  9710. var B = rgba[2] / 255;
  9711. var vMin = Math.min(R, G, B); // Min. value of RGB
  9712. var vMax = Math.max(R, G, B); // Max. value of RGB
  9713. var delta = vMax - vMin; // Delta RGB value
  9714. var L = (vMax + vMin) / 2;
  9715. var H;
  9716. var S;
  9717. // HSL results from 0 to 1
  9718. if (delta === 0) {
  9719. H = 0;
  9720. S = 0;
  9721. }
  9722. else {
  9723. if (L < 0.5) {
  9724. S = delta / (vMax + vMin);
  9725. }
  9726. else {
  9727. S = delta / (2 - vMax - vMin);
  9728. }
  9729. var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
  9730. var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
  9731. var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
  9732. if (R === vMax) {
  9733. H = deltaB - deltaG;
  9734. }
  9735. else if (G === vMax) {
  9736. H = (1 / 3) + deltaR - deltaB;
  9737. }
  9738. else if (B === vMax) {
  9739. H = (2 / 3) + deltaG - deltaR;
  9740. }
  9741. if (H < 0) {
  9742. H += 1;
  9743. }
  9744. if (H > 1) {
  9745. H -= 1;
  9746. }
  9747. }
  9748. var hsla = [H * 360, S, L];
  9749. if (rgba[3] != null) {
  9750. hsla.push(rgba[3]);
  9751. }
  9752. return hsla;
  9753. }
  9754. /**
  9755. * @param {string} color
  9756. * @param {number} level
  9757. * @return {string}
  9758. * @memberOf module:zrender/util/color
  9759. */
  9760. function lift(color, level) {
  9761. var colorArr = parse(color);
  9762. if (colorArr) {
  9763. for (var i = 0; i < 3; i++) {
  9764. if (level < 0) {
  9765. colorArr[i] = colorArr[i] * (1 - level) | 0;
  9766. }
  9767. else {
  9768. colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
  9769. }
  9770. }
  9771. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  9772. }
  9773. }
  9774. /**
  9775. * @param {string} color
  9776. * @return {string}
  9777. * @memberOf module:zrender/util/color
  9778. */
  9779. function toHex(color, level) {
  9780. var colorArr = parse(color);
  9781. if (colorArr) {
  9782. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
  9783. }
  9784. }
  9785. /**
  9786. * Map value to color. Faster than mapToColor methods because color is represented by rgba array.
  9787. * @param {number} normalizedValue A float between 0 and 1.
  9788. * @param {Array.<Array.<number>>} colors List of rgba color array
  9789. * @param {Array.<number>} [out] Mapped gba color array
  9790. * @return {Array.<number>} will be null/undefined if input illegal.
  9791. */
  9792. function fastMapToColor(normalizedValue, colors, out) {
  9793. if (!(colors && colors.length)
  9794. || !(normalizedValue >= 0 && normalizedValue <= 1)
  9795. ) {
  9796. return;
  9797. }
  9798. out = out || [];
  9799. var value = normalizedValue * (colors.length - 1);
  9800. var leftIndex = Math.floor(value);
  9801. var rightIndex = Math.ceil(value);
  9802. var leftColor = colors[leftIndex];
  9803. var rightColor = colors[rightIndex];
  9804. var dv = value - leftIndex;
  9805. out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv));
  9806. out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv));
  9807. out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv));
  9808. out[3] = clampCssFloat(lerp(leftColor[3], rightColor[3], dv));
  9809. return out;
  9810. }
  9811. /**
  9812. * @param {number} normalizedValue A float between 0 and 1.
  9813. * @param {Array.<string>} colors Color list.
  9814. * @param {boolean=} fullOutput Default false.
  9815. * @return {(string|Object)} Result color. If fullOutput,
  9816. * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
  9817. * @memberOf module:zrender/util/color
  9818. */
  9819. function mapToColor(normalizedValue, colors, fullOutput) {
  9820. if (!(colors && colors.length)
  9821. || !(normalizedValue >= 0 && normalizedValue <= 1)
  9822. ) {
  9823. return;
  9824. }
  9825. var value = normalizedValue * (colors.length - 1);
  9826. var leftIndex = Math.floor(value);
  9827. var rightIndex = Math.ceil(value);
  9828. var leftColor = parse(colors[leftIndex]);
  9829. var rightColor = parse(colors[rightIndex]);
  9830. var dv = value - leftIndex;
  9831. var color = stringify(
  9832. [
  9833. clampCssByte(lerp(leftColor[0], rightColor[0], dv)),
  9834. clampCssByte(lerp(leftColor[1], rightColor[1], dv)),
  9835. clampCssByte(lerp(leftColor[2], rightColor[2], dv)),
  9836. clampCssFloat(lerp(leftColor[3], rightColor[3], dv))
  9837. ],
  9838. 'rgba'
  9839. );
  9840. return fullOutput
  9841. ? {
  9842. color: color,
  9843. leftIndex: leftIndex,
  9844. rightIndex: rightIndex,
  9845. value: value
  9846. }
  9847. : color;
  9848. }
  9849. /**
  9850. * @param {string} color
  9851. * @param {number=} h 0 ~ 360, ignore when null.
  9852. * @param {number=} s 0 ~ 1, ignore when null.
  9853. * @param {number=} l 0 ~ 1, ignore when null.
  9854. * @return {string} Color string in rgba format.
  9855. * @memberOf module:zrender/util/color
  9856. */
  9857. function modifyHSL(color, h, s, l) {
  9858. color = parse(color);
  9859. if (color) {
  9860. color = rgba2hsla(color);
  9861. h != null && (color[0] = clampCssAngle(h));
  9862. s != null && (color[1] = parseCssFloat(s));
  9863. l != null && (color[2] = parseCssFloat(l));
  9864. return stringify(hsla2rgba(color), 'rgba');
  9865. }
  9866. }
  9867. /**
  9868. * @param {string} color
  9869. * @param {number=} alpha 0 ~ 1
  9870. * @return {string} Color string in rgba format.
  9871. * @memberOf module:zrender/util/color
  9872. */
  9873. function modifyAlpha(color, alpha) {
  9874. color = parse(color);
  9875. if (color && alpha != null) {
  9876. color[3] = clampCssFloat(alpha);
  9877. return stringify(color, 'rgba');
  9878. }
  9879. }
  9880. /**
  9881. * @param {Array.<number>} arrColor like [12,33,44,0.4]
  9882. * @param {string} type 'rgba', 'hsva', ...
  9883. * @return {string} Result color. (If input illegal, return undefined).
  9884. */
  9885. function stringify(arrColor, type) {
  9886. if (!arrColor || !arrColor.length) {
  9887. return;
  9888. }
  9889. var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
  9890. if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
  9891. colorStr += ',' + arrColor[3];
  9892. }
  9893. return type + '(' + colorStr + ')';
  9894. }
  9895. module.exports = {
  9896. parse: parse,
  9897. lift: lift,
  9898. toHex: toHex,
  9899. fastMapToColor: fastMapToColor,
  9900. mapToColor: mapToColor,
  9901. modifyHSL: modifyHSL,
  9902. modifyAlpha: modifyAlpha,
  9903. stringify: stringify
  9904. };
  9905. /***/ },
  9906. /* 32 */
  9907. /***/ function(module, exports) {
  9908. // Simple LRU cache use doubly linked list
  9909. // @module zrender/core/LRU
  9910. /**
  9911. * Simple double linked list. Compared with array, it has O(1) remove operation.
  9912. * @constructor
  9913. */
  9914. var LinkedList = function () {
  9915. /**
  9916. * @type {module:zrender/core/LRU~Entry}
  9917. */
  9918. this.head = null;
  9919. /**
  9920. * @type {module:zrender/core/LRU~Entry}
  9921. */
  9922. this.tail = null;
  9923. this._len = 0;
  9924. };
  9925. var linkedListProto = LinkedList.prototype;
  9926. /**
  9927. * Insert a new value at the tail
  9928. * @param {} val
  9929. * @return {module:zrender/core/LRU~Entry}
  9930. */
  9931. linkedListProto.insert = function (val) {
  9932. var entry = new Entry(val);
  9933. this.insertEntry(entry);
  9934. return entry;
  9935. };
  9936. /**
  9937. * Insert an entry at the tail
  9938. * @param {module:zrender/core/LRU~Entry} entry
  9939. */
  9940. linkedListProto.insertEntry = function (entry) {
  9941. if (!this.head) {
  9942. this.head = this.tail = entry;
  9943. }
  9944. else {
  9945. this.tail.next = entry;
  9946. entry.prev = this.tail;
  9947. entry.next = null;
  9948. this.tail = entry;
  9949. }
  9950. this._len++;
  9951. };
  9952. /**
  9953. * Remove entry.
  9954. * @param {module:zrender/core/LRU~Entry} entry
  9955. */
  9956. linkedListProto.remove = function (entry) {
  9957. var prev = entry.prev;
  9958. var next = entry.next;
  9959. if (prev) {
  9960. prev.next = next;
  9961. }
  9962. else {
  9963. // Is head
  9964. this.head = next;
  9965. }
  9966. if (next) {
  9967. next.prev = prev;
  9968. }
  9969. else {
  9970. // Is tail
  9971. this.tail = prev;
  9972. }
  9973. entry.next = entry.prev = null;
  9974. this._len--;
  9975. };
  9976. /**
  9977. * @return {number}
  9978. */
  9979. linkedListProto.len = function () {
  9980. return this._len;
  9981. };
  9982. /**
  9983. * Clear list
  9984. */
  9985. linkedListProto.clear = function () {
  9986. this.head = this.tail = null;
  9987. this._len = 0;
  9988. };
  9989. /**
  9990. * @constructor
  9991. * @param {} val
  9992. */
  9993. var Entry = function (val) {
  9994. /**
  9995. * @type {}
  9996. */
  9997. this.value = val;
  9998. /**
  9999. * @type {module:zrender/core/LRU~Entry}
  10000. */
  10001. this.next;
  10002. /**
  10003. * @type {module:zrender/core/LRU~Entry}
  10004. */
  10005. this.prev;
  10006. };
  10007. /**
  10008. * LRU Cache
  10009. * @constructor
  10010. * @alias module:zrender/core/LRU
  10011. */
  10012. var LRU = function (maxSize) {
  10013. this._list = new LinkedList();
  10014. this._map = {};
  10015. this._maxSize = maxSize || 10;
  10016. this._lastRemovedEntry = null;
  10017. };
  10018. var LRUProto = LRU.prototype;
  10019. /**
  10020. * @param {string} key
  10021. * @param {} value
  10022. * @return {} Removed value
  10023. */
  10024. LRUProto.put = function (key, value) {
  10025. var list = this._list;
  10026. var map = this._map;
  10027. var removed = null;
  10028. if (map[key] == null) {
  10029. var len = list.len();
  10030. // Reuse last removed entry
  10031. var entry = this._lastRemovedEntry;
  10032. if (len >= this._maxSize && len > 0) {
  10033. // Remove the least recently used
  10034. var leastUsedEntry = list.head;
  10035. list.remove(leastUsedEntry);
  10036. delete map[leastUsedEntry.key];
  10037. removed = leastUsedEntry.value;
  10038. this._lastRemovedEntry = leastUsedEntry;
  10039. }
  10040. if (entry) {
  10041. entry.value = value;
  10042. }
  10043. else {
  10044. entry = new Entry(value);
  10045. }
  10046. entry.key = key;
  10047. list.insertEntry(entry);
  10048. map[key] = entry;
  10049. }
  10050. return removed;
  10051. };
  10052. /**
  10053. * @param {string} key
  10054. * @return {}
  10055. */
  10056. LRUProto.get = function (key) {
  10057. var entry = this._map[key];
  10058. var list = this._list;
  10059. if (entry != null) {
  10060. // Put the latest used entry in the tail
  10061. if (entry !== list.tail) {
  10062. list.remove(entry);
  10063. list.insertEntry(entry);
  10064. }
  10065. return entry.value;
  10066. }
  10067. };
  10068. /**
  10069. * Clear the cache
  10070. */
  10071. LRUProto.clear = function () {
  10072. this._list.clear();
  10073. this._map = {};
  10074. };
  10075. module.exports = LRU;
  10076. /***/ },
  10077. /* 33 */
  10078. /***/ function(module, exports, __webpack_require__) {
  10079. var config = __webpack_require__(34);
  10080. /**
  10081. * @exports zrender/tool/log
  10082. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  10083. */
  10084. module.exports = function() {
  10085. if (config.debugMode === 0) {
  10086. return;
  10087. }
  10088. else if (config.debugMode == 1) {
  10089. for (var k in arguments) {
  10090. throw new Error(arguments[k]);
  10091. }
  10092. }
  10093. else if (config.debugMode > 1) {
  10094. for (var k in arguments) {
  10095. console.log(arguments[k]);
  10096. }
  10097. }
  10098. };
  10099. /* for debug
  10100. return function(mes) {
  10101. document.getElementById('wrong-message').innerHTML =
  10102. mes + ' ' + (new Date() - 0)
  10103. + '<br/>'
  10104. + document.getElementById('wrong-message').innerHTML;
  10105. };
  10106. */
  10107. /***/ },
  10108. /* 34 */
  10109. /***/ function(module, exports) {
  10110. var dpr = 1;
  10111. // If in browser environment
  10112. if (typeof window !== 'undefined') {
  10113. dpr = Math.max(window.devicePixelRatio || 1, 1);
  10114. }
  10115. /**
  10116. * config默认配置项
  10117. * @exports zrender/config
  10118. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  10119. */
  10120. var config = {
  10121. /**
  10122. * debug日志选项:catchBrushException为true下有效
  10123. * 0 : 不生成debug数据,发布用
  10124. * 1 : 异常抛出,调试用
  10125. * 2 : 控制台输出,调试用
  10126. */
  10127. debugMode: 0,
  10128. // retina 屏幕优化
  10129. devicePixelRatio: dpr
  10130. };
  10131. module.exports = config;
  10132. /***/ },
  10133. /* 35 */
  10134. /***/ function(module, exports, __webpack_require__) {
  10135. /**
  10136. * Mixin for drawing text in a element bounding rect
  10137. * @module zrender/mixin/RectText
  10138. */
  10139. var textContain = __webpack_require__(8);
  10140. var BoundingRect = __webpack_require__(9);
  10141. var tmpRect = new BoundingRect();
  10142. var RectText = function () {};
  10143. function parsePercent(value, maxValue) {
  10144. if (typeof value === 'string') {
  10145. if (value.lastIndexOf('%') >= 0) {
  10146. return parseFloat(value) / 100 * maxValue;
  10147. }
  10148. return parseFloat(value);
  10149. }
  10150. return value;
  10151. }
  10152. RectText.prototype = {
  10153. constructor: RectText,
  10154. /**
  10155. * Draw text in a rect with specified position.
  10156. * @param {CanvasRenderingContext} ctx
  10157. * @param {Object} rect Displayable rect
  10158. * @return {Object} textRect Alternative precalculated text bounding rect
  10159. */
  10160. drawRectText: function (ctx, rect, textRect) {
  10161. var style = this.style;
  10162. var text = style.text;
  10163. // Convert to string
  10164. text != null && (text += '');
  10165. if (!text) {
  10166. return;
  10167. }
  10168. // FIXME
  10169. ctx.save();
  10170. var x;
  10171. var y;
  10172. var textPosition = style.textPosition;
  10173. var textOffset = style.textOffset;
  10174. var distance = style.textDistance;
  10175. var align = style.textAlign;
  10176. var font = style.textFont || style.font;
  10177. var baseline = style.textBaseline;
  10178. var verticalAlign = style.textVerticalAlign;
  10179. rect = style.textPositionRect || rect;
  10180. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  10181. // Transform rect to view space
  10182. var transform = this.transform;
  10183. if (!style.textTransform) {
  10184. if (transform) {
  10185. tmpRect.copy(rect);
  10186. tmpRect.applyTransform(transform);
  10187. rect = tmpRect;
  10188. }
  10189. }
  10190. else {
  10191. this.setTransform(ctx);
  10192. }
  10193. // Text position represented by coord
  10194. if (textPosition instanceof Array) {
  10195. // Percent
  10196. x = rect.x + parsePercent(textPosition[0], rect.width);
  10197. y = rect.y + parsePercent(textPosition[1], rect.height);
  10198. align = align || 'left';
  10199. baseline = baseline || 'top';
  10200. if (verticalAlign) {
  10201. switch (verticalAlign) {
  10202. case 'middle':
  10203. y -= textRect.height / 2 - textRect.lineHeight / 2;
  10204. break;
  10205. case 'bottom':
  10206. y -= textRect.height - textRect.lineHeight / 2;
  10207. break;
  10208. default:
  10209. y += textRect.lineHeight / 2;
  10210. }
  10211. // Force bseline to be middle
  10212. baseline = 'middle';
  10213. }
  10214. }
  10215. else {
  10216. var res = textContain.adjustTextPositionOnRect(
  10217. textPosition, rect, textRect, distance
  10218. );
  10219. x = res.x;
  10220. y = res.y;
  10221. // Default align and baseline when has textPosition
  10222. align = align || res.textAlign;
  10223. baseline = baseline || res.textBaseline;
  10224. }
  10225. if (textOffset) {
  10226. x += textOffset[0];
  10227. y += textOffset[1];
  10228. }
  10229. // Use canvas default left textAlign. Giving invalid value will cause state not change
  10230. ctx.textAlign = align || 'left';
  10231. // Use canvas default alphabetic baseline
  10232. ctx.textBaseline = baseline || 'alphabetic';
  10233. var textFill = style.textFill;
  10234. var textStroke = style.textStroke;
  10235. textFill && (ctx.fillStyle = textFill);
  10236. textStroke && (ctx.strokeStyle = textStroke);
  10237. // TODO Invalid font
  10238. ctx.font = font || '12px sans-serif';
  10239. // Text shadow
  10240. // Always set shadowBlur and shadowOffset to avoid leak from displayable
  10241. ctx.shadowBlur = style.textShadowBlur;
  10242. ctx.shadowColor = style.textShadowColor || 'transparent';
  10243. ctx.shadowOffsetX = style.textShadowOffsetX;
  10244. ctx.shadowOffsetY = style.textShadowOffsetY;
  10245. var textLines = text.split('\n');
  10246. if (style.textRotation) {
  10247. transform && ctx.translate(transform[4], transform[5]);
  10248. ctx.rotate(style.textRotation);
  10249. transform && ctx.translate(-transform[4], -transform[5]);
  10250. }
  10251. for (var i = 0; i < textLines.length; i++) {
  10252. // Fill after stroke so the outline will not cover the main part.
  10253. textStroke && ctx.strokeText(textLines[i], x, y);
  10254. textFill && ctx.fillText(textLines[i], x, y);
  10255. y += textRect.lineHeight;
  10256. }
  10257. ctx.restore();
  10258. }
  10259. };
  10260. module.exports = RectText;
  10261. /***/ },
  10262. /* 36 */
  10263. /***/ function(module, exports, __webpack_require__) {
  10264. 'use strict';
  10265. /**
  10266. * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中
  10267. * 可以用于 isInsidePath 判断以及获取boundingRect
  10268. *
  10269. * @module zrender/core/PathProxy
  10270. * @author Yi Shen (http://www.github.com/pissang)
  10271. */
  10272. // TODO getTotalLength, getPointAtLength
  10273. var curve = __webpack_require__(37);
  10274. var vec2 = __webpack_require__(10);
  10275. var bbox = __webpack_require__(38);
  10276. var BoundingRect = __webpack_require__(9);
  10277. var dpr = __webpack_require__(34).devicePixelRatio;
  10278. var CMD = {
  10279. M: 1,
  10280. L: 2,
  10281. C: 3,
  10282. Q: 4,
  10283. A: 5,
  10284. Z: 6,
  10285. // Rect
  10286. R: 7
  10287. };
  10288. // var CMD_MEM_SIZE = {
  10289. // M: 3,
  10290. // L: 3,
  10291. // C: 7,
  10292. // Q: 5,
  10293. // A: 9,
  10294. // R: 5,
  10295. // Z: 1
  10296. // };
  10297. var min = [];
  10298. var max = [];
  10299. var min2 = [];
  10300. var max2 = [];
  10301. var mathMin = Math.min;
  10302. var mathMax = Math.max;
  10303. var mathCos = Math.cos;
  10304. var mathSin = Math.sin;
  10305. var mathSqrt = Math.sqrt;
  10306. var mathAbs = Math.abs;
  10307. var hasTypedArray = typeof Float32Array != 'undefined';
  10308. /**
  10309. * @alias module:zrender/core/PathProxy
  10310. * @constructor
  10311. */
  10312. var PathProxy = function (notSaveData) {
  10313. this._saveData = !(notSaveData || false);
  10314. if (this._saveData) {
  10315. /**
  10316. * Path data. Stored as flat array
  10317. * @type {Array.<Object>}
  10318. */
  10319. this.data = [];
  10320. }
  10321. this._ctx = null;
  10322. };
  10323. /**
  10324. * 快速计算Path包围盒(并不是最小包围盒)
  10325. * @return {Object}
  10326. */
  10327. PathProxy.prototype = {
  10328. constructor: PathProxy,
  10329. _xi: 0,
  10330. _yi: 0,
  10331. _x0: 0,
  10332. _y0: 0,
  10333. // Unit x, Unit y. Provide for avoiding drawing that too short line segment
  10334. _ux: 0,
  10335. _uy: 0,
  10336. _len: 0,
  10337. _lineDash: null,
  10338. _dashOffset: 0,
  10339. _dashIdx: 0,
  10340. _dashSum: 0,
  10341. /**
  10342. * @readOnly
  10343. */
  10344. setScale: function (sx, sy) {
  10345. this._ux = mathAbs(1 / dpr / sx) || 0;
  10346. this._uy = mathAbs(1 / dpr / sy) || 0;
  10347. },
  10348. getContext: function () {
  10349. return this._ctx;
  10350. },
  10351. /**
  10352. * @param {CanvasRenderingContext2D} ctx
  10353. * @return {module:zrender/core/PathProxy}
  10354. */
  10355. beginPath: function (ctx) {
  10356. this._ctx = ctx;
  10357. ctx && ctx.beginPath();
  10358. ctx && (this.dpr = ctx.dpr);
  10359. // Reset
  10360. if (this._saveData) {
  10361. this._len = 0;
  10362. }
  10363. if (this._lineDash) {
  10364. this._lineDash = null;
  10365. this._dashOffset = 0;
  10366. }
  10367. return this;
  10368. },
  10369. /**
  10370. * @param {number} x
  10371. * @param {number} y
  10372. * @return {module:zrender/core/PathProxy}
  10373. */
  10374. moveTo: function (x, y) {
  10375. this.addData(CMD.M, x, y);
  10376. this._ctx && this._ctx.moveTo(x, y);
  10377. // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用
  10378. // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。
  10379. // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要
  10380. // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持
  10381. this._x0 = x;
  10382. this._y0 = y;
  10383. this._xi = x;
  10384. this._yi = y;
  10385. return this;
  10386. },
  10387. /**
  10388. * @param {number} x
  10389. * @param {number} y
  10390. * @return {module:zrender/core/PathProxy}
  10391. */
  10392. lineTo: function (x, y) {
  10393. var exceedUnit = mathAbs(x - this._xi) > this._ux
  10394. || mathAbs(y - this._yi) > this._uy
  10395. // Force draw the first segment
  10396. || this._len < 5;
  10397. this.addData(CMD.L, x, y);
  10398. if (this._ctx && exceedUnit) {
  10399. this._needsDash() ? this._dashedLineTo(x, y)
  10400. : this._ctx.lineTo(x, y);
  10401. }
  10402. if (exceedUnit) {
  10403. this._xi = x;
  10404. this._yi = y;
  10405. }
  10406. return this;
  10407. },
  10408. /**
  10409. * @param {number} x1
  10410. * @param {number} y1
  10411. * @param {number} x2
  10412. * @param {number} y2
  10413. * @param {number} x3
  10414. * @param {number} y3
  10415. * @return {module:zrender/core/PathProxy}
  10416. */
  10417. bezierCurveTo: function (x1, y1, x2, y2, x3, y3) {
  10418. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  10419. if (this._ctx) {
  10420. this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3)
  10421. : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  10422. }
  10423. this._xi = x3;
  10424. this._yi = y3;
  10425. return this;
  10426. },
  10427. /**
  10428. * @param {number} x1
  10429. * @param {number} y1
  10430. * @param {number} x2
  10431. * @param {number} y2
  10432. * @return {module:zrender/core/PathProxy}
  10433. */
  10434. quadraticCurveTo: function (x1, y1, x2, y2) {
  10435. this.addData(CMD.Q, x1, y1, x2, y2);
  10436. if (this._ctx) {
  10437. this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2)
  10438. : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  10439. }
  10440. this._xi = x2;
  10441. this._yi = y2;
  10442. return this;
  10443. },
  10444. /**
  10445. * @param {number} cx
  10446. * @param {number} cy
  10447. * @param {number} r
  10448. * @param {number} startAngle
  10449. * @param {number} endAngle
  10450. * @param {boolean} anticlockwise
  10451. * @return {module:zrender/core/PathProxy}
  10452. */
  10453. arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  10454. this.addData(
  10455. CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1
  10456. );
  10457. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  10458. this._xi = mathCos(endAngle) * r + cx;
  10459. this._yi = mathSin(endAngle) * r + cx;
  10460. return this;
  10461. },
  10462. // TODO
  10463. arcTo: function (x1, y1, x2, y2, radius) {
  10464. if (this._ctx) {
  10465. this._ctx.arcTo(x1, y1, x2, y2, radius);
  10466. }
  10467. return this;
  10468. },
  10469. // TODO
  10470. rect: function (x, y, w, h) {
  10471. this._ctx && this._ctx.rect(x, y, w, h);
  10472. this.addData(CMD.R, x, y, w, h);
  10473. return this;
  10474. },
  10475. /**
  10476. * @return {module:zrender/core/PathProxy}
  10477. */
  10478. closePath: function () {
  10479. this.addData(CMD.Z);
  10480. var ctx = this._ctx;
  10481. var x0 = this._x0;
  10482. var y0 = this._y0;
  10483. if (ctx) {
  10484. this._needsDash() && this._dashedLineTo(x0, y0);
  10485. ctx.closePath();
  10486. }
  10487. this._xi = x0;
  10488. this._yi = y0;
  10489. return this;
  10490. },
  10491. /**
  10492. * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。
  10493. * stroke 同样
  10494. * @param {CanvasRenderingContext2D} ctx
  10495. * @return {module:zrender/core/PathProxy}
  10496. */
  10497. fill: function (ctx) {
  10498. ctx && ctx.fill();
  10499. this.toStatic();
  10500. },
  10501. /**
  10502. * @param {CanvasRenderingContext2D} ctx
  10503. * @return {module:zrender/core/PathProxy}
  10504. */
  10505. stroke: function (ctx) {
  10506. ctx && ctx.stroke();
  10507. this.toStatic();
  10508. },
  10509. /**
  10510. * 必须在其它绘制命令前调用
  10511. * Must be invoked before all other path drawing methods
  10512. * @return {module:zrender/core/PathProxy}
  10513. */
  10514. setLineDash: function (lineDash) {
  10515. if (lineDash instanceof Array) {
  10516. this._lineDash = lineDash;
  10517. this._dashIdx = 0;
  10518. var lineDashSum = 0;
  10519. for (var i = 0; i < lineDash.length; i++) {
  10520. lineDashSum += lineDash[i];
  10521. }
  10522. this._dashSum = lineDashSum;
  10523. }
  10524. return this;
  10525. },
  10526. /**
  10527. * 必须在其它绘制命令前调用
  10528. * Must be invoked before all other path drawing methods
  10529. * @return {module:zrender/core/PathProxy}
  10530. */
  10531. setLineDashOffset: function (offset) {
  10532. this._dashOffset = offset;
  10533. return this;
  10534. },
  10535. /**
  10536. *
  10537. * @return {boolean}
  10538. */
  10539. len: function () {
  10540. return this._len;
  10541. },
  10542. /**
  10543. * 直接设置 Path 数据
  10544. */
  10545. setData: function (data) {
  10546. var len = data.length;
  10547. if (! (this.data && this.data.length == len) && hasTypedArray) {
  10548. this.data = new Float32Array(len);
  10549. }
  10550. for (var i = 0; i < len; i++) {
  10551. this.data[i] = data[i];
  10552. }
  10553. this._len = len;
  10554. },
  10555. /**
  10556. * 添加子路径
  10557. * @param {module:zrender/core/PathProxy|Array.<module:zrender/core/PathProxy>} path
  10558. */
  10559. appendPath: function (path) {
  10560. if (!(path instanceof Array)) {
  10561. path = [path];
  10562. }
  10563. var len = path.length;
  10564. var appendSize = 0;
  10565. var offset = this._len;
  10566. for (var i = 0; i < len; i++) {
  10567. appendSize += path[i].len();
  10568. }
  10569. if (hasTypedArray && (this.data instanceof Float32Array)) {
  10570. this.data = new Float32Array(offset + appendSize);
  10571. }
  10572. for (var i = 0; i < len; i++) {
  10573. var appendPathData = path[i].data;
  10574. for (var k = 0; k < appendPathData.length; k++) {
  10575. this.data[offset++] = appendPathData[k];
  10576. }
  10577. }
  10578. this._len = offset;
  10579. },
  10580. /**
  10581. * 填充 Path 数据。
  10582. * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。
  10583. */
  10584. addData: function (cmd) {
  10585. if (!this._saveData) {
  10586. return;
  10587. }
  10588. var data = this.data;
  10589. if (this._len + arguments.length > data.length) {
  10590. // 因为之前的数组已经转换成静态的 Float32Array
  10591. // 所以不够用时需要扩展一个新的动态数组
  10592. this._expandData();
  10593. data = this.data;
  10594. }
  10595. for (var i = 0; i < arguments.length; i++) {
  10596. data[this._len++] = arguments[i];
  10597. }
  10598. this._prevCmd = cmd;
  10599. },
  10600. _expandData: function () {
  10601. // Only if data is Float32Array
  10602. if (!(this.data instanceof Array)) {
  10603. var newData = [];
  10604. for (var i = 0; i < this._len; i++) {
  10605. newData[i] = this.data[i];
  10606. }
  10607. this.data = newData;
  10608. }
  10609. },
  10610. /**
  10611. * If needs js implemented dashed line
  10612. * @return {boolean}
  10613. * @private
  10614. */
  10615. _needsDash: function () {
  10616. return this._lineDash;
  10617. },
  10618. _dashedLineTo: function (x1, y1) {
  10619. var dashSum = this._dashSum;
  10620. var offset = this._dashOffset;
  10621. var lineDash = this._lineDash;
  10622. var ctx = this._ctx;
  10623. var x0 = this._xi;
  10624. var y0 = this._yi;
  10625. var dx = x1 - x0;
  10626. var dy = y1 - y0;
  10627. var dist = mathSqrt(dx * dx + dy * dy);
  10628. var x = x0;
  10629. var y = y0;
  10630. var dash;
  10631. var nDash = lineDash.length;
  10632. var idx;
  10633. dx /= dist;
  10634. dy /= dist;
  10635. if (offset < 0) {
  10636. // Convert to positive offset
  10637. offset = dashSum + offset;
  10638. }
  10639. offset %= dashSum;
  10640. x -= offset * dx;
  10641. y -= offset * dy;
  10642. while ((dx > 0 && x <= x1) || (dx < 0 && x >= x1)
  10643. || (dx == 0 && ((dy > 0 && y <= y1) || (dy < 0 && y >= y1)))) {
  10644. idx = this._dashIdx;
  10645. dash = lineDash[idx];
  10646. x += dx * dash;
  10647. y += dy * dash;
  10648. this._dashIdx = (idx + 1) % nDash;
  10649. // Skip positive offset
  10650. if ((dx > 0 && x < x0) || (dx < 0 && x > x0) || (dy > 0 && y < y0) || (dy < 0 && y > y0)) {
  10651. continue;
  10652. }
  10653. ctx[idx % 2 ? 'moveTo' : 'lineTo'](
  10654. dx >= 0 ? mathMin(x, x1) : mathMax(x, x1),
  10655. dy >= 0 ? mathMin(y, y1) : mathMax(y, y1)
  10656. );
  10657. }
  10658. // Offset for next lineTo
  10659. dx = x - x1;
  10660. dy = y - y1;
  10661. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  10662. },
  10663. // Not accurate dashed line to
  10664. _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) {
  10665. var dashSum = this._dashSum;
  10666. var offset = this._dashOffset;
  10667. var lineDash = this._lineDash;
  10668. var ctx = this._ctx;
  10669. var x0 = this._xi;
  10670. var y0 = this._yi;
  10671. var t;
  10672. var dx;
  10673. var dy;
  10674. var cubicAt = curve.cubicAt;
  10675. var bezierLen = 0;
  10676. var idx = this._dashIdx;
  10677. var nDash = lineDash.length;
  10678. var x;
  10679. var y;
  10680. var tmpLen = 0;
  10681. if (offset < 0) {
  10682. // Convert to positive offset
  10683. offset = dashSum + offset;
  10684. }
  10685. offset %= dashSum;
  10686. // Bezier approx length
  10687. for (t = 0; t < 1; t += 0.1) {
  10688. dx = cubicAt(x0, x1, x2, x3, t + 0.1)
  10689. - cubicAt(x0, x1, x2, x3, t);
  10690. dy = cubicAt(y0, y1, y2, y3, t + 0.1)
  10691. - cubicAt(y0, y1, y2, y3, t);
  10692. bezierLen += mathSqrt(dx * dx + dy * dy);
  10693. }
  10694. // Find idx after add offset
  10695. for (; idx < nDash; idx++) {
  10696. tmpLen += lineDash[idx];
  10697. if (tmpLen > offset) {
  10698. break;
  10699. }
  10700. }
  10701. t = (tmpLen - offset) / bezierLen;
  10702. while (t <= 1) {
  10703. x = cubicAt(x0, x1, x2, x3, t);
  10704. y = cubicAt(y0, y1, y2, y3, t);
  10705. // Use line to approximate dashed bezier
  10706. // Bad result if dash is long
  10707. idx % 2 ? ctx.moveTo(x, y)
  10708. : ctx.lineTo(x, y);
  10709. t += lineDash[idx] / bezierLen;
  10710. idx = (idx + 1) % nDash;
  10711. }
  10712. // Finish the last segment and calculate the new offset
  10713. (idx % 2 !== 0) && ctx.lineTo(x3, y3);
  10714. dx = x3 - x;
  10715. dy = y3 - y;
  10716. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  10717. },
  10718. _dashedQuadraticTo: function (x1, y1, x2, y2) {
  10719. // Convert quadratic to cubic using degree elevation
  10720. var x3 = x2;
  10721. var y3 = y2;
  10722. x2 = (x2 + 2 * x1) / 3;
  10723. y2 = (y2 + 2 * y1) / 3;
  10724. x1 = (this._xi + 2 * x1) / 3;
  10725. y1 = (this._yi + 2 * y1) / 3;
  10726. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  10727. },
  10728. /**
  10729. * 转成静态的 Float32Array 减少堆内存占用
  10730. * Convert dynamic array to static Float32Array
  10731. */
  10732. toStatic: function () {
  10733. var data = this.data;
  10734. if (data instanceof Array) {
  10735. data.length = this._len;
  10736. if (hasTypedArray) {
  10737. this.data = new Float32Array(data);
  10738. }
  10739. }
  10740. },
  10741. /**
  10742. * @return {module:zrender/core/BoundingRect}
  10743. */
  10744. getBoundingRect: function () {
  10745. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  10746. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  10747. var data = this.data;
  10748. var xi = 0;
  10749. var yi = 0;
  10750. var x0 = 0;
  10751. var y0 = 0;
  10752. for (var i = 0; i < data.length;) {
  10753. var cmd = data[i++];
  10754. if (i == 1) {
  10755. // 如果第一个命令是 L, C, Q
  10756. // 则 previous point 同绘制命令的第一个 point
  10757. //
  10758. // 第一个命令为 Arc 的情况下会在后面特殊处理
  10759. xi = data[i];
  10760. yi = data[i + 1];
  10761. x0 = xi;
  10762. y0 = yi;
  10763. }
  10764. switch (cmd) {
  10765. case CMD.M:
  10766. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  10767. // 在 closePath 的时候使用
  10768. x0 = data[i++];
  10769. y0 = data[i++];
  10770. xi = x0;
  10771. yi = y0;
  10772. min2[0] = x0;
  10773. min2[1] = y0;
  10774. max2[0] = x0;
  10775. max2[1] = y0;
  10776. break;
  10777. case CMD.L:
  10778. bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  10779. xi = data[i++];
  10780. yi = data[i++];
  10781. break;
  10782. case CMD.C:
  10783. bbox.fromCubic(
  10784. xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  10785. min2, max2
  10786. );
  10787. xi = data[i++];
  10788. yi = data[i++];
  10789. break;
  10790. case CMD.Q:
  10791. bbox.fromQuadratic(
  10792. xi, yi, data[i++], data[i++], data[i], data[i + 1],
  10793. min2, max2
  10794. );
  10795. xi = data[i++];
  10796. yi = data[i++];
  10797. break;
  10798. case CMD.A:
  10799. // TODO Arc 判断的开销比较大
  10800. var cx = data[i++];
  10801. var cy = data[i++];
  10802. var rx = data[i++];
  10803. var ry = data[i++];
  10804. var startAngle = data[i++];
  10805. var endAngle = data[i++] + startAngle;
  10806. // TODO Arc 旋转
  10807. var psi = data[i++];
  10808. var anticlockwise = 1 - data[i++];
  10809. if (i == 1) {
  10810. // 直接使用 arc 命令
  10811. // 第一个命令起点还未定义
  10812. x0 = mathCos(startAngle) * rx + cx;
  10813. y0 = mathSin(startAngle) * ry + cy;
  10814. }
  10815. bbox.fromArc(
  10816. cx, cy, rx, ry, startAngle, endAngle,
  10817. anticlockwise, min2, max2
  10818. );
  10819. xi = mathCos(endAngle) * rx + cx;
  10820. yi = mathSin(endAngle) * ry + cy;
  10821. break;
  10822. case CMD.R:
  10823. x0 = xi = data[i++];
  10824. y0 = yi = data[i++];
  10825. var width = data[i++];
  10826. var height = data[i++];
  10827. // Use fromLine
  10828. bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  10829. break;
  10830. case CMD.Z:
  10831. xi = x0;
  10832. yi = y0;
  10833. break;
  10834. }
  10835. // Union
  10836. vec2.min(min, min, min2);
  10837. vec2.max(max, max, max2);
  10838. }
  10839. // No data
  10840. if (i === 0) {
  10841. min[0] = min[1] = max[0] = max[1] = 0;
  10842. }
  10843. return new BoundingRect(
  10844. min[0], min[1], max[0] - min[0], max[1] - min[1]
  10845. );
  10846. },
  10847. /**
  10848. * Rebuild path from current data
  10849. * Rebuild path will not consider javascript implemented line dash.
  10850. * @param {CanvasRenderingContext} ctx
  10851. */
  10852. rebuildPath: function (ctx) {
  10853. var d = this.data;
  10854. var x0, y0;
  10855. var xi, yi;
  10856. var x, y;
  10857. var ux = this._ux;
  10858. var uy = this._uy;
  10859. var len = this._len;
  10860. for (var i = 0; i < len;) {
  10861. var cmd = d[i++];
  10862. if (i == 1) {
  10863. // 如果第一个命令是 L, C, Q
  10864. // 则 previous point 同绘制命令的第一个 point
  10865. //
  10866. // 第一个命令为 Arc 的情况下会在后面特殊处理
  10867. xi = d[i];
  10868. yi = d[i + 1];
  10869. x0 = xi;
  10870. y0 = yi;
  10871. }
  10872. switch (cmd) {
  10873. case CMD.M:
  10874. x0 = xi = d[i++];
  10875. y0 = yi = d[i++];
  10876. ctx.moveTo(xi, yi);
  10877. break;
  10878. case CMD.L:
  10879. x = d[i++];
  10880. y = d[i++];
  10881. // Not draw too small seg between
  10882. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
  10883. ctx.lineTo(x, y);
  10884. xi = x;
  10885. yi = y;
  10886. }
  10887. break;
  10888. case CMD.C:
  10889. ctx.bezierCurveTo(
  10890. d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]
  10891. );
  10892. xi = d[i - 2];
  10893. yi = d[i - 1];
  10894. break;
  10895. case CMD.Q:
  10896. ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
  10897. xi = d[i - 2];
  10898. yi = d[i - 1];
  10899. break;
  10900. case CMD.A:
  10901. var cx = d[i++];
  10902. var cy = d[i++];
  10903. var rx = d[i++];
  10904. var ry = d[i++];
  10905. var theta = d[i++];
  10906. var dTheta = d[i++];
  10907. var psi = d[i++];
  10908. var fs = d[i++];
  10909. var r = (rx > ry) ? rx : ry;
  10910. var scaleX = (rx > ry) ? 1 : rx / ry;
  10911. var scaleY = (rx > ry) ? ry / rx : 1;
  10912. var isEllipse = Math.abs(rx - ry) > 1e-3;
  10913. var endAngle = theta + dTheta;
  10914. if (isEllipse) {
  10915. ctx.translate(cx, cy);
  10916. ctx.rotate(psi);
  10917. ctx.scale(scaleX, scaleY);
  10918. ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
  10919. ctx.scale(1 / scaleX, 1 / scaleY);
  10920. ctx.rotate(-psi);
  10921. ctx.translate(-cx, -cy);
  10922. }
  10923. else {
  10924. ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
  10925. }
  10926. if (i == 1) {
  10927. // 直接使用 arc 命令
  10928. // 第一个命令起点还未定义
  10929. x0 = mathCos(theta) * rx + cx;
  10930. y0 = mathSin(theta) * ry + cy;
  10931. }
  10932. xi = mathCos(endAngle) * rx + cx;
  10933. yi = mathSin(endAngle) * ry + cy;
  10934. break;
  10935. case CMD.R:
  10936. x0 = xi = d[i];
  10937. y0 = yi = d[i + 1];
  10938. ctx.rect(d[i++], d[i++], d[i++], d[i++]);
  10939. break;
  10940. case CMD.Z:
  10941. ctx.closePath();
  10942. xi = x0;
  10943. yi = y0;
  10944. }
  10945. }
  10946. }
  10947. };
  10948. PathProxy.CMD = CMD;
  10949. module.exports = PathProxy;
  10950. /***/ },
  10951. /* 37 */
  10952. /***/ function(module, exports, __webpack_require__) {
  10953. 'use strict';
  10954. /**
  10955. * 曲线辅助模块
  10956. * @module zrender/core/curve
  10957. * @author pissang(https://www.github.com/pissang)
  10958. */
  10959. var vec2 = __webpack_require__(10);
  10960. var v2Create = vec2.create;
  10961. var v2DistSquare = vec2.distSquare;
  10962. var mathPow = Math.pow;
  10963. var mathSqrt = Math.sqrt;
  10964. var EPSILON = 1e-8;
  10965. var EPSILON_NUMERIC = 1e-4;
  10966. var THREE_SQRT = mathSqrt(3);
  10967. var ONE_THIRD = 1 / 3;
  10968. // 临时变量
  10969. var _v0 = v2Create();
  10970. var _v1 = v2Create();
  10971. var _v2 = v2Create();
  10972. // var _v3 = vec2.create();
  10973. function isAroundZero(val) {
  10974. return val > -EPSILON && val < EPSILON;
  10975. }
  10976. function isNotAroundZero(val) {
  10977. return val > EPSILON || val < -EPSILON;
  10978. }
  10979. /**
  10980. * 计算三次贝塞尔值
  10981. * @memberOf module:zrender/core/curve
  10982. * @param {number} p0
  10983. * @param {number} p1
  10984. * @param {number} p2
  10985. * @param {number} p3
  10986. * @param {number} t
  10987. * @return {number}
  10988. */
  10989. function cubicAt(p0, p1, p2, p3, t) {
  10990. var onet = 1 - t;
  10991. return onet * onet * (onet * p0 + 3 * t * p1)
  10992. + t * t * (t * p3 + 3 * onet * p2);
  10993. }
  10994. /**
  10995. * 计算三次贝塞尔导数值
  10996. * @memberOf module:zrender/core/curve
  10997. * @param {number} p0
  10998. * @param {number} p1
  10999. * @param {number} p2
  11000. * @param {number} p3
  11001. * @param {number} t
  11002. * @return {number}
  11003. */
  11004. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  11005. var onet = 1 - t;
  11006. return 3 * (
  11007. ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet
  11008. + (p3 - p2) * t * t
  11009. );
  11010. }
  11011. /**
  11012. * 计算三次贝塞尔方程根,使用盛金公式
  11013. * @memberOf module:zrender/core/curve
  11014. * @param {number} p0
  11015. * @param {number} p1
  11016. * @param {number} p2
  11017. * @param {number} p3
  11018. * @param {number} val
  11019. * @param {Array.<number>} roots
  11020. * @return {number} 有效根数目
  11021. */
  11022. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  11023. // Evaluate roots of cubic functions
  11024. var a = p3 + 3 * (p1 - p2) - p0;
  11025. var b = 3 * (p2 - p1 * 2 + p0);
  11026. var c = 3 * (p1 - p0);
  11027. var d = p0 - val;
  11028. var A = b * b - 3 * a * c;
  11029. var B = b * c - 9 * a * d;
  11030. var C = c * c - 3 * b * d;
  11031. var n = 0;
  11032. if (isAroundZero(A) && isAroundZero(B)) {
  11033. if (isAroundZero(b)) {
  11034. roots[0] = 0;
  11035. }
  11036. else {
  11037. var t1 = -c / b; //t1, t2, t3, b is not zero
  11038. if (t1 >= 0 && t1 <= 1) {
  11039. roots[n++] = t1;
  11040. }
  11041. }
  11042. }
  11043. else {
  11044. var disc = B * B - 4 * A * C;
  11045. if (isAroundZero(disc)) {
  11046. var K = B / A;
  11047. var t1 = -b / a + K; // t1, a is not zero
  11048. var t2 = -K / 2; // t2, t3
  11049. if (t1 >= 0 && t1 <= 1) {
  11050. roots[n++] = t1;
  11051. }
  11052. if (t2 >= 0 && t2 <= 1) {
  11053. roots[n++] = t2;
  11054. }
  11055. }
  11056. else if (disc > 0) {
  11057. var discSqrt = mathSqrt(disc);
  11058. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  11059. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  11060. if (Y1 < 0) {
  11061. Y1 = -mathPow(-Y1, ONE_THIRD);
  11062. }
  11063. else {
  11064. Y1 = mathPow(Y1, ONE_THIRD);
  11065. }
  11066. if (Y2 < 0) {
  11067. Y2 = -mathPow(-Y2, ONE_THIRD);
  11068. }
  11069. else {
  11070. Y2 = mathPow(Y2, ONE_THIRD);
  11071. }
  11072. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  11073. if (t1 >= 0 && t1 <= 1) {
  11074. roots[n++] = t1;
  11075. }
  11076. }
  11077. else {
  11078. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A));
  11079. var theta = Math.acos(T) / 3;
  11080. var ASqrt = mathSqrt(A);
  11081. var tmp = Math.cos(theta);
  11082. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  11083. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  11084. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  11085. if (t1 >= 0 && t1 <= 1) {
  11086. roots[n++] = t1;
  11087. }
  11088. if (t2 >= 0 && t2 <= 1) {
  11089. roots[n++] = t2;
  11090. }
  11091. if (t3 >= 0 && t3 <= 1) {
  11092. roots[n++] = t3;
  11093. }
  11094. }
  11095. }
  11096. return n;
  11097. }
  11098. /**
  11099. * 计算三次贝塞尔方程极限值的位置
  11100. * @memberOf module:zrender/core/curve
  11101. * @param {number} p0
  11102. * @param {number} p1
  11103. * @param {number} p2
  11104. * @param {number} p3
  11105. * @param {Array.<number>} extrema
  11106. * @return {number} 有效数目
  11107. */
  11108. function cubicExtrema(p0, p1, p2, p3, extrema) {
  11109. var b = 6 * p2 - 12 * p1 + 6 * p0;
  11110. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  11111. var c = 3 * p1 - 3 * p0;
  11112. var n = 0;
  11113. if (isAroundZero(a)) {
  11114. if (isNotAroundZero(b)) {
  11115. var t1 = -c / b;
  11116. if (t1 >= 0 && t1 <=1) {
  11117. extrema[n++] = t1;
  11118. }
  11119. }
  11120. }
  11121. else {
  11122. var disc = b * b - 4 * a * c;
  11123. if (isAroundZero(disc)) {
  11124. extrema[0] = -b / (2 * a);
  11125. }
  11126. else if (disc > 0) {
  11127. var discSqrt = mathSqrt(disc);
  11128. var t1 = (-b + discSqrt) / (2 * a);
  11129. var t2 = (-b - discSqrt) / (2 * a);
  11130. if (t1 >= 0 && t1 <= 1) {
  11131. extrema[n++] = t1;
  11132. }
  11133. if (t2 >= 0 && t2 <= 1) {
  11134. extrema[n++] = t2;
  11135. }
  11136. }
  11137. }
  11138. return n;
  11139. }
  11140. /**
  11141. * 细分三次贝塞尔曲线
  11142. * @memberOf module:zrender/core/curve
  11143. * @param {number} p0
  11144. * @param {number} p1
  11145. * @param {number} p2
  11146. * @param {number} p3
  11147. * @param {number} t
  11148. * @param {Array.<number>} out
  11149. */
  11150. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  11151. var p01 = (p1 - p0) * t + p0;
  11152. var p12 = (p2 - p1) * t + p1;
  11153. var p23 = (p3 - p2) * t + p2;
  11154. var p012 = (p12 - p01) * t + p01;
  11155. var p123 = (p23 - p12) * t + p12;
  11156. var p0123 = (p123 - p012) * t + p012;
  11157. // Seg0
  11158. out[0] = p0;
  11159. out[1] = p01;
  11160. out[2] = p012;
  11161. out[3] = p0123;
  11162. // Seg1
  11163. out[4] = p0123;
  11164. out[5] = p123;
  11165. out[6] = p23;
  11166. out[7] = p3;
  11167. }
  11168. /**
  11169. * 投射点到三次贝塞尔曲线上,返回投射距离。
  11170. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  11171. * @param {number} x0
  11172. * @param {number} y0
  11173. * @param {number} x1
  11174. * @param {number} y1
  11175. * @param {number} x2
  11176. * @param {number} y2
  11177. * @param {number} x3
  11178. * @param {number} y3
  11179. * @param {number} x
  11180. * @param {number} y
  11181. * @param {Array.<number>} [out] 投射点
  11182. * @return {number}
  11183. */
  11184. function cubicProjectPoint(
  11185. x0, y0, x1, y1, x2, y2, x3, y3,
  11186. x, y, out
  11187. ) {
  11188. // http://pomax.github.io/bezierinfo/#projections
  11189. var t;
  11190. var interval = 0.005;
  11191. var d = Infinity;
  11192. var prev;
  11193. var next;
  11194. var d1;
  11195. var d2;
  11196. _v0[0] = x;
  11197. _v0[1] = y;
  11198. // 先粗略估计一下可能的最小距离的 t 值
  11199. // PENDING
  11200. for (var _t = 0; _t < 1; _t += 0.05) {
  11201. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  11202. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  11203. d1 = v2DistSquare(_v0, _v1);
  11204. if (d1 < d) {
  11205. t = _t;
  11206. d = d1;
  11207. }
  11208. }
  11209. d = Infinity;
  11210. // At most 32 iteration
  11211. for (var i = 0; i < 32; i++) {
  11212. if (interval < EPSILON_NUMERIC) {
  11213. break;
  11214. }
  11215. prev = t - interval;
  11216. next = t + interval;
  11217. // t - interval
  11218. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  11219. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  11220. d1 = v2DistSquare(_v1, _v0);
  11221. if (prev >= 0 && d1 < d) {
  11222. t = prev;
  11223. d = d1;
  11224. }
  11225. else {
  11226. // t + interval
  11227. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  11228. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  11229. d2 = v2DistSquare(_v2, _v0);
  11230. if (next <= 1 && d2 < d) {
  11231. t = next;
  11232. d = d2;
  11233. }
  11234. else {
  11235. interval *= 0.5;
  11236. }
  11237. }
  11238. }
  11239. // t
  11240. if (out) {
  11241. out[0] = cubicAt(x0, x1, x2, x3, t);
  11242. out[1] = cubicAt(y0, y1, y2, y3, t);
  11243. }
  11244. // console.log(interval, i);
  11245. return mathSqrt(d);
  11246. }
  11247. /**
  11248. * 计算二次方贝塞尔值
  11249. * @param {number} p0
  11250. * @param {number} p1
  11251. * @param {number} p2
  11252. * @param {number} t
  11253. * @return {number}
  11254. */
  11255. function quadraticAt(p0, p1, p2, t) {
  11256. var onet = 1 - t;
  11257. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  11258. }
  11259. /**
  11260. * 计算二次方贝塞尔导数值
  11261. * @param {number} p0
  11262. * @param {number} p1
  11263. * @param {number} p2
  11264. * @param {number} t
  11265. * @return {number}
  11266. */
  11267. function quadraticDerivativeAt(p0, p1, p2, t) {
  11268. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  11269. }
  11270. /**
  11271. * 计算二次方贝塞尔方程根
  11272. * @param {number} p0
  11273. * @param {number} p1
  11274. * @param {number} p2
  11275. * @param {number} t
  11276. * @param {Array.<number>} roots
  11277. * @return {number} 有效根数目
  11278. */
  11279. function quadraticRootAt(p0, p1, p2, val, roots) {
  11280. var a = p0 - 2 * p1 + p2;
  11281. var b = 2 * (p1 - p0);
  11282. var c = p0 - val;
  11283. var n = 0;
  11284. if (isAroundZero(a)) {
  11285. if (isNotAroundZero(b)) {
  11286. var t1 = -c / b;
  11287. if (t1 >= 0 && t1 <= 1) {
  11288. roots[n++] = t1;
  11289. }
  11290. }
  11291. }
  11292. else {
  11293. var disc = b * b - 4 * a * c;
  11294. if (isAroundZero(disc)) {
  11295. var t1 = -b / (2 * a);
  11296. if (t1 >= 0 && t1 <= 1) {
  11297. roots[n++] = t1;
  11298. }
  11299. }
  11300. else if (disc > 0) {
  11301. var discSqrt = mathSqrt(disc);
  11302. var t1 = (-b + discSqrt) / (2 * a);
  11303. var t2 = (-b - discSqrt) / (2 * a);
  11304. if (t1 >= 0 && t1 <= 1) {
  11305. roots[n++] = t1;
  11306. }
  11307. if (t2 >= 0 && t2 <= 1) {
  11308. roots[n++] = t2;
  11309. }
  11310. }
  11311. }
  11312. return n;
  11313. }
  11314. /**
  11315. * 计算二次贝塞尔方程极限值
  11316. * @memberOf module:zrender/core/curve
  11317. * @param {number} p0
  11318. * @param {number} p1
  11319. * @param {number} p2
  11320. * @return {number}
  11321. */
  11322. function quadraticExtremum(p0, p1, p2) {
  11323. var divider = p0 + p2 - 2 * p1;
  11324. if (divider === 0) {
  11325. // p1 is center of p0 and p2
  11326. return 0.5;
  11327. }
  11328. else {
  11329. return (p0 - p1) / divider;
  11330. }
  11331. }
  11332. /**
  11333. * 细分二次贝塞尔曲线
  11334. * @memberOf module:zrender/core/curve
  11335. * @param {number} p0
  11336. * @param {number} p1
  11337. * @param {number} p2
  11338. * @param {number} t
  11339. * @param {Array.<number>} out
  11340. */
  11341. function quadraticSubdivide(p0, p1, p2, t, out) {
  11342. var p01 = (p1 - p0) * t + p0;
  11343. var p12 = (p2 - p1) * t + p1;
  11344. var p012 = (p12 - p01) * t + p01;
  11345. // Seg0
  11346. out[0] = p0;
  11347. out[1] = p01;
  11348. out[2] = p012;
  11349. // Seg1
  11350. out[3] = p012;
  11351. out[4] = p12;
  11352. out[5] = p2;
  11353. }
  11354. /**
  11355. * 投射点到二次贝塞尔曲线上,返回投射距离。
  11356. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  11357. * @param {number} x0
  11358. * @param {number} y0
  11359. * @param {number} x1
  11360. * @param {number} y1
  11361. * @param {number} x2
  11362. * @param {number} y2
  11363. * @param {number} x
  11364. * @param {number} y
  11365. * @param {Array.<number>} out 投射点
  11366. * @return {number}
  11367. */
  11368. function quadraticProjectPoint(
  11369. x0, y0, x1, y1, x2, y2,
  11370. x, y, out
  11371. ) {
  11372. // http://pomax.github.io/bezierinfo/#projections
  11373. var t;
  11374. var interval = 0.005;
  11375. var d = Infinity;
  11376. _v0[0] = x;
  11377. _v0[1] = y;
  11378. // 先粗略估计一下可能的最小距离的 t 值
  11379. // PENDING
  11380. for (var _t = 0; _t < 1; _t += 0.05) {
  11381. _v1[0] = quadraticAt(x0, x1, x2, _t);
  11382. _v1[1] = quadraticAt(y0, y1, y2, _t);
  11383. var d1 = v2DistSquare(_v0, _v1);
  11384. if (d1 < d) {
  11385. t = _t;
  11386. d = d1;
  11387. }
  11388. }
  11389. d = Infinity;
  11390. // At most 32 iteration
  11391. for (var i = 0; i < 32; i++) {
  11392. if (interval < EPSILON_NUMERIC) {
  11393. break;
  11394. }
  11395. var prev = t - interval;
  11396. var next = t + interval;
  11397. // t - interval
  11398. _v1[0] = quadraticAt(x0, x1, x2, prev);
  11399. _v1[1] = quadraticAt(y0, y1, y2, prev);
  11400. var d1 = v2DistSquare(_v1, _v0);
  11401. if (prev >= 0 && d1 < d) {
  11402. t = prev;
  11403. d = d1;
  11404. }
  11405. else {
  11406. // t + interval
  11407. _v2[0] = quadraticAt(x0, x1, x2, next);
  11408. _v2[1] = quadraticAt(y0, y1, y2, next);
  11409. var d2 = v2DistSquare(_v2, _v0);
  11410. if (next <= 1 && d2 < d) {
  11411. t = next;
  11412. d = d2;
  11413. }
  11414. else {
  11415. interval *= 0.5;
  11416. }
  11417. }
  11418. }
  11419. // t
  11420. if (out) {
  11421. out[0] = quadraticAt(x0, x1, x2, t);
  11422. out[1] = quadraticAt(y0, y1, y2, t);
  11423. }
  11424. // console.log(interval, i);
  11425. return mathSqrt(d);
  11426. }
  11427. module.exports = {
  11428. cubicAt: cubicAt,
  11429. cubicDerivativeAt: cubicDerivativeAt,
  11430. cubicRootAt: cubicRootAt,
  11431. cubicExtrema: cubicExtrema,
  11432. cubicSubdivide: cubicSubdivide,
  11433. cubicProjectPoint: cubicProjectPoint,
  11434. quadraticAt: quadraticAt,
  11435. quadraticDerivativeAt: quadraticDerivativeAt,
  11436. quadraticRootAt: quadraticRootAt,
  11437. quadraticExtremum: quadraticExtremum,
  11438. quadraticSubdivide: quadraticSubdivide,
  11439. quadraticProjectPoint: quadraticProjectPoint
  11440. };
  11441. /***/ },
  11442. /* 38 */
  11443. /***/ function(module, exports, __webpack_require__) {
  11444. /**
  11445. * @author Yi Shen(https://github.com/pissang)
  11446. */
  11447. var vec2 = __webpack_require__(10);
  11448. var curve = __webpack_require__(37);
  11449. var bbox = {};
  11450. var mathMin = Math.min;
  11451. var mathMax = Math.max;
  11452. var mathSin = Math.sin;
  11453. var mathCos = Math.cos;
  11454. var start = vec2.create();
  11455. var end = vec2.create();
  11456. var extremity = vec2.create();
  11457. var PI2 = Math.PI * 2;
  11458. /**
  11459. * 从顶点数组中计算出最小包围盒,写入`min`和`max`中
  11460. * @module zrender/core/bbox
  11461. * @param {Array<Object>} points 顶点数组
  11462. * @param {number} min
  11463. * @param {number} max
  11464. */
  11465. bbox.fromPoints = function(points, min, max) {
  11466. if (points.length === 0) {
  11467. return;
  11468. }
  11469. var p = points[0];
  11470. var left = p[0];
  11471. var right = p[0];
  11472. var top = p[1];
  11473. var bottom = p[1];
  11474. var i;
  11475. for (i = 1; i < points.length; i++) {
  11476. p = points[i];
  11477. left = mathMin(left, p[0]);
  11478. right = mathMax(right, p[0]);
  11479. top = mathMin(top, p[1]);
  11480. bottom = mathMax(bottom, p[1]);
  11481. }
  11482. min[0] = left;
  11483. min[1] = top;
  11484. max[0] = right;
  11485. max[1] = bottom;
  11486. };
  11487. /**
  11488. * @memberOf module:zrender/core/bbox
  11489. * @param {number} x0
  11490. * @param {number} y0
  11491. * @param {number} x1
  11492. * @param {number} y1
  11493. * @param {Array.<number>} min
  11494. * @param {Array.<number>} max
  11495. */
  11496. bbox.fromLine = function (x0, y0, x1, y1, min, max) {
  11497. min[0] = mathMin(x0, x1);
  11498. min[1] = mathMin(y0, y1);
  11499. max[0] = mathMax(x0, x1);
  11500. max[1] = mathMax(y0, y1);
  11501. };
  11502. var xDim = [];
  11503. var yDim = [];
  11504. /**
  11505. * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中
  11506. * @memberOf module:zrender/core/bbox
  11507. * @param {number} x0
  11508. * @param {number} y0
  11509. * @param {number} x1
  11510. * @param {number} y1
  11511. * @param {number} x2
  11512. * @param {number} y2
  11513. * @param {number} x3
  11514. * @param {number} y3
  11515. * @param {Array.<number>} min
  11516. * @param {Array.<number>} max
  11517. */
  11518. bbox.fromCubic = function(
  11519. x0, y0, x1, y1, x2, y2, x3, y3, min, max
  11520. ) {
  11521. var cubicExtrema = curve.cubicExtrema;
  11522. var cubicAt = curve.cubicAt;
  11523. var i;
  11524. var n = cubicExtrema(x0, x1, x2, x3, xDim);
  11525. min[0] = Infinity;
  11526. min[1] = Infinity;
  11527. max[0] = -Infinity;
  11528. max[1] = -Infinity;
  11529. for (i = 0; i < n; i++) {
  11530. var x = cubicAt(x0, x1, x2, x3, xDim[i]);
  11531. min[0] = mathMin(x, min[0]);
  11532. max[0] = mathMax(x, max[0]);
  11533. }
  11534. n = cubicExtrema(y0, y1, y2, y3, yDim);
  11535. for (i = 0; i < n; i++) {
  11536. var y = cubicAt(y0, y1, y2, y3, yDim[i]);
  11537. min[1] = mathMin(y, min[1]);
  11538. max[1] = mathMax(y, max[1]);
  11539. }
  11540. min[0] = mathMin(x0, min[0]);
  11541. max[0] = mathMax(x0, max[0]);
  11542. min[0] = mathMin(x3, min[0]);
  11543. max[0] = mathMax(x3, max[0]);
  11544. min[1] = mathMin(y0, min[1]);
  11545. max[1] = mathMax(y0, max[1]);
  11546. min[1] = mathMin(y3, min[1]);
  11547. max[1] = mathMax(y3, max[1]);
  11548. };
  11549. /**
  11550. * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中
  11551. * @memberOf module:zrender/core/bbox
  11552. * @param {number} x0
  11553. * @param {number} y0
  11554. * @param {number} x1
  11555. * @param {number} y1
  11556. * @param {number} x2
  11557. * @param {number} y2
  11558. * @param {Array.<number>} min
  11559. * @param {Array.<number>} max
  11560. */
  11561. bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) {
  11562. var quadraticExtremum = curve.quadraticExtremum;
  11563. var quadraticAt = curve.quadraticAt;
  11564. // Find extremities, where derivative in x dim or y dim is zero
  11565. var tx =
  11566. mathMax(
  11567. mathMin(quadraticExtremum(x0, x1, x2), 1), 0
  11568. );
  11569. var ty =
  11570. mathMax(
  11571. mathMin(quadraticExtremum(y0, y1, y2), 1), 0
  11572. );
  11573. var x = quadraticAt(x0, x1, x2, tx);
  11574. var y = quadraticAt(y0, y1, y2, ty);
  11575. min[0] = mathMin(x0, x2, x);
  11576. min[1] = mathMin(y0, y2, y);
  11577. max[0] = mathMax(x0, x2, x);
  11578. max[1] = mathMax(y0, y2, y);
  11579. };
  11580. /**
  11581. * 从圆弧中计算出最小包围盒,写入`min`和`max`中
  11582. * @method
  11583. * @memberOf module:zrender/core/bbox
  11584. * @param {number} x
  11585. * @param {number} y
  11586. * @param {number} rx
  11587. * @param {number} ry
  11588. * @param {number} startAngle
  11589. * @param {number} endAngle
  11590. * @param {number} anticlockwise
  11591. * @param {Array.<number>} min
  11592. * @param {Array.<number>} max
  11593. */
  11594. bbox.fromArc = function (
  11595. x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max
  11596. ) {
  11597. var vec2Min = vec2.min;
  11598. var vec2Max = vec2.max;
  11599. var diff = Math.abs(startAngle - endAngle);
  11600. if (diff % PI2 < 1e-4 && diff > 1e-4) {
  11601. // Is a circle
  11602. min[0] = x - rx;
  11603. min[1] = y - ry;
  11604. max[0] = x + rx;
  11605. max[1] = y + ry;
  11606. return;
  11607. }
  11608. start[0] = mathCos(startAngle) * rx + x;
  11609. start[1] = mathSin(startAngle) * ry + y;
  11610. end[0] = mathCos(endAngle) * rx + x;
  11611. end[1] = mathSin(endAngle) * ry + y;
  11612. vec2Min(min, start, end);
  11613. vec2Max(max, start, end);
  11614. // Thresh to [0, Math.PI * 2]
  11615. startAngle = startAngle % (PI2);
  11616. if (startAngle < 0) {
  11617. startAngle = startAngle + PI2;
  11618. }
  11619. endAngle = endAngle % (PI2);
  11620. if (endAngle < 0) {
  11621. endAngle = endAngle + PI2;
  11622. }
  11623. if (startAngle > endAngle && !anticlockwise) {
  11624. endAngle += PI2;
  11625. }
  11626. else if (startAngle < endAngle && anticlockwise) {
  11627. startAngle += PI2;
  11628. }
  11629. if (anticlockwise) {
  11630. var tmp = endAngle;
  11631. endAngle = startAngle;
  11632. startAngle = tmp;
  11633. }
  11634. // var number = 0;
  11635. // var step = (anticlockwise ? -Math.PI : Math.PI) / 2;
  11636. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  11637. if (angle > startAngle) {
  11638. extremity[0] = mathCos(angle) * rx + x;
  11639. extremity[1] = mathSin(angle) * ry + y;
  11640. vec2Min(min, extremity, min);
  11641. vec2Max(max, extremity, max);
  11642. }
  11643. }
  11644. };
  11645. module.exports = bbox;
  11646. /***/ },
  11647. /* 39 */
  11648. /***/ function(module, exports, __webpack_require__) {
  11649. 'use strict';
  11650. var CMD = __webpack_require__(36).CMD;
  11651. var line = __webpack_require__(40);
  11652. var cubic = __webpack_require__(41);
  11653. var quadratic = __webpack_require__(42);
  11654. var arc = __webpack_require__(43);
  11655. var normalizeRadian = __webpack_require__(44).normalizeRadian;
  11656. var curve = __webpack_require__(37);
  11657. var windingLine = __webpack_require__(45);
  11658. var containStroke = line.containStroke;
  11659. var PI2 = Math.PI * 2;
  11660. var EPSILON = 1e-4;
  11661. function isAroundEqual(a, b) {
  11662. return Math.abs(a - b) < EPSILON;
  11663. }
  11664. // 临时数组
  11665. var roots = [-1, -1, -1];
  11666. var extrema = [-1, -1];
  11667. function swapExtrema() {
  11668. var tmp = extrema[0];
  11669. extrema[0] = extrema[1];
  11670. extrema[1] = tmp;
  11671. }
  11672. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  11673. // Quick reject
  11674. if (
  11675. (y > y0 && y > y1 && y > y2 && y > y3)
  11676. || (y < y0 && y < y1 && y < y2 && y < y3)
  11677. ) {
  11678. return 0;
  11679. }
  11680. var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
  11681. if (nRoots === 0) {
  11682. return 0;
  11683. }
  11684. else {
  11685. var w = 0;
  11686. var nExtrema = -1;
  11687. var y0_, y1_;
  11688. for (var i = 0; i < nRoots; i++) {
  11689. var t = roots[i];
  11690. // Avoid winding error when intersection point is the connect point of two line of polygon
  11691. var unit = (t === 0 || t === 1) ? 0.5 : 1;
  11692. var x_ = curve.cubicAt(x0, x1, x2, x3, t);
  11693. if (x_ < x) { // Quick reject
  11694. continue;
  11695. }
  11696. if (nExtrema < 0) {
  11697. nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
  11698. if (extrema[1] < extrema[0] && nExtrema > 1) {
  11699. swapExtrema();
  11700. }
  11701. y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
  11702. if (nExtrema > 1) {
  11703. y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
  11704. }
  11705. }
  11706. if (nExtrema == 2) {
  11707. // 分成三段单调函数
  11708. if (t < extrema[0]) {
  11709. w += y0_ < y0 ? unit : -unit;
  11710. }
  11711. else if (t < extrema[1]) {
  11712. w += y1_ < y0_ ? unit : -unit;
  11713. }
  11714. else {
  11715. w += y3 < y1_ ? unit : -unit;
  11716. }
  11717. }
  11718. else {
  11719. // 分成两段单调函数
  11720. if (t < extrema[0]) {
  11721. w += y0_ < y0 ? unit : -unit;
  11722. }
  11723. else {
  11724. w += y3 < y0_ ? unit : -unit;
  11725. }
  11726. }
  11727. }
  11728. return w;
  11729. }
  11730. }
  11731. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  11732. // Quick reject
  11733. if (
  11734. (y > y0 && y > y1 && y > y2)
  11735. || (y < y0 && y < y1 && y < y2)
  11736. ) {
  11737. return 0;
  11738. }
  11739. var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
  11740. if (nRoots === 0) {
  11741. return 0;
  11742. }
  11743. else {
  11744. var t = curve.quadraticExtremum(y0, y1, y2);
  11745. if (t >= 0 && t <= 1) {
  11746. var w = 0;
  11747. var y_ = curve.quadraticAt(y0, y1, y2, t);
  11748. for (var i = 0; i < nRoots; i++) {
  11749. // Remove one endpoint.
  11750. var unit = (roots[i] === 0 || roots[i] === 1) ? 0.5 : 1;
  11751. var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
  11752. if (x_ < x) { // Quick reject
  11753. continue;
  11754. }
  11755. if (roots[i] < t) {
  11756. w += y_ < y0 ? unit : -unit;
  11757. }
  11758. else {
  11759. w += y2 < y_ ? unit : -unit;
  11760. }
  11761. }
  11762. return w;
  11763. }
  11764. else {
  11765. // Remove one endpoint.
  11766. var unit = (roots[0] === 0 || roots[0] === 1) ? 0.5 : 1;
  11767. var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
  11768. if (x_ < x) { // Quick reject
  11769. return 0;
  11770. }
  11771. return y2 < y0 ? unit : -unit;
  11772. }
  11773. }
  11774. }
  11775. // TODO
  11776. // Arc 旋转
  11777. function windingArc(
  11778. cx, cy, r, startAngle, endAngle, anticlockwise, x, y
  11779. ) {
  11780. y -= cy;
  11781. if (y > r || y < -r) {
  11782. return 0;
  11783. }
  11784. var tmp = Math.sqrt(r * r - y * y);
  11785. roots[0] = -tmp;
  11786. roots[1] = tmp;
  11787. var diff = Math.abs(startAngle - endAngle);
  11788. if (diff < 1e-4) {
  11789. return 0;
  11790. }
  11791. if (diff % PI2 < 1e-4) {
  11792. // Is a circle
  11793. startAngle = 0;
  11794. endAngle = PI2;
  11795. var dir = anticlockwise ? 1 : -1;
  11796. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  11797. return dir;
  11798. } else {
  11799. return 0;
  11800. }
  11801. }
  11802. if (anticlockwise) {
  11803. var tmp = startAngle;
  11804. startAngle = normalizeRadian(endAngle);
  11805. endAngle = normalizeRadian(tmp);
  11806. }
  11807. else {
  11808. startAngle = normalizeRadian(startAngle);
  11809. endAngle = normalizeRadian(endAngle);
  11810. }
  11811. if (startAngle > endAngle) {
  11812. endAngle += PI2;
  11813. }
  11814. var w = 0;
  11815. for (var i = 0; i < 2; i++) {
  11816. var x_ = roots[i];
  11817. if (x_ + cx > x) {
  11818. var angle = Math.atan2(y, x_);
  11819. var dir = anticlockwise ? 1 : -1;
  11820. if (angle < 0) {
  11821. angle = PI2 + angle;
  11822. }
  11823. if (
  11824. (angle >= startAngle && angle <= endAngle)
  11825. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle)
  11826. ) {
  11827. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  11828. dir = -dir;
  11829. }
  11830. w += dir;
  11831. }
  11832. }
  11833. }
  11834. return w;
  11835. }
  11836. function containPath(data, lineWidth, isStroke, x, y) {
  11837. var w = 0;
  11838. var xi = 0;
  11839. var yi = 0;
  11840. var x0 = 0;
  11841. var y0 = 0;
  11842. for (var i = 0; i < data.length;) {
  11843. var cmd = data[i++];
  11844. // Begin a new subpath
  11845. if (cmd === CMD.M && i > 1) {
  11846. // Close previous subpath
  11847. if (!isStroke) {
  11848. w += windingLine(xi, yi, x0, y0, x, y);
  11849. }
  11850. // 如果被任何一个 subpath 包含
  11851. // if (w !== 0) {
  11852. // return true;
  11853. // }
  11854. }
  11855. if (i == 1) {
  11856. // 如果第一个命令是 L, C, Q
  11857. // 则 previous point 同绘制命令的第一个 point
  11858. //
  11859. // 第一个命令为 Arc 的情况下会在后面特殊处理
  11860. xi = data[i];
  11861. yi = data[i + 1];
  11862. x0 = xi;
  11863. y0 = yi;
  11864. }
  11865. switch (cmd) {
  11866. case CMD.M:
  11867. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  11868. // 在 closePath 的时候使用
  11869. x0 = data[i++];
  11870. y0 = data[i++];
  11871. xi = x0;
  11872. yi = y0;
  11873. break;
  11874. case CMD.L:
  11875. if (isStroke) {
  11876. if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  11877. return true;
  11878. }
  11879. }
  11880. else {
  11881. // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN
  11882. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  11883. }
  11884. xi = data[i++];
  11885. yi = data[i++];
  11886. break;
  11887. case CMD.C:
  11888. if (isStroke) {
  11889. if (cubic.containStroke(xi, yi,
  11890. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11891. lineWidth, x, y
  11892. )) {
  11893. return true;
  11894. }
  11895. }
  11896. else {
  11897. w += windingCubic(
  11898. xi, yi,
  11899. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11900. x, y
  11901. ) || 0;
  11902. }
  11903. xi = data[i++];
  11904. yi = data[i++];
  11905. break;
  11906. case CMD.Q:
  11907. if (isStroke) {
  11908. if (quadratic.containStroke(xi, yi,
  11909. data[i++], data[i++], data[i], data[i + 1],
  11910. lineWidth, x, y
  11911. )) {
  11912. return true;
  11913. }
  11914. }
  11915. else {
  11916. w += windingQuadratic(
  11917. xi, yi,
  11918. data[i++], data[i++], data[i], data[i + 1],
  11919. x, y
  11920. ) || 0;
  11921. }
  11922. xi = data[i++];
  11923. yi = data[i++];
  11924. break;
  11925. case CMD.A:
  11926. // TODO Arc 判断的开销比较大
  11927. var cx = data[i++];
  11928. var cy = data[i++];
  11929. var rx = data[i++];
  11930. var ry = data[i++];
  11931. var theta = data[i++];
  11932. var dTheta = data[i++];
  11933. // TODO Arc 旋转
  11934. var psi = data[i++];
  11935. var anticlockwise = 1 - data[i++];
  11936. var x1 = Math.cos(theta) * rx + cx;
  11937. var y1 = Math.sin(theta) * ry + cy;
  11938. // 不是直接使用 arc 命令
  11939. if (i > 1) {
  11940. w += windingLine(xi, yi, x1, y1, x, y);
  11941. }
  11942. else {
  11943. // 第一个命令起点还未定义
  11944. x0 = x1;
  11945. y0 = y1;
  11946. }
  11947. // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  11948. var _x = (x - cx) * ry / rx + cx;
  11949. if (isStroke) {
  11950. if (arc.containStroke(
  11951. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  11952. lineWidth, _x, y
  11953. )) {
  11954. return true;
  11955. }
  11956. }
  11957. else {
  11958. w += windingArc(
  11959. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  11960. _x, y
  11961. );
  11962. }
  11963. xi = Math.cos(theta + dTheta) * rx + cx;
  11964. yi = Math.sin(theta + dTheta) * ry + cy;
  11965. break;
  11966. case CMD.R:
  11967. x0 = xi = data[i++];
  11968. y0 = yi = data[i++];
  11969. var width = data[i++];
  11970. var height = data[i++];
  11971. var x1 = x0 + width;
  11972. var y1 = y0 + height;
  11973. if (isStroke) {
  11974. if (containStroke(x0, y0, x1, y0, lineWidth, x, y)
  11975. || containStroke(x1, y0, x1, y1, lineWidth, x, y)
  11976. || containStroke(x1, y1, x0, y1, lineWidth, x, y)
  11977. || containStroke(x0, y1, x0, y0, lineWidth, x, y)
  11978. ) {
  11979. return true;
  11980. }
  11981. }
  11982. else {
  11983. // FIXME Clockwise ?
  11984. w += windingLine(x1, y0, x1, y1, x, y);
  11985. w += windingLine(x0, y1, x0, y0, x, y);
  11986. }
  11987. break;
  11988. case CMD.Z:
  11989. if (isStroke) {
  11990. if (containStroke(
  11991. xi, yi, x0, y0, lineWidth, x, y
  11992. )) {
  11993. return true;
  11994. }
  11995. }
  11996. else {
  11997. // Close a subpath
  11998. w += windingLine(xi, yi, x0, y0, x, y);
  11999. // 如果被任何一个 subpath 包含
  12000. // FIXME subpaths may overlap
  12001. // if (w !== 0) {
  12002. // return true;
  12003. // }
  12004. }
  12005. xi = x0;
  12006. yi = y0;
  12007. break;
  12008. }
  12009. }
  12010. if (!isStroke && !isAroundEqual(yi, y0)) {
  12011. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  12012. }
  12013. return w !== 0;
  12014. }
  12015. module.exports = {
  12016. contain: function (pathData, x, y) {
  12017. return containPath(pathData, 0, false, x, y);
  12018. },
  12019. containStroke: function (pathData, lineWidth, x, y) {
  12020. return containPath(pathData, lineWidth, true, x, y);
  12021. }
  12022. };
  12023. /***/ },
  12024. /* 40 */
  12025. /***/ function(module, exports) {
  12026. module.exports = {
  12027. /**
  12028. * 线段包含判断
  12029. * @param {number} x0
  12030. * @param {number} y0
  12031. * @param {number} x1
  12032. * @param {number} y1
  12033. * @param {number} lineWidth
  12034. * @param {number} x
  12035. * @param {number} y
  12036. * @return {boolean}
  12037. */
  12038. containStroke: function (x0, y0, x1, y1, lineWidth, x, y) {
  12039. if (lineWidth === 0) {
  12040. return false;
  12041. }
  12042. var _l = lineWidth;
  12043. var _a = 0;
  12044. var _b = x0;
  12045. // Quick reject
  12046. if (
  12047. (y > y0 + _l && y > y1 + _l)
  12048. || (y < y0 - _l && y < y1 - _l)
  12049. || (x > x0 + _l && x > x1 + _l)
  12050. || (x < x0 - _l && x < x1 - _l)
  12051. ) {
  12052. return false;
  12053. }
  12054. if (x0 !== x1) {
  12055. _a = (y0 - y1) / (x0 - x1);
  12056. _b = (x0 * y1 - x1 * y0) / (x0 - x1) ;
  12057. }
  12058. else {
  12059. return Math.abs(x - x0) <= _l / 2;
  12060. }
  12061. var tmp = _a * x - y + _b;
  12062. var _s = tmp * tmp / (_a * _a + 1);
  12063. return _s <= _l / 2 * _l / 2;
  12064. }
  12065. };
  12066. /***/ },
  12067. /* 41 */
  12068. /***/ function(module, exports, __webpack_require__) {
  12069. var curve = __webpack_require__(37);
  12070. module.exports = {
  12071. /**
  12072. * 三次贝塞尔曲线描边包含判断
  12073. * @param {number} x0
  12074. * @param {number} y0
  12075. * @param {number} x1
  12076. * @param {number} y1
  12077. * @param {number} x2
  12078. * @param {number} y2
  12079. * @param {number} x3
  12080. * @param {number} y3
  12081. * @param {number} lineWidth
  12082. * @param {number} x
  12083. * @param {number} y
  12084. * @return {boolean}
  12085. */
  12086. containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  12087. if (lineWidth === 0) {
  12088. return false;
  12089. }
  12090. var _l = lineWidth;
  12091. // Quick reject
  12092. if (
  12093. (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
  12094. || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
  12095. || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
  12096. || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
  12097. ) {
  12098. return false;
  12099. }
  12100. var d = curve.cubicProjectPoint(
  12101. x0, y0, x1, y1, x2, y2, x3, y3,
  12102. x, y, null
  12103. );
  12104. return d <= _l / 2;
  12105. }
  12106. };
  12107. /***/ },
  12108. /* 42 */
  12109. /***/ function(module, exports, __webpack_require__) {
  12110. var curve = __webpack_require__(37);
  12111. module.exports = {
  12112. /**
  12113. * 二次贝塞尔曲线描边包含判断
  12114. * @param {number} x0
  12115. * @param {number} y0
  12116. * @param {number} x1
  12117. * @param {number} y1
  12118. * @param {number} x2
  12119. * @param {number} y2
  12120. * @param {number} lineWidth
  12121. * @param {number} x
  12122. * @param {number} y
  12123. * @return {boolean}
  12124. */
  12125. containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  12126. if (lineWidth === 0) {
  12127. return false;
  12128. }
  12129. var _l = lineWidth;
  12130. // Quick reject
  12131. if (
  12132. (y > y0 + _l && y > y1 + _l && y > y2 + _l)
  12133. || (y < y0 - _l && y < y1 - _l && y < y2 - _l)
  12134. || (x > x0 + _l && x > x1 + _l && x > x2 + _l)
  12135. || (x < x0 - _l && x < x1 - _l && x < x2 - _l)
  12136. ) {
  12137. return false;
  12138. }
  12139. var d = curve.quadraticProjectPoint(
  12140. x0, y0, x1, y1, x2, y2,
  12141. x, y, null
  12142. );
  12143. return d <= _l / 2;
  12144. }
  12145. };
  12146. /***/ },
  12147. /* 43 */
  12148. /***/ function(module, exports, __webpack_require__) {
  12149. var normalizeRadian = __webpack_require__(44).normalizeRadian;
  12150. var PI2 = Math.PI * 2;
  12151. module.exports = {
  12152. /**
  12153. * 圆弧描边包含判断
  12154. * @param {number} cx
  12155. * @param {number} cy
  12156. * @param {number} r
  12157. * @param {number} startAngle
  12158. * @param {number} endAngle
  12159. * @param {boolean} anticlockwise
  12160. * @param {number} lineWidth
  12161. * @param {number} x
  12162. * @param {number} y
  12163. * @return {Boolean}
  12164. */
  12165. containStroke: function (
  12166. cx, cy, r, startAngle, endAngle, anticlockwise,
  12167. lineWidth, x, y
  12168. ) {
  12169. if (lineWidth === 0) {
  12170. return false;
  12171. }
  12172. var _l = lineWidth;
  12173. x -= cx;
  12174. y -= cy;
  12175. var d = Math.sqrt(x * x + y * y);
  12176. if ((d - _l > r) || (d + _l < r)) {
  12177. return false;
  12178. }
  12179. if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
  12180. // Is a circle
  12181. return true;
  12182. }
  12183. if (anticlockwise) {
  12184. var tmp = startAngle;
  12185. startAngle = normalizeRadian(endAngle);
  12186. endAngle = normalizeRadian(tmp);
  12187. } else {
  12188. startAngle = normalizeRadian(startAngle);
  12189. endAngle = normalizeRadian(endAngle);
  12190. }
  12191. if (startAngle > endAngle) {
  12192. endAngle += PI2;
  12193. }
  12194. var angle = Math.atan2(y, x);
  12195. if (angle < 0) {
  12196. angle += PI2;
  12197. }
  12198. return (angle >= startAngle && angle <= endAngle)
  12199. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle);
  12200. }
  12201. };
  12202. /***/ },
  12203. /* 44 */
  12204. /***/ function(module, exports) {
  12205. var PI2 = Math.PI * 2;
  12206. module.exports = {
  12207. normalizeRadian: function(angle) {
  12208. angle %= PI2;
  12209. if (angle < 0) {
  12210. angle += PI2;
  12211. }
  12212. return angle;
  12213. }
  12214. };
  12215. /***/ },
  12216. /* 45 */
  12217. /***/ function(module, exports) {
  12218. module.exports = function windingLine(x0, y0, x1, y1, x, y) {
  12219. if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
  12220. return 0;
  12221. }
  12222. // Ignore horizontal line
  12223. if (y1 === y0) {
  12224. return 0;
  12225. }
  12226. var dir = y1 < y0 ? 1 : -1;
  12227. var t = (y - y0) / (y1 - y0);
  12228. // Avoid winding error when intersection point is the connect point of two line of polygon
  12229. if (t === 1 || t === 0) {
  12230. dir = y1 < y0 ? 0.5 : -0.5;
  12231. }
  12232. var x_ = t * (x1 - x0) + x0;
  12233. return x_ > x ? dir : 0;
  12234. };
  12235. /***/ },
  12236. /* 46 */
  12237. /***/ function(module, exports) {
  12238. var Pattern = function (image, repeat) {
  12239. // Should do nothing more in this constructor. Because gradient can be
  12240. // declard by `color: {image: ...}`, where this constructor will not be called.
  12241. this.image = image;
  12242. this.repeat = repeat;
  12243. // Can be cloned
  12244. this.type = 'pattern';
  12245. };
  12246. Pattern.prototype.getCanvasPattern = function (ctx) {
  12247. return ctx.createPattern(this.image, this.repeat || 'repeat');
  12248. };
  12249. module.exports = Pattern;
  12250. /***/ },
  12251. /* 47 */
  12252. /***/ function(module, exports, __webpack_require__) {
  12253. var CMD = __webpack_require__(36).CMD;
  12254. var vec2 = __webpack_require__(10);
  12255. var v2ApplyTransform = vec2.applyTransform;
  12256. var points = [[], [], []];
  12257. var mathSqrt = Math.sqrt;
  12258. var mathAtan2 = Math.atan2;
  12259. function transformPath(path, m) {
  12260. var data = path.data;
  12261. var cmd;
  12262. var nPoint;
  12263. var i;
  12264. var j;
  12265. var k;
  12266. var p;
  12267. var M = CMD.M;
  12268. var C = CMD.C;
  12269. var L = CMD.L;
  12270. var R = CMD.R;
  12271. var A = CMD.A;
  12272. var Q = CMD.Q;
  12273. for (i = 0, j = 0; i < data.length;) {
  12274. cmd = data[i++];
  12275. j = i;
  12276. nPoint = 0;
  12277. switch (cmd) {
  12278. case M:
  12279. nPoint = 1;
  12280. break;
  12281. case L:
  12282. nPoint = 1;
  12283. break;
  12284. case C:
  12285. nPoint = 3;
  12286. break;
  12287. case Q:
  12288. nPoint = 2;
  12289. break;
  12290. case A:
  12291. var x = m[4];
  12292. var y = m[5];
  12293. var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
  12294. var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
  12295. var angle = mathAtan2(-m[1] / sy, m[0] / sx);
  12296. // cx
  12297. data[i] *= sx;
  12298. data[i++] += x;
  12299. // cy
  12300. data[i] *= sy;
  12301. data[i++] += y;
  12302. // Scale rx and ry
  12303. // FIXME Assume psi is 0 here
  12304. data[i++] *= sx;
  12305. data[i++] *= sy;
  12306. // Start angle
  12307. data[i++] += angle;
  12308. // end angle
  12309. data[i++] += angle;
  12310. // FIXME psi
  12311. i += 2;
  12312. j = i;
  12313. break;
  12314. case R:
  12315. // x0, y0
  12316. p[0] = data[i++];
  12317. p[1] = data[i++];
  12318. v2ApplyTransform(p, p, m);
  12319. data[j++] = p[0];
  12320. data[j++] = p[1];
  12321. // x1, y1
  12322. p[0] += data[i++];
  12323. p[1] += data[i++];
  12324. v2ApplyTransform(p, p, m);
  12325. data[j++] = p[0];
  12326. data[j++] = p[1];
  12327. }
  12328. for (k = 0; k < nPoint; k++) {
  12329. var p = points[k];
  12330. p[0] = data[i++];
  12331. p[1] = data[i++];
  12332. v2ApplyTransform(p, p, m);
  12333. // Write back
  12334. data[j++] = p[0];
  12335. data[j++] = p[1];
  12336. }
  12337. }
  12338. }
  12339. module.exports = transformPath;
  12340. /***/ },
  12341. /* 48 */
  12342. /***/ function(module, exports, __webpack_require__) {
  12343. /**
  12344. * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
  12345. * @module zrender/graphic/Group
  12346. * @example
  12347. * var Group = require('zrender/lib/container/Group');
  12348. * var Circle = require('zrender/lib/graphic/shape/Circle');
  12349. * var g = new Group();
  12350. * g.position[0] = 100;
  12351. * g.position[1] = 100;
  12352. * g.add(new Circle({
  12353. * style: {
  12354. * x: 100,
  12355. * y: 100,
  12356. * r: 20,
  12357. * }
  12358. * }));
  12359. * zr.add(g);
  12360. */
  12361. var zrUtil = __webpack_require__(4);
  12362. var Element = __webpack_require__(23);
  12363. var BoundingRect = __webpack_require__(9);
  12364. /**
  12365. * @alias module:zrender/graphic/Group
  12366. * @constructor
  12367. * @extends module:zrender/mixin/Transformable
  12368. * @extends module:zrender/mixin/Eventful
  12369. */
  12370. var Group = function (opts) {
  12371. opts = opts || {};
  12372. Element.call(this, opts);
  12373. for (var key in opts) {
  12374. if (opts.hasOwnProperty(key)) {
  12375. this[key] = opts[key];
  12376. }
  12377. }
  12378. this._children = [];
  12379. this.__storage = null;
  12380. this.__dirty = true;
  12381. };
  12382. Group.prototype = {
  12383. constructor: Group,
  12384. isGroup: true,
  12385. /**
  12386. * @type {string}
  12387. */
  12388. type: 'group',
  12389. /**
  12390. * 所有子孙元素是否响应鼠标事件
  12391. * @name module:/zrender/container/Group#silent
  12392. * @type {boolean}
  12393. * @default false
  12394. */
  12395. silent: false,
  12396. /**
  12397. * @return {Array.<module:zrender/Element>}
  12398. */
  12399. children: function () {
  12400. return this._children.slice();
  12401. },
  12402. /**
  12403. * 获取指定 index 的儿子节点
  12404. * @param {number} idx
  12405. * @return {module:zrender/Element}
  12406. */
  12407. childAt: function (idx) {
  12408. return this._children[idx];
  12409. },
  12410. /**
  12411. * 获取指定名字的儿子节点
  12412. * @param {string} name
  12413. * @return {module:zrender/Element}
  12414. */
  12415. childOfName: function (name) {
  12416. var children = this._children;
  12417. for (var i = 0; i < children.length; i++) {
  12418. if (children[i].name === name) {
  12419. return children[i];
  12420. }
  12421. }
  12422. },
  12423. /**
  12424. * @return {number}
  12425. */
  12426. childCount: function () {
  12427. return this._children.length;
  12428. },
  12429. /**
  12430. * 添加子节点到最后
  12431. * @param {module:zrender/Element} child
  12432. */
  12433. add: function (child) {
  12434. if (child && child !== this && child.parent !== this) {
  12435. this._children.push(child);
  12436. this._doAdd(child);
  12437. }
  12438. return this;
  12439. },
  12440. /**
  12441. * 添加子节点在 nextSibling 之前
  12442. * @param {module:zrender/Element} child
  12443. * @param {module:zrender/Element} nextSibling
  12444. */
  12445. addBefore: function (child, nextSibling) {
  12446. if (child && child !== this && child.parent !== this
  12447. && nextSibling && nextSibling.parent === this) {
  12448. var children = this._children;
  12449. var idx = children.indexOf(nextSibling);
  12450. if (idx >= 0) {
  12451. children.splice(idx, 0, child);
  12452. this._doAdd(child);
  12453. }
  12454. }
  12455. return this;
  12456. },
  12457. _doAdd: function (child) {
  12458. if (child.parent) {
  12459. child.parent.remove(child);
  12460. }
  12461. child.parent = this;
  12462. var storage = this.__storage;
  12463. var zr = this.__zr;
  12464. if (storage && storage !== child.__storage) {
  12465. storage.addToStorage(child);
  12466. if (child instanceof Group) {
  12467. child.addChildrenToStorage(storage);
  12468. }
  12469. }
  12470. zr && zr.refresh();
  12471. },
  12472. /**
  12473. * 移除子节点
  12474. * @param {module:zrender/Element} child
  12475. */
  12476. remove: function (child) {
  12477. var zr = this.__zr;
  12478. var storage = this.__storage;
  12479. var children = this._children;
  12480. var idx = zrUtil.indexOf(children, child);
  12481. if (idx < 0) {
  12482. return this;
  12483. }
  12484. children.splice(idx, 1);
  12485. child.parent = null;
  12486. if (storage) {
  12487. storage.delFromStorage(child);
  12488. if (child instanceof Group) {
  12489. child.delChildrenFromStorage(storage);
  12490. }
  12491. }
  12492. zr && zr.refresh();
  12493. return this;
  12494. },
  12495. /**
  12496. * 移除所有子节点
  12497. */
  12498. removeAll: function () {
  12499. var children = this._children;
  12500. var storage = this.__storage;
  12501. var child;
  12502. var i;
  12503. for (i = 0; i < children.length; i++) {
  12504. child = children[i];
  12505. if (storage) {
  12506. storage.delFromStorage(child);
  12507. if (child instanceof Group) {
  12508. child.delChildrenFromStorage(storage);
  12509. }
  12510. }
  12511. child.parent = null;
  12512. }
  12513. children.length = 0;
  12514. return this;
  12515. },
  12516. /**
  12517. * 遍历所有子节点
  12518. * @param {Function} cb
  12519. * @param {} context
  12520. */
  12521. eachChild: function (cb, context) {
  12522. var children = this._children;
  12523. for (var i = 0; i < children.length; i++) {
  12524. var child = children[i];
  12525. cb.call(context, child, i);
  12526. }
  12527. return this;
  12528. },
  12529. /**
  12530. * 深度优先遍历所有子孙节点
  12531. * @param {Function} cb
  12532. * @param {} context
  12533. */
  12534. traverse: function (cb, context) {
  12535. for (var i = 0; i < this._children.length; i++) {
  12536. var child = this._children[i];
  12537. cb.call(context, child);
  12538. if (child.type === 'group') {
  12539. child.traverse(cb, context);
  12540. }
  12541. }
  12542. return this;
  12543. },
  12544. addChildrenToStorage: function (storage) {
  12545. for (var i = 0; i < this._children.length; i++) {
  12546. var child = this._children[i];
  12547. storage.addToStorage(child);
  12548. if (child instanceof Group) {
  12549. child.addChildrenToStorage(storage);
  12550. }
  12551. }
  12552. },
  12553. delChildrenFromStorage: function (storage) {
  12554. for (var i = 0; i < this._children.length; i++) {
  12555. var child = this._children[i];
  12556. storage.delFromStorage(child);
  12557. if (child instanceof Group) {
  12558. child.delChildrenFromStorage(storage);
  12559. }
  12560. }
  12561. },
  12562. dirty: function () {
  12563. this.__dirty = true;
  12564. this.__zr && this.__zr.refresh();
  12565. return this;
  12566. },
  12567. /**
  12568. * @return {module:zrender/core/BoundingRect}
  12569. */
  12570. getBoundingRect: function (includeChildren) {
  12571. // TODO Caching
  12572. var rect = null;
  12573. var tmpRect = new BoundingRect(0, 0, 0, 0);
  12574. var children = includeChildren || this._children;
  12575. var tmpMat = [];
  12576. for (var i = 0; i < children.length; i++) {
  12577. var child = children[i];
  12578. if (child.ignore || child.invisible) {
  12579. continue;
  12580. }
  12581. var childRect = child.getBoundingRect();
  12582. var transform = child.getLocalTransform(tmpMat);
  12583. // TODO
  12584. // The boundingRect cacluated by transforming original
  12585. // rect may be bigger than the actual bundingRect when rotation
  12586. // is used. (Consider a circle rotated aginst its center, where
  12587. // the actual boundingRect should be the same as that not be
  12588. // rotated.) But we can not find better approach to calculate
  12589. // actual boundingRect yet, considering performance.
  12590. if (transform) {
  12591. tmpRect.copy(childRect);
  12592. tmpRect.applyTransform(transform);
  12593. rect = rect || tmpRect.clone();
  12594. rect.union(tmpRect);
  12595. }
  12596. else {
  12597. rect = rect || childRect.clone();
  12598. rect.union(childRect);
  12599. }
  12600. }
  12601. return rect || tmpRect;
  12602. }
  12603. };
  12604. zrUtil.inherits(Group, Element);
  12605. module.exports = Group;
  12606. /***/ },
  12607. /* 49 */
  12608. /***/ function(module, exports, __webpack_require__) {
  12609. /**
  12610. * Image element
  12611. * @module zrender/graphic/Image
  12612. */
  12613. var Displayable = __webpack_require__(21);
  12614. var BoundingRect = __webpack_require__(9);
  12615. var zrUtil = __webpack_require__(4);
  12616. var LRU = __webpack_require__(32);
  12617. var globalImageCache = new LRU(50);
  12618. /**
  12619. * @alias zrender/graphic/Image
  12620. * @extends module:zrender/graphic/Displayable
  12621. * @constructor
  12622. * @param {Object} opts
  12623. */
  12624. function ZImage(opts) {
  12625. Displayable.call(this, opts);
  12626. }
  12627. ZImage.prototype = {
  12628. constructor: ZImage,
  12629. type: 'image',
  12630. brush: function (ctx, prevEl) {
  12631. var style = this.style;
  12632. var src = style.image;
  12633. var image;
  12634. // Must bind each time
  12635. style.bind(ctx, this, prevEl);
  12636. // style.image is a url string
  12637. if (typeof src === 'string') {
  12638. image = this._image;
  12639. }
  12640. // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas
  12641. else {
  12642. image = src;
  12643. }
  12644. // FIXME Case create many images with src
  12645. if (!image && src) {
  12646. // Try get from global image cache
  12647. var cachedImgObj = globalImageCache.get(src);
  12648. if (!cachedImgObj) {
  12649. // Create a new image
  12650. image = new Image();
  12651. image.onload = function () {
  12652. image.onload = null;
  12653. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  12654. cachedImgObj.pending[i].dirty();
  12655. }
  12656. };
  12657. cachedImgObj = {
  12658. image: image,
  12659. pending: [this]
  12660. };
  12661. image.src = src;
  12662. globalImageCache.put(src, cachedImgObj);
  12663. this._image = image;
  12664. return;
  12665. }
  12666. else {
  12667. image = cachedImgObj.image;
  12668. this._image = image;
  12669. // Image is not complete finish, add to pending list
  12670. if (!image.width || !image.height) {
  12671. cachedImgObj.pending.push(this);
  12672. return;
  12673. }
  12674. }
  12675. }
  12676. if (image) {
  12677. // 图片已经加载完成
  12678. // if (image.nodeName.toUpperCase() == 'IMG') {
  12679. // if (!image.complete) {
  12680. // return;
  12681. // }
  12682. // }
  12683. // Else is canvas
  12684. var x = style.x || 0;
  12685. var y = style.y || 0;
  12686. // 图片加载失败
  12687. if (!image.width || !image.height) {
  12688. return;
  12689. }
  12690. var width = style.width;
  12691. var height = style.height;
  12692. var aspect = image.width / image.height;
  12693. if (width == null && height != null) {
  12694. // Keep image/height ratio
  12695. width = height * aspect;
  12696. }
  12697. else if (height == null && width != null) {
  12698. height = width / aspect;
  12699. }
  12700. else if (width == null && height == null) {
  12701. width = image.width;
  12702. height = image.height;
  12703. }
  12704. // 设置transform
  12705. this.setTransform(ctx);
  12706. if (style.sWidth && style.sHeight) {
  12707. var sx = style.sx || 0;
  12708. var sy = style.sy || 0;
  12709. ctx.drawImage(
  12710. image,
  12711. sx, sy, style.sWidth, style.sHeight,
  12712. x, y, width, height
  12713. );
  12714. }
  12715. else if (style.sx && style.sy) {
  12716. var sx = style.sx;
  12717. var sy = style.sy;
  12718. var sWidth = width - sx;
  12719. var sHeight = height - sy;
  12720. ctx.drawImage(
  12721. image,
  12722. sx, sy, sWidth, sHeight,
  12723. x, y, width, height
  12724. );
  12725. }
  12726. else {
  12727. ctx.drawImage(image, x, y, width, height);
  12728. }
  12729. this.restoreTransform(ctx);
  12730. // Draw rect text
  12731. if (style.text != null) {
  12732. this.drawRectText(ctx, this.getBoundingRect());
  12733. }
  12734. }
  12735. },
  12736. getBoundingRect: function () {
  12737. var style = this.style;
  12738. if (! this._rect) {
  12739. this._rect = new BoundingRect(
  12740. style.x || 0, style.y || 0, style.width || 0, style.height || 0
  12741. );
  12742. }
  12743. return this._rect;
  12744. }
  12745. };
  12746. zrUtil.inherits(ZImage, Displayable);
  12747. module.exports = ZImage;
  12748. /***/ },
  12749. /* 50 */
  12750. /***/ function(module, exports, __webpack_require__) {
  12751. /**
  12752. * Text element
  12753. * @module zrender/graphic/Text
  12754. *
  12755. * TODO Wrapping
  12756. *
  12757. * Text not support gradient
  12758. */
  12759. var Displayable = __webpack_require__(21);
  12760. var zrUtil = __webpack_require__(4);
  12761. var textContain = __webpack_require__(8);
  12762. /**
  12763. * @alias zrender/graphic/Text
  12764. * @extends module:zrender/graphic/Displayable
  12765. * @constructor
  12766. * @param {Object} opts
  12767. */
  12768. var Text = function (opts) {
  12769. Displayable.call(this, opts);
  12770. };
  12771. Text.prototype = {
  12772. constructor: Text,
  12773. type: 'text',
  12774. brush: function (ctx, prevEl) {
  12775. var style = this.style;
  12776. var x = style.x || 0;
  12777. var y = style.y || 0;
  12778. // Convert to string
  12779. var text = style.text;
  12780. // Convert to string
  12781. text != null && (text += '');
  12782. // Always bind style
  12783. style.bind(ctx, this, prevEl);
  12784. if (text) {
  12785. this.setTransform(ctx);
  12786. var textBaseline;
  12787. var textAlign = style.textAlign;
  12788. var font = style.textFont || style.font;
  12789. if (style.textVerticalAlign) {
  12790. var rect = textContain.getBoundingRect(
  12791. text, font, style.textAlign, 'top'
  12792. );
  12793. // Ignore textBaseline
  12794. textBaseline = 'middle';
  12795. switch (style.textVerticalAlign) {
  12796. case 'middle':
  12797. y -= rect.height / 2 - rect.lineHeight / 2;
  12798. break;
  12799. case 'bottom':
  12800. y -= rect.height - rect.lineHeight / 2;
  12801. break;
  12802. default:
  12803. y += rect.lineHeight / 2;
  12804. }
  12805. }
  12806. else {
  12807. textBaseline = style.textBaseline;
  12808. }
  12809. // TODO Invalid font
  12810. ctx.font = font || '12px sans-serif';
  12811. ctx.textAlign = textAlign || 'left';
  12812. // Use canvas default left textAlign. Giving invalid value will cause state not change
  12813. if (ctx.textAlign !== textAlign) {
  12814. ctx.textAlign = 'left';
  12815. }
  12816. // FIXME in text contain default is top
  12817. ctx.textBaseline = textBaseline || 'alphabetic';
  12818. // Use canvas default alphabetic baseline
  12819. if (ctx.textBaseline !== textBaseline) {
  12820. ctx.textBaseline = 'alphabetic';
  12821. }
  12822. var lineHeight = textContain.measureText('国', ctx.font).width;
  12823. var textLines = text.split('\n');
  12824. for (var i = 0; i < textLines.length; i++) {
  12825. // Fill after stroke so the outline will not cover the main part.
  12826. style.hasStroke() && ctx.strokeText(textLines[i], x, y);
  12827. style.hasFill() && ctx.fillText(textLines[i], x, y);
  12828. y += lineHeight;
  12829. }
  12830. this.restoreTransform(ctx);
  12831. }
  12832. },
  12833. getBoundingRect: function () {
  12834. var style = this.style;
  12835. if (!this._rect) {
  12836. var textVerticalAlign = style.textVerticalAlign;
  12837. var rect = textContain.getBoundingRect(
  12838. style.text + '', style.textFont || style.font, style.textAlign,
  12839. textVerticalAlign ? 'top' : style.textBaseline
  12840. );
  12841. switch (textVerticalAlign) {
  12842. case 'middle':
  12843. rect.y -= rect.height / 2;
  12844. break;
  12845. case 'bottom':
  12846. rect.y -= rect.height;
  12847. break;
  12848. }
  12849. rect.x += style.x || 0;
  12850. rect.y += style.y || 0;
  12851. if (style.hasStroke()) {
  12852. var w = style.lineWidth;
  12853. rect.x -= w / 2;
  12854. rect.y -= w / 2;
  12855. rect.width += w;
  12856. rect.height += w;
  12857. }
  12858. this._rect = rect;
  12859. }
  12860. return this._rect;
  12861. }
  12862. };
  12863. zrUtil.inherits(Text, Displayable);
  12864. module.exports = Text;
  12865. /***/ },
  12866. /* 51 */
  12867. /***/ function(module, exports, __webpack_require__) {
  12868. 'use strict';
  12869. /**
  12870. * 圆形
  12871. * @module zrender/shape/Circle
  12872. */
  12873. module.exports = __webpack_require__(20).extend({
  12874. type: 'circle',
  12875. shape: {
  12876. cx: 0,
  12877. cy: 0,
  12878. r: 0
  12879. },
  12880. buildPath : function (ctx, shape, inBundle) {
  12881. // Better stroking in ShapeBundle
  12882. // Always do it may have performence issue ( fill may be 2x more cost)
  12883. if (inBundle) {
  12884. ctx.moveTo(shape.cx + shape.r, shape.cy);
  12885. }
  12886. // else {
  12887. // if (ctx.allocate && !ctx.data.length) {
  12888. // ctx.allocate(ctx.CMD_MEM_SIZE.A);
  12889. // }
  12890. // }
  12891. // Better stroking in ShapeBundle
  12892. // ctx.moveTo(shape.cx + shape.r, shape.cy);
  12893. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true);
  12894. }
  12895. });
  12896. /***/ },
  12897. /* 52 */
  12898. /***/ function(module, exports, __webpack_require__) {
  12899. /**
  12900. * 扇形
  12901. * @module zrender/graphic/shape/Sector
  12902. */
  12903. var env = __webpack_require__(2);
  12904. var Path = __webpack_require__(20);
  12905. var shadowTemp = [
  12906. ['shadowBlur', 0],
  12907. ['shadowColor', '#000'],
  12908. ['shadowOffsetX', 0],
  12909. ['shadowOffsetY', 0]
  12910. ];
  12911. module.exports = Path.extend({
  12912. type: 'sector',
  12913. shape: {
  12914. cx: 0,
  12915. cy: 0,
  12916. r0: 0,
  12917. r: 0,
  12918. startAngle: 0,
  12919. endAngle: Math.PI * 2,
  12920. clockwise: true
  12921. },
  12922. brush: (env.browser.ie && env.browser.version >= 11) // version: '11.0'
  12923. // Fix weird bug in some version of IE11 (like 11.0.9600.17801),
  12924. // where exception "unexpected call to method or property access"
  12925. // might be thrown when calling ctx.fill after a path whose area size
  12926. // is zero is drawn and ctx.clip() is called and shadowBlur is set.
  12927. // (e.g.,
  12928. // ctx.moveTo(10, 10);
  12929. // ctx.lineTo(20, 10);
  12930. // ctx.closePath();
  12931. // ctx.clip();
  12932. // ctx.shadowBlur = 10;
  12933. // ...
  12934. // ctx.fill();
  12935. // )
  12936. ? function () {
  12937. var clipPaths = this.__clipPaths;
  12938. var style = this.style;
  12939. var modified;
  12940. if (clipPaths) {
  12941. for (var i = 0; i < clipPaths.length; i++) {
  12942. var shape = clipPaths[i] && clipPaths[i].shape;
  12943. if (shape && shape.startAngle === shape.endAngle) {
  12944. for (var j = 0; j < shadowTemp.length; j++) {
  12945. shadowTemp[j][2] = style[shadowTemp[j][0]];
  12946. style[shadowTemp[j][0]] = shadowTemp[j][1];
  12947. }
  12948. modified = true;
  12949. break;
  12950. }
  12951. }
  12952. }
  12953. Path.prototype.brush.apply(this, arguments);
  12954. if (modified) {
  12955. for (var j = 0; j < shadowTemp.length; j++) {
  12956. style[shadowTemp[j][0]] = shadowTemp[j][2];
  12957. }
  12958. }
  12959. }
  12960. : Path.prototype.brush,
  12961. buildPath: function (ctx, shape) {
  12962. var x = shape.cx;
  12963. var y = shape.cy;
  12964. var r0 = Math.max(shape.r0 || 0, 0);
  12965. var r = Math.max(shape.r, 0);
  12966. var startAngle = shape.startAngle;
  12967. var endAngle = shape.endAngle;
  12968. var clockwise = shape.clockwise;
  12969. var unitX = Math.cos(startAngle);
  12970. var unitY = Math.sin(startAngle);
  12971. ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  12972. ctx.lineTo(unitX * r + x, unitY * r + y);
  12973. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  12974. ctx.lineTo(
  12975. Math.cos(endAngle) * r0 + x,
  12976. Math.sin(endAngle) * r0 + y
  12977. );
  12978. if (r0 !== 0) {
  12979. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  12980. }
  12981. ctx.closePath();
  12982. }
  12983. });
  12984. /***/ },
  12985. /* 53 */
  12986. /***/ function(module, exports, __webpack_require__) {
  12987. /**
  12988. * 圆环
  12989. * @module zrender/graphic/shape/Ring
  12990. */
  12991. module.exports = __webpack_require__(20).extend({
  12992. type: 'ring',
  12993. shape: {
  12994. cx: 0,
  12995. cy: 0,
  12996. r: 0,
  12997. r0: 0
  12998. },
  12999. buildPath: function (ctx, shape) {
  13000. var x = shape.cx;
  13001. var y = shape.cy;
  13002. var PI2 = Math.PI * 2;
  13003. ctx.moveTo(x + shape.r, y);
  13004. ctx.arc(x, y, shape.r, 0, PI2, false);
  13005. ctx.moveTo(x + shape.r0, y);
  13006. ctx.arc(x, y, shape.r0, 0, PI2, true);
  13007. }
  13008. });
  13009. /***/ },
  13010. /* 54 */
  13011. /***/ function(module, exports, __webpack_require__) {
  13012. /**
  13013. * 多边形
  13014. * @module zrender/shape/Polygon
  13015. */
  13016. var polyHelper = __webpack_require__(55);
  13017. module.exports = __webpack_require__(20).extend({
  13018. type: 'polygon',
  13019. shape: {
  13020. points: null,
  13021. smooth: false,
  13022. smoothConstraint: null
  13023. },
  13024. buildPath: function (ctx, shape) {
  13025. polyHelper.buildPath(ctx, shape, true);
  13026. }
  13027. });
  13028. /***/ },
  13029. /* 55 */
  13030. /***/ function(module, exports, __webpack_require__) {
  13031. var smoothSpline = __webpack_require__(56);
  13032. var smoothBezier = __webpack_require__(57);
  13033. module.exports = {
  13034. buildPath: function (ctx, shape, closePath) {
  13035. var points = shape.points;
  13036. var smooth = shape.smooth;
  13037. if (points && points.length >= 2) {
  13038. if (smooth && smooth !== 'spline') {
  13039. var controlPoints = smoothBezier(
  13040. points, smooth, closePath, shape.smoothConstraint
  13041. );
  13042. ctx.moveTo(points[0][0], points[0][1]);
  13043. var len = points.length;
  13044. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  13045. var cp1 = controlPoints[i * 2];
  13046. var cp2 = controlPoints[i * 2 + 1];
  13047. var p = points[(i + 1) % len];
  13048. ctx.bezierCurveTo(
  13049. cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]
  13050. );
  13051. }
  13052. }
  13053. else {
  13054. if (smooth === 'spline') {
  13055. points = smoothSpline(points, closePath);
  13056. }
  13057. ctx.moveTo(points[0][0], points[0][1]);
  13058. for (var i = 1, l = points.length; i < l; i++) {
  13059. ctx.lineTo(points[i][0], points[i][1]);
  13060. }
  13061. }
  13062. closePath && ctx.closePath();
  13063. }
  13064. }
  13065. };
  13066. /***/ },
  13067. /* 56 */
  13068. /***/ function(module, exports, __webpack_require__) {
  13069. /**
  13070. * Catmull-Rom spline 插值折线
  13071. * @module zrender/shape/util/smoothSpline
  13072. * @author pissang (https://www.github.com/pissang)
  13073. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  13074. * errorrik (errorrik@gmail.com)
  13075. */
  13076. var vec2 = __webpack_require__(10);
  13077. /**
  13078. * @inner
  13079. */
  13080. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  13081. var v0 = (p2 - p0) * 0.5;
  13082. var v1 = (p3 - p1) * 0.5;
  13083. return (2 * (p1 - p2) + v0 + v1) * t3
  13084. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  13085. + v0 * t + p1;
  13086. }
  13087. /**
  13088. * @alias module:zrender/shape/util/smoothSpline
  13089. * @param {Array} points 线段顶点数组
  13090. * @param {boolean} isLoop
  13091. * @return {Array}
  13092. */
  13093. module.exports = function (points, isLoop) {
  13094. var len = points.length;
  13095. var ret = [];
  13096. var distance = 0;
  13097. for (var i = 1; i < len; i++) {
  13098. distance += vec2.distance(points[i - 1], points[i]);
  13099. }
  13100. var segs = distance / 2;
  13101. segs = segs < len ? len : segs;
  13102. for (var i = 0; i < segs; i++) {
  13103. var pos = i / (segs - 1) * (isLoop ? len : len - 1);
  13104. var idx = Math.floor(pos);
  13105. var w = pos - idx;
  13106. var p0;
  13107. var p1 = points[idx % len];
  13108. var p2;
  13109. var p3;
  13110. if (!isLoop) {
  13111. p0 = points[idx === 0 ? idx : idx - 1];
  13112. p2 = points[idx > len - 2 ? len - 1 : idx + 1];
  13113. p3 = points[idx > len - 3 ? len - 1 : idx + 2];
  13114. }
  13115. else {
  13116. p0 = points[(idx - 1 + len) % len];
  13117. p2 = points[(idx + 1) % len];
  13118. p3 = points[(idx + 2) % len];
  13119. }
  13120. var w2 = w * w;
  13121. var w3 = w * w2;
  13122. ret.push([
  13123. interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
  13124. interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
  13125. ]);
  13126. }
  13127. return ret;
  13128. };
  13129. /***/ },
  13130. /* 57 */
  13131. /***/ function(module, exports, __webpack_require__) {
  13132. /**
  13133. * 贝塞尔平滑曲线
  13134. * @module zrender/shape/util/smoothBezier
  13135. * @author pissang (https://www.github.com/pissang)
  13136. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  13137. * errorrik (errorrik@gmail.com)
  13138. */
  13139. var vec2 = __webpack_require__(10);
  13140. var v2Min = vec2.min;
  13141. var v2Max = vec2.max;
  13142. var v2Scale = vec2.scale;
  13143. var v2Distance = vec2.distance;
  13144. var v2Add = vec2.add;
  13145. /**
  13146. * 贝塞尔平滑曲线
  13147. * @alias module:zrender/shape/util/smoothBezier
  13148. * @param {Array} points 线段顶点数组
  13149. * @param {number} smooth 平滑等级, 0-1
  13150. * @param {boolean} isLoop
  13151. * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内
  13152. * 比如 [[0, 0], [100, 100]], 这个包围盒会与
  13153. * 整个折线的包围盒做一个并集用来约束控制点。
  13154. * @param {Array} 计算出来的控制点数组
  13155. */
  13156. module.exports = function (points, smooth, isLoop, constraint) {
  13157. var cps = [];
  13158. var v = [];
  13159. var v1 = [];
  13160. var v2 = [];
  13161. var prevPoint;
  13162. var nextPoint;
  13163. var min, max;
  13164. if (constraint) {
  13165. min = [Infinity, Infinity];
  13166. max = [-Infinity, -Infinity];
  13167. for (var i = 0, len = points.length; i < len; i++) {
  13168. v2Min(min, min, points[i]);
  13169. v2Max(max, max, points[i]);
  13170. }
  13171. // 与指定的包围盒做并集
  13172. v2Min(min, min, constraint[0]);
  13173. v2Max(max, max, constraint[1]);
  13174. }
  13175. for (var i = 0, len = points.length; i < len; i++) {
  13176. var point = points[i];
  13177. if (isLoop) {
  13178. prevPoint = points[i ? i - 1 : len - 1];
  13179. nextPoint = points[(i + 1) % len];
  13180. }
  13181. else {
  13182. if (i === 0 || i === len - 1) {
  13183. cps.push(vec2.clone(points[i]));
  13184. continue;
  13185. }
  13186. else {
  13187. prevPoint = points[i - 1];
  13188. nextPoint = points[i + 1];
  13189. }
  13190. }
  13191. vec2.sub(v, nextPoint, prevPoint);
  13192. // use degree to scale the handle length
  13193. v2Scale(v, v, smooth);
  13194. var d0 = v2Distance(point, prevPoint);
  13195. var d1 = v2Distance(point, nextPoint);
  13196. var sum = d0 + d1;
  13197. if (sum !== 0) {
  13198. d0 /= sum;
  13199. d1 /= sum;
  13200. }
  13201. v2Scale(v1, v, -d0);
  13202. v2Scale(v2, v, d1);
  13203. var cp0 = v2Add([], point, v1);
  13204. var cp1 = v2Add([], point, v2);
  13205. if (constraint) {
  13206. v2Max(cp0, cp0, min);
  13207. v2Min(cp0, cp0, max);
  13208. v2Max(cp1, cp1, min);
  13209. v2Min(cp1, cp1, max);
  13210. }
  13211. cps.push(cp0);
  13212. cps.push(cp1);
  13213. }
  13214. if (isLoop) {
  13215. cps.push(cps.shift());
  13216. }
  13217. return cps;
  13218. };
  13219. /***/ },
  13220. /* 58 */
  13221. /***/ function(module, exports, __webpack_require__) {
  13222. /**
  13223. * @module zrender/graphic/shape/Polyline
  13224. */
  13225. var polyHelper = __webpack_require__(55);
  13226. module.exports = __webpack_require__(20).extend({
  13227. type: 'polyline',
  13228. shape: {
  13229. points: null,
  13230. smooth: false,
  13231. smoothConstraint: null
  13232. },
  13233. style: {
  13234. stroke: '#000',
  13235. fill: null
  13236. },
  13237. buildPath: function (ctx, shape) {
  13238. polyHelper.buildPath(ctx, shape, false);
  13239. }
  13240. });
  13241. /***/ },
  13242. /* 59 */
  13243. /***/ function(module, exports, __webpack_require__) {
  13244. /**
  13245. * 矩形
  13246. * @module zrender/graphic/shape/Rect
  13247. */
  13248. var roundRectHelper = __webpack_require__(60);
  13249. module.exports = __webpack_require__(20).extend({
  13250. type: 'rect',
  13251. shape: {
  13252. // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
  13253. // r缩写为1 相当于 [1, 1, 1, 1]
  13254. // r缩写为[1] 相当于 [1, 1, 1, 1]
  13255. // r缩写为[1, 2] 相当于 [1, 2, 1, 2]
  13256. // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2]
  13257. r: 0,
  13258. x: 0,
  13259. y: 0,
  13260. width: 0,
  13261. height: 0
  13262. },
  13263. buildPath: function (ctx, shape) {
  13264. var x = shape.x;
  13265. var y = shape.y;
  13266. var width = shape.width;
  13267. var height = shape.height;
  13268. if (!shape.r) {
  13269. ctx.rect(x, y, width, height);
  13270. }
  13271. else {
  13272. roundRectHelper.buildPath(ctx, shape);
  13273. }
  13274. ctx.closePath();
  13275. return;
  13276. }
  13277. });
  13278. /***/ },
  13279. /* 60 */
  13280. /***/ function(module, exports) {
  13281. module.exports = {
  13282. buildPath: function (ctx, shape) {
  13283. var x = shape.x;
  13284. var y = shape.y;
  13285. var width = shape.width;
  13286. var height = shape.height;
  13287. var r = shape.r;
  13288. var r1;
  13289. var r2;
  13290. var r3;
  13291. var r4;
  13292. // Convert width and height to positive for better borderRadius
  13293. if (width < 0) {
  13294. x = x + width;
  13295. width = -width;
  13296. }
  13297. if (height < 0) {
  13298. y = y + height;
  13299. height = -height;
  13300. }
  13301. if (typeof r === 'number') {
  13302. r1 = r2 = r3 = r4 = r;
  13303. }
  13304. else if (r instanceof Array) {
  13305. if (r.length === 1) {
  13306. r1 = r2 = r3 = r4 = r[0];
  13307. }
  13308. else if (r.length === 2) {
  13309. r1 = r3 = r[0];
  13310. r2 = r4 = r[1];
  13311. }
  13312. else if (r.length === 3) {
  13313. r1 = r[0];
  13314. r2 = r4 = r[1];
  13315. r3 = r[2];
  13316. }
  13317. else {
  13318. r1 = r[0];
  13319. r2 = r[1];
  13320. r3 = r[2];
  13321. r4 = r[3];
  13322. }
  13323. }
  13324. else {
  13325. r1 = r2 = r3 = r4 = 0;
  13326. }
  13327. var total;
  13328. if (r1 + r2 > width) {
  13329. total = r1 + r2;
  13330. r1 *= width / total;
  13331. r2 *= width / total;
  13332. }
  13333. if (r3 + r4 > width) {
  13334. total = r3 + r4;
  13335. r3 *= width / total;
  13336. r4 *= width / total;
  13337. }
  13338. if (r2 + r3 > height) {
  13339. total = r2 + r3;
  13340. r2 *= height / total;
  13341. r3 *= height / total;
  13342. }
  13343. if (r1 + r4 > height) {
  13344. total = r1 + r4;
  13345. r1 *= height / total;
  13346. r4 *= height / total;
  13347. }
  13348. ctx.moveTo(x + r1, y);
  13349. ctx.lineTo(x + width - r2, y);
  13350. r2 !== 0 && ctx.quadraticCurveTo(
  13351. x + width, y, x + width, y + r2
  13352. );
  13353. ctx.lineTo(x + width, y + height - r3);
  13354. r3 !== 0 && ctx.quadraticCurveTo(
  13355. x + width, y + height, x + width - r3, y + height
  13356. );
  13357. ctx.lineTo(x + r4, y + height);
  13358. r4 !== 0 && ctx.quadraticCurveTo(
  13359. x, y + height, x, y + height - r4
  13360. );
  13361. ctx.lineTo(x, y + r1);
  13362. r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
  13363. }
  13364. };
  13365. /***/ },
  13366. /* 61 */
  13367. /***/ function(module, exports, __webpack_require__) {
  13368. /**
  13369. * 直线
  13370. * @module zrender/graphic/shape/Line
  13371. */
  13372. module.exports = __webpack_require__(20).extend({
  13373. type: 'line',
  13374. shape: {
  13375. // Start point
  13376. x1: 0,
  13377. y1: 0,
  13378. // End point
  13379. x2: 0,
  13380. y2: 0,
  13381. percent: 1
  13382. },
  13383. style: {
  13384. stroke: '#000',
  13385. fill: null
  13386. },
  13387. buildPath: function (ctx, shape) {
  13388. var x1 = shape.x1;
  13389. var y1 = shape.y1;
  13390. var x2 = shape.x2;
  13391. var y2 = shape.y2;
  13392. var percent = shape.percent;
  13393. if (percent === 0) {
  13394. return;
  13395. }
  13396. ctx.moveTo(x1, y1);
  13397. if (percent < 1) {
  13398. x2 = x1 * (1 - percent) + x2 * percent;
  13399. y2 = y1 * (1 - percent) + y2 * percent;
  13400. }
  13401. ctx.lineTo(x2, y2);
  13402. },
  13403. /**
  13404. * Get point at percent
  13405. * @param {number} percent
  13406. * @return {Array.<number>}
  13407. */
  13408. pointAt: function (p) {
  13409. var shape = this.shape;
  13410. return [
  13411. shape.x1 * (1 - p) + shape.x2 * p,
  13412. shape.y1 * (1 - p) + shape.y2 * p
  13413. ];
  13414. }
  13415. });
  13416. /***/ },
  13417. /* 62 */
  13418. /***/ function(module, exports, __webpack_require__) {
  13419. 'use strict';
  13420. /**
  13421. * 贝塞尔曲线
  13422. * @module zrender/shape/BezierCurve
  13423. */
  13424. var curveTool = __webpack_require__(37);
  13425. var vec2 = __webpack_require__(10);
  13426. var quadraticSubdivide = curveTool.quadraticSubdivide;
  13427. var cubicSubdivide = curveTool.cubicSubdivide;
  13428. var quadraticAt = curveTool.quadraticAt;
  13429. var cubicAt = curveTool.cubicAt;
  13430. var quadraticDerivativeAt = curveTool.quadraticDerivativeAt;
  13431. var cubicDerivativeAt = curveTool.cubicDerivativeAt;
  13432. var out = [];
  13433. function someVectorAt(shape, t, isTangent) {
  13434. var cpx2 = shape.cpx2;
  13435. var cpy2 = shape.cpy2;
  13436. if (cpx2 === null || cpy2 === null) {
  13437. return [
  13438. (isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t),
  13439. (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)
  13440. ];
  13441. }
  13442. else {
  13443. return [
  13444. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t),
  13445. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)
  13446. ];
  13447. }
  13448. }
  13449. module.exports = __webpack_require__(20).extend({
  13450. type: 'bezier-curve',
  13451. shape: {
  13452. x1: 0,
  13453. y1: 0,
  13454. x2: 0,
  13455. y2: 0,
  13456. cpx1: 0,
  13457. cpy1: 0,
  13458. // cpx2: 0,
  13459. // cpy2: 0
  13460. // Curve show percent, for animating
  13461. percent: 1
  13462. },
  13463. style: {
  13464. stroke: '#000',
  13465. fill: null
  13466. },
  13467. buildPath: function (ctx, shape) {
  13468. var x1 = shape.x1;
  13469. var y1 = shape.y1;
  13470. var x2 = shape.x2;
  13471. var y2 = shape.y2;
  13472. var cpx1 = shape.cpx1;
  13473. var cpy1 = shape.cpy1;
  13474. var cpx2 = shape.cpx2;
  13475. var cpy2 = shape.cpy2;
  13476. var percent = shape.percent;
  13477. if (percent === 0) {
  13478. return;
  13479. }
  13480. ctx.moveTo(x1, y1);
  13481. if (cpx2 == null || cpy2 == null) {
  13482. if (percent < 1) {
  13483. quadraticSubdivide(
  13484. x1, cpx1, x2, percent, out
  13485. );
  13486. cpx1 = out[1];
  13487. x2 = out[2];
  13488. quadraticSubdivide(
  13489. y1, cpy1, y2, percent, out
  13490. );
  13491. cpy1 = out[1];
  13492. y2 = out[2];
  13493. }
  13494. ctx.quadraticCurveTo(
  13495. cpx1, cpy1,
  13496. x2, y2
  13497. );
  13498. }
  13499. else {
  13500. if (percent < 1) {
  13501. cubicSubdivide(
  13502. x1, cpx1, cpx2, x2, percent, out
  13503. );
  13504. cpx1 = out[1];
  13505. cpx2 = out[2];
  13506. x2 = out[3];
  13507. cubicSubdivide(
  13508. y1, cpy1, cpy2, y2, percent, out
  13509. );
  13510. cpy1 = out[1];
  13511. cpy2 = out[2];
  13512. y2 = out[3];
  13513. }
  13514. ctx.bezierCurveTo(
  13515. cpx1, cpy1,
  13516. cpx2, cpy2,
  13517. x2, y2
  13518. );
  13519. }
  13520. },
  13521. /**
  13522. * Get point at percent
  13523. * @param {number} t
  13524. * @return {Array.<number>}
  13525. */
  13526. pointAt: function (t) {
  13527. return someVectorAt(this.shape, t, false);
  13528. },
  13529. /**
  13530. * Get tangent at percent
  13531. * @param {number} t
  13532. * @return {Array.<number>}
  13533. */
  13534. tangentAt: function (t) {
  13535. var p = someVectorAt(this.shape, t, true);
  13536. return vec2.normalize(p, p);
  13537. }
  13538. });
  13539. /***/ },
  13540. /* 63 */
  13541. /***/ function(module, exports, __webpack_require__) {
  13542. /**
  13543. * 圆弧
  13544. * @module zrender/graphic/shape/Arc
  13545. */
  13546. module.exports = __webpack_require__(20).extend({
  13547. type: 'arc',
  13548. shape: {
  13549. cx: 0,
  13550. cy: 0,
  13551. r: 0,
  13552. startAngle: 0,
  13553. endAngle: Math.PI * 2,
  13554. clockwise: true
  13555. },
  13556. style: {
  13557. stroke: '#000',
  13558. fill: null
  13559. },
  13560. buildPath: function (ctx, shape) {
  13561. var x = shape.cx;
  13562. var y = shape.cy;
  13563. var r = Math.max(shape.r, 0);
  13564. var startAngle = shape.startAngle;
  13565. var endAngle = shape.endAngle;
  13566. var clockwise = shape.clockwise;
  13567. var unitX = Math.cos(startAngle);
  13568. var unitY = Math.sin(startAngle);
  13569. ctx.moveTo(unitX * r + x, unitY * r + y);
  13570. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  13571. }
  13572. });
  13573. /***/ },
  13574. /* 64 */
  13575. /***/ function(module, exports, __webpack_require__) {
  13576. // CompoundPath to improve performance
  13577. var Path = __webpack_require__(20);
  13578. module.exports = Path.extend({
  13579. type: 'compound',
  13580. shape: {
  13581. paths: null
  13582. },
  13583. _updatePathDirty: function () {
  13584. var dirtyPath = this.__dirtyPath;
  13585. var paths = this.shape.paths;
  13586. for (var i = 0; i < paths.length; i++) {
  13587. // Mark as dirty if any subpath is dirty
  13588. dirtyPath = dirtyPath || paths[i].__dirtyPath;
  13589. }
  13590. this.__dirtyPath = dirtyPath;
  13591. this.__dirty = this.__dirty || dirtyPath;
  13592. },
  13593. beforeBrush: function () {
  13594. this._updatePathDirty();
  13595. var paths = this.shape.paths || [];
  13596. var scale = this.getGlobalScale();
  13597. // Update path scale
  13598. for (var i = 0; i < paths.length; i++) {
  13599. if (!paths[i].path) {
  13600. paths[i].createPathProxy();
  13601. }
  13602. paths[i].path.setScale(scale[0], scale[1]);
  13603. }
  13604. },
  13605. buildPath: function (ctx, shape) {
  13606. var paths = shape.paths || [];
  13607. for (var i = 0; i < paths.length; i++) {
  13608. paths[i].buildPath(ctx, paths[i].shape, true);
  13609. }
  13610. },
  13611. afterBrush: function () {
  13612. var paths = this.shape.paths;
  13613. for (var i = 0; i < paths.length; i++) {
  13614. paths[i].__dirtyPath = false;
  13615. }
  13616. },
  13617. getBoundingRect: function () {
  13618. this._updatePathDirty();
  13619. return Path.prototype.getBoundingRect.call(this);
  13620. }
  13621. });
  13622. /***/ },
  13623. /* 65 */
  13624. /***/ function(module, exports, __webpack_require__) {
  13625. 'use strict';
  13626. var zrUtil = __webpack_require__(4);
  13627. var Gradient = __webpack_require__(66);
  13628. /**
  13629. * x, y, x2, y2 are all percent from 0 to 1
  13630. * @param {number} [x=0]
  13631. * @param {number} [y=0]
  13632. * @param {number} [x2=1]
  13633. * @param {number} [y2=0]
  13634. * @param {Array.<Object>} colorStops
  13635. * @param {boolean} [globalCoord=false]
  13636. */
  13637. var LinearGradient = function (x, y, x2, y2, colorStops, globalCoord) {
  13638. // Should do nothing more in this constructor. Because gradient can be
  13639. // declard by `color: {type: 'linear', colorStops: ...}`, where
  13640. // this constructor will not be called.
  13641. this.x = x == null ? 0 : x;
  13642. this.y = y == null ? 0 : y;
  13643. this.x2 = x2 == null ? 1 : x2;
  13644. this.y2 = y2 == null ? 0 : y2;
  13645. // Can be cloned
  13646. this.type = 'linear';
  13647. // If use global coord
  13648. this.global = globalCoord || false;
  13649. Gradient.call(this, colorStops);
  13650. };
  13651. LinearGradient.prototype = {
  13652. constructor: LinearGradient
  13653. };
  13654. zrUtil.inherits(LinearGradient, Gradient);
  13655. module.exports = LinearGradient;
  13656. /***/ },
  13657. /* 66 */
  13658. /***/ function(module, exports) {
  13659. /**
  13660. * @param {Array.<Object>} colorStops
  13661. */
  13662. var Gradient = function (colorStops) {
  13663. this.colorStops = colorStops || [];
  13664. };
  13665. Gradient.prototype = {
  13666. constructor: Gradient,
  13667. addColorStop: function (offset, color) {
  13668. this.colorStops.push({
  13669. offset: offset,
  13670. color: color
  13671. });
  13672. }
  13673. };
  13674. module.exports = Gradient;
  13675. /***/ },
  13676. /* 67 */
  13677. /***/ function(module, exports, __webpack_require__) {
  13678. 'use strict';
  13679. var zrUtil = __webpack_require__(4);
  13680. var Gradient = __webpack_require__(66);
  13681. /**
  13682. * x, y, r are all percent from 0 to 1
  13683. * @param {number} [x=0.5]
  13684. * @param {number} [y=0.5]
  13685. * @param {number} [r=0.5]
  13686. * @param {Array.<Object>} [colorStops]
  13687. * @param {boolean} [globalCoord=false]
  13688. */
  13689. var RadialGradient = function (x, y, r, colorStops, globalCoord) {
  13690. // Should do nothing more in this constructor. Because gradient can be
  13691. // declard by `color: {type: 'radial', colorStops: ...}`, where
  13692. // this constructor will not be called.
  13693. this.x = x == null ? 0.5 : x;
  13694. this.y = y == null ? 0.5 : y;
  13695. this.r = r == null ? 0.5 : r;
  13696. // Can be cloned
  13697. this.type = 'radial';
  13698. // If use global coord
  13699. this.global = globalCoord || false;
  13700. Gradient.call(this, colorStops);
  13701. };
  13702. RadialGradient.prototype = {
  13703. constructor: RadialGradient
  13704. };
  13705. zrUtil.inherits(RadialGradient, Gradient);
  13706. module.exports = RadialGradient;
  13707. /***/ },
  13708. /* 68 */
  13709. /***/ function(module, exports, __webpack_require__) {
  13710. var getItemStyle = __webpack_require__(15)(
  13711. [
  13712. ['fill', 'color'],
  13713. ['stroke', 'borderColor'],
  13714. ['lineWidth', 'borderWidth'],
  13715. ['opacity'],
  13716. ['shadowBlur'],
  13717. ['shadowOffsetX'],
  13718. ['shadowOffsetY'],
  13719. ['shadowColor'],
  13720. ['textPosition'],
  13721. ['textAlign']
  13722. ]
  13723. );
  13724. module.exports = {
  13725. getItemStyle: function (excludes, includes) {
  13726. var style = getItemStyle.call(this, excludes, includes);
  13727. var lineDash = this.getBorderLineDash();
  13728. lineDash && (style.lineDash = lineDash);
  13729. return style;
  13730. },
  13731. getBorderLineDash: function () {
  13732. var lineType = this.get('borderType');
  13733. return (lineType === 'solid' || lineType == null) ? null
  13734. : (lineType === 'dashed' ? [5, 5] : [1, 1]);
  13735. }
  13736. };
  13737. /***/ },
  13738. /* 69 */
  13739. /***/ function(module, exports, __webpack_require__) {
  13740. /**
  13741. * Component model
  13742. *
  13743. * @module echarts/model/Component
  13744. */
  13745. var Model = __webpack_require__(12);
  13746. var zrUtil = __webpack_require__(4);
  13747. var arrayPush = Array.prototype.push;
  13748. var componentUtil = __webpack_require__(70);
  13749. var clazzUtil = __webpack_require__(13);
  13750. var layout = __webpack_require__(71);
  13751. /**
  13752. * @alias module:echarts/model/Component
  13753. * @constructor
  13754. * @param {Object} option
  13755. * @param {module:echarts/model/Model} parentModel
  13756. * @param {module:echarts/model/Model} ecModel
  13757. */
  13758. var ComponentModel = Model.extend({
  13759. type: 'component',
  13760. /**
  13761. * @readOnly
  13762. * @type {string}
  13763. */
  13764. id: '',
  13765. /**
  13766. * @readOnly
  13767. */
  13768. name: '',
  13769. /**
  13770. * @readOnly
  13771. * @type {string}
  13772. */
  13773. mainType: '',
  13774. /**
  13775. * @readOnly
  13776. * @type {string}
  13777. */
  13778. subType: '',
  13779. /**
  13780. * @readOnly
  13781. * @type {number}
  13782. */
  13783. componentIndex: 0,
  13784. /**
  13785. * @type {Object}
  13786. * @protected
  13787. */
  13788. defaultOption: null,
  13789. /**
  13790. * @type {module:echarts/model/Global}
  13791. * @readOnly
  13792. */
  13793. ecModel: null,
  13794. /**
  13795. * key: componentType
  13796. * value: Component model list, can not be null.
  13797. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  13798. * @readOnly
  13799. */
  13800. dependentModels: [],
  13801. /**
  13802. * @type {string}
  13803. * @readOnly
  13804. */
  13805. uid: null,
  13806. /**
  13807. * Support merge layout params.
  13808. * Only support 'box' now (left/right/top/bottom/width/height).
  13809. * @type {string|Object} Object can be {ignoreSize: true}
  13810. * @readOnly
  13811. */
  13812. layoutMode: null,
  13813. $constructor: function (option, parentModel, ecModel, extraOpt) {
  13814. Model.call(this, option, parentModel, ecModel, extraOpt);
  13815. this.uid = componentUtil.getUID('componentModel');
  13816. },
  13817. init: function (option, parentModel, ecModel, extraOpt) {
  13818. this.mergeDefaultAndTheme(option, ecModel);
  13819. },
  13820. mergeDefaultAndTheme: function (option, ecModel) {
  13821. var layoutMode = this.layoutMode;
  13822. var inputPositionParams = layoutMode
  13823. ? layout.getLayoutParams(option) : {};
  13824. var themeModel = ecModel.getTheme();
  13825. zrUtil.merge(option, themeModel.get(this.mainType));
  13826. zrUtil.merge(option, this.getDefaultOption());
  13827. if (layoutMode) {
  13828. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  13829. }
  13830. },
  13831. mergeOption: function (option, extraOpt) {
  13832. zrUtil.merge(this.option, option, true);
  13833. var layoutMode = this.layoutMode;
  13834. if (layoutMode) {
  13835. layout.mergeLayoutParam(this.option, option, layoutMode);
  13836. }
  13837. },
  13838. // Hooker after init or mergeOption
  13839. optionUpdated: function (newCptOption, isInit) {},
  13840. getDefaultOption: function () {
  13841. if (!clazzUtil.hasOwn(this, '__defaultOption')) {
  13842. var optList = [];
  13843. var Class = this.constructor;
  13844. while (Class) {
  13845. var opt = Class.prototype.defaultOption;
  13846. opt && optList.push(opt);
  13847. Class = Class.superClass;
  13848. }
  13849. var defaultOption = {};
  13850. for (var i = optList.length - 1; i >= 0; i--) {
  13851. defaultOption = zrUtil.merge(defaultOption, optList[i], true);
  13852. }
  13853. clazzUtil.set(this, '__defaultOption', defaultOption);
  13854. }
  13855. return clazzUtil.get(this, '__defaultOption');
  13856. },
  13857. getReferringComponents: function (mainType) {
  13858. return this.ecModel.queryComponents({
  13859. mainType: mainType,
  13860. index: this.get(mainType + 'Index', true),
  13861. id: this.get(mainType + 'Id', true)
  13862. });
  13863. }
  13864. });
  13865. // Reset ComponentModel.extend, add preConstruct.
  13866. // clazzUtil.enableClassExtend(
  13867. // ComponentModel,
  13868. // function (option, parentModel, ecModel, extraOpt) {
  13869. // // Set dependentModels, componentIndex, name, id, mainType, subType.
  13870. // zrUtil.extend(this, extraOpt);
  13871. // this.uid = componentUtil.getUID('componentModel');
  13872. // // this.setReadOnly([
  13873. // // 'type', 'id', 'uid', 'name', 'mainType', 'subType',
  13874. // // 'dependentModels', 'componentIndex'
  13875. // // ]);
  13876. // }
  13877. // );
  13878. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  13879. clazzUtil.enableClassManagement(
  13880. ComponentModel, {registerWhenExtend: true}
  13881. );
  13882. componentUtil.enableSubTypeDefaulter(ComponentModel);
  13883. // Add capability of ComponentModel.topologicalTravel.
  13884. componentUtil.enableTopologicalTravel(ComponentModel, getDependencies);
  13885. function getDependencies(componentType) {
  13886. var deps = [];
  13887. zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) {
  13888. arrayPush.apply(deps, Clazz.prototype.dependencies || []);
  13889. });
  13890. // Ensure main type
  13891. return zrUtil.map(deps, function (type) {
  13892. return clazzUtil.parseClassType(type).main;
  13893. });
  13894. }
  13895. zrUtil.mixin(ComponentModel, __webpack_require__(72));
  13896. module.exports = ComponentModel;
  13897. /***/ },
  13898. /* 70 */
  13899. /***/ function(module, exports, __webpack_require__) {
  13900. var zrUtil = __webpack_require__(4);
  13901. var clazz = __webpack_require__(13);
  13902. var parseClassType = clazz.parseClassType;
  13903. var base = 0;
  13904. var componentUtil = {};
  13905. var DELIMITER = '_';
  13906. /**
  13907. * @public
  13908. * @param {string} type
  13909. * @return {string}
  13910. */
  13911. componentUtil.getUID = function (type) {
  13912. // Considering the case of crossing js context,
  13913. // use Math.random to make id as unique as possible.
  13914. return [(type || ''), base++, Math.random()].join(DELIMITER);
  13915. };
  13916. /**
  13917. * @inner
  13918. */
  13919. componentUtil.enableSubTypeDefaulter = function (entity) {
  13920. var subTypeDefaulters = {};
  13921. entity.registerSubTypeDefaulter = function (componentType, defaulter) {
  13922. componentType = parseClassType(componentType);
  13923. subTypeDefaulters[componentType.main] = defaulter;
  13924. };
  13925. entity.determineSubType = function (componentType, option) {
  13926. var type = option.type;
  13927. if (!type) {
  13928. var componentTypeMain = parseClassType(componentType).main;
  13929. if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) {
  13930. type = subTypeDefaulters[componentTypeMain](option);
  13931. }
  13932. }
  13933. return type;
  13934. };
  13935. return entity;
  13936. };
  13937. /**
  13938. * Topological travel on Activity Network (Activity On Vertices).
  13939. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  13940. *
  13941. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  13942. *
  13943. * If there is circle dependencey, Error will be thrown.
  13944. *
  13945. */
  13946. componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) {
  13947. /**
  13948. * @public
  13949. * @param {Array.<string>} targetNameList Target Component type list.
  13950. * Can be ['aa', 'bb', 'aa.xx']
  13951. * @param {Array.<string>} fullNameList By which we can build dependency graph.
  13952. * @param {Function} callback Params: componentType, dependencies.
  13953. * @param {Object} context Scope of callback.
  13954. */
  13955. entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) {
  13956. if (!targetNameList.length) {
  13957. return;
  13958. }
  13959. var result = makeDepndencyGraph(fullNameList);
  13960. var graph = result.graph;
  13961. var stack = result.noEntryList;
  13962. var targetNameSet = {};
  13963. zrUtil.each(targetNameList, function (name) {
  13964. targetNameSet[name] = true;
  13965. });
  13966. while (stack.length) {
  13967. var currComponentType = stack.pop();
  13968. var currVertex = graph[currComponentType];
  13969. var isInTargetNameSet = !!targetNameSet[currComponentType];
  13970. if (isInTargetNameSet) {
  13971. callback.call(context, currComponentType, currVertex.originalDeps.slice());
  13972. delete targetNameSet[currComponentType];
  13973. }
  13974. zrUtil.each(
  13975. currVertex.successor,
  13976. isInTargetNameSet ? removeEdgeAndAdd : removeEdge
  13977. );
  13978. }
  13979. zrUtil.each(targetNameSet, function () {
  13980. throw new Error('Circle dependency may exists');
  13981. });
  13982. function removeEdge(succComponentType) {
  13983. graph[succComponentType].entryCount--;
  13984. if (graph[succComponentType].entryCount === 0) {
  13985. stack.push(succComponentType);
  13986. }
  13987. }
  13988. // Consider this case: legend depends on series, and we call
  13989. // chart.setOption({series: [...]}), where only series is in option.
  13990. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  13991. // not be called, but only sereis.mergeOption is called. Thus legend
  13992. // have no chance to update its local record about series (like which
  13993. // name of series is available in legend).
  13994. function removeEdgeAndAdd(succComponentType) {
  13995. targetNameSet[succComponentType] = true;
  13996. removeEdge(succComponentType);
  13997. }
  13998. };
  13999. /**
  14000. * DepndencyGraph: {Object}
  14001. * key: conponentType,
  14002. * value: {
  14003. * successor: [conponentTypes...],
  14004. * originalDeps: [conponentTypes...],
  14005. * entryCount: {number}
  14006. * }
  14007. */
  14008. function makeDepndencyGraph(fullNameList) {
  14009. var graph = {};
  14010. var noEntryList = [];
  14011. zrUtil.each(fullNameList, function (name) {
  14012. var thisItem = createDependencyGraphItem(graph, name);
  14013. var originalDeps = thisItem.originalDeps = dependencyGetter(name);
  14014. var availableDeps = getAvailableDependencies(originalDeps, fullNameList);
  14015. thisItem.entryCount = availableDeps.length;
  14016. if (thisItem.entryCount === 0) {
  14017. noEntryList.push(name);
  14018. }
  14019. zrUtil.each(availableDeps, function (dependentName) {
  14020. if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) {
  14021. thisItem.predecessor.push(dependentName);
  14022. }
  14023. var thatItem = createDependencyGraphItem(graph, dependentName);
  14024. if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) {
  14025. thatItem.successor.push(name);
  14026. }
  14027. });
  14028. });
  14029. return {graph: graph, noEntryList: noEntryList};
  14030. }
  14031. function createDependencyGraphItem(graph, name) {
  14032. if (!graph[name]) {
  14033. graph[name] = {predecessor: [], successor: []};
  14034. }
  14035. return graph[name];
  14036. }
  14037. function getAvailableDependencies(originalDeps, fullNameList) {
  14038. var availableDeps = [];
  14039. zrUtil.each(originalDeps, function (dep) {
  14040. zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep);
  14041. });
  14042. return availableDeps;
  14043. }
  14044. };
  14045. module.exports = componentUtil;
  14046. /***/ },
  14047. /* 71 */
  14048. /***/ function(module, exports, __webpack_require__) {
  14049. 'use strict';
  14050. // Layout helpers for each component positioning
  14051. var zrUtil = __webpack_require__(4);
  14052. var BoundingRect = __webpack_require__(9);
  14053. var numberUtil = __webpack_require__(7);
  14054. var formatUtil = __webpack_require__(6);
  14055. var parsePercent = numberUtil.parsePercent;
  14056. var each = zrUtil.each;
  14057. var layout = {};
  14058. /**
  14059. * @public
  14060. */
  14061. var LOCATION_PARAMS = layout.LOCATION_PARAMS = [
  14062. 'left', 'right', 'top', 'bottom', 'width', 'height'
  14063. ];
  14064. /**
  14065. * @public
  14066. */
  14067. var HV_NAMES = layout.HV_NAMES = [
  14068. ['width', 'left', 'right'],
  14069. ['height', 'top', 'bottom']
  14070. ];
  14071. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  14072. var x = 0;
  14073. var y = 0;
  14074. if (maxWidth == null) {
  14075. maxWidth = Infinity;
  14076. }
  14077. if (maxHeight == null) {
  14078. maxHeight = Infinity;
  14079. }
  14080. var currentLineMaxSize = 0;
  14081. group.eachChild(function (child, idx) {
  14082. var position = child.position;
  14083. var rect = child.getBoundingRect();
  14084. var nextChild = group.childAt(idx + 1);
  14085. var nextChildRect = nextChild && nextChild.getBoundingRect();
  14086. var nextX;
  14087. var nextY;
  14088. if (orient === 'horizontal') {
  14089. var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
  14090. nextX = x + moveX;
  14091. // Wrap when width exceeds maxWidth or meet a `newline` group
  14092. if (nextX > maxWidth || child.newline) {
  14093. x = 0;
  14094. nextX = moveX;
  14095. y += currentLineMaxSize + gap;
  14096. currentLineMaxSize = rect.height;
  14097. }
  14098. else {
  14099. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
  14100. }
  14101. }
  14102. else {
  14103. var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
  14104. nextY = y + moveY;
  14105. // Wrap when width exceeds maxHeight or meet a `newline` group
  14106. if (nextY > maxHeight || child.newline) {
  14107. x += currentLineMaxSize + gap;
  14108. y = 0;
  14109. nextY = moveY;
  14110. currentLineMaxSize = rect.width;
  14111. }
  14112. else {
  14113. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
  14114. }
  14115. }
  14116. if (child.newline) {
  14117. return;
  14118. }
  14119. position[0] = x;
  14120. position[1] = y;
  14121. orient === 'horizontal'
  14122. ? (x = nextX + gap)
  14123. : (y = nextY + gap);
  14124. });
  14125. }
  14126. /**
  14127. * VBox or HBox layouting
  14128. * @param {string} orient
  14129. * @param {module:zrender/container/Group} group
  14130. * @param {number} gap
  14131. * @param {number} [width=Infinity]
  14132. * @param {number} [height=Infinity]
  14133. */
  14134. layout.box = boxLayout;
  14135. /**
  14136. * VBox layouting
  14137. * @param {module:zrender/container/Group} group
  14138. * @param {number} gap
  14139. * @param {number} [width=Infinity]
  14140. * @param {number} [height=Infinity]
  14141. */
  14142. layout.vbox = zrUtil.curry(boxLayout, 'vertical');
  14143. /**
  14144. * HBox layouting
  14145. * @param {module:zrender/container/Group} group
  14146. * @param {number} gap
  14147. * @param {number} [width=Infinity]
  14148. * @param {number} [height=Infinity]
  14149. */
  14150. layout.hbox = zrUtil.curry(boxLayout, 'horizontal');
  14151. /**
  14152. * If x or x2 is not specified or 'center' 'left' 'right',
  14153. * the width would be as long as possible.
  14154. * If y or y2 is not specified or 'middle' 'top' 'bottom',
  14155. * the height would be as long as possible.
  14156. *
  14157. * @param {Object} positionInfo
  14158. * @param {number|string} [positionInfo.x]
  14159. * @param {number|string} [positionInfo.y]
  14160. * @param {number|string} [positionInfo.x2]
  14161. * @param {number|string} [positionInfo.y2]
  14162. * @param {Object} containerRect
  14163. * @param {string|number} margin
  14164. * @return {Object} {width, height}
  14165. */
  14166. layout.getAvailableSize = function (positionInfo, containerRect, margin) {
  14167. var containerWidth = containerRect.width;
  14168. var containerHeight = containerRect.height;
  14169. var x = parsePercent(positionInfo.x, containerWidth);
  14170. var y = parsePercent(positionInfo.y, containerHeight);
  14171. var x2 = parsePercent(positionInfo.x2, containerWidth);
  14172. var y2 = parsePercent(positionInfo.y2, containerHeight);
  14173. (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0);
  14174. (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth);
  14175. (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0);
  14176. (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight);
  14177. margin = formatUtil.normalizeCssArray(margin || 0);
  14178. return {
  14179. width: Math.max(x2 - x - margin[1] - margin[3], 0),
  14180. height: Math.max(y2 - y - margin[0] - margin[2], 0)
  14181. };
  14182. };
  14183. /**
  14184. * Parse position info.
  14185. *
  14186. * @param {Object} positionInfo
  14187. * @param {number|string} [positionInfo.left]
  14188. * @param {number|string} [positionInfo.top]
  14189. * @param {number|string} [positionInfo.right]
  14190. * @param {number|string} [positionInfo.bottom]
  14191. * @param {number|string} [positionInfo.width]
  14192. * @param {number|string} [positionInfo.height]
  14193. * @param {number|string} [positionInfo.aspect] Aspect is width / height
  14194. * @param {Object} containerRect
  14195. * @param {string|number} [margin]
  14196. *
  14197. * @return {module:zrender/core/BoundingRect}
  14198. */
  14199. layout.getLayoutRect = function (
  14200. positionInfo, containerRect, margin
  14201. ) {
  14202. margin = formatUtil.normalizeCssArray(margin || 0);
  14203. var containerWidth = containerRect.width;
  14204. var containerHeight = containerRect.height;
  14205. var left = parsePercent(positionInfo.left, containerWidth);
  14206. var top = parsePercent(positionInfo.top, containerHeight);
  14207. var right = parsePercent(positionInfo.right, containerWidth);
  14208. var bottom = parsePercent(positionInfo.bottom, containerHeight);
  14209. var width = parsePercent(positionInfo.width, containerWidth);
  14210. var height = parsePercent(positionInfo.height, containerHeight);
  14211. var verticalMargin = margin[2] + margin[0];
  14212. var horizontalMargin = margin[1] + margin[3];
  14213. var aspect = positionInfo.aspect;
  14214. // If width is not specified, calculate width from left and right
  14215. if (isNaN(width)) {
  14216. width = containerWidth - right - horizontalMargin - left;
  14217. }
  14218. if (isNaN(height)) {
  14219. height = containerHeight - bottom - verticalMargin - top;
  14220. }
  14221. // If width and height are not given
  14222. // 1. Graph should not exceeds the container
  14223. // 2. Aspect must be keeped
  14224. // 3. Graph should take the space as more as possible
  14225. if (isNaN(width) && isNaN(height)) {
  14226. if (aspect > containerWidth / containerHeight) {
  14227. width = containerWidth * 0.8;
  14228. }
  14229. else {
  14230. height = containerHeight * 0.8;
  14231. }
  14232. }
  14233. if (aspect != null) {
  14234. // Calculate width or height with given aspect
  14235. if (isNaN(width)) {
  14236. width = aspect * height;
  14237. }
  14238. if (isNaN(height)) {
  14239. height = width / aspect;
  14240. }
  14241. }
  14242. // If left is not specified, calculate left from right and width
  14243. if (isNaN(left)) {
  14244. left = containerWidth - right - width - horizontalMargin;
  14245. }
  14246. if (isNaN(top)) {
  14247. top = containerHeight - bottom - height - verticalMargin;
  14248. }
  14249. // Align left and top
  14250. switch (positionInfo.left || positionInfo.right) {
  14251. case 'center':
  14252. left = containerWidth / 2 - width / 2 - margin[3];
  14253. break;
  14254. case 'right':
  14255. left = containerWidth - width - horizontalMargin;
  14256. break;
  14257. }
  14258. switch (positionInfo.top || positionInfo.bottom) {
  14259. case 'middle':
  14260. case 'center':
  14261. top = containerHeight / 2 - height / 2 - margin[0];
  14262. break;
  14263. case 'bottom':
  14264. top = containerHeight - height - verticalMargin;
  14265. break;
  14266. }
  14267. // If something is wrong and left, top, width, height are calculated as NaN
  14268. left = left || 0;
  14269. top = top || 0;
  14270. if (isNaN(width)) {
  14271. // Width may be NaN if only one value is given except width
  14272. width = containerWidth - left - (right || 0);
  14273. }
  14274. if (isNaN(height)) {
  14275. // Height may be NaN if only one value is given except height
  14276. height = containerHeight - top - (bottom || 0);
  14277. }
  14278. var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
  14279. rect.margin = margin;
  14280. return rect;
  14281. };
  14282. /**
  14283. * Position a zr element in viewport
  14284. * Group position is specified by either
  14285. * {left, top}, {right, bottom}
  14286. * If all properties exists, right and bottom will be igonred.
  14287. *
  14288. * Logic:
  14289. * 1. Scale (against origin point in parent coord)
  14290. * 2. Rotate (against origin point in parent coord)
  14291. * 3. Traslate (with el.position by this method)
  14292. * So this method only fixes the last step 'Traslate', which does not affect
  14293. * scaling and rotating.
  14294. *
  14295. * If be called repeatly with the same input el, the same result will be gotten.
  14296. *
  14297. * @param {module:zrender/Element} el Should have `getBoundingRect` method.
  14298. * @param {Object} positionInfo
  14299. * @param {number|string} [positionInfo.left]
  14300. * @param {number|string} [positionInfo.top]
  14301. * @param {number|string} [positionInfo.right]
  14302. * @param {number|string} [positionInfo.bottom]
  14303. * @param {Object} containerRect
  14304. * @param {string|number} margin
  14305. * @param {Object} [opt]
  14306. * @param {Array.<number>} [opt.hv=[1,1]] Only horizontal or only vertical.
  14307. * @param {Array.<number>} [opt.boundingMode='all']
  14308. * Specify how to calculate boundingRect when locating.
  14309. * 'all': Position the boundingRect that is transformed and uioned
  14310. * both itself and its descendants.
  14311. * This mode simplies confine the elements in the bounding
  14312. * of their container (e.g., using 'right: 0').
  14313. * 'raw': Position the boundingRect that is not transformed and only itself.
  14314. * This mode is useful when you want a element can overflow its
  14315. * container. (Consider a rotated circle needs to be located in a corner.)
  14316. * In this mode positionInfo.width/height can only be number.
  14317. */
  14318. layout.positionElement = function (el, positionInfo, containerRect, margin, opt) {
  14319. var h = !opt || !opt.hv || opt.hv[0];
  14320. var v = !opt || !opt.hv || opt.hv[1];
  14321. var boundingMode = opt && opt.boundingMode || 'all';
  14322. if (!h && !v) {
  14323. return;
  14324. }
  14325. var rect;
  14326. if (boundingMode === 'raw') {
  14327. rect = el.type === 'group'
  14328. ? new BoundingRect(0, 0, +positionInfo.width || 0, +positionInfo.height || 0)
  14329. : el.getBoundingRect();
  14330. }
  14331. else {
  14332. rect = el.getBoundingRect();
  14333. if (el.needLocalTransform()) {
  14334. var transform = el.getLocalTransform();
  14335. // Notice: raw rect may be inner object of el,
  14336. // which should not be modified.
  14337. rect = rect.clone();
  14338. rect.applyTransform(transform);
  14339. }
  14340. }
  14341. positionInfo = layout.getLayoutRect(
  14342. zrUtil.defaults(
  14343. {width: rect.width, height: rect.height},
  14344. positionInfo
  14345. ),
  14346. containerRect,
  14347. margin
  14348. );
  14349. // Because 'tranlate' is the last step in transform
  14350. // (see zrender/core/Transformable#getLocalTransfrom),
  14351. // we can just only modify el.position to get final result.
  14352. var elPos = el.position;
  14353. var dx = h ? positionInfo.x - rect.x : 0;
  14354. var dy = v ? positionInfo.y - rect.y : 0;
  14355. el.attr('position', boundingMode === 'raw' ? [dx, dy] : [elPos[0] + dx, elPos[1] + dy]);
  14356. };
  14357. /**
  14358. * @param {Object} option Contains some of the properties in HV_NAMES.
  14359. * @param {number} hvIdx 0: horizontal; 1: vertical.
  14360. */
  14361. layout.sizeCalculable = function (option, hvIdx) {
  14362. return option[HV_NAMES[hvIdx][0]] != null
  14363. || (option[HV_NAMES[hvIdx][1]] != null && option[HV_NAMES[hvIdx][2]] != null);
  14364. };
  14365. /**
  14366. * Consider Case:
  14367. * When defulat option has {left: 0, width: 100}, and we set {right: 0}
  14368. * through setOption or media query, using normal zrUtil.merge will cause
  14369. * {right: 0} does not take effect.
  14370. *
  14371. * @example
  14372. * ComponentModel.extend({
  14373. * init: function () {
  14374. * ...
  14375. * var inputPositionParams = layout.getLayoutParams(option);
  14376. * this.mergeOption(inputPositionParams);
  14377. * },
  14378. * mergeOption: function (newOption) {
  14379. * newOption && zrUtil.merge(thisOption, newOption, true);
  14380. * layout.mergeLayoutParam(thisOption, newOption);
  14381. * }
  14382. * });
  14383. *
  14384. * @param {Object} targetOption
  14385. * @param {Object} newOption
  14386. * @param {Object|string} [opt]
  14387. * @param {boolean|Array.<boolean>} [opt.ignoreSize=false] Some component must has width and height.
  14388. */
  14389. layout.mergeLayoutParam = function (targetOption, newOption, opt) {
  14390. !zrUtil.isObject(opt) && (opt = {});
  14391. var ignoreSize = opt.ignoreSize;
  14392. !zrUtil.isArray(ignoreSize) && (ignoreSize = [ignoreSize, ignoreSize]);
  14393. var hResult = merge(HV_NAMES[0], 0);
  14394. var vResult = merge(HV_NAMES[1], 1);
  14395. copy(HV_NAMES[0], targetOption, hResult);
  14396. copy(HV_NAMES[1], targetOption, vResult);
  14397. function merge(names, hvIdx) {
  14398. var newParams = {};
  14399. var newValueCount = 0;
  14400. var merged = {};
  14401. var mergedValueCount = 0;
  14402. var enoughParamNumber = 2;
  14403. each(names, function (name) {
  14404. merged[name] = targetOption[name];
  14405. });
  14406. each(names, function (name) {
  14407. // Consider case: newOption.width is null, which is
  14408. // set by user for removing width setting.
  14409. hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
  14410. hasValue(newParams, name) && newValueCount++;
  14411. hasValue(merged, name) && mergedValueCount++;
  14412. });
  14413. if (ignoreSize[hvIdx]) {
  14414. // Only one of left/right is premitted to exist.
  14415. if (hasValue(newOption, names[1])) {
  14416. merged[names[2]] = null;
  14417. }
  14418. else if (hasValue(newOption, names[2])) {
  14419. merged[names[1]] = null;
  14420. }
  14421. return merged;
  14422. }
  14423. // Case: newOption: {width: ..., right: ...},
  14424. // or targetOption: {right: ...} and newOption: {width: ...},
  14425. // There is no conflict when merged only has params count
  14426. // little than enoughParamNumber.
  14427. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  14428. return merged;
  14429. }
  14430. // Case: newOption: {width: ..., right: ...},
  14431. // Than we can make sure user only want those two, and ignore
  14432. // all origin params in targetOption.
  14433. else if (newValueCount >= enoughParamNumber) {
  14434. return newParams;
  14435. }
  14436. else {
  14437. // Chose another param from targetOption by priority.
  14438. for (var i = 0; i < names.length; i++) {
  14439. var name = names[i];
  14440. if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
  14441. newParams[name] = targetOption[name];
  14442. break;
  14443. }
  14444. }
  14445. return newParams;
  14446. }
  14447. }
  14448. function hasProp(obj, name) {
  14449. return obj.hasOwnProperty(name);
  14450. }
  14451. function hasValue(obj, name) {
  14452. return obj[name] != null && obj[name] !== 'auto';
  14453. }
  14454. function copy(names, target, source) {
  14455. each(names, function (name) {
  14456. target[name] = source[name];
  14457. });
  14458. }
  14459. };
  14460. /**
  14461. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  14462. * @param {Object} source
  14463. * @return {Object} Result contains those props.
  14464. */
  14465. layout.getLayoutParams = function (source) {
  14466. return layout.copyLayoutParams({}, source);
  14467. };
  14468. /**
  14469. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  14470. * @param {Object} source
  14471. * @return {Object} Result contains those props.
  14472. */
  14473. layout.copyLayoutParams = function (target, source) {
  14474. source && target && each(LOCATION_PARAMS, function (name) {
  14475. source.hasOwnProperty(name) && (target[name] = source[name]);
  14476. });
  14477. return target;
  14478. };
  14479. module.exports = layout;
  14480. /***/ },
  14481. /* 72 */
  14482. /***/ function(module, exports) {
  14483. module.exports = {
  14484. getBoxLayoutParams: function () {
  14485. return {
  14486. left: this.get('left'),
  14487. top: this.get('top'),
  14488. right: this.get('right'),
  14489. bottom: this.get('bottom'),
  14490. width: this.get('width'),
  14491. height: this.get('height')
  14492. };
  14493. }
  14494. };
  14495. /***/ },
  14496. /* 73 */
  14497. /***/ function(module, exports) {
  14498. var platform = '';
  14499. // Navigator not exists in node
  14500. if (typeof navigator !== 'undefined') {
  14501. platform = navigator.platform || '';
  14502. }
  14503. module.exports = {
  14504. // 全图默认背景
  14505. // backgroundColor: 'rgba(0,0,0,0)',
  14506. // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization
  14507. // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'],
  14508. // 浅色
  14509. // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
  14510. // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'],
  14511. // 深色
  14512. color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
  14513. // 默认需要 Grid 配置项
  14514. // grid: {},
  14515. // 主题,主题
  14516. textStyle: {
  14517. // color: '#000',
  14518. // decoration: 'none',
  14519. // PENDING
  14520. fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
  14521. // fontFamily: 'Arial, Verdana, sans-serif',
  14522. fontSize: 12,
  14523. fontStyle: 'normal',
  14524. fontWeight: 'normal'
  14525. },
  14526. // http://blogs.adobe.com/webplatform/2014/02/24/using-blend-modes-in-html-canvas/
  14527. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  14528. // Default is source-over
  14529. blendMode: null,
  14530. animation: 'auto',
  14531. animationDuration: 1000,
  14532. animationDurationUpdate: 300,
  14533. animationEasing: 'exponentialOut',
  14534. animationEasingUpdate: 'cubicOut',
  14535. animationThreshold: 2000,
  14536. // Configuration for progressive/incremental rendering
  14537. progressiveThreshold: 3000,
  14538. progressive: 400,
  14539. // Threshold of if use single hover layer to optimize.
  14540. // It is recommended that `hoverLayerThreshold` is equivalent to or less than
  14541. // `progressiveThreshold`, otherwise hover will cause restart of progressive,
  14542. // which is unexpected.
  14543. // see example <echarts/test/heatmap-large.html>.
  14544. hoverLayerThreshold: 3000,
  14545. // See: module:echarts/scale/Time
  14546. useUTC: false
  14547. };
  14548. /***/ },
  14549. /* 74 */
  14550. /***/ function(module, exports, __webpack_require__) {
  14551. var classUtil = __webpack_require__(13);
  14552. var set = classUtil.set;
  14553. var get = classUtil.get;
  14554. module.exports = {
  14555. clearColorPalette: function () {
  14556. set(this, 'colorIdx', 0);
  14557. set(this, 'colorNameMap', {});
  14558. },
  14559. getColorFromPalette: function (name, scope) {
  14560. scope = scope || this;
  14561. var colorIdx = get(scope, 'colorIdx') || 0;
  14562. var colorNameMap = get(scope, 'colorNameMap') || set(scope, 'colorNameMap', {});
  14563. // Use `hasOwnProperty` to avoid conflict with Object.prototype.
  14564. if (colorNameMap.hasOwnProperty(name)) {
  14565. return colorNameMap[name];
  14566. }
  14567. var colorPalette = this.get('color', true) || [];
  14568. if (!colorPalette.length) {
  14569. return;
  14570. }
  14571. var color = colorPalette[colorIdx];
  14572. if (name) {
  14573. colorNameMap[name] = color;
  14574. }
  14575. set(scope, 'colorIdx', (colorIdx + 1) % colorPalette.length);
  14576. return color;
  14577. }
  14578. };
  14579. /***/ },
  14580. /* 75 */
  14581. /***/ function(module, exports, __webpack_require__) {
  14582. 'use strict';
  14583. var zrUtil = __webpack_require__(4);
  14584. var echartsAPIList = [
  14585. 'getDom', 'getZr', 'getWidth', 'getHeight', 'getDevicePixelRatio', 'dispatchAction', 'isDisposed',
  14586. 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption',
  14587. 'getViewOfComponentModel', 'getViewOfSeriesModel'
  14588. ];
  14589. // And `getCoordinateSystems` and `getComponentByElement` will be injected in echarts.js
  14590. function ExtensionAPI(chartInstance) {
  14591. zrUtil.each(echartsAPIList, function (name) {
  14592. this[name] = zrUtil.bind(chartInstance[name], chartInstance);
  14593. }, this);
  14594. }
  14595. module.exports = ExtensionAPI;
  14596. /***/ },
  14597. /* 76 */
  14598. /***/ function(module, exports, __webpack_require__) {
  14599. 'use strict';
  14600. var zrUtil = __webpack_require__(4);
  14601. var coordinateSystemCreators = {};
  14602. function CoordinateSystemManager() {
  14603. this._coordinateSystems = [];
  14604. }
  14605. CoordinateSystemManager.prototype = {
  14606. constructor: CoordinateSystemManager,
  14607. create: function (ecModel, api) {
  14608. var coordinateSystems = [];
  14609. zrUtil.each(coordinateSystemCreators, function (creater, type) {
  14610. var list = creater.create(ecModel, api);
  14611. coordinateSystems = coordinateSystems.concat(list || []);
  14612. });
  14613. this._coordinateSystems = coordinateSystems;
  14614. },
  14615. update: function (ecModel, api) {
  14616. zrUtil.each(this._coordinateSystems, function (coordSys) {
  14617. // FIXME MUST have
  14618. coordSys.update && coordSys.update(ecModel, api);
  14619. });
  14620. },
  14621. getCoordinateSystems: function () {
  14622. return this._coordinateSystems.slice();
  14623. }
  14624. };
  14625. CoordinateSystemManager.register = function (type, coordinateSystemCreator) {
  14626. coordinateSystemCreators[type] = coordinateSystemCreator;
  14627. };
  14628. CoordinateSystemManager.get = function (type) {
  14629. return coordinateSystemCreators[type];
  14630. };
  14631. module.exports = CoordinateSystemManager;
  14632. /***/ },
  14633. /* 77 */
  14634. /***/ function(module, exports, __webpack_require__) {
  14635. /**
  14636. * ECharts option manager
  14637. *
  14638. * @module {echarts/model/OptionManager}
  14639. */
  14640. var zrUtil = __webpack_require__(4);
  14641. var modelUtil = __webpack_require__(5);
  14642. var ComponentModel = __webpack_require__(69);
  14643. var each = zrUtil.each;
  14644. var clone = zrUtil.clone;
  14645. var map = zrUtil.map;
  14646. var merge = zrUtil.merge;
  14647. var QUERY_REG = /^(min|max)?(.+)$/;
  14648. /**
  14649. * TERM EXPLANATIONS:
  14650. *
  14651. * [option]:
  14652. *
  14653. * An object that contains definitions of components. For example:
  14654. * var option = {
  14655. * title: {...},
  14656. * legend: {...},
  14657. * visualMap: {...},
  14658. * series: [
  14659. * {data: [...]},
  14660. * {data: [...]},
  14661. * ...
  14662. * ]
  14663. * };
  14664. *
  14665. * [rawOption]:
  14666. *
  14667. * An object input to echarts.setOption. 'rawOption' may be an
  14668. * 'option', or may be an object contains multi-options. For example:
  14669. * var option = {
  14670. * baseOption: {
  14671. * title: {...},
  14672. * legend: {...},
  14673. * series: [
  14674. * {data: [...]},
  14675. * {data: [...]},
  14676. * ...
  14677. * ]
  14678. * },
  14679. * timeline: {...},
  14680. * options: [
  14681. * {title: {...}, series: {data: [...]}},
  14682. * {title: {...}, series: {data: [...]}},
  14683. * ...
  14684. * ],
  14685. * media: [
  14686. * {
  14687. * query: {maxWidth: 320},
  14688. * option: {series: {x: 20}, visualMap: {show: false}}
  14689. * },
  14690. * {
  14691. * query: {minWidth: 320, maxWidth: 720},
  14692. * option: {series: {x: 500}, visualMap: {show: true}}
  14693. * },
  14694. * {
  14695. * option: {series: {x: 1200}, visualMap: {show: true}}
  14696. * }
  14697. * ]
  14698. * };
  14699. *
  14700. * @alias module:echarts/model/OptionManager
  14701. * @param {module:echarts/ExtensionAPI} api
  14702. */
  14703. function OptionManager(api) {
  14704. /**
  14705. * @private
  14706. * @type {module:echarts/ExtensionAPI}
  14707. */
  14708. this._api = api;
  14709. /**
  14710. * @private
  14711. * @type {Array.<number>}
  14712. */
  14713. this._timelineOptions = [];
  14714. /**
  14715. * @private
  14716. * @type {Array.<Object>}
  14717. */
  14718. this._mediaList = [];
  14719. /**
  14720. * @private
  14721. * @type {Object}
  14722. */
  14723. this._mediaDefault;
  14724. /**
  14725. * -1, means default.
  14726. * empty means no media.
  14727. * @private
  14728. * @type {Array.<number>}
  14729. */
  14730. this._currentMediaIndices = [];
  14731. /**
  14732. * @private
  14733. * @type {Object}
  14734. */
  14735. this._optionBackup;
  14736. /**
  14737. * @private
  14738. * @type {Object}
  14739. */
  14740. this._newBaseOption;
  14741. }
  14742. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  14743. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  14744. // rawOption cloned and backuped when timeline changed, which does no
  14745. // good to performance. What's more, that both timeline and setOption
  14746. // method supply 'notMerge' brings complex and some problems.
  14747. // Consider this case:
  14748. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  14749. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  14750. OptionManager.prototype = {
  14751. constructor: OptionManager,
  14752. /**
  14753. * @public
  14754. * @param {Object} rawOption Raw option.
  14755. * @param {module:echarts/model/Global} ecModel
  14756. * @param {Array.<Function>} optionPreprocessorFuncs
  14757. * @return {Object} Init option
  14758. */
  14759. setOption: function (rawOption, optionPreprocessorFuncs) {
  14760. rawOption = clone(rawOption, true);
  14761. // FIXME
  14762. // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。
  14763. var oldOptionBackup = this._optionBackup;
  14764. var newParsedOption = parseRawOption.call(
  14765. this, rawOption, optionPreprocessorFuncs, !oldOptionBackup
  14766. );
  14767. this._newBaseOption = newParsedOption.baseOption;
  14768. // For setOption at second time (using merge mode);
  14769. if (oldOptionBackup) {
  14770. // Only baseOption can be merged.
  14771. mergeOption(oldOptionBackup.baseOption, newParsedOption.baseOption);
  14772. // For simplicity, timeline options and media options do not support merge,
  14773. // that is, if you `setOption` twice and both has timeline options, the latter
  14774. // timeline opitons will not be merged to the formers, but just substitude them.
  14775. if (newParsedOption.timelineOptions.length) {
  14776. oldOptionBackup.timelineOptions = newParsedOption.timelineOptions;
  14777. }
  14778. if (newParsedOption.mediaList.length) {
  14779. oldOptionBackup.mediaList = newParsedOption.mediaList;
  14780. }
  14781. if (newParsedOption.mediaDefault) {
  14782. oldOptionBackup.mediaDefault = newParsedOption.mediaDefault;
  14783. }
  14784. }
  14785. else {
  14786. this._optionBackup = newParsedOption;
  14787. }
  14788. },
  14789. /**
  14790. * @param {boolean} isRecreate
  14791. * @return {Object}
  14792. */
  14793. mountOption: function (isRecreate) {
  14794. var optionBackup = this._optionBackup;
  14795. // TODO
  14796. // 如果没有reset功能则不clone。
  14797. this._timelineOptions = map(optionBackup.timelineOptions, clone);
  14798. this._mediaList = map(optionBackup.mediaList, clone);
  14799. this._mediaDefault = clone(optionBackup.mediaDefault);
  14800. this._currentMediaIndices = [];
  14801. return clone(isRecreate
  14802. // this._optionBackup.baseOption, which is created at the first `setOption`
  14803. // called, and is merged into every new option by inner method `mergeOption`
  14804. // each time `setOption` called, can be only used in `isRecreate`, because
  14805. // its reliability is under suspicion. In other cases option merge is
  14806. // performed by `model.mergeOption`.
  14807. ? optionBackup.baseOption : this._newBaseOption
  14808. );
  14809. },
  14810. /**
  14811. * @param {module:echarts/model/Global} ecModel
  14812. * @return {Object}
  14813. */
  14814. getTimelineOption: function (ecModel) {
  14815. var option;
  14816. var timelineOptions = this._timelineOptions;
  14817. if (timelineOptions.length) {
  14818. // getTimelineOption can only be called after ecModel inited,
  14819. // so we can get currentIndex from timelineModel.
  14820. var timelineModel = ecModel.getComponent('timeline');
  14821. if (timelineModel) {
  14822. option = clone(
  14823. timelineOptions[timelineModel.getCurrentIndex()],
  14824. true
  14825. );
  14826. }
  14827. }
  14828. return option;
  14829. },
  14830. /**
  14831. * @param {module:echarts/model/Global} ecModel
  14832. * @return {Array.<Object>}
  14833. */
  14834. getMediaOption: function (ecModel) {
  14835. var ecWidth = this._api.getWidth();
  14836. var ecHeight = this._api.getHeight();
  14837. var mediaList = this._mediaList;
  14838. var mediaDefault = this._mediaDefault;
  14839. var indices = [];
  14840. var result = [];
  14841. // No media defined.
  14842. if (!mediaList.length && !mediaDefault) {
  14843. return result;
  14844. }
  14845. // Multi media may be applied, the latter defined media has higher priority.
  14846. for (var i = 0, len = mediaList.length; i < len; i++) {
  14847. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  14848. indices.push(i);
  14849. }
  14850. }
  14851. // FIXME
  14852. // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。
  14853. if (!indices.length && mediaDefault) {
  14854. indices = [-1];
  14855. }
  14856. if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) {
  14857. result = map(indices, function (index) {
  14858. return clone(
  14859. index === -1 ? mediaDefault.option : mediaList[index].option
  14860. );
  14861. });
  14862. }
  14863. // Otherwise return nothing.
  14864. this._currentMediaIndices = indices;
  14865. return result;
  14866. }
  14867. };
  14868. function parseRawOption(rawOption, optionPreprocessorFuncs, isNew) {
  14869. var timelineOptions = [];
  14870. var mediaList = [];
  14871. var mediaDefault;
  14872. var baseOption;
  14873. // Compatible with ec2.
  14874. var timelineOpt = rawOption.timeline;
  14875. if (rawOption.baseOption) {
  14876. baseOption = rawOption.baseOption;
  14877. }
  14878. // For timeline
  14879. if (timelineOpt || rawOption.options) {
  14880. baseOption = baseOption || {};
  14881. timelineOptions = (rawOption.options || []).slice();
  14882. }
  14883. // For media query
  14884. if (rawOption.media) {
  14885. baseOption = baseOption || {};
  14886. var media = rawOption.media;
  14887. each(media, function (singleMedia) {
  14888. if (singleMedia && singleMedia.option) {
  14889. if (singleMedia.query) {
  14890. mediaList.push(singleMedia);
  14891. }
  14892. else if (!mediaDefault) {
  14893. // Use the first media default.
  14894. mediaDefault = singleMedia;
  14895. }
  14896. }
  14897. });
  14898. }
  14899. // For normal option
  14900. if (!baseOption) {
  14901. baseOption = rawOption;
  14902. }
  14903. // Set timelineOpt to baseOption in ec3,
  14904. // which is convenient for merge option.
  14905. if (!baseOption.timeline) {
  14906. baseOption.timeline = timelineOpt;
  14907. }
  14908. // Preprocess.
  14909. each([baseOption].concat(timelineOptions)
  14910. .concat(zrUtil.map(mediaList, function (media) {
  14911. return media.option;
  14912. })),
  14913. function (option) {
  14914. each(optionPreprocessorFuncs, function (preProcess) {
  14915. preProcess(option, isNew);
  14916. });
  14917. }
  14918. );
  14919. return {
  14920. baseOption: baseOption,
  14921. timelineOptions: timelineOptions,
  14922. mediaDefault: mediaDefault,
  14923. mediaList: mediaList
  14924. };
  14925. }
  14926. /**
  14927. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  14928. * Support: width, height, aspectRatio
  14929. * Can use max or min as prefix.
  14930. */
  14931. function applyMediaQuery(query, ecWidth, ecHeight) {
  14932. var realMap = {
  14933. width: ecWidth,
  14934. height: ecHeight,
  14935. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  14936. };
  14937. var applicatable = true;
  14938. zrUtil.each(query, function (value, attr) {
  14939. var matched = attr.match(QUERY_REG);
  14940. if (!matched || !matched[1] || !matched[2]) {
  14941. return;
  14942. }
  14943. var operator = matched[1];
  14944. var realAttr = matched[2].toLowerCase();
  14945. if (!compare(realMap[realAttr], value, operator)) {
  14946. applicatable = false;
  14947. }
  14948. });
  14949. return applicatable;
  14950. }
  14951. function compare(real, expect, operator) {
  14952. if (operator === 'min') {
  14953. return real >= expect;
  14954. }
  14955. else if (operator === 'max') {
  14956. return real <= expect;
  14957. }
  14958. else { // Equals
  14959. return real === expect;
  14960. }
  14961. }
  14962. function indicesEquals(indices1, indices2) {
  14963. // indices is always order by asc and has only finite number.
  14964. return indices1.join(',') === indices2.join(',');
  14965. }
  14966. /**
  14967. * Consider case:
  14968. * `chart.setOption(opt1);`
  14969. * Then user do some interaction like dataZoom, dataView changing.
  14970. * `chart.setOption(opt2);`
  14971. * Then user press 'reset button' in toolbox.
  14972. *
  14973. * After doing that all of the interaction effects should be reset, the
  14974. * chart should be the same as the result of invoke
  14975. * `chart.setOption(opt1); chart.setOption(opt2);`.
  14976. *
  14977. * Although it is not able ensure that
  14978. * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to
  14979. * `chart.setOption(merge(opt1, opt2));` exactly,
  14980. * this might be the only simple way to implement that feature.
  14981. *
  14982. * MEMO: We've considered some other approaches:
  14983. * 1. Each model handle its self restoration but not uniform treatment.
  14984. * (Too complex in logic and error-prone)
  14985. * 2. Use a shadow ecModel. (Performace expensive)
  14986. */
  14987. function mergeOption(oldOption, newOption) {
  14988. newOption = newOption || {};
  14989. each(newOption, function (newCptOpt, mainType) {
  14990. if (newCptOpt == null) {
  14991. return;
  14992. }
  14993. var oldCptOpt = oldOption[mainType];
  14994. if (!ComponentModel.hasClass(mainType)) {
  14995. oldOption[mainType] = merge(oldCptOpt, newCptOpt, true);
  14996. }
  14997. else {
  14998. newCptOpt = modelUtil.normalizeToArray(newCptOpt);
  14999. oldCptOpt = modelUtil.normalizeToArray(oldCptOpt);
  15000. var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt);
  15001. oldOption[mainType] = map(mapResult, function (item) {
  15002. return (item.option && item.exist)
  15003. ? merge(item.exist, item.option, true)
  15004. : (item.exist || item.option);
  15005. });
  15006. }
  15007. });
  15008. }
  15009. module.exports = OptionManager;
  15010. /***/ },
  15011. /* 78 */
  15012. /***/ function(module, exports, __webpack_require__) {
  15013. 'use strict';
  15014. var zrUtil = __webpack_require__(4);
  15015. var formatUtil = __webpack_require__(6);
  15016. var classUtil = __webpack_require__(13);
  15017. var modelUtil = __webpack_require__(5);
  15018. var ComponentModel = __webpack_require__(69);
  15019. var colorPaletteMixin = __webpack_require__(74);
  15020. var env = __webpack_require__(2);
  15021. var layout = __webpack_require__(71);
  15022. var set = classUtil.set;
  15023. var get = classUtil.get;
  15024. var encodeHTML = formatUtil.encodeHTML;
  15025. var addCommas = formatUtil.addCommas;
  15026. var SeriesModel = ComponentModel.extend({
  15027. type: 'series.__base__',
  15028. /**
  15029. * @readOnly
  15030. */
  15031. seriesIndex: 0,
  15032. // coodinateSystem will be injected in the echarts/CoordinateSystem
  15033. coordinateSystem: null,
  15034. /**
  15035. * @type {Object}
  15036. * @protected
  15037. */
  15038. defaultOption: null,
  15039. /**
  15040. * Data provided for legend
  15041. * @type {Function}
  15042. */
  15043. // PENDING
  15044. legendDataProvider: null,
  15045. /**
  15046. * Access path of color for visual
  15047. */
  15048. visualColorAccessPath: 'itemStyle.normal.color',
  15049. /**
  15050. * Support merge layout params.
  15051. * Only support 'box' now (left/right/top/bottom/width/height).
  15052. * @type {string|Object} Object can be {ignoreSize: true}
  15053. * @readOnly
  15054. */
  15055. layoutMode: null,
  15056. init: function (option, parentModel, ecModel, extraOpt) {
  15057. /**
  15058. * @type {number}
  15059. * @readOnly
  15060. */
  15061. this.seriesIndex = this.componentIndex;
  15062. this.mergeDefaultAndTheme(option, ecModel);
  15063. var data = this.getInitialData(option, ecModel);
  15064. if (true) {
  15065. zrUtil.assert(data, 'getInitialData returned invalid data.');
  15066. }
  15067. /**
  15068. * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph}
  15069. * @private
  15070. */
  15071. set(this, 'dataBeforeProcessed', data);
  15072. // If we reverse the order (make data firstly, and then make
  15073. // dataBeforeProcessed by cloneShallow), cloneShallow will
  15074. // cause data.graph.data !== data when using
  15075. // module:echarts/data/Graph or module:echarts/data/Tree.
  15076. // See module:echarts/data/helper/linkList
  15077. this.restoreData();
  15078. },
  15079. /**
  15080. * Util for merge default and theme to option
  15081. * @param {Object} option
  15082. * @param {module:echarts/model/Global} ecModel
  15083. */
  15084. mergeDefaultAndTheme: function (option, ecModel) {
  15085. var layoutMode = this.layoutMode;
  15086. var inputPositionParams = layoutMode
  15087. ? layout.getLayoutParams(option) : {};
  15088. zrUtil.merge(
  15089. option,
  15090. ecModel.getTheme().get(this.subType)
  15091. );
  15092. zrUtil.merge(option, this.getDefaultOption());
  15093. // Default label emphasis `position` and `show`
  15094. // FIXME Set label in mergeOption
  15095. modelUtil.defaultEmphasis(option.label, modelUtil.LABEL_OPTIONS);
  15096. this.fillDataTextStyle(option.data);
  15097. if (layoutMode) {
  15098. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  15099. }
  15100. },
  15101. mergeOption: function (newSeriesOption, ecModel) {
  15102. newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true);
  15103. this.fillDataTextStyle(newSeriesOption.data);
  15104. var layoutMode = this.layoutMode;
  15105. if (layoutMode) {
  15106. layout.mergeLayoutParam(this.option, newSeriesOption, layoutMode);
  15107. }
  15108. var data = this.getInitialData(newSeriesOption, ecModel);
  15109. // TODO Merge data?
  15110. if (data) {
  15111. set(this, 'data', data);
  15112. set(this, 'dataBeforeProcessed', data.cloneShallow());
  15113. }
  15114. },
  15115. fillDataTextStyle: function (data) {
  15116. // Default data label emphasis `position` and `show`
  15117. // FIXME Tree structure data ?
  15118. // FIXME Performance ?
  15119. if (data) {
  15120. for (var i = 0; i < data.length; i++) {
  15121. if (data[i] && data[i].label) {
  15122. modelUtil.defaultEmphasis(data[i].label, modelUtil.LABEL_OPTIONS);
  15123. }
  15124. }
  15125. }
  15126. },
  15127. /**
  15128. * Init a data structure from data related option in series
  15129. * Must be overwritten
  15130. */
  15131. getInitialData: function () {},
  15132. /**
  15133. * @param {string} [dataType]
  15134. * @return {module:echarts/data/List}
  15135. */
  15136. getData: function (dataType) {
  15137. var data = get(this, 'data');
  15138. return dataType == null ? data : data.getLinkedData(dataType);
  15139. },
  15140. /**
  15141. * @param {module:echarts/data/List} data
  15142. */
  15143. setData: function (data) {
  15144. set(this, 'data', data);
  15145. },
  15146. /**
  15147. * Get data before processed
  15148. * @return {module:echarts/data/List}
  15149. */
  15150. getRawData: function () {
  15151. return get(this, 'dataBeforeProcessed');
  15152. },
  15153. /**
  15154. * Coord dimension to data dimension.
  15155. *
  15156. * By default the result is the same as dimensions of series data.
  15157. * But in some series data dimensions are different from coord dimensions (i.e.
  15158. * candlestick and boxplot). Override this method to handle those cases.
  15159. *
  15160. * Coord dimension to data dimension can be one-to-many
  15161. *
  15162. * @param {string} coordDim
  15163. * @return {Array.<string>} dimensions on the axis.
  15164. */
  15165. coordDimToDataDim: function (coordDim) {
  15166. return modelUtil.coordDimToDataDim(this.getData(), coordDim);
  15167. },
  15168. /**
  15169. * Convert data dimension to coord dimension.
  15170. *
  15171. * @param {string|number} dataDim
  15172. * @return {string}
  15173. */
  15174. dataDimToCoordDim: function (dataDim) {
  15175. return modelUtil.dataDimToCoordDim(this.getData(), dataDim);
  15176. },
  15177. /**
  15178. * Get base axis if has coordinate system and has axis.
  15179. * By default use coordSys.getBaseAxis();
  15180. * Can be overrided for some chart.
  15181. * @return {type} description
  15182. */
  15183. getBaseAxis: function () {
  15184. var coordSys = this.coordinateSystem;
  15185. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
  15186. },
  15187. // FIXME
  15188. /**
  15189. * Default tooltip formatter
  15190. *
  15191. * @param {number} dataIndex
  15192. * @param {boolean} [multipleSeries=false]
  15193. * @param {number} [dataType]
  15194. */
  15195. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  15196. function formatArrayValue(value) {
  15197. var vertially = zrUtil.reduce(value, function (vertially, val, idx) {
  15198. var dimItem = data.getDimensionInfo(idx);
  15199. return vertially |= dimItem && dimItem.tooltip !== false && dimItem.tooltipName != null;
  15200. }, 0);
  15201. var result = [];
  15202. var tooltipDims = modelUtil.otherDimToDataDim(data, 'tooltip');
  15203. tooltipDims.length
  15204. ? zrUtil.each(tooltipDims, function (dimIdx) {
  15205. setEachItem(data.get(dimIdx, dataIndex), dimIdx);
  15206. })
  15207. // By default, all dims is used on tooltip.
  15208. : zrUtil.each(value, setEachItem);
  15209. function setEachItem(val, dimIdx) {
  15210. var dimInfo = data.getDimensionInfo(dimIdx);
  15211. // If `dimInfo.tooltip` is not set, show tooltip.
  15212. if (!dimInfo || dimInfo.otherDims.tooltip === false) {
  15213. return;
  15214. }
  15215. var dimType = dimInfo.type;
  15216. var valStr = (vertially ? '- ' + (dimInfo.tooltipName || dimInfo.name) + ': ' : '')
  15217. + (dimType === 'ordinal'
  15218. ? val + ''
  15219. : dimType === 'time'
  15220. ? (multipleSeries ? '' : formatUtil.formatTime('yyyy/MM/dd hh:mm:ss', val))
  15221. : addCommas(val)
  15222. );
  15223. valStr && result.push(encodeHTML(valStr));
  15224. }
  15225. return (vertially ? '<br/>' : '') + result.join(vertially ? '<br/>' : ', ');
  15226. }
  15227. var data = get(this, 'data');
  15228. var value = this.getRawValue(dataIndex);
  15229. var formattedValue = zrUtil.isArray(value)
  15230. ? formatArrayValue(value) : encodeHTML(addCommas(value));
  15231. var name = data.getName(dataIndex);
  15232. var color = data.getItemVisual(dataIndex, 'color');
  15233. if (zrUtil.isObject(color) && color.colorStops) {
  15234. color = (color.colorStops[0] || {}).color;
  15235. }
  15236. color = color || 'transparent';
  15237. var colorEl = formatUtil.getTooltipMarker(color);
  15238. var seriesName = this.name;
  15239. // FIXME
  15240. if (seriesName === '\0-') {
  15241. // Not show '-'
  15242. seriesName = '';
  15243. }
  15244. seriesName = seriesName
  15245. ? encodeHTML(seriesName) + (!multipleSeries ? '<br/>' : ': ')
  15246. : '';
  15247. return !multipleSeries
  15248. ? seriesName + colorEl
  15249. + (name
  15250. ? encodeHTML(name) + ': ' + formattedValue
  15251. : formattedValue
  15252. )
  15253. : colorEl + seriesName + formattedValue;
  15254. },
  15255. /**
  15256. * @return {boolean}
  15257. */
  15258. isAnimationEnabled: function () {
  15259. if (env.node) {
  15260. return false;
  15261. }
  15262. var animationEnabled = this.getShallow('animation');
  15263. if (animationEnabled) {
  15264. if (this.getData().count() > this.getShallow('animationThreshold')) {
  15265. animationEnabled = false;
  15266. }
  15267. }
  15268. return animationEnabled;
  15269. },
  15270. restoreData: function () {
  15271. set(this, 'data', get(this, 'dataBeforeProcessed').cloneShallow());
  15272. },
  15273. getColorFromPalette: function (name, scope) {
  15274. var ecModel = this.ecModel;
  15275. // PENDING
  15276. var color = colorPaletteMixin.getColorFromPalette.call(this, name, scope);
  15277. if (!color) {
  15278. color = ecModel.getColorFromPalette(name, scope);
  15279. }
  15280. return color;
  15281. },
  15282. /**
  15283. * Get data indices for show tooltip content. See tooltip.
  15284. * @abstract
  15285. * @param {Array.<string>|string} dim
  15286. * @param {Array.<number>} value
  15287. * @param {module:echarts/coord/single/SingleAxis} baseAxis
  15288. * @return {Object} {dataIndices, nestestValue}.
  15289. */
  15290. getAxisTooltipData: null,
  15291. /**
  15292. * See tooltip.
  15293. * @abstract
  15294. * @param {number} dataIndex
  15295. * @return {Array.<number>} Point of tooltip. null/undefined can be returned.
  15296. */
  15297. getTooltipPosition: null
  15298. });
  15299. zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin);
  15300. zrUtil.mixin(SeriesModel, colorPaletteMixin);
  15301. module.exports = SeriesModel;
  15302. /***/ },
  15303. /* 79 */
  15304. /***/ function(module, exports, __webpack_require__) {
  15305. var Group = __webpack_require__(48);
  15306. var componentUtil = __webpack_require__(70);
  15307. var clazzUtil = __webpack_require__(13);
  15308. var Component = function () {
  15309. /**
  15310. * @type {module:zrender/container/Group}
  15311. * @readOnly
  15312. */
  15313. this.group = new Group();
  15314. /**
  15315. * @type {string}
  15316. * @readOnly
  15317. */
  15318. this.uid = componentUtil.getUID('viewComponent');
  15319. };
  15320. Component.prototype = {
  15321. constructor: Component,
  15322. init: function (ecModel, api) {},
  15323. render: function (componentModel, ecModel, api, payload) {},
  15324. dispose: function () {}
  15325. };
  15326. var componentProto = Component.prototype;
  15327. componentProto.updateView
  15328. = componentProto.updateLayout
  15329. = componentProto.updateVisual
  15330. = function (seriesModel, ecModel, api, payload) {
  15331. // Do nothing;
  15332. };
  15333. // Enable Component.extend.
  15334. clazzUtil.enableClassExtend(Component);
  15335. // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  15336. clazzUtil.enableClassManagement(Component, {registerWhenExtend: true});
  15337. module.exports = Component;
  15338. /***/ },
  15339. /* 80 */
  15340. /***/ function(module, exports, __webpack_require__) {
  15341. var Group = __webpack_require__(48);
  15342. var componentUtil = __webpack_require__(70);
  15343. var clazzUtil = __webpack_require__(13);
  15344. var modelUtil = __webpack_require__(5);
  15345. var zrUtil = __webpack_require__(4);
  15346. function Chart() {
  15347. /**
  15348. * @type {module:zrender/container/Group}
  15349. * @readOnly
  15350. */
  15351. this.group = new Group();
  15352. /**
  15353. * @type {string}
  15354. * @readOnly
  15355. */
  15356. this.uid = componentUtil.getUID('viewChart');
  15357. }
  15358. Chart.prototype = {
  15359. type: 'chart',
  15360. /**
  15361. * Init the chart
  15362. * @param {module:echarts/model/Global} ecModel
  15363. * @param {module:echarts/ExtensionAPI} api
  15364. */
  15365. init: function (ecModel, api) {},
  15366. /**
  15367. * Render the chart
  15368. * @param {module:echarts/model/Series} seriesModel
  15369. * @param {module:echarts/model/Global} ecModel
  15370. * @param {module:echarts/ExtensionAPI} api
  15371. * @param {Object} payload
  15372. */
  15373. render: function (seriesModel, ecModel, api, payload) {},
  15374. /**
  15375. * Highlight series or specified data item
  15376. * @param {module:echarts/model/Series} seriesModel
  15377. * @param {module:echarts/model/Global} ecModel
  15378. * @param {module:echarts/ExtensionAPI} api
  15379. * @param {Object} payload
  15380. */
  15381. highlight: function (seriesModel, ecModel, api, payload) {
  15382. toggleHighlight(seriesModel.getData(), payload, 'emphasis');
  15383. },
  15384. /**
  15385. * Downplay series or specified data item
  15386. * @param {module:echarts/model/Series} seriesModel
  15387. * @param {module:echarts/model/Global} ecModel
  15388. * @param {module:echarts/ExtensionAPI} api
  15389. * @param {Object} payload
  15390. */
  15391. downplay: function (seriesModel, ecModel, api, payload) {
  15392. toggleHighlight(seriesModel.getData(), payload, 'normal');
  15393. },
  15394. /**
  15395. * Remove self
  15396. * @param {module:echarts/model/Global} ecModel
  15397. * @param {module:echarts/ExtensionAPI} api
  15398. */
  15399. remove: function (ecModel, api) {
  15400. this.group.removeAll();
  15401. },
  15402. /**
  15403. * Dispose self
  15404. * @param {module:echarts/model/Global} ecModel
  15405. * @param {module:echarts/ExtensionAPI} api
  15406. */
  15407. dispose: function () {}
  15408. /**
  15409. * The view contains the given point.
  15410. * @interface
  15411. * @param {Array.<number>} point
  15412. * @return {boolean}
  15413. */
  15414. // containPoint: function () {}
  15415. };
  15416. var chartProto = Chart.prototype;
  15417. chartProto.updateView
  15418. = chartProto.updateLayout
  15419. = chartProto.updateVisual
  15420. = function (seriesModel, ecModel, api, payload) {
  15421. this.render(seriesModel, ecModel, api, payload);
  15422. };
  15423. /**
  15424. * Set state of single element
  15425. * @param {module:zrender/Element} el
  15426. * @param {string} state
  15427. */
  15428. function elSetState(el, state) {
  15429. if (el) {
  15430. el.trigger(state);
  15431. if (el.type === 'group') {
  15432. for (var i = 0; i < el.childCount(); i++) {
  15433. elSetState(el.childAt(i), state);
  15434. }
  15435. }
  15436. }
  15437. }
  15438. /**
  15439. * @param {module:echarts/data/List} data
  15440. * @param {Object} payload
  15441. * @param {string} state 'normal'|'emphasis'
  15442. * @inner
  15443. */
  15444. function toggleHighlight(data, payload, state) {
  15445. var dataIndex = modelUtil.queryDataIndex(data, payload);
  15446. if (dataIndex != null) {
  15447. zrUtil.each(modelUtil.normalizeToArray(dataIndex), function (dataIdx) {
  15448. elSetState(data.getItemGraphicEl(dataIdx), state);
  15449. });
  15450. }
  15451. else {
  15452. data.eachItemGraphicEl(function (el) {
  15453. elSetState(el, state);
  15454. });
  15455. }
  15456. }
  15457. // Enable Chart.extend.
  15458. clazzUtil.enableClassExtend(Chart, ['dispose']);
  15459. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  15460. clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true});
  15461. module.exports = Chart;
  15462. /***/ },
  15463. /* 81 */
  15464. /***/ function(module, exports) {
  15465. var lib = {};
  15466. var ORIGIN_METHOD = '\0__throttleOriginMethod';
  15467. var RATE = '\0__throttleRate';
  15468. var THROTTLE_TYPE = '\0__throttleType';
  15469. /**
  15470. * @public
  15471. * @param {(Function)} fn
  15472. * @param {number} [delay=0] Unit: ms.
  15473. * @param {boolean} [debounce=false]
  15474. * true: If call interval less than `delay`, only the last call works.
  15475. * false: If call interval less than `delay, call works on fixed rate.
  15476. * @return {(Function)} throttled fn.
  15477. */
  15478. lib.throttle = function (fn, delay, debounce) {
  15479. var currCall;
  15480. var lastCall = 0;
  15481. var lastExec = 0;
  15482. var timer = null;
  15483. var diff;
  15484. var scope;
  15485. var args;
  15486. var debounceNextCall;
  15487. delay = delay || 0;
  15488. function exec() {
  15489. lastExec = (new Date()).getTime();
  15490. timer = null;
  15491. fn.apply(scope, args || []);
  15492. }
  15493. var cb = function () {
  15494. currCall = (new Date()).getTime();
  15495. scope = this;
  15496. args = arguments;
  15497. var thisDelay = debounceNextCall || delay;
  15498. var thisDebounce = debounceNextCall || debounce;
  15499. debounceNextCall = null;
  15500. diff = currCall - (thisDebounce ? lastCall : lastExec) - thisDelay;
  15501. clearTimeout(timer);
  15502. if (thisDebounce) {
  15503. timer = setTimeout(exec, thisDelay);
  15504. }
  15505. else {
  15506. if (diff >= 0) {
  15507. exec();
  15508. }
  15509. else {
  15510. timer = setTimeout(exec, -diff);
  15511. }
  15512. }
  15513. lastCall = currCall;
  15514. };
  15515. /**
  15516. * Clear throttle.
  15517. * @public
  15518. */
  15519. cb.clear = function () {
  15520. if (timer) {
  15521. clearTimeout(timer);
  15522. timer = null;
  15523. }
  15524. };
  15525. /**
  15526. * Enable debounce once.
  15527. */
  15528. cb.debounceNextCall = function (debounceDelay) {
  15529. debounceNextCall = debounceDelay;
  15530. };
  15531. return cb;
  15532. };
  15533. /**
  15534. * Create throttle method or update throttle rate.
  15535. *
  15536. * @example
  15537. * ComponentView.prototype.render = function () {
  15538. * ...
  15539. * throttle.createOrUpdate(
  15540. * this,
  15541. * '_dispatchAction',
  15542. * this.model.get('throttle'),
  15543. * 'fixRate'
  15544. * );
  15545. * };
  15546. * ComponentView.prototype.remove = function () {
  15547. * throttle.clear(this, '_dispatchAction');
  15548. * };
  15549. * ComponentView.prototype.dispose = function () {
  15550. * throttle.clear(this, '_dispatchAction');
  15551. * };
  15552. *
  15553. * @public
  15554. * @param {Object} obj
  15555. * @param {string} fnAttr
  15556. * @param {number} [rate]
  15557. * @param {string} [throttleType='fixRate'] 'fixRate' or 'debounce'
  15558. * @return {Function} throttled function.
  15559. */
  15560. lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) {
  15561. var fn = obj[fnAttr];
  15562. if (!fn) {
  15563. return;
  15564. }
  15565. var originFn = fn[ORIGIN_METHOD] || fn;
  15566. var lastThrottleType = fn[THROTTLE_TYPE];
  15567. var lastRate = fn[RATE];
  15568. if (lastRate !== rate || lastThrottleType !== throttleType) {
  15569. if (rate == null || !throttleType) {
  15570. return (obj[fnAttr] = originFn);
  15571. }
  15572. fn = obj[fnAttr] = lib.throttle(
  15573. originFn, rate, throttleType === 'debounce'
  15574. );
  15575. fn[ORIGIN_METHOD] = originFn;
  15576. fn[THROTTLE_TYPE] = throttleType;
  15577. fn[RATE] = rate;
  15578. }
  15579. return fn;
  15580. };
  15581. /**
  15582. * Clear throttle. Example see throttle.createOrUpdate.
  15583. *
  15584. * @public
  15585. * @param {Object} obj
  15586. * @param {string} fnAttr
  15587. */
  15588. lib.clear = function (obj, fnAttr) {
  15589. var fn = obj[fnAttr];
  15590. if (fn && fn[ORIGIN_METHOD]) {
  15591. obj[fnAttr] = fn[ORIGIN_METHOD];
  15592. }
  15593. };
  15594. module.exports = lib;
  15595. /***/ },
  15596. /* 82 */
  15597. /***/ function(module, exports, __webpack_require__) {
  15598. /*!
  15599. * ZRender, a high performance 2d drawing library.
  15600. *
  15601. * Copyright (c) 2013, Baidu Inc.
  15602. * All rights reserved.
  15603. *
  15604. * LICENSE
  15605. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  15606. */
  15607. // Global defines
  15608. var guid = __webpack_require__(24);
  15609. var env = __webpack_require__(2);
  15610. var zrUtil = __webpack_require__(4);
  15611. var Handler = __webpack_require__(83);
  15612. var Storage = __webpack_require__(85);
  15613. var Animation = __webpack_require__(87);
  15614. var HandlerProxy = __webpack_require__(90);
  15615. var useVML = !env.canvasSupported;
  15616. var painterCtors = {
  15617. canvas: __webpack_require__(92)
  15618. };
  15619. var instances = {}; // ZRender实例map索引
  15620. var zrender = {};
  15621. /**
  15622. * @type {string}
  15623. */
  15624. zrender.version = '3.5.2';
  15625. /**
  15626. * Initializing a zrender instance
  15627. * @param {HTMLElement} dom
  15628. * @param {Object} opts
  15629. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  15630. * @param {number} [opts.devicePixelRatio]
  15631. * @param {number|string} [opts.width] Can be 'auto' (the same as null/undefined)
  15632. * @param {number|string} [opts.height] Can be 'auto' (the same as null/undefined)
  15633. * @return {module:zrender/ZRender}
  15634. */
  15635. zrender.init = function(dom, opts) {
  15636. var zr = new ZRender(guid(), dom, opts);
  15637. instances[zr.id] = zr;
  15638. return zr;
  15639. };
  15640. /**
  15641. * Dispose zrender instance
  15642. * @param {module:zrender/ZRender} zr
  15643. */
  15644. zrender.dispose = function (zr) {
  15645. if (zr) {
  15646. zr.dispose();
  15647. }
  15648. else {
  15649. for (var key in instances) {
  15650. if (instances.hasOwnProperty(key)) {
  15651. instances[key].dispose();
  15652. }
  15653. }
  15654. instances = {};
  15655. }
  15656. return zrender;
  15657. };
  15658. /**
  15659. * Get zrender instance by id
  15660. * @param {string} id zrender instance id
  15661. * @return {module:zrender/ZRender}
  15662. */
  15663. zrender.getInstance = function (id) {
  15664. return instances[id];
  15665. };
  15666. zrender.registerPainter = function (name, Ctor) {
  15667. painterCtors[name] = Ctor;
  15668. };
  15669. function delInstance(id) {
  15670. delete instances[id];
  15671. }
  15672. /**
  15673. * @module zrender/ZRender
  15674. */
  15675. /**
  15676. * @constructor
  15677. * @alias module:zrender/ZRender
  15678. * @param {string} id
  15679. * @param {HTMLDomElement} dom
  15680. * @param {Object} opts
  15681. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  15682. * @param {number} [opts.devicePixelRatio]
  15683. * @param {number} [opts.width] Can be 'auto' (the same as null/undefined)
  15684. * @param {number} [opts.height] Can be 'auto' (the same as null/undefined)
  15685. */
  15686. var ZRender = function(id, dom, opts) {
  15687. opts = opts || {};
  15688. /**
  15689. * @type {HTMLDomElement}
  15690. */
  15691. this.dom = dom;
  15692. /**
  15693. * @type {string}
  15694. */
  15695. this.id = id;
  15696. var self = this;
  15697. var storage = new Storage();
  15698. var rendererType = opts.renderer;
  15699. // TODO WebGL
  15700. if (useVML) {
  15701. if (!painterCtors.vml) {
  15702. throw new Error('You need to require \'zrender/vml/vml\' to support IE8');
  15703. }
  15704. rendererType = 'vml';
  15705. }
  15706. else if (!rendererType || !painterCtors[rendererType]) {
  15707. rendererType = 'canvas';
  15708. }
  15709. var painter = new painterCtors[rendererType](dom, storage, opts);
  15710. this.storage = storage;
  15711. this.painter = painter;
  15712. var handerProxy = !env.node ? new HandlerProxy(painter.getViewportRoot()) : null;
  15713. this.handler = new Handler(storage, painter, handerProxy, painter.root);
  15714. /**
  15715. * @type {module:zrender/animation/Animation}
  15716. */
  15717. this.animation = new Animation({
  15718. stage: {
  15719. update: zrUtil.bind(this.flush, this)
  15720. }
  15721. });
  15722. this.animation.start();
  15723. /**
  15724. * @type {boolean}
  15725. * @private
  15726. */
  15727. this._needsRefresh;
  15728. // 修改 storage.delFromStorage, 每次删除元素之前删除动画
  15729. // FIXME 有点ugly
  15730. var oldDelFromStorage = storage.delFromStorage;
  15731. var oldAddToStorage = storage.addToStorage;
  15732. storage.delFromStorage = function (el) {
  15733. oldDelFromStorage.call(storage, el);
  15734. el && el.removeSelfFromZr(self);
  15735. };
  15736. storage.addToStorage = function (el) {
  15737. oldAddToStorage.call(storage, el);
  15738. el.addSelfToZr(self);
  15739. };
  15740. };
  15741. ZRender.prototype = {
  15742. constructor: ZRender,
  15743. /**
  15744. * 获取实例唯一标识
  15745. * @return {string}
  15746. */
  15747. getId: function () {
  15748. return this.id;
  15749. },
  15750. /**
  15751. * 添加元素
  15752. * @param {module:zrender/Element} el
  15753. */
  15754. add: function (el) {
  15755. this.storage.addRoot(el);
  15756. this._needsRefresh = true;
  15757. },
  15758. /**
  15759. * 删除元素
  15760. * @param {module:zrender/Element} el
  15761. */
  15762. remove: function (el) {
  15763. this.storage.delRoot(el);
  15764. this._needsRefresh = true;
  15765. },
  15766. /**
  15767. * Change configuration of layer
  15768. * @param {string} zLevel
  15769. * @param {Object} config
  15770. * @param {string} [config.clearColor=0] Clear color
  15771. * @param {string} [config.motionBlur=false] If enable motion blur
  15772. * @param {number} [config.lastFrameAlpha=0.7] Motion blur factor. Larger value cause longer trailer
  15773. */
  15774. configLayer: function (zLevel, config) {
  15775. this.painter.configLayer(zLevel, config);
  15776. this._needsRefresh = true;
  15777. },
  15778. /**
  15779. * Repaint the canvas immediately
  15780. */
  15781. refreshImmediately: function () {
  15782. // Clear needsRefresh ahead to avoid something wrong happens in refresh
  15783. // Or it will cause zrender refreshes again and again.
  15784. this._needsRefresh = false;
  15785. this.painter.refresh();
  15786. /**
  15787. * Avoid trigger zr.refresh in Element#beforeUpdate hook
  15788. */
  15789. this._needsRefresh = false;
  15790. },
  15791. /**
  15792. * Mark and repaint the canvas in the next frame of browser
  15793. */
  15794. refresh: function() {
  15795. this._needsRefresh = true;
  15796. },
  15797. /**
  15798. * Perform all refresh
  15799. */
  15800. flush: function () {
  15801. if (this._needsRefresh) {
  15802. this.refreshImmediately();
  15803. }
  15804. if (this._needsRefreshHover) {
  15805. this.refreshHoverImmediately();
  15806. }
  15807. },
  15808. /**
  15809. * Add element to hover layer
  15810. * @param {module:zrender/Element} el
  15811. * @param {Object} style
  15812. */
  15813. addHover: function (el, style) {
  15814. if (this.painter.addHover) {
  15815. this.painter.addHover(el, style);
  15816. this.refreshHover();
  15817. }
  15818. },
  15819. /**
  15820. * Add element from hover layer
  15821. * @param {module:zrender/Element} el
  15822. */
  15823. removeHover: function (el) {
  15824. if (this.painter.removeHover) {
  15825. this.painter.removeHover(el);
  15826. this.refreshHover();
  15827. }
  15828. },
  15829. /**
  15830. * Clear all hover elements in hover layer
  15831. * @param {module:zrender/Element} el
  15832. */
  15833. clearHover: function () {
  15834. if (this.painter.clearHover) {
  15835. this.painter.clearHover();
  15836. this.refreshHover();
  15837. }
  15838. },
  15839. /**
  15840. * Refresh hover in next frame
  15841. */
  15842. refreshHover: function () {
  15843. this._needsRefreshHover = true;
  15844. },
  15845. /**
  15846. * Refresh hover immediately
  15847. */
  15848. refreshHoverImmediately: function () {
  15849. this._needsRefreshHover = false;
  15850. this.painter.refreshHover && this.painter.refreshHover();
  15851. },
  15852. /**
  15853. * Resize the canvas.
  15854. * Should be invoked when container size is changed
  15855. * @param {Object} [opts]
  15856. * @param {number|string} [opts.width] Can be 'auto' (the same as null/undefined)
  15857. * @param {number|string} [opts.height] Can be 'auto' (the same as null/undefined)
  15858. */
  15859. resize: function(opts) {
  15860. opts = opts || {};
  15861. this.painter.resize(opts.width, opts.height);
  15862. this.handler.resize();
  15863. },
  15864. /**
  15865. * Stop and clear all animation immediately
  15866. */
  15867. clearAnimation: function () {
  15868. this.animation.clear();
  15869. },
  15870. /**
  15871. * Get container width
  15872. */
  15873. getWidth: function() {
  15874. return this.painter.getWidth();
  15875. },
  15876. /**
  15877. * Get container height
  15878. */
  15879. getHeight: function() {
  15880. return this.painter.getHeight();
  15881. },
  15882. /**
  15883. * Export the canvas as Base64 URL
  15884. * @param {string} type
  15885. * @param {string} [backgroundColor='#fff']
  15886. * @return {string} Base64 URL
  15887. */
  15888. // toDataURL: function(type, backgroundColor) {
  15889. // return this.painter.getRenderedCanvas({
  15890. // backgroundColor: backgroundColor
  15891. // }).toDataURL(type);
  15892. // },
  15893. /**
  15894. * Converting a path to image.
  15895. * It has much better performance of drawing image rather than drawing a vector path.
  15896. * @param {module:zrender/graphic/Path} e
  15897. * @param {number} width
  15898. * @param {number} height
  15899. */
  15900. pathToImage: function(e, dpr) {
  15901. return this.painter.pathToImage(e, dpr);
  15902. },
  15903. /**
  15904. * Set default cursor
  15905. * @param {string} [cursorStyle='default'] 例如 crosshair
  15906. */
  15907. setCursorStyle: function (cursorStyle) {
  15908. this.handler.setCursorStyle(cursorStyle);
  15909. },
  15910. /**
  15911. * Find hovered element
  15912. * @param {number} x
  15913. * @param {number} y
  15914. * @return {Object} {target, topTarget}
  15915. */
  15916. findHover: function (x, y) {
  15917. return this.handler.findHover(x, y);
  15918. },
  15919. /**
  15920. * Bind event
  15921. *
  15922. * @param {string} eventName Event name
  15923. * @param {Function} eventHandler Handler function
  15924. * @param {Object} [context] Context object
  15925. */
  15926. on: function(eventName, eventHandler, context) {
  15927. this.handler.on(eventName, eventHandler, context);
  15928. },
  15929. /**
  15930. * Unbind event
  15931. * @param {string} eventName Event name
  15932. * @param {Function} [eventHandler] Handler function
  15933. */
  15934. off: function(eventName, eventHandler) {
  15935. this.handler.off(eventName, eventHandler);
  15936. },
  15937. /**
  15938. * Trigger event manually
  15939. *
  15940. * @param {string} eventName Event name
  15941. * @param {event=} event Event object
  15942. */
  15943. trigger: function (eventName, event) {
  15944. this.handler.trigger(eventName, event);
  15945. },
  15946. /**
  15947. * Clear all objects and the canvas.
  15948. */
  15949. clear: function () {
  15950. this.storage.delRoot();
  15951. this.painter.clear();
  15952. },
  15953. /**
  15954. * Dispose self.
  15955. */
  15956. dispose: function () {
  15957. this.animation.stop();
  15958. this.clear();
  15959. this.storage.dispose();
  15960. this.painter.dispose();
  15961. this.handler.dispose();
  15962. this.animation =
  15963. this.storage =
  15964. this.painter =
  15965. this.handler = null;
  15966. delInstance(this.id);
  15967. }
  15968. };
  15969. module.exports = zrender;
  15970. /***/ },
  15971. /* 83 */
  15972. /***/ function(module, exports, __webpack_require__) {
  15973. 'use strict';
  15974. /**
  15975. * Handler
  15976. * @module zrender/Handler
  15977. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  15978. * errorrik (errorrik@gmail.com)
  15979. * pissang (shenyi.914@gmail.com)
  15980. */
  15981. var util = __webpack_require__(4);
  15982. var Draggable = __webpack_require__(84);
  15983. var Eventful = __webpack_require__(25);
  15984. var SILENT = 'silent';
  15985. function makeEventPacket(eveType, targetInfo, event) {
  15986. return {
  15987. type: eveType,
  15988. event: event,
  15989. // target can only be an element that is not silent.
  15990. target: targetInfo.target,
  15991. // topTarget can be a silent element.
  15992. topTarget: targetInfo.topTarget,
  15993. cancelBubble: false,
  15994. offsetX: event.zrX,
  15995. offsetY: event.zrY,
  15996. gestureEvent: event.gestureEvent,
  15997. pinchX: event.pinchX,
  15998. pinchY: event.pinchY,
  15999. pinchScale: event.pinchScale,
  16000. wheelDelta: event.zrDelta,
  16001. zrByTouch: event.zrByTouch
  16002. };
  16003. }
  16004. function EmptyProxy () {}
  16005. EmptyProxy.prototype.dispose = function () {};
  16006. var handlerNames = [
  16007. 'click', 'dblclick', 'mousewheel', 'mouseout',
  16008. 'mouseup', 'mousedown', 'mousemove', 'contextmenu'
  16009. ];
  16010. /**
  16011. * @alias module:zrender/Handler
  16012. * @constructor
  16013. * @extends module:zrender/mixin/Eventful
  16014. * @param {module:zrender/Storage} storage Storage instance.
  16015. * @param {module:zrender/Painter} painter Painter instance.
  16016. * @param {module:zrender/dom/HandlerProxy} proxy HandlerProxy instance.
  16017. * @param {HTMLElement} painterRoot painter.root (not painter.getViewportRoot()).
  16018. */
  16019. var Handler = function(storage, painter, proxy, painterRoot) {
  16020. Eventful.call(this);
  16021. this.storage = storage;
  16022. this.painter = painter;
  16023. this.painterRoot = painterRoot;
  16024. proxy = proxy || new EmptyProxy();
  16025. /**
  16026. * Proxy of event. can be Dom, WebGLSurface, etc.
  16027. */
  16028. this.proxy = proxy;
  16029. // Attach handler
  16030. proxy.handler = this;
  16031. /**
  16032. * {target, topTarget}
  16033. * @private
  16034. * @type {Object}
  16035. */
  16036. this._hovered = {};
  16037. /**
  16038. * @private
  16039. * @type {Date}
  16040. */
  16041. this._lastTouchMoment;
  16042. /**
  16043. * @private
  16044. * @type {number}
  16045. */
  16046. this._lastX;
  16047. /**
  16048. * @private
  16049. * @type {number}
  16050. */
  16051. this._lastY;
  16052. Draggable.call(this);
  16053. util.each(handlerNames, function (name) {
  16054. proxy.on && proxy.on(name, this[name], this);
  16055. }, this);
  16056. };
  16057. Handler.prototype = {
  16058. constructor: Handler,
  16059. mousemove: function (event) {
  16060. var x = event.zrX;
  16061. var y = event.zrY;
  16062. var lastHovered = this._hovered;
  16063. var hovered = this._hovered = this.findHover(x, y);
  16064. var hoveredTarget = hovered.target;
  16065. var lastHoveredTarget = lastHovered.target;
  16066. var proxy = this.proxy;
  16067. proxy.setCursor && proxy.setCursor(hoveredTarget ? hoveredTarget.cursor : 'default');
  16068. // Mouse out on previous hovered element
  16069. if (lastHoveredTarget && hoveredTarget !== lastHoveredTarget && lastHoveredTarget.__zr) {
  16070. this.dispatchToElement(lastHovered, 'mouseout', event);
  16071. }
  16072. // Mouse moving on one element
  16073. this.dispatchToElement(hovered, 'mousemove', event);
  16074. // Mouse over on a new element
  16075. if (hoveredTarget && hoveredTarget !== lastHoveredTarget) {
  16076. this.dispatchToElement(hovered, 'mouseover', event);
  16077. }
  16078. },
  16079. mouseout: function (event) {
  16080. this.dispatchToElement(this._hovered, 'mouseout', event);
  16081. // There might be some doms created by upper layer application
  16082. // at the same level of painter.getViewportRoot() (e.g., tooltip
  16083. // dom created by echarts), where 'globalout' event should not
  16084. // be triggered when mouse enters these doms. (But 'mouseout'
  16085. // should be triggered at the original hovered element as usual).
  16086. var element = event.toElement || event.relatedTarget;
  16087. var innerDom;
  16088. do {
  16089. element = element && element.parentNode;
  16090. }
  16091. while (element && element.nodeType != 9 && !(
  16092. innerDom = element === this.painterRoot
  16093. ));
  16094. !innerDom && this.trigger('globalout', {event: event});
  16095. },
  16096. /**
  16097. * Resize
  16098. */
  16099. resize: function (event) {
  16100. this._hovered = {};
  16101. },
  16102. /**
  16103. * Dispatch event
  16104. * @param {string} eventName
  16105. * @param {event=} eventArgs
  16106. */
  16107. dispatch: function (eventName, eventArgs) {
  16108. var handler = this[eventName];
  16109. handler && handler.call(this, eventArgs);
  16110. },
  16111. /**
  16112. * Dispose
  16113. */
  16114. dispose: function () {
  16115. this.proxy.dispose();
  16116. this.storage =
  16117. this.proxy =
  16118. this.painter = null;
  16119. },
  16120. /**
  16121. * 设置默认的cursor style
  16122. * @param {string} [cursorStyle='default'] 例如 crosshair
  16123. */
  16124. setCursorStyle: function (cursorStyle) {
  16125. var proxy = this.proxy;
  16126. proxy.setCursor && proxy.setCursor(cursorStyle);
  16127. },
  16128. /**
  16129. * 事件分发代理
  16130. *
  16131. * @private
  16132. * @param {Object} targetInfo {target, topTarget} 目标图形元素
  16133. * @param {string} eventName 事件名称
  16134. * @param {Object} event 事件对象
  16135. */
  16136. dispatchToElement: function (targetInfo, eventName, event) {
  16137. targetInfo = targetInfo || {};
  16138. var eventHandler = 'on' + eventName;
  16139. var eventPacket = makeEventPacket(eventName, targetInfo, event);
  16140. var el = targetInfo.target;
  16141. while (el) {
  16142. el[eventHandler]
  16143. && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket));
  16144. el.trigger(eventName, eventPacket);
  16145. el = el.parent;
  16146. if (eventPacket.cancelBubble) {
  16147. break;
  16148. }
  16149. }
  16150. if (!eventPacket.cancelBubble) {
  16151. // 冒泡到顶级 zrender 对象
  16152. this.trigger(eventName, eventPacket);
  16153. // 分发事件到用户自定义层
  16154. // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在
  16155. this.painter && this.painter.eachOtherLayer(function (layer) {
  16156. if (typeof(layer[eventHandler]) == 'function') {
  16157. layer[eventHandler].call(layer, eventPacket);
  16158. }
  16159. if (layer.trigger) {
  16160. layer.trigger(eventName, eventPacket);
  16161. }
  16162. });
  16163. }
  16164. },
  16165. /**
  16166. * @private
  16167. * @param {number} x
  16168. * @param {number} y
  16169. * @param {module:zrender/graphic/Displayable} exclude
  16170. * @return {model:zrender/Element}
  16171. * @method
  16172. */
  16173. findHover: function(x, y, exclude) {
  16174. var list = this.storage.getDisplayList();
  16175. var out = {};
  16176. for (var i = list.length - 1; i >= 0 ; i--) {
  16177. var hoverCheckResult;
  16178. if (list[i] !== exclude
  16179. // getDisplayList may include ignored item in VML mode
  16180. && !list[i].ignore
  16181. && (hoverCheckResult = isHover(list[i], x, y))
  16182. ) {
  16183. !out.topTarget && (out.topTarget = list[i]);
  16184. if (hoverCheckResult !== SILENT) {
  16185. out.target = list[i];
  16186. break;
  16187. }
  16188. }
  16189. }
  16190. return out;
  16191. }
  16192. };
  16193. // Common handlers
  16194. util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
  16195. Handler.prototype[name] = function (event) {
  16196. // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover
  16197. var hovered = this.findHover(event.zrX, event.zrY);
  16198. var hoveredTarget = hovered.target;
  16199. if (name === 'mousedown') {
  16200. this._downel = hoveredTarget;
  16201. // In case click triggered before mouseup
  16202. this._upel = hoveredTarget;
  16203. }
  16204. else if (name === 'mosueup') {
  16205. this._upel = hoveredTarget;
  16206. }
  16207. else if (name === 'click') {
  16208. if (this._downel !== this._upel) {
  16209. return;
  16210. }
  16211. }
  16212. this.dispatchToElement(hovered, name, event);
  16213. };
  16214. });
  16215. function isHover(displayable, x, y) {
  16216. if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) {
  16217. var el = displayable;
  16218. var isSilent;
  16219. while (el) {
  16220. // If clipped by ancestor.
  16221. // FIXME: If clipPath has neither stroke nor fill,
  16222. // el.clipPath.contain(x, y) will always return false.
  16223. if (el.clipPath && !el.clipPath.contain(x, y)) {
  16224. return false;
  16225. }
  16226. if (el.silent) {
  16227. isSilent = true;
  16228. }
  16229. el = el.parent;
  16230. }
  16231. return isSilent ? SILENT : true;
  16232. }
  16233. return false;
  16234. }
  16235. util.mixin(Handler, Eventful);
  16236. util.mixin(Handler, Draggable);
  16237. module.exports = Handler;
  16238. /***/ },
  16239. /* 84 */
  16240. /***/ function(module, exports) {
  16241. // TODO Draggable for group
  16242. // FIXME Draggable on element which has parent rotation or scale
  16243. function Draggable() {
  16244. this.on('mousedown', this._dragStart, this);
  16245. this.on('mousemove', this._drag, this);
  16246. this.on('mouseup', this._dragEnd, this);
  16247. this.on('globalout', this._dragEnd, this);
  16248. // this._dropTarget = null;
  16249. // this._draggingTarget = null;
  16250. // this._x = 0;
  16251. // this._y = 0;
  16252. }
  16253. Draggable.prototype = {
  16254. constructor: Draggable,
  16255. _dragStart: function (e) {
  16256. var draggingTarget = e.target;
  16257. if (draggingTarget && draggingTarget.draggable) {
  16258. this._draggingTarget = draggingTarget;
  16259. draggingTarget.dragging = true;
  16260. this._x = e.offsetX;
  16261. this._y = e.offsetY;
  16262. this.dispatchToElement(param(draggingTarget, e), 'dragstart', e.event);
  16263. }
  16264. },
  16265. _drag: function (e) {
  16266. var draggingTarget = this._draggingTarget;
  16267. if (draggingTarget) {
  16268. var x = e.offsetX;
  16269. var y = e.offsetY;
  16270. var dx = x - this._x;
  16271. var dy = y - this._y;
  16272. this._x = x;
  16273. this._y = y;
  16274. draggingTarget.drift(dx, dy, e);
  16275. this.dispatchToElement(param(draggingTarget, e), 'drag', e.event);
  16276. var dropTarget = this.findHover(x, y, draggingTarget).target;
  16277. var lastDropTarget = this._dropTarget;
  16278. this._dropTarget = dropTarget;
  16279. if (draggingTarget !== dropTarget) {
  16280. if (lastDropTarget && dropTarget !== lastDropTarget) {
  16281. this.dispatchToElement(param(lastDropTarget, e), 'dragleave', e.event);
  16282. }
  16283. if (dropTarget && dropTarget !== lastDropTarget) {
  16284. this.dispatchToElement(param(dropTarget, e), 'dragenter', e.event);
  16285. }
  16286. }
  16287. }
  16288. },
  16289. _dragEnd: function (e) {
  16290. var draggingTarget = this._draggingTarget;
  16291. if (draggingTarget) {
  16292. draggingTarget.dragging = false;
  16293. }
  16294. this.dispatchToElement(param(draggingTarget, e), 'dragend', e.event);
  16295. if (this._dropTarget) {
  16296. this.dispatchToElement(param(this._dropTarget, e), 'drop', e.event);
  16297. }
  16298. this._draggingTarget = null;
  16299. this._dropTarget = null;
  16300. }
  16301. };
  16302. function param(target, e) {
  16303. return {target: target, topTarget: e && e.topTarget};
  16304. }
  16305. module.exports = Draggable;
  16306. /***/ },
  16307. /* 85 */
  16308. /***/ function(module, exports, __webpack_require__) {
  16309. 'use strict';
  16310. /**
  16311. * Storage内容仓库模块
  16312. * @module zrender/Storage
  16313. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  16314. * @author errorrik (errorrik@gmail.com)
  16315. * @author pissang (https://github.com/pissang/)
  16316. */
  16317. var util = __webpack_require__(4);
  16318. var env = __webpack_require__(2);
  16319. var Group = __webpack_require__(48);
  16320. // Use timsort because in most case elements are partially sorted
  16321. // https://jsfiddle.net/pissang/jr4x7mdm/8/
  16322. var timsort = __webpack_require__(86);
  16323. function shapeCompareFunc(a, b) {
  16324. if (a.zlevel === b.zlevel) {
  16325. if (a.z === b.z) {
  16326. // if (a.z2 === b.z2) {
  16327. // // FIXME Slow has renderidx compare
  16328. // // http://stackoverflow.com/questions/20883421/sorting-in-javascript-should-every-compare-function-have-a-return-0-statement
  16329. // // https://github.com/v8/v8/blob/47cce544a31ed5577ffe2963f67acb4144ee0232/src/js/array.js#L1012
  16330. // return a.__renderidx - b.__renderidx;
  16331. // }
  16332. return a.z2 - b.z2;
  16333. }
  16334. return a.z - b.z;
  16335. }
  16336. return a.zlevel - b.zlevel;
  16337. }
  16338. /**
  16339. * 内容仓库 (M)
  16340. * @alias module:zrender/Storage
  16341. * @constructor
  16342. */
  16343. var Storage = function () {
  16344. this._roots = [];
  16345. this._displayList = [];
  16346. this._displayListLen = 0;
  16347. };
  16348. Storage.prototype = {
  16349. constructor: Storage,
  16350. /**
  16351. * @param {Function} cb
  16352. *
  16353. */
  16354. traverse: function (cb, context) {
  16355. for (var i = 0; i < this._roots.length; i++) {
  16356. this._roots[i].traverse(cb, context);
  16357. }
  16358. },
  16359. /**
  16360. * 返回所有图形的绘制队列
  16361. * @param {boolean} [update=false] 是否在返回前更新该数组
  16362. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效
  16363. *
  16364. * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList}
  16365. * @return {Array.<module:zrender/graphic/Displayable>}
  16366. */
  16367. getDisplayList: function (update, includeIgnore) {
  16368. includeIgnore = includeIgnore || false;
  16369. if (update) {
  16370. this.updateDisplayList(includeIgnore);
  16371. }
  16372. return this._displayList;
  16373. },
  16374. /**
  16375. * 更新图形的绘制队列。
  16376. * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中,
  16377. * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列
  16378. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组
  16379. */
  16380. updateDisplayList: function (includeIgnore) {
  16381. this._displayListLen = 0;
  16382. var roots = this._roots;
  16383. var displayList = this._displayList;
  16384. for (var i = 0, len = roots.length; i < len; i++) {
  16385. this._updateAndAddDisplayable(roots[i], null, includeIgnore);
  16386. }
  16387. displayList.length = this._displayListLen;
  16388. // for (var i = 0, len = displayList.length; i < len; i++) {
  16389. // displayList[i].__renderidx = i;
  16390. // }
  16391. // displayList.sort(shapeCompareFunc);
  16392. env.canvasSupported && timsort(displayList, shapeCompareFunc);
  16393. },
  16394. _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) {
  16395. if (el.ignore && !includeIgnore) {
  16396. return;
  16397. }
  16398. el.beforeUpdate();
  16399. if (el.__dirty) {
  16400. el.update();
  16401. }
  16402. el.afterUpdate();
  16403. var userSetClipPath = el.clipPath;
  16404. if (userSetClipPath) {
  16405. // FIXME 效率影响
  16406. if (clipPaths) {
  16407. clipPaths = clipPaths.slice();
  16408. }
  16409. else {
  16410. clipPaths = [];
  16411. }
  16412. var currentClipPath = userSetClipPath;
  16413. var parentClipPath = el;
  16414. // Recursively add clip path
  16415. while (currentClipPath) {
  16416. // clipPath 的变换是基于使用这个 clipPath 的元素
  16417. currentClipPath.parent = parentClipPath;
  16418. currentClipPath.updateTransform();
  16419. clipPaths.push(currentClipPath);
  16420. parentClipPath = currentClipPath;
  16421. currentClipPath = currentClipPath.clipPath;
  16422. }
  16423. }
  16424. if (el.isGroup) {
  16425. var children = el._children;
  16426. for (var i = 0; i < children.length; i++) {
  16427. var child = children[i];
  16428. // Force to mark as dirty if group is dirty
  16429. // FIXME __dirtyPath ?
  16430. if (el.__dirty) {
  16431. child.__dirty = true;
  16432. }
  16433. this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
  16434. }
  16435. // Mark group clean here
  16436. el.__dirty = false;
  16437. }
  16438. else {
  16439. el.__clipPaths = clipPaths;
  16440. this._displayList[this._displayListLen++] = el;
  16441. }
  16442. },
  16443. /**
  16444. * 添加图形(Shape)或者组(Group)到根节点
  16445. * @param {module:zrender/Element} el
  16446. */
  16447. addRoot: function (el) {
  16448. if (el.__storage === this) {
  16449. return;
  16450. }
  16451. if (el instanceof Group) {
  16452. el.addChildrenToStorage(this);
  16453. }
  16454. this.addToStorage(el);
  16455. this._roots.push(el);
  16456. },
  16457. /**
  16458. * 删除指定的图形(Shape)或者组(Group)
  16459. * @param {string|Array.<string>} [el] 如果为空清空整个Storage
  16460. */
  16461. delRoot: function (el) {
  16462. if (el == null) {
  16463. // 不指定el清空
  16464. for (var i = 0; i < this._roots.length; i++) {
  16465. var root = this._roots[i];
  16466. if (root instanceof Group) {
  16467. root.delChildrenFromStorage(this);
  16468. }
  16469. }
  16470. this._roots = [];
  16471. this._displayList = [];
  16472. this._displayListLen = 0;
  16473. return;
  16474. }
  16475. if (el instanceof Array) {
  16476. for (var i = 0, l = el.length; i < l; i++) {
  16477. this.delRoot(el[i]);
  16478. }
  16479. return;
  16480. }
  16481. var idx = util.indexOf(this._roots, el);
  16482. if (idx >= 0) {
  16483. this.delFromStorage(el);
  16484. this._roots.splice(idx, 1);
  16485. if (el instanceof Group) {
  16486. el.delChildrenFromStorage(this);
  16487. }
  16488. }
  16489. },
  16490. addToStorage: function (el) {
  16491. el.__storage = this;
  16492. el.dirty(false);
  16493. return this;
  16494. },
  16495. delFromStorage: function (el) {
  16496. if (el) {
  16497. el.__storage = null;
  16498. }
  16499. return this;
  16500. },
  16501. /**
  16502. * 清空并且释放Storage
  16503. */
  16504. dispose: function () {
  16505. this._renderList =
  16506. this._roots = null;
  16507. },
  16508. displayableSortFunc: shapeCompareFunc
  16509. };
  16510. module.exports = Storage;
  16511. /***/ },
  16512. /* 86 */
  16513. /***/ function(module, exports) {
  16514. // https://github.com/mziccard/node-timsort
  16515. var DEFAULT_MIN_MERGE = 32;
  16516. var DEFAULT_MIN_GALLOPING = 7;
  16517. var DEFAULT_TMP_STORAGE_LENGTH = 256;
  16518. function minRunLength(n) {
  16519. var r = 0;
  16520. while (n >= DEFAULT_MIN_MERGE) {
  16521. r |= n & 1;
  16522. n >>= 1;
  16523. }
  16524. return n + r;
  16525. }
  16526. function makeAscendingRun(array, lo, hi, compare) {
  16527. var runHi = lo + 1;
  16528. if (runHi === hi) {
  16529. return 1;
  16530. }
  16531. if (compare(array[runHi++], array[lo]) < 0) {
  16532. while (runHi < hi && compare(array[runHi], array[runHi - 1]) < 0) {
  16533. runHi++;
  16534. }
  16535. reverseRun(array, lo, runHi);
  16536. }
  16537. else {
  16538. while (runHi < hi && compare(array[runHi], array[runHi - 1]) >= 0) {
  16539. runHi++;
  16540. }
  16541. }
  16542. return runHi - lo;
  16543. }
  16544. function reverseRun(array, lo, hi) {
  16545. hi--;
  16546. while (lo < hi) {
  16547. var t = array[lo];
  16548. array[lo++] = array[hi];
  16549. array[hi--] = t;
  16550. }
  16551. }
  16552. function binaryInsertionSort(array, lo, hi, start, compare) {
  16553. if (start === lo) {
  16554. start++;
  16555. }
  16556. for (; start < hi; start++) {
  16557. var pivot = array[start];
  16558. var left = lo;
  16559. var right = start;
  16560. var mid;
  16561. while (left < right) {
  16562. mid = left + right >>> 1;
  16563. if (compare(pivot, array[mid]) < 0) {
  16564. right = mid;
  16565. }
  16566. else {
  16567. left = mid + 1;
  16568. }
  16569. }
  16570. var n = start - left;
  16571. switch (n) {
  16572. case 3:
  16573. array[left + 3] = array[left + 2];
  16574. case 2:
  16575. array[left + 2] = array[left + 1];
  16576. case 1:
  16577. array[left + 1] = array[left];
  16578. break;
  16579. default:
  16580. while (n > 0) {
  16581. array[left + n] = array[left + n - 1];
  16582. n--;
  16583. }
  16584. }
  16585. array[left] = pivot;
  16586. }
  16587. }
  16588. function gallopLeft(value, array, start, length, hint, compare) {
  16589. var lastOffset = 0;
  16590. var maxOffset = 0;
  16591. var offset = 1;
  16592. if (compare(value, array[start + hint]) > 0) {
  16593. maxOffset = length - hint;
  16594. while (offset < maxOffset && compare(value, array[start + hint + offset]) > 0) {
  16595. lastOffset = offset;
  16596. offset = (offset << 1) + 1;
  16597. if (offset <= 0) {
  16598. offset = maxOffset;
  16599. }
  16600. }
  16601. if (offset > maxOffset) {
  16602. offset = maxOffset;
  16603. }
  16604. lastOffset += hint;
  16605. offset += hint;
  16606. }
  16607. else {
  16608. maxOffset = hint + 1;
  16609. while (offset < maxOffset && compare(value, array[start + hint - offset]) <= 0) {
  16610. lastOffset = offset;
  16611. offset = (offset << 1) + 1;
  16612. if (offset <= 0) {
  16613. offset = maxOffset;
  16614. }
  16615. }
  16616. if (offset > maxOffset) {
  16617. offset = maxOffset;
  16618. }
  16619. var tmp = lastOffset;
  16620. lastOffset = hint - offset;
  16621. offset = hint - tmp;
  16622. }
  16623. lastOffset++;
  16624. while (lastOffset < offset) {
  16625. var m = lastOffset + (offset - lastOffset >>> 1);
  16626. if (compare(value, array[start + m]) > 0) {
  16627. lastOffset = m + 1;
  16628. }
  16629. else {
  16630. offset = m;
  16631. }
  16632. }
  16633. return offset;
  16634. }
  16635. function gallopRight(value, array, start, length, hint, compare) {
  16636. var lastOffset = 0;
  16637. var maxOffset = 0;
  16638. var offset = 1;
  16639. if (compare(value, array[start + hint]) < 0) {
  16640. maxOffset = hint + 1;
  16641. while (offset < maxOffset && compare(value, array[start + hint - offset]) < 0) {
  16642. lastOffset = offset;
  16643. offset = (offset << 1) + 1;
  16644. if (offset <= 0) {
  16645. offset = maxOffset;
  16646. }
  16647. }
  16648. if (offset > maxOffset) {
  16649. offset = maxOffset;
  16650. }
  16651. var tmp = lastOffset;
  16652. lastOffset = hint - offset;
  16653. offset = hint - tmp;
  16654. }
  16655. else {
  16656. maxOffset = length - hint;
  16657. while (offset < maxOffset && compare(value, array[start + hint + offset]) >= 0) {
  16658. lastOffset = offset;
  16659. offset = (offset << 1) + 1;
  16660. if (offset <= 0) {
  16661. offset = maxOffset;
  16662. }
  16663. }
  16664. if (offset > maxOffset) {
  16665. offset = maxOffset;
  16666. }
  16667. lastOffset += hint;
  16668. offset += hint;
  16669. }
  16670. lastOffset++;
  16671. while (lastOffset < offset) {
  16672. var m = lastOffset + (offset - lastOffset >>> 1);
  16673. if (compare(value, array[start + m]) < 0) {
  16674. offset = m;
  16675. }
  16676. else {
  16677. lastOffset = m + 1;
  16678. }
  16679. }
  16680. return offset;
  16681. }
  16682. function TimSort(array, compare) {
  16683. var minGallop = DEFAULT_MIN_GALLOPING;
  16684. var length = 0;
  16685. var tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH;
  16686. var stackLength = 0;
  16687. var runStart;
  16688. var runLength;
  16689. var stackSize = 0;
  16690. length = array.length;
  16691. if (length < 2 * DEFAULT_TMP_STORAGE_LENGTH) {
  16692. tmpStorageLength = length >>> 1;
  16693. }
  16694. var tmp = [];
  16695. stackLength = length < 120 ? 5 : length < 1542 ? 10 : length < 119151 ? 19 : 40;
  16696. runStart = [];
  16697. runLength = [];
  16698. function pushRun(_runStart, _runLength) {
  16699. runStart[stackSize] = _runStart;
  16700. runLength[stackSize] = _runLength;
  16701. stackSize += 1;
  16702. }
  16703. function mergeRuns() {
  16704. while (stackSize > 1) {
  16705. var n = stackSize - 2;
  16706. if (n >= 1 && runLength[n - 1] <= runLength[n] + runLength[n + 1] || n >= 2 && runLength[n - 2] <= runLength[n] + runLength[n - 1]) {
  16707. if (runLength[n - 1] < runLength[n + 1]) {
  16708. n--;
  16709. }
  16710. }
  16711. else if (runLength[n] > runLength[n + 1]) {
  16712. break;
  16713. }
  16714. mergeAt(n);
  16715. }
  16716. }
  16717. function forceMergeRuns() {
  16718. while (stackSize > 1) {
  16719. var n = stackSize - 2;
  16720. if (n > 0 && runLength[n - 1] < runLength[n + 1]) {
  16721. n--;
  16722. }
  16723. mergeAt(n);
  16724. }
  16725. }
  16726. function mergeAt(i) {
  16727. var start1 = runStart[i];
  16728. var length1 = runLength[i];
  16729. var start2 = runStart[i + 1];
  16730. var length2 = runLength[i + 1];
  16731. runLength[i] = length1 + length2;
  16732. if (i === stackSize - 3) {
  16733. runStart[i + 1] = runStart[i + 2];
  16734. runLength[i + 1] = runLength[i + 2];
  16735. }
  16736. stackSize--;
  16737. var k = gallopRight(array[start2], array, start1, length1, 0, compare);
  16738. start1 += k;
  16739. length1 -= k;
  16740. if (length1 === 0) {
  16741. return;
  16742. }
  16743. length2 = gallopLeft(array[start1 + length1 - 1], array, start2, length2, length2 - 1, compare);
  16744. if (length2 === 0) {
  16745. return;
  16746. }
  16747. if (length1 <= length2) {
  16748. mergeLow(start1, length1, start2, length2);
  16749. }
  16750. else {
  16751. mergeHigh(start1, length1, start2, length2);
  16752. }
  16753. }
  16754. function mergeLow(start1, length1, start2, length2) {
  16755. var i = 0;
  16756. for (i = 0; i < length1; i++) {
  16757. tmp[i] = array[start1 + i];
  16758. }
  16759. var cursor1 = 0;
  16760. var cursor2 = start2;
  16761. var dest = start1;
  16762. array[dest++] = array[cursor2++];
  16763. if (--length2 === 0) {
  16764. for (i = 0; i < length1; i++) {
  16765. array[dest + i] = tmp[cursor1 + i];
  16766. }
  16767. return;
  16768. }
  16769. if (length1 === 1) {
  16770. for (i = 0; i < length2; i++) {
  16771. array[dest + i] = array[cursor2 + i];
  16772. }
  16773. array[dest + length2] = tmp[cursor1];
  16774. return;
  16775. }
  16776. var _minGallop = minGallop;
  16777. var count1, count2, exit;
  16778. while (1) {
  16779. count1 = 0;
  16780. count2 = 0;
  16781. exit = false;
  16782. do {
  16783. if (compare(array[cursor2], tmp[cursor1]) < 0) {
  16784. array[dest++] = array[cursor2++];
  16785. count2++;
  16786. count1 = 0;
  16787. if (--length2 === 0) {
  16788. exit = true;
  16789. break;
  16790. }
  16791. }
  16792. else {
  16793. array[dest++] = tmp[cursor1++];
  16794. count1++;
  16795. count2 = 0;
  16796. if (--length1 === 1) {
  16797. exit = true;
  16798. break;
  16799. }
  16800. }
  16801. } while ((count1 | count2) < _minGallop);
  16802. if (exit) {
  16803. break;
  16804. }
  16805. do {
  16806. count1 = gallopRight(array[cursor2], tmp, cursor1, length1, 0, compare);
  16807. if (count1 !== 0) {
  16808. for (i = 0; i < count1; i++) {
  16809. array[dest + i] = tmp[cursor1 + i];
  16810. }
  16811. dest += count1;
  16812. cursor1 += count1;
  16813. length1 -= count1;
  16814. if (length1 <= 1) {
  16815. exit = true;
  16816. break;
  16817. }
  16818. }
  16819. array[dest++] = array[cursor2++];
  16820. if (--length2 === 0) {
  16821. exit = true;
  16822. break;
  16823. }
  16824. count2 = gallopLeft(tmp[cursor1], array, cursor2, length2, 0, compare);
  16825. if (count2 !== 0) {
  16826. for (i = 0; i < count2; i++) {
  16827. array[dest + i] = array[cursor2 + i];
  16828. }
  16829. dest += count2;
  16830. cursor2 += count2;
  16831. length2 -= count2;
  16832. if (length2 === 0) {
  16833. exit = true;
  16834. break;
  16835. }
  16836. }
  16837. array[dest++] = tmp[cursor1++];
  16838. if (--length1 === 1) {
  16839. exit = true;
  16840. break;
  16841. }
  16842. _minGallop--;
  16843. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  16844. if (exit) {
  16845. break;
  16846. }
  16847. if (_minGallop < 0) {
  16848. _minGallop = 0;
  16849. }
  16850. _minGallop += 2;
  16851. }
  16852. minGallop = _minGallop;
  16853. minGallop < 1 && (minGallop = 1);
  16854. if (length1 === 1) {
  16855. for (i = 0; i < length2; i++) {
  16856. array[dest + i] = array[cursor2 + i];
  16857. }
  16858. array[dest + length2] = tmp[cursor1];
  16859. }
  16860. else if (length1 === 0) {
  16861. throw new Error();
  16862. // throw new Error('mergeLow preconditions were not respected');
  16863. }
  16864. else {
  16865. for (i = 0; i < length1; i++) {
  16866. array[dest + i] = tmp[cursor1 + i];
  16867. }
  16868. }
  16869. }
  16870. function mergeHigh (start1, length1, start2, length2) {
  16871. var i = 0;
  16872. for (i = 0; i < length2; i++) {
  16873. tmp[i] = array[start2 + i];
  16874. }
  16875. var cursor1 = start1 + length1 - 1;
  16876. var cursor2 = length2 - 1;
  16877. var dest = start2 + length2 - 1;
  16878. var customCursor = 0;
  16879. var customDest = 0;
  16880. array[dest--] = array[cursor1--];
  16881. if (--length1 === 0) {
  16882. customCursor = dest - (length2 - 1);
  16883. for (i = 0; i < length2; i++) {
  16884. array[customCursor + i] = tmp[i];
  16885. }
  16886. return;
  16887. }
  16888. if (length2 === 1) {
  16889. dest -= length1;
  16890. cursor1 -= length1;
  16891. customDest = dest + 1;
  16892. customCursor = cursor1 + 1;
  16893. for (i = length1 - 1; i >= 0; i--) {
  16894. array[customDest + i] = array[customCursor + i];
  16895. }
  16896. array[dest] = tmp[cursor2];
  16897. return;
  16898. }
  16899. var _minGallop = minGallop;
  16900. while (true) {
  16901. var count1 = 0;
  16902. var count2 = 0;
  16903. var exit = false;
  16904. do {
  16905. if (compare(tmp[cursor2], array[cursor1]) < 0) {
  16906. array[dest--] = array[cursor1--];
  16907. count1++;
  16908. count2 = 0;
  16909. if (--length1 === 0) {
  16910. exit = true;
  16911. break;
  16912. }
  16913. }
  16914. else {
  16915. array[dest--] = tmp[cursor2--];
  16916. count2++;
  16917. count1 = 0;
  16918. if (--length2 === 1) {
  16919. exit = true;
  16920. break;
  16921. }
  16922. }
  16923. } while ((count1 | count2) < _minGallop);
  16924. if (exit) {
  16925. break;
  16926. }
  16927. do {
  16928. count1 = length1 - gallopRight(tmp[cursor2], array, start1, length1, length1 - 1, compare);
  16929. if (count1 !== 0) {
  16930. dest -= count1;
  16931. cursor1 -= count1;
  16932. length1 -= count1;
  16933. customDest = dest + 1;
  16934. customCursor = cursor1 + 1;
  16935. for (i = count1 - 1; i >= 0; i--) {
  16936. array[customDest + i] = array[customCursor + i];
  16937. }
  16938. if (length1 === 0) {
  16939. exit = true;
  16940. break;
  16941. }
  16942. }
  16943. array[dest--] = tmp[cursor2--];
  16944. if (--length2 === 1) {
  16945. exit = true;
  16946. break;
  16947. }
  16948. count2 = length2 - gallopLeft(array[cursor1], tmp, 0, length2, length2 - 1, compare);
  16949. if (count2 !== 0) {
  16950. dest -= count2;
  16951. cursor2 -= count2;
  16952. length2 -= count2;
  16953. customDest = dest + 1;
  16954. customCursor = cursor2 + 1;
  16955. for (i = 0; i < count2; i++) {
  16956. array[customDest + i] = tmp[customCursor + i];
  16957. }
  16958. if (length2 <= 1) {
  16959. exit = true;
  16960. break;
  16961. }
  16962. }
  16963. array[dest--] = array[cursor1--];
  16964. if (--length1 === 0) {
  16965. exit = true;
  16966. break;
  16967. }
  16968. _minGallop--;
  16969. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  16970. if (exit) {
  16971. break;
  16972. }
  16973. if (_minGallop < 0) {
  16974. _minGallop = 0;
  16975. }
  16976. _minGallop += 2;
  16977. }
  16978. minGallop = _minGallop;
  16979. if (minGallop < 1) {
  16980. minGallop = 1;
  16981. }
  16982. if (length2 === 1) {
  16983. dest -= length1;
  16984. cursor1 -= length1;
  16985. customDest = dest + 1;
  16986. customCursor = cursor1 + 1;
  16987. for (i = length1 - 1; i >= 0; i--) {
  16988. array[customDest + i] = array[customCursor + i];
  16989. }
  16990. array[dest] = tmp[cursor2];
  16991. }
  16992. else if (length2 === 0) {
  16993. throw new Error();
  16994. // throw new Error('mergeHigh preconditions were not respected');
  16995. }
  16996. else {
  16997. customCursor = dest - (length2 - 1);
  16998. for (i = 0; i < length2; i++) {
  16999. array[customCursor + i] = tmp[i];
  17000. }
  17001. }
  17002. }
  17003. this.mergeRuns = mergeRuns;
  17004. this.forceMergeRuns = forceMergeRuns;
  17005. this.pushRun = pushRun;
  17006. }
  17007. function sort(array, compare, lo, hi) {
  17008. if (!lo) {
  17009. lo = 0;
  17010. }
  17011. if (!hi) {
  17012. hi = array.length;
  17013. }
  17014. var remaining = hi - lo;
  17015. if (remaining < 2) {
  17016. return;
  17017. }
  17018. var runLength = 0;
  17019. if (remaining < DEFAULT_MIN_MERGE) {
  17020. runLength = makeAscendingRun(array, lo, hi, compare);
  17021. binaryInsertionSort(array, lo, hi, lo + runLength, compare);
  17022. return;
  17023. }
  17024. var ts = new TimSort(array, compare);
  17025. var minRun = minRunLength(remaining);
  17026. do {
  17027. runLength = makeAscendingRun(array, lo, hi, compare);
  17028. if (runLength < minRun) {
  17029. var force = remaining;
  17030. if (force > minRun) {
  17031. force = minRun;
  17032. }
  17033. binaryInsertionSort(array, lo, lo + force, lo + runLength, compare);
  17034. runLength = force;
  17035. }
  17036. ts.pushRun(lo, runLength);
  17037. ts.mergeRuns();
  17038. remaining -= runLength;
  17039. lo += runLength;
  17040. } while (remaining !== 0);
  17041. ts.forceMergeRuns();
  17042. }
  17043. module.exports = sort;
  17044. /***/ },
  17045. /* 87 */
  17046. /***/ function(module, exports, __webpack_require__) {
  17047. 'use strict';
  17048. /**
  17049. * 动画主类, 调度和管理所有动画控制器
  17050. *
  17051. * @module zrender/animation/Animation
  17052. * @author pissang(https://github.com/pissang)
  17053. */
  17054. // TODO Additive animation
  17055. // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/
  17056. // https://developer.apple.com/videos/wwdc2014/#236
  17057. var util = __webpack_require__(4);
  17058. var Dispatcher = __webpack_require__(88).Dispatcher;
  17059. var requestAnimationFrame = __webpack_require__(89);
  17060. var Animator = __webpack_require__(28);
  17061. /**
  17062. * @typedef {Object} IZRenderStage
  17063. * @property {Function} update
  17064. */
  17065. /**
  17066. * @alias module:zrender/animation/Animation
  17067. * @constructor
  17068. * @param {Object} [options]
  17069. * @param {Function} [options.onframe]
  17070. * @param {IZRenderStage} [options.stage]
  17071. * @example
  17072. * var animation = new Animation();
  17073. * var obj = {
  17074. * x: 100,
  17075. * y: 100
  17076. * };
  17077. * animation.animate(node.position)
  17078. * .when(1000, {
  17079. * x: 500,
  17080. * y: 500
  17081. * })
  17082. * .when(2000, {
  17083. * x: 100,
  17084. * y: 100
  17085. * })
  17086. * .start('spline');
  17087. */
  17088. var Animation = function (options) {
  17089. options = options || {};
  17090. this.stage = options.stage || {};
  17091. this.onframe = options.onframe || function() {};
  17092. // private properties
  17093. this._clips = [];
  17094. this._running = false;
  17095. this._time;
  17096. this._pausedTime;
  17097. this._pauseStart;
  17098. this._paused = false;
  17099. Dispatcher.call(this);
  17100. };
  17101. Animation.prototype = {
  17102. constructor: Animation,
  17103. /**
  17104. * 添加 clip
  17105. * @param {module:zrender/animation/Clip} clip
  17106. */
  17107. addClip: function (clip) {
  17108. this._clips.push(clip);
  17109. },
  17110. /**
  17111. * 添加 animator
  17112. * @param {module:zrender/animation/Animator} animator
  17113. */
  17114. addAnimator: function (animator) {
  17115. animator.animation = this;
  17116. var clips = animator.getClips();
  17117. for (var i = 0; i < clips.length; i++) {
  17118. this.addClip(clips[i]);
  17119. }
  17120. },
  17121. /**
  17122. * 删除动画片段
  17123. * @param {module:zrender/animation/Clip} clip
  17124. */
  17125. removeClip: function(clip) {
  17126. var idx = util.indexOf(this._clips, clip);
  17127. if (idx >= 0) {
  17128. this._clips.splice(idx, 1);
  17129. }
  17130. },
  17131. /**
  17132. * 删除动画片段
  17133. * @param {module:zrender/animation/Animator} animator
  17134. */
  17135. removeAnimator: function (animator) {
  17136. var clips = animator.getClips();
  17137. for (var i = 0; i < clips.length; i++) {
  17138. this.removeClip(clips[i]);
  17139. }
  17140. animator.animation = null;
  17141. },
  17142. _update: function() {
  17143. var time = new Date().getTime() - this._pausedTime;
  17144. var delta = time - this._time;
  17145. var clips = this._clips;
  17146. var len = clips.length;
  17147. var deferredEvents = [];
  17148. var deferredClips = [];
  17149. for (var i = 0; i < len; i++) {
  17150. var clip = clips[i];
  17151. var e = clip.step(time, delta);
  17152. // Throw out the events need to be called after
  17153. // stage.update, like destroy
  17154. if (e) {
  17155. deferredEvents.push(e);
  17156. deferredClips.push(clip);
  17157. }
  17158. }
  17159. // Remove the finished clip
  17160. for (var i = 0; i < len;) {
  17161. if (clips[i]._needsRemove) {
  17162. clips[i] = clips[len - 1];
  17163. clips.pop();
  17164. len--;
  17165. }
  17166. else {
  17167. i++;
  17168. }
  17169. }
  17170. len = deferredEvents.length;
  17171. for (var i = 0; i < len; i++) {
  17172. deferredClips[i].fire(deferredEvents[i]);
  17173. }
  17174. this._time = time;
  17175. this.onframe(delta);
  17176. this.trigger('frame', delta);
  17177. if (this.stage.update) {
  17178. this.stage.update();
  17179. }
  17180. },
  17181. _startLoop: function () {
  17182. var self = this;
  17183. this._running = true;
  17184. function step() {
  17185. if (self._running) {
  17186. requestAnimationFrame(step);
  17187. !self._paused && self._update();
  17188. }
  17189. }
  17190. requestAnimationFrame(step);
  17191. },
  17192. /**
  17193. * 开始运行动画
  17194. */
  17195. start: function () {
  17196. this._time = new Date().getTime();
  17197. this._pausedTime = 0;
  17198. this._startLoop();
  17199. },
  17200. /**
  17201. * 停止运行动画
  17202. */
  17203. stop: function () {
  17204. this._running = false;
  17205. },
  17206. /**
  17207. * Pause
  17208. */
  17209. pause: function () {
  17210. if (!this._paused) {
  17211. this._pauseStart = new Date().getTime();
  17212. this._paused = true;
  17213. }
  17214. },
  17215. /**
  17216. * Resume
  17217. */
  17218. resume: function () {
  17219. if (this._paused) {
  17220. this._pausedTime += (new Date().getTime()) - this._pauseStart;
  17221. this._paused = false;
  17222. }
  17223. },
  17224. /**
  17225. * 清除所有动画片段
  17226. */
  17227. clear: function () {
  17228. this._clips = [];
  17229. },
  17230. /**
  17231. * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画
  17232. * @param {Object} target
  17233. * @param {Object} options
  17234. * @param {boolean} [options.loop=false] 是否循环播放动画
  17235. * @param {Function} [options.getter=null]
  17236. * 如果指定getter函数,会通过getter函数取属性值
  17237. * @param {Function} [options.setter=null]
  17238. * 如果指定setter函数,会通过setter函数设置属性值
  17239. * @return {module:zrender/animation/Animation~Animator}
  17240. */
  17241. // TODO Gap
  17242. animate: function (target, options) {
  17243. options = options || {};
  17244. var animator = new Animator(
  17245. target,
  17246. options.loop,
  17247. options.getter,
  17248. options.setter
  17249. );
  17250. this.addAnimator(animator);
  17251. return animator;
  17252. }
  17253. };
  17254. util.mixin(Animation, Dispatcher);
  17255. module.exports = Animation;
  17256. /***/ },
  17257. /* 88 */
  17258. /***/ function(module, exports, __webpack_require__) {
  17259. 'use strict';
  17260. /**
  17261. * 事件辅助类
  17262. * @module zrender/core/event
  17263. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  17264. */
  17265. var Eventful = __webpack_require__(25);
  17266. var env = __webpack_require__(2);
  17267. var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
  17268. function getBoundingClientRect(el) {
  17269. // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect
  17270. return el.getBoundingClientRect ? el.getBoundingClientRect() : {left: 0, top: 0};
  17271. }
  17272. // `calculate` is optional, default false
  17273. function clientToLocal(el, e, out, calculate) {
  17274. out = out || {};
  17275. // According to the W3C Working Draft, offsetX and offsetY should be relative
  17276. // to the padding edge of the target element. The only browser using this convention
  17277. // is IE. Webkit uses the border edge, Opera uses the content edge, and FireFox does
  17278. // not support the properties.
  17279. // (see http://www.jacklmoore.com/notes/mouse-position/)
  17280. // In zr painter.dom, padding edge equals to border edge.
  17281. // FIXME
  17282. // When mousemove event triggered on ec tooltip, target is not zr painter.dom, and
  17283. // offsetX/Y is relative to e.target, where the calculation of zrX/Y via offsetX/Y
  17284. // is too complex. So css-transfrom dont support in this case temporarily.
  17285. if (calculate || !env.canvasSupported) {
  17286. defaultGetZrXY(el, e, out);
  17287. }
  17288. // Caution: In FireFox, layerX/layerY Mouse position relative to the closest positioned
  17289. // ancestor element, so we should make sure el is positioned (e.g., not position:static).
  17290. // BTW1, Webkit don't return the same results as FF in non-simple cases (like add
  17291. // zoom-factor, overflow / opacity layers, transforms ...)
  17292. // BTW2, (ev.offsetY || ev.pageY - $(ev.target).offset().top) is not correct in preserve-3d.
  17293. // <https://bugs.jquery.com/ticket/8523#comment:14>
  17294. // BTW3, In ff, offsetX/offsetY is always 0.
  17295. else if (env.browser.firefox && e.layerX != null && e.layerX !== e.offsetX) {
  17296. out.zrX = e.layerX;
  17297. out.zrY = e.layerY;
  17298. }
  17299. // For IE6+, chrome, safari, opera. (When will ff support offsetX?)
  17300. else if (e.offsetX != null) {
  17301. out.zrX = e.offsetX;
  17302. out.zrY = e.offsetY;
  17303. }
  17304. // For some other device, e.g., IOS safari.
  17305. else {
  17306. defaultGetZrXY(el, e, out);
  17307. }
  17308. return out;
  17309. }
  17310. function defaultGetZrXY(el, e, out) {
  17311. // This well-known method below does not support css transform.
  17312. var box = getBoundingClientRect(el);
  17313. out.zrX = e.clientX - box.left;
  17314. out.zrY = e.clientY - box.top;
  17315. }
  17316. /**
  17317. * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标.
  17318. * `calculate` is optional, default false.
  17319. */
  17320. function normalizeEvent(el, e, calculate) {
  17321. e = e || window.event;
  17322. if (e.zrX != null) {
  17323. return e;
  17324. }
  17325. var eventType = e.type;
  17326. var isTouch = eventType && eventType.indexOf('touch') >= 0;
  17327. if (!isTouch) {
  17328. clientToLocal(el, e, e, calculate);
  17329. e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3;
  17330. }
  17331. else {
  17332. var touch = eventType != 'touchend'
  17333. ? e.targetTouches[0]
  17334. : e.changedTouches[0];
  17335. touch && clientToLocal(el, touch, e, calculate);
  17336. }
  17337. return e;
  17338. }
  17339. function addEventListener(el, name, handler) {
  17340. if (isDomLevel2) {
  17341. el.addEventListener(name, handler);
  17342. }
  17343. else {
  17344. el.attachEvent('on' + name, handler);
  17345. }
  17346. }
  17347. function removeEventListener(el, name, handler) {
  17348. if (isDomLevel2) {
  17349. el.removeEventListener(name, handler);
  17350. }
  17351. else {
  17352. el.detachEvent('on' + name, handler);
  17353. }
  17354. }
  17355. /**
  17356. * preventDefault and stopPropagation.
  17357. * Notice: do not do that in zrender. Upper application
  17358. * do that if necessary.
  17359. *
  17360. * @memberOf module:zrender/core/event
  17361. * @method
  17362. * @param {Event} e : event对象
  17363. */
  17364. var stop = isDomLevel2
  17365. ? function (e) {
  17366. e.preventDefault();
  17367. e.stopPropagation();
  17368. e.cancelBubble = true;
  17369. }
  17370. : function (e) {
  17371. e.returnValue = false;
  17372. e.cancelBubble = true;
  17373. };
  17374. module.exports = {
  17375. clientToLocal: clientToLocal,
  17376. normalizeEvent: normalizeEvent,
  17377. addEventListener: addEventListener,
  17378. removeEventListener: removeEventListener,
  17379. stop: stop,
  17380. // 做向上兼容
  17381. Dispatcher: Eventful
  17382. };
  17383. /***/ },
  17384. /* 89 */
  17385. /***/ function(module, exports) {
  17386. module.exports = (typeof window !== 'undefined' &&
  17387. ((window.requestAnimationFrame && window.requestAnimationFrame.bind(window))
  17388. // https://github.com/ecomfe/zrender/issues/189#issuecomment-224919809
  17389. || (window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window))
  17390. || window.mozRequestAnimationFrame
  17391. || window.webkitRequestAnimationFrame)
  17392. )
  17393. || function (func) {
  17394. setTimeout(func, 16);
  17395. };
  17396. /***/ },
  17397. /* 90 */
  17398. /***/ function(module, exports, __webpack_require__) {
  17399. var eventTool = __webpack_require__(88);
  17400. var zrUtil = __webpack_require__(4);
  17401. var Eventful = __webpack_require__(25);
  17402. var env = __webpack_require__(2);
  17403. var GestureMgr = __webpack_require__(91);
  17404. var addEventListener = eventTool.addEventListener;
  17405. var removeEventListener = eventTool.removeEventListener;
  17406. var normalizeEvent = eventTool.normalizeEvent;
  17407. var TOUCH_CLICK_DELAY = 300;
  17408. var mouseHandlerNames = [
  17409. 'click', 'dblclick', 'mousewheel', 'mouseout',
  17410. 'mouseup', 'mousedown', 'mousemove', 'contextmenu'
  17411. ];
  17412. var touchHandlerNames = [
  17413. 'touchstart', 'touchend', 'touchmove'
  17414. ];
  17415. var pointerEventNames = {
  17416. pointerdown: 1, pointerup: 1, pointermove: 1, pointerout: 1
  17417. };
  17418. var pointerHandlerNames = zrUtil.map(mouseHandlerNames, function (name) {
  17419. var nm = name.replace('mouse', 'pointer');
  17420. return pointerEventNames[nm] ? nm : name;
  17421. });
  17422. function eventNameFix(name) {
  17423. return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name;
  17424. }
  17425. function processGesture(proxy, event, stage) {
  17426. var gestureMgr = proxy._gestureMgr;
  17427. stage === 'start' && gestureMgr.clear();
  17428. var gestureInfo = gestureMgr.recognize(
  17429. event,
  17430. proxy.handler.findHover(event.zrX, event.zrY, null).target,
  17431. proxy.dom
  17432. );
  17433. stage === 'end' && gestureMgr.clear();
  17434. // Do not do any preventDefault here. Upper application do that if necessary.
  17435. if (gestureInfo) {
  17436. var type = gestureInfo.type;
  17437. event.gestureEvent = type;
  17438. proxy.handler.dispatchToElement({target: gestureInfo.target}, type, gestureInfo.event);
  17439. }
  17440. }
  17441. // function onMSGestureChange(proxy, event) {
  17442. // if (event.translationX || event.translationY) {
  17443. // // mousemove is carried by MSGesture to reduce the sensitivity.
  17444. // proxy.handler.dispatchToElement(event.target, 'mousemove', event);
  17445. // }
  17446. // if (event.scale !== 1) {
  17447. // event.pinchX = event.offsetX;
  17448. // event.pinchY = event.offsetY;
  17449. // event.pinchScale = event.scale;
  17450. // proxy.handler.dispatchToElement(event.target, 'pinch', event);
  17451. // }
  17452. // }
  17453. /**
  17454. * Prevent mouse event from being dispatched after Touch Events action
  17455. * @see <https://github.com/deltakosh/handjs/blob/master/src/hand.base.js>
  17456. * 1. Mobile browsers dispatch mouse events 300ms after touchend.
  17457. * 2. Chrome for Android dispatch mousedown for long-touch about 650ms
  17458. * Result: Blocking Mouse Events for 700ms.
  17459. */
  17460. function setTouchTimer(instance) {
  17461. instance._touching = true;
  17462. clearTimeout(instance._touchTimer);
  17463. instance._touchTimer = setTimeout(function () {
  17464. instance._touching = false;
  17465. }, 700);
  17466. }
  17467. var domHandlers = {
  17468. /**
  17469. * Mouse move handler
  17470. * @inner
  17471. * @param {Event} event
  17472. */
  17473. mousemove: function (event) {
  17474. event = normalizeEvent(this.dom, event);
  17475. this.trigger('mousemove', event);
  17476. },
  17477. /**
  17478. * Mouse out handler
  17479. * @inner
  17480. * @param {Event} event
  17481. */
  17482. mouseout: function (event) {
  17483. event = normalizeEvent(this.dom, event);
  17484. var element = event.toElement || event.relatedTarget;
  17485. if (element != this.dom) {
  17486. while (element && element.nodeType != 9) {
  17487. // 忽略包含在root中的dom引起的mouseOut
  17488. if (element === this.dom) {
  17489. return;
  17490. }
  17491. element = element.parentNode;
  17492. }
  17493. }
  17494. this.trigger('mouseout', event);
  17495. },
  17496. /**
  17497. * Touch开始响应函数
  17498. * @inner
  17499. * @param {Event} event
  17500. */
  17501. touchstart: function (event) {
  17502. // Default mouse behaviour should not be disabled here.
  17503. // For example, page may needs to be slided.
  17504. event = normalizeEvent(this.dom, event);
  17505. // Mark touch, which is useful in distinguish touch and
  17506. // mouse event in upper applicatoin.
  17507. event.zrByTouch = true;
  17508. this._lastTouchMoment = new Date();
  17509. processGesture(this, event, 'start');
  17510. // In touch device, trigger `mousemove`(`mouseover`) should
  17511. // be triggered, and must before `mousedown` triggered.
  17512. domHandlers.mousemove.call(this, event);
  17513. domHandlers.mousedown.call(this, event);
  17514. setTouchTimer(this);
  17515. },
  17516. /**
  17517. * Touch移动响应函数
  17518. * @inner
  17519. * @param {Event} event
  17520. */
  17521. touchmove: function (event) {
  17522. event = normalizeEvent(this.dom, event);
  17523. // Mark touch, which is useful in distinguish touch and
  17524. // mouse event in upper applicatoin.
  17525. event.zrByTouch = true;
  17526. processGesture(this, event, 'change');
  17527. // Mouse move should always be triggered no matter whether
  17528. // there is gestrue event, because mouse move and pinch may
  17529. // be used at the same time.
  17530. domHandlers.mousemove.call(this, event);
  17531. setTouchTimer(this);
  17532. },
  17533. /**
  17534. * Touch结束响应函数
  17535. * @inner
  17536. * @param {Event} event
  17537. */
  17538. touchend: function (event) {
  17539. event = normalizeEvent(this.dom, event);
  17540. // Mark touch, which is useful in distinguish touch and
  17541. // mouse event in upper applicatoin.
  17542. event.zrByTouch = true;
  17543. processGesture(this, event, 'end');
  17544. domHandlers.mouseup.call(this, event);
  17545. // Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
  17546. // triggered in `touchstart`. This seems to be illogical, but by this mechanism,
  17547. // we can conveniently implement "hover style" in both PC and touch device just
  17548. // by listening to `mouseover` to add "hover style" and listening to `mouseout`
  17549. // to remove "hover style" on an element, without any additional code for
  17550. // compatibility. (`mouseout` will not be triggered in `touchend`, so "hover
  17551. // style" will remain for user view)
  17552. // click event should always be triggered no matter whether
  17553. // there is gestrue event. System click can not be prevented.
  17554. if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
  17555. domHandlers.click.call(this, event);
  17556. }
  17557. setTouchTimer(this);
  17558. },
  17559. pointerdown: function (event) {
  17560. domHandlers.mousedown.call(this, event);
  17561. // if (useMSGuesture(this, event)) {
  17562. // this._msGesture.addPointer(event.pointerId);
  17563. // }
  17564. },
  17565. pointermove: function (event) {
  17566. // FIXME
  17567. // pointermove is so sensitive that it always triggered when
  17568. // tap(click) on touch screen, which affect some judgement in
  17569. // upper application. So, we dont support mousemove on MS touch
  17570. // device yet.
  17571. if (!isPointerFromTouch(event)) {
  17572. domHandlers.mousemove.call(this, event);
  17573. }
  17574. },
  17575. pointerup: function (event) {
  17576. domHandlers.mouseup.call(this, event);
  17577. },
  17578. pointerout: function (event) {
  17579. // pointerout will be triggered when tap on touch screen
  17580. // (IE11+/Edge on MS Surface) after click event triggered,
  17581. // which is inconsistent with the mousout behavior we defined
  17582. // in touchend. So we unify them.
  17583. // (check domHandlers.touchend for detailed explanation)
  17584. if (!isPointerFromTouch(event)) {
  17585. domHandlers.mouseout.call(this, event);
  17586. }
  17587. }
  17588. };
  17589. function isPointerFromTouch(event) {
  17590. var pointerType = event.pointerType;
  17591. return pointerType === 'pen' || pointerType === 'touch';
  17592. }
  17593. // function useMSGuesture(handlerProxy, event) {
  17594. // return isPointerFromTouch(event) && !!handlerProxy._msGesture;
  17595. // }
  17596. // Common handlers
  17597. zrUtil.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
  17598. domHandlers[name] = function (event) {
  17599. event = normalizeEvent(this.dom, event);
  17600. this.trigger(name, event);
  17601. };
  17602. });
  17603. /**
  17604. * 为控制类实例初始化dom 事件处理函数
  17605. *
  17606. * @inner
  17607. * @param {module:zrender/Handler} instance 控制类实例
  17608. */
  17609. function initDomHandler(instance) {
  17610. zrUtil.each(touchHandlerNames, function (name) {
  17611. instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
  17612. });
  17613. zrUtil.each(pointerHandlerNames, function (name) {
  17614. instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
  17615. });
  17616. zrUtil.each(mouseHandlerNames, function (name) {
  17617. instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
  17618. });
  17619. function makeMouseHandler(fn, instance) {
  17620. return function () {
  17621. if (instance._touching) {
  17622. return;
  17623. }
  17624. return fn.apply(instance, arguments);
  17625. };
  17626. }
  17627. }
  17628. function HandlerDomProxy(dom) {
  17629. Eventful.call(this);
  17630. this.dom = dom;
  17631. /**
  17632. * @private
  17633. * @type {boolean}
  17634. */
  17635. this._touching = false;
  17636. /**
  17637. * @private
  17638. * @type {number}
  17639. */
  17640. this._touchTimer;
  17641. /**
  17642. * @private
  17643. * @type {module:zrender/core/GestureMgr}
  17644. */
  17645. this._gestureMgr = new GestureMgr();
  17646. this._handlers = {};
  17647. initDomHandler(this);
  17648. if (env.pointerEventsSupported) { // Only IE11+/Edge
  17649. // 1. On devices that both enable touch and mouse (e.g., MS Surface and lenovo X240),
  17650. // IE11+/Edge do not trigger touch event, but trigger pointer event and mouse event
  17651. // at the same time.
  17652. // 2. On MS Surface, it probablely only trigger mousedown but no mouseup when tap on
  17653. // screen, which do not occurs in pointer event.
  17654. // So we use pointer event to both detect touch gesture and mouse behavior.
  17655. mountHandlers(pointerHandlerNames, this);
  17656. // FIXME
  17657. // Note: MS Gesture require CSS touch-action set. But touch-action is not reliable,
  17658. // which does not prevent defuault behavior occasionally (which may cause view port
  17659. // zoomed in but use can not zoom it back). And event.preventDefault() does not work.
  17660. // So we have to not to use MSGesture and not to support touchmove and pinch on MS
  17661. // touch screen. And we only support click behavior on MS touch screen now.
  17662. // MS Gesture Event is only supported on IE11+/Edge and on Windows 8+.
  17663. // We dont support touch on IE on win7.
  17664. // See <https://msdn.microsoft.com/en-us/library/dn433243(v=vs.85).aspx>
  17665. // if (typeof MSGesture === 'function') {
  17666. // (this._msGesture = new MSGesture()).target = dom; // jshint ignore:line
  17667. // dom.addEventListener('MSGestureChange', onMSGestureChange);
  17668. // }
  17669. }
  17670. else {
  17671. if (env.touchEventsSupported) {
  17672. mountHandlers(touchHandlerNames, this);
  17673. // Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
  17674. // addEventListener(root, 'mouseout', this._mouseoutHandler);
  17675. }
  17676. // 1. Considering some devices that both enable touch and mouse event (like on MS Surface
  17677. // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise
  17678. // mouse event can not be handle in those devices.
  17679. // 2. On MS Surface, Chrome will trigger both touch event and mouse event. How to prevent
  17680. // mouseevent after touch event triggered, see `setTouchTimer`.
  17681. mountHandlers(mouseHandlerNames, this);
  17682. }
  17683. function mountHandlers(handlerNames, instance) {
  17684. zrUtil.each(handlerNames, function (name) {
  17685. addEventListener(dom, eventNameFix(name), instance._handlers[name]);
  17686. }, instance);
  17687. }
  17688. }
  17689. var handlerDomProxyProto = HandlerDomProxy.prototype;
  17690. handlerDomProxyProto.dispose = function () {
  17691. var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
  17692. for (var i = 0; i < handlerNames.length; i++) {
  17693. var name = handlerNames[i];
  17694. removeEventListener(this.dom, eventNameFix(name), this._handlers[name]);
  17695. }
  17696. };
  17697. handlerDomProxyProto.setCursor = function (cursorStyle) {
  17698. this.dom.style.cursor = cursorStyle || 'default';
  17699. };
  17700. zrUtil.mixin(HandlerDomProxy, Eventful);
  17701. module.exports = HandlerDomProxy;
  17702. /***/ },
  17703. /* 91 */
  17704. /***/ function(module, exports, __webpack_require__) {
  17705. 'use strict';
  17706. /**
  17707. * Only implements needed gestures for mobile.
  17708. */
  17709. var eventUtil = __webpack_require__(88);
  17710. var GestureMgr = function () {
  17711. /**
  17712. * @private
  17713. * @type {Array.<Object>}
  17714. */
  17715. this._track = [];
  17716. };
  17717. GestureMgr.prototype = {
  17718. constructor: GestureMgr,
  17719. recognize: function (event, target, root) {
  17720. this._doTrack(event, target, root);
  17721. return this._recognize(event);
  17722. },
  17723. clear: function () {
  17724. this._track.length = 0;
  17725. return this;
  17726. },
  17727. _doTrack: function (event, target, root) {
  17728. var touches = event.touches;
  17729. if (!touches) {
  17730. return;
  17731. }
  17732. var trackItem = {
  17733. points: [],
  17734. touches: [],
  17735. target: target,
  17736. event: event
  17737. };
  17738. for (var i = 0, len = touches.length; i < len; i++) {
  17739. var touch = touches[i];
  17740. var pos = eventUtil.clientToLocal(root, touch, {});
  17741. trackItem.points.push([pos.zrX, pos.zrY]);
  17742. trackItem.touches.push(touch);
  17743. }
  17744. this._track.push(trackItem);
  17745. },
  17746. _recognize: function (event) {
  17747. for (var eventName in recognizers) {
  17748. if (recognizers.hasOwnProperty(eventName)) {
  17749. var gestureInfo = recognizers[eventName](this._track, event);
  17750. if (gestureInfo) {
  17751. return gestureInfo;
  17752. }
  17753. }
  17754. }
  17755. }
  17756. };
  17757. function dist(pointPair) {
  17758. var dx = pointPair[1][0] - pointPair[0][0];
  17759. var dy = pointPair[1][1] - pointPair[0][1];
  17760. return Math.sqrt(dx * dx + dy * dy);
  17761. }
  17762. function center(pointPair) {
  17763. return [
  17764. (pointPair[0][0] + pointPair[1][0]) / 2,
  17765. (pointPair[0][1] + pointPair[1][1]) / 2
  17766. ];
  17767. }
  17768. var recognizers = {
  17769. pinch: function (track, event) {
  17770. var trackLen = track.length;
  17771. if (!trackLen) {
  17772. return;
  17773. }
  17774. var pinchEnd = (track[trackLen - 1] || {}).points;
  17775. var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd;
  17776. if (pinchPre
  17777. && pinchPre.length > 1
  17778. && pinchEnd
  17779. && pinchEnd.length > 1
  17780. ) {
  17781. var pinchScale = dist(pinchEnd) / dist(pinchPre);
  17782. !isFinite(pinchScale) && (pinchScale = 1);
  17783. event.pinchScale = pinchScale;
  17784. var pinchCenter = center(pinchEnd);
  17785. event.pinchX = pinchCenter[0];
  17786. event.pinchY = pinchCenter[1];
  17787. return {
  17788. type: 'pinch',
  17789. target: track[0].target,
  17790. event: event
  17791. };
  17792. }
  17793. }
  17794. // Only pinch currently.
  17795. };
  17796. module.exports = GestureMgr;
  17797. /***/ },
  17798. /* 92 */
  17799. /***/ function(module, exports, __webpack_require__) {
  17800. 'use strict';
  17801. /**
  17802. * Default canvas painter
  17803. * @module zrender/Painter
  17804. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  17805. * errorrik (errorrik@gmail.com)
  17806. * pissang (https://www.github.com/pissang)
  17807. */
  17808. var config = __webpack_require__(34);
  17809. var util = __webpack_require__(4);
  17810. var log = __webpack_require__(33);
  17811. var BoundingRect = __webpack_require__(9);
  17812. var timsort = __webpack_require__(86);
  17813. var Layer = __webpack_require__(93);
  17814. var requestAnimationFrame = __webpack_require__(89);
  17815. // PENDIGN
  17816. // Layer exceeds MAX_PROGRESSIVE_LAYER_NUMBER may have some problem when flush directly second time.
  17817. //
  17818. // Maximum progressive layer. When exceeding this number. All elements will be drawed in the last layer.
  17819. var MAX_PROGRESSIVE_LAYER_NUMBER = 5;
  17820. function parseInt10(val) {
  17821. return parseInt(val, 10);
  17822. }
  17823. function isLayerValid(layer) {
  17824. if (!layer) {
  17825. return false;
  17826. }
  17827. if (layer.__builtin__) {
  17828. return true;
  17829. }
  17830. if (typeof(layer.resize) !== 'function'
  17831. || typeof(layer.refresh) !== 'function'
  17832. ) {
  17833. return false;
  17834. }
  17835. return true;
  17836. }
  17837. function preProcessLayer(layer) {
  17838. layer.__unusedCount++;
  17839. }
  17840. function postProcessLayer(layer) {
  17841. if (layer.__unusedCount == 1) {
  17842. layer.clear();
  17843. }
  17844. }
  17845. var tmpRect = new BoundingRect(0, 0, 0, 0);
  17846. var viewRect = new BoundingRect(0, 0, 0, 0);
  17847. function isDisplayableCulled(el, width, height) {
  17848. tmpRect.copy(el.getBoundingRect());
  17849. if (el.transform) {
  17850. tmpRect.applyTransform(el.transform);
  17851. }
  17852. viewRect.width = width;
  17853. viewRect.height = height;
  17854. return !tmpRect.intersect(viewRect);
  17855. }
  17856. function isClipPathChanged(clipPaths, prevClipPaths) {
  17857. if (clipPaths == prevClipPaths) { // Can both be null or undefined
  17858. return false;
  17859. }
  17860. if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) {
  17861. return true;
  17862. }
  17863. for (var i = 0; i < clipPaths.length; i++) {
  17864. if (clipPaths[i] !== prevClipPaths[i]) {
  17865. return true;
  17866. }
  17867. }
  17868. }
  17869. function doClip(clipPaths, ctx) {
  17870. for (var i = 0; i < clipPaths.length; i++) {
  17871. var clipPath = clipPaths[i];
  17872. clipPath.setTransform(ctx);
  17873. ctx.beginPath();
  17874. clipPath.buildPath(ctx, clipPath.shape);
  17875. ctx.clip();
  17876. // Transform back
  17877. clipPath.restoreTransform(ctx);
  17878. }
  17879. }
  17880. function createRoot(width, height) {
  17881. var domRoot = document.createElement('div');
  17882. // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬
  17883. domRoot.style.cssText = [
  17884. 'position:relative',
  17885. 'overflow:hidden',
  17886. 'width:' + width + 'px',
  17887. 'height:' + height + 'px',
  17888. 'padding:0',
  17889. 'margin:0',
  17890. 'border-width:0'
  17891. ].join(';') + ';';
  17892. return domRoot;
  17893. }
  17894. /**
  17895. * @alias module:zrender/Painter
  17896. * @constructor
  17897. * @param {HTMLElement} root 绘图容器
  17898. * @param {module:zrender/Storage} storage
  17899. * @param {Ojbect} opts
  17900. */
  17901. var Painter = function (root, storage, opts) {
  17902. // In node environment using node-canvas
  17903. var singleCanvas = !root.nodeName // In node ?
  17904. || root.nodeName.toUpperCase() === 'CANVAS';
  17905. this._opts = opts = util.extend({}, opts || {});
  17906. /**
  17907. * @type {number}
  17908. */
  17909. this.dpr = opts.devicePixelRatio || config.devicePixelRatio;
  17910. /**
  17911. * @type {boolean}
  17912. * @private
  17913. */
  17914. this._singleCanvas = singleCanvas;
  17915. /**
  17916. * 绘图容器
  17917. * @type {HTMLElement}
  17918. */
  17919. this.root = root;
  17920. var rootStyle = root.style;
  17921. if (rootStyle) {
  17922. rootStyle['-webkit-tap-highlight-color'] = 'transparent';
  17923. rootStyle['-webkit-user-select'] =
  17924. rootStyle['user-select'] =
  17925. rootStyle['-webkit-touch-callout'] = 'none';
  17926. root.innerHTML = '';
  17927. }
  17928. /**
  17929. * @type {module:zrender/Storage}
  17930. */
  17931. this.storage = storage;
  17932. /**
  17933. * @type {Array.<number>}
  17934. * @private
  17935. */
  17936. var zlevelList = this._zlevelList = [];
  17937. /**
  17938. * @type {Object.<string, module:zrender/Layer>}
  17939. * @private
  17940. */
  17941. var layers = this._layers = {};
  17942. /**
  17943. * @type {Object.<string, Object>}
  17944. * @type {private}
  17945. */
  17946. this._layerConfig = {};
  17947. if (!singleCanvas) {
  17948. this._width = this._getSize(0);
  17949. this._height = this._getSize(1);
  17950. var domRoot = this._domRoot = createRoot(
  17951. this._width, this._height
  17952. );
  17953. root.appendChild(domRoot);
  17954. }
  17955. else {
  17956. if (opts.width != null) {
  17957. root.width = opts.width;
  17958. }
  17959. if (opts.height != null) {
  17960. root.height = opts.height;
  17961. }
  17962. // Use canvas width and height directly
  17963. var width = root.width;
  17964. var height = root.height;
  17965. this._width = width;
  17966. this._height = height;
  17967. // Create layer if only one given canvas
  17968. // Device pixel ratio is fixed to 1 because given canvas has its specified width and height
  17969. var mainLayer = new Layer(root, this, 1);
  17970. mainLayer.initContext();
  17971. // FIXME Use canvas width and height
  17972. // mainLayer.resize(width, height);
  17973. layers[0] = mainLayer;
  17974. zlevelList.push(0);
  17975. this._domRoot = root;
  17976. }
  17977. // Layers for progressive rendering
  17978. this._progressiveLayers = [];
  17979. /**
  17980. * @type {module:zrender/Layer}
  17981. * @private
  17982. */
  17983. this._hoverlayer;
  17984. this._hoverElements = [];
  17985. };
  17986. Painter.prototype = {
  17987. constructor: Painter,
  17988. /**
  17989. * If painter use a single canvas
  17990. * @return {boolean}
  17991. */
  17992. isSingleCanvas: function () {
  17993. return this._singleCanvas;
  17994. },
  17995. /**
  17996. * @return {HTMLDivElement}
  17997. */
  17998. getViewportRoot: function () {
  17999. return this._domRoot;
  18000. },
  18001. /**
  18002. * 刷新
  18003. * @param {boolean} [paintAll=false] 强制绘制所有displayable
  18004. */
  18005. refresh: function (paintAll) {
  18006. var list = this.storage.getDisplayList(true);
  18007. var zlevelList = this._zlevelList;
  18008. this._paintList(list, paintAll);
  18009. // Paint custum layers
  18010. for (var i = 0; i < zlevelList.length; i++) {
  18011. var z = zlevelList[i];
  18012. var layer = this._layers[z];
  18013. if (!layer.__builtin__ && layer.refresh) {
  18014. layer.refresh();
  18015. }
  18016. }
  18017. this.refreshHover();
  18018. if (this._progressiveLayers.length) {
  18019. this._startProgessive();
  18020. }
  18021. return this;
  18022. },
  18023. addHover: function (el, hoverStyle) {
  18024. if (el.__hoverMir) {
  18025. return;
  18026. }
  18027. var elMirror = new el.constructor({
  18028. style: el.style,
  18029. shape: el.shape
  18030. });
  18031. elMirror.__from = el;
  18032. el.__hoverMir = elMirror;
  18033. elMirror.setStyle(hoverStyle);
  18034. this._hoverElements.push(elMirror);
  18035. },
  18036. removeHover: function (el) {
  18037. var elMirror = el.__hoverMir;
  18038. var hoverElements = this._hoverElements;
  18039. var idx = util.indexOf(hoverElements, elMirror);
  18040. if (idx >= 0) {
  18041. hoverElements.splice(idx, 1);
  18042. }
  18043. el.__hoverMir = null;
  18044. },
  18045. clearHover: function (el) {
  18046. var hoverElements = this._hoverElements;
  18047. for (var i = 0; i < hoverElements.length; i++) {
  18048. var from = hoverElements[i].__from;
  18049. if (from) {
  18050. from.__hoverMir = null;
  18051. }
  18052. }
  18053. hoverElements.length = 0;
  18054. },
  18055. refreshHover: function () {
  18056. var hoverElements = this._hoverElements;
  18057. var len = hoverElements.length;
  18058. var hoverLayer = this._hoverlayer;
  18059. hoverLayer && hoverLayer.clear();
  18060. if (!len) {
  18061. return;
  18062. }
  18063. timsort(hoverElements, this.storage.displayableSortFunc);
  18064. // Use a extream large zlevel
  18065. // FIXME?
  18066. if (!hoverLayer) {
  18067. hoverLayer = this._hoverlayer = this.getLayer(1e5);
  18068. }
  18069. var scope = {};
  18070. hoverLayer.ctx.save();
  18071. for (var i = 0; i < len;) {
  18072. var el = hoverElements[i];
  18073. var originalEl = el.__from;
  18074. // Original el is removed
  18075. // PENDING
  18076. if (!(originalEl && originalEl.__zr)) {
  18077. hoverElements.splice(i, 1);
  18078. originalEl.__hoverMir = null;
  18079. len--;
  18080. continue;
  18081. }
  18082. i++;
  18083. // Use transform
  18084. // FIXME style and shape ?
  18085. if (!originalEl.invisible) {
  18086. el.transform = originalEl.transform;
  18087. el.invTransform = originalEl.invTransform;
  18088. el.__clipPaths = originalEl.__clipPaths;
  18089. // el.
  18090. this._doPaintEl(el, hoverLayer, true, scope);
  18091. }
  18092. }
  18093. hoverLayer.ctx.restore();
  18094. },
  18095. _startProgessive: function () {
  18096. var self = this;
  18097. if (!self._furtherProgressive) {
  18098. return;
  18099. }
  18100. // Use a token to stop progress steps triggered by
  18101. // previous zr.refresh calling.
  18102. var token = self._progressiveToken = +new Date();
  18103. self._progress++;
  18104. requestAnimationFrame(step);
  18105. function step() {
  18106. // In case refreshed or disposed
  18107. if (token === self._progressiveToken && self.storage) {
  18108. self._doPaintList(self.storage.getDisplayList());
  18109. if (self._furtherProgressive) {
  18110. self._progress++;
  18111. requestAnimationFrame(step);
  18112. }
  18113. else {
  18114. self._progressiveToken = -1;
  18115. }
  18116. }
  18117. }
  18118. },
  18119. _clearProgressive: function () {
  18120. this._progressiveToken = -1;
  18121. this._progress = 0;
  18122. util.each(this._progressiveLayers, function (layer) {
  18123. layer.__dirty && layer.clear();
  18124. });
  18125. },
  18126. _paintList: function (list, paintAll) {
  18127. if (paintAll == null) {
  18128. paintAll = false;
  18129. }
  18130. this._updateLayerStatus(list);
  18131. this._clearProgressive();
  18132. this.eachBuiltinLayer(preProcessLayer);
  18133. this._doPaintList(list, paintAll);
  18134. this.eachBuiltinLayer(postProcessLayer);
  18135. },
  18136. _doPaintList: function (list, paintAll) {
  18137. var currentLayer;
  18138. var currentZLevel;
  18139. var ctx;
  18140. // var invTransform = [];
  18141. var scope;
  18142. var progressiveLayerIdx = 0;
  18143. var currentProgressiveLayer;
  18144. var width = this._width;
  18145. var height = this._height;
  18146. var layerProgress;
  18147. var frame = this._progress;
  18148. function flushProgressiveLayer(layer) {
  18149. var dpr = ctx.dpr || 1;
  18150. ctx.save();
  18151. ctx.globalAlpha = 1;
  18152. ctx.shadowBlur = 0;
  18153. // Avoid layer don't clear in next progressive frame
  18154. currentLayer.__dirty = true;
  18155. ctx.setTransform(1, 0, 0, 1, 0, 0);
  18156. ctx.drawImage(layer.dom, 0, 0, width * dpr, height * dpr);
  18157. ctx.restore();
  18158. }
  18159. for (var i = 0, l = list.length; i < l; i++) {
  18160. var el = list[i];
  18161. var elZLevel = this._singleCanvas ? 0 : el.zlevel;
  18162. var elFrame = el.__frame;
  18163. // Flush at current context
  18164. // PENDING
  18165. if (elFrame < 0 && currentProgressiveLayer) {
  18166. flushProgressiveLayer(currentProgressiveLayer);
  18167. currentProgressiveLayer = null;
  18168. }
  18169. // Change draw layer
  18170. if (currentZLevel !== elZLevel) {
  18171. if (ctx) {
  18172. ctx.restore();
  18173. }
  18174. // Reset scope
  18175. scope = {};
  18176. // Only 0 zlevel if only has one canvas
  18177. currentZLevel = elZLevel;
  18178. currentLayer = this.getLayer(currentZLevel);
  18179. if (!currentLayer.__builtin__) {
  18180. log(
  18181. 'ZLevel ' + currentZLevel
  18182. + ' has been used by unkown layer ' + currentLayer.id
  18183. );
  18184. }
  18185. ctx = currentLayer.ctx;
  18186. ctx.save();
  18187. // Reset the count
  18188. currentLayer.__unusedCount = 0;
  18189. if (currentLayer.__dirty || paintAll) {
  18190. currentLayer.clear();
  18191. }
  18192. }
  18193. if (!(currentLayer.__dirty || paintAll)) {
  18194. continue;
  18195. }
  18196. if (elFrame >= 0) {
  18197. // Progressive layer changed
  18198. if (!currentProgressiveLayer) {
  18199. currentProgressiveLayer = this._progressiveLayers[
  18200. Math.min(progressiveLayerIdx++, MAX_PROGRESSIVE_LAYER_NUMBER - 1)
  18201. ];
  18202. currentProgressiveLayer.ctx.save();
  18203. currentProgressiveLayer.renderScope = {};
  18204. if (currentProgressiveLayer
  18205. && (currentProgressiveLayer.__progress > currentProgressiveLayer.__maxProgress)
  18206. ) {
  18207. // flushProgressiveLayer(currentProgressiveLayer);
  18208. // Quick jump all progressive elements
  18209. // All progressive element are not dirty, jump over and flush directly
  18210. i = currentProgressiveLayer.__nextIdxNotProg - 1;
  18211. // currentProgressiveLayer = null;
  18212. continue;
  18213. }
  18214. layerProgress = currentProgressiveLayer.__progress;
  18215. if (!currentProgressiveLayer.__dirty) {
  18216. // Keep rendering
  18217. frame = layerProgress;
  18218. }
  18219. currentProgressiveLayer.__progress = frame + 1;
  18220. }
  18221. if (elFrame === frame) {
  18222. this._doPaintEl(el, currentProgressiveLayer, true, currentProgressiveLayer.renderScope);
  18223. }
  18224. }
  18225. else {
  18226. this._doPaintEl(el, currentLayer, paintAll, scope);
  18227. }
  18228. el.__dirty = false;
  18229. }
  18230. if (currentProgressiveLayer) {
  18231. flushProgressiveLayer(currentProgressiveLayer);
  18232. }
  18233. // Restore the lastLayer ctx
  18234. ctx && ctx.restore();
  18235. // If still has clipping state
  18236. // if (scope.prevElClipPaths) {
  18237. // ctx.restore();
  18238. // }
  18239. this._furtherProgressive = false;
  18240. util.each(this._progressiveLayers, function (layer) {
  18241. if (layer.__maxProgress >= layer.__progress) {
  18242. this._furtherProgressive = true;
  18243. }
  18244. }, this);
  18245. },
  18246. _doPaintEl: function (el, currentLayer, forcePaint, scope) {
  18247. var ctx = currentLayer.ctx;
  18248. var m = el.transform;
  18249. if (
  18250. (currentLayer.__dirty || forcePaint)
  18251. // Ignore invisible element
  18252. && !el.invisible
  18253. // Ignore transparent element
  18254. && el.style.opacity !== 0
  18255. // Ignore scale 0 element, in some environment like node-canvas
  18256. // Draw a scale 0 element can cause all following draw wrong
  18257. // And setTransform with scale 0 will cause set back transform failed.
  18258. && !(m && !m[0] && !m[3])
  18259. // Ignore culled element
  18260. && !(el.culling && isDisplayableCulled(el, this._width, this._height))
  18261. ) {
  18262. var clipPaths = el.__clipPaths;
  18263. // Optimize when clipping on group with several elements
  18264. if (scope.prevClipLayer !== currentLayer
  18265. || isClipPathChanged(clipPaths, scope.prevElClipPaths)
  18266. ) {
  18267. // If has previous clipping state, restore from it
  18268. if (scope.prevElClipPaths) {
  18269. scope.prevClipLayer.ctx.restore();
  18270. scope.prevClipLayer = scope.prevElClipPaths = null;
  18271. // Reset prevEl since context has been restored
  18272. scope.prevEl = null;
  18273. }
  18274. // New clipping state
  18275. if (clipPaths) {
  18276. ctx.save();
  18277. doClip(clipPaths, ctx);
  18278. scope.prevClipLayer = currentLayer;
  18279. scope.prevElClipPaths = clipPaths;
  18280. }
  18281. }
  18282. el.beforeBrush && el.beforeBrush(ctx);
  18283. el.brush(ctx, scope.prevEl || null);
  18284. scope.prevEl = el;
  18285. el.afterBrush && el.afterBrush(ctx);
  18286. }
  18287. },
  18288. /**
  18289. * 获取 zlevel 所在层,如果不存在则会创建一个新的层
  18290. * @param {number} zlevel
  18291. * @return {module:zrender/Layer}
  18292. */
  18293. getLayer: function (zlevel) {
  18294. if (this._singleCanvas) {
  18295. return this._layers[0];
  18296. }
  18297. var layer = this._layers[zlevel];
  18298. if (!layer) {
  18299. // Create a new layer
  18300. layer = new Layer('zr_' + zlevel, this, this.dpr);
  18301. layer.__builtin__ = true;
  18302. if (this._layerConfig[zlevel]) {
  18303. util.merge(layer, this._layerConfig[zlevel], true);
  18304. }
  18305. this.insertLayer(zlevel, layer);
  18306. // Context is created after dom inserted to document
  18307. // Or excanvas will get 0px clientWidth and clientHeight
  18308. layer.initContext();
  18309. }
  18310. return layer;
  18311. },
  18312. insertLayer: function (zlevel, layer) {
  18313. var layersMap = this._layers;
  18314. var zlevelList = this._zlevelList;
  18315. var len = zlevelList.length;
  18316. var prevLayer = null;
  18317. var i = -1;
  18318. var domRoot = this._domRoot;
  18319. if (layersMap[zlevel]) {
  18320. log('ZLevel ' + zlevel + ' has been used already');
  18321. return;
  18322. }
  18323. // Check if is a valid layer
  18324. if (!isLayerValid(layer)) {
  18325. log('Layer of zlevel ' + zlevel + ' is not valid');
  18326. return;
  18327. }
  18328. if (len > 0 && zlevel > zlevelList[0]) {
  18329. for (i = 0; i < len - 1; i++) {
  18330. if (
  18331. zlevelList[i] < zlevel
  18332. && zlevelList[i + 1] > zlevel
  18333. ) {
  18334. break;
  18335. }
  18336. }
  18337. prevLayer = layersMap[zlevelList[i]];
  18338. }
  18339. zlevelList.splice(i + 1, 0, zlevel);
  18340. layersMap[zlevel] = layer;
  18341. // Vitual layer will not directly show on the screen.
  18342. // (It can be a WebGL layer and assigned to a ZImage element)
  18343. // But it still under management of zrender.
  18344. if (!layer.virtual) {
  18345. if (prevLayer) {
  18346. var prevDom = prevLayer.dom;
  18347. if (prevDom.nextSibling) {
  18348. domRoot.insertBefore(
  18349. layer.dom,
  18350. prevDom.nextSibling
  18351. );
  18352. }
  18353. else {
  18354. domRoot.appendChild(layer.dom);
  18355. }
  18356. }
  18357. else {
  18358. if (domRoot.firstChild) {
  18359. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  18360. }
  18361. else {
  18362. domRoot.appendChild(layer.dom);
  18363. }
  18364. }
  18365. }
  18366. },
  18367. // Iterate each layer
  18368. eachLayer: function (cb, context) {
  18369. var zlevelList = this._zlevelList;
  18370. var z;
  18371. var i;
  18372. for (i = 0; i < zlevelList.length; i++) {
  18373. z = zlevelList[i];
  18374. cb.call(context, this._layers[z], z);
  18375. }
  18376. },
  18377. // Iterate each buildin layer
  18378. eachBuiltinLayer: function (cb, context) {
  18379. var zlevelList = this._zlevelList;
  18380. var layer;
  18381. var z;
  18382. var i;
  18383. for (i = 0; i < zlevelList.length; i++) {
  18384. z = zlevelList[i];
  18385. layer = this._layers[z];
  18386. if (layer.__builtin__) {
  18387. cb.call(context, layer, z);
  18388. }
  18389. }
  18390. },
  18391. // Iterate each other layer except buildin layer
  18392. eachOtherLayer: function (cb, context) {
  18393. var zlevelList = this._zlevelList;
  18394. var layer;
  18395. var z;
  18396. var i;
  18397. for (i = 0; i < zlevelList.length; i++) {
  18398. z = zlevelList[i];
  18399. layer = this._layers[z];
  18400. if (!layer.__builtin__) {
  18401. cb.call(context, layer, z);
  18402. }
  18403. }
  18404. },
  18405. /**
  18406. * 获取所有已创建的层
  18407. * @param {Array.<module:zrender/Layer>} [prevLayer]
  18408. */
  18409. getLayers: function () {
  18410. return this._layers;
  18411. },
  18412. _updateLayerStatus: function (list) {
  18413. var layers = this._layers;
  18414. var progressiveLayers = this._progressiveLayers;
  18415. var elCountsLastFrame = {};
  18416. var progressiveElCountsLastFrame = {};
  18417. this.eachBuiltinLayer(function (layer, z) {
  18418. elCountsLastFrame[z] = layer.elCount;
  18419. layer.elCount = 0;
  18420. layer.__dirty = false;
  18421. });
  18422. util.each(progressiveLayers, function (layer, idx) {
  18423. progressiveElCountsLastFrame[idx] = layer.elCount;
  18424. layer.elCount = 0;
  18425. layer.__dirty = false;
  18426. });
  18427. var progressiveLayerCount = 0;
  18428. var currentProgressiveLayer;
  18429. var lastProgressiveKey;
  18430. var frameCount = 0;
  18431. for (var i = 0, l = list.length; i < l; i++) {
  18432. var el = list[i];
  18433. var zlevel = this._singleCanvas ? 0 : el.zlevel;
  18434. var layer = layers[zlevel];
  18435. var elProgress = el.progressive;
  18436. if (layer) {
  18437. layer.elCount++;
  18438. layer.__dirty = layer.__dirty || el.__dirty;
  18439. }
  18440. /////// Update progressive
  18441. if (elProgress >= 0) {
  18442. // Fix wrong progressive sequence problem.
  18443. if (lastProgressiveKey !== elProgress) {
  18444. lastProgressiveKey = elProgress;
  18445. frameCount++;
  18446. }
  18447. var elFrame = el.__frame = frameCount - 1;
  18448. if (!currentProgressiveLayer) {
  18449. var idx = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER - 1);
  18450. currentProgressiveLayer = progressiveLayers[idx];
  18451. if (!currentProgressiveLayer) {
  18452. currentProgressiveLayer = progressiveLayers[idx] = new Layer(
  18453. 'progressive', this, this.dpr
  18454. );
  18455. currentProgressiveLayer.initContext();
  18456. }
  18457. currentProgressiveLayer.__maxProgress = 0;
  18458. }
  18459. currentProgressiveLayer.__dirty = currentProgressiveLayer.__dirty || el.__dirty;
  18460. currentProgressiveLayer.elCount++;
  18461. currentProgressiveLayer.__maxProgress = Math.max(
  18462. currentProgressiveLayer.__maxProgress, elFrame
  18463. );
  18464. if (currentProgressiveLayer.__maxProgress >= currentProgressiveLayer.__progress) {
  18465. // Should keep rendering this layer because progressive rendering is not finished yet
  18466. layer.__dirty = true;
  18467. }
  18468. }
  18469. else {
  18470. el.__frame = -1;
  18471. if (currentProgressiveLayer) {
  18472. currentProgressiveLayer.__nextIdxNotProg = i;
  18473. progressiveLayerCount++;
  18474. currentProgressiveLayer = null;
  18475. }
  18476. }
  18477. }
  18478. if (currentProgressiveLayer) {
  18479. progressiveLayerCount++;
  18480. currentProgressiveLayer.__nextIdxNotProg = i;
  18481. }
  18482. // 层中的元素数量有发生变化
  18483. this.eachBuiltinLayer(function (layer, z) {
  18484. if (elCountsLastFrame[z] !== layer.elCount) {
  18485. layer.__dirty = true;
  18486. }
  18487. });
  18488. progressiveLayers.length = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER);
  18489. util.each(progressiveLayers, function (layer, idx) {
  18490. if (progressiveElCountsLastFrame[idx] !== layer.elCount) {
  18491. el.__dirty = true;
  18492. }
  18493. if (layer.__dirty) {
  18494. layer.__progress = 0;
  18495. }
  18496. });
  18497. },
  18498. /**
  18499. * 清除hover层外所有内容
  18500. */
  18501. clear: function () {
  18502. this.eachBuiltinLayer(this._clearLayer);
  18503. return this;
  18504. },
  18505. _clearLayer: function (layer) {
  18506. layer.clear();
  18507. },
  18508. /**
  18509. * 修改指定zlevel的绘制参数
  18510. *
  18511. * @param {string} zlevel
  18512. * @param {Object} config 配置对象
  18513. * @param {string} [config.clearColor=0] 每次清空画布的颜色
  18514. * @param {string} [config.motionBlur=false] 是否开启动态模糊
  18515. * @param {number} [config.lastFrameAlpha=0.7]
  18516. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  18517. */
  18518. configLayer: function (zlevel, config) {
  18519. if (config) {
  18520. var layerConfig = this._layerConfig;
  18521. if (!layerConfig[zlevel]) {
  18522. layerConfig[zlevel] = config;
  18523. }
  18524. else {
  18525. util.merge(layerConfig[zlevel], config, true);
  18526. }
  18527. var layer = this._layers[zlevel];
  18528. if (layer) {
  18529. util.merge(layer, layerConfig[zlevel], true);
  18530. }
  18531. }
  18532. },
  18533. /**
  18534. * 删除指定层
  18535. * @param {number} zlevel 层所在的zlevel
  18536. */
  18537. delLayer: function (zlevel) {
  18538. var layers = this._layers;
  18539. var zlevelList = this._zlevelList;
  18540. var layer = layers[zlevel];
  18541. if (!layer) {
  18542. return;
  18543. }
  18544. layer.dom.parentNode.removeChild(layer.dom);
  18545. delete layers[zlevel];
  18546. zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
  18547. },
  18548. /**
  18549. * 区域大小变化后重绘
  18550. */
  18551. resize: function (width, height) {
  18552. var domRoot = this._domRoot;
  18553. // FIXME Why ?
  18554. domRoot.style.display = 'none';
  18555. // Save input w/h
  18556. var opts = this._opts;
  18557. width != null && (opts.width = width);
  18558. height != null && (opts.height = height);
  18559. width = this._getSize(0);
  18560. height = this._getSize(1);
  18561. domRoot.style.display = '';
  18562. // 优化没有实际改变的resize
  18563. if (this._width != width || height != this._height) {
  18564. domRoot.style.width = width + 'px';
  18565. domRoot.style.height = height + 'px';
  18566. for (var id in this._layers) {
  18567. if (this._layers.hasOwnProperty(id)) {
  18568. this._layers[id].resize(width, height);
  18569. }
  18570. }
  18571. util.each(this._progressiveLayers, function (layer) {
  18572. layer.resize(width, height);
  18573. });
  18574. this.refresh(true);
  18575. }
  18576. this._width = width;
  18577. this._height = height;
  18578. return this;
  18579. },
  18580. /**
  18581. * 清除单独的一个层
  18582. * @param {number} zlevel
  18583. */
  18584. clearLayer: function (zlevel) {
  18585. var layer = this._layers[zlevel];
  18586. if (layer) {
  18587. layer.clear();
  18588. }
  18589. },
  18590. /**
  18591. * 释放
  18592. */
  18593. dispose: function () {
  18594. this.root.innerHTML = '';
  18595. this.root =
  18596. this.storage =
  18597. this._domRoot =
  18598. this._layers = null;
  18599. },
  18600. /**
  18601. * Get canvas which has all thing rendered
  18602. * @param {Object} opts
  18603. * @param {string} [opts.backgroundColor]
  18604. */
  18605. getRenderedCanvas: function (opts) {
  18606. opts = opts || {};
  18607. if (this._singleCanvas) {
  18608. return this._layers[0].dom;
  18609. }
  18610. var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
  18611. imageLayer.initContext();
  18612. imageLayer.clearColor = opts.backgroundColor;
  18613. imageLayer.clear();
  18614. var displayList = this.storage.getDisplayList(true);
  18615. var scope = {};
  18616. var zlevel;
  18617. var self = this;
  18618. function findAndDrawOtherLayer(smaller, larger) {
  18619. var zlevelList = self._zlevelList;
  18620. if (smaller == null) {
  18621. smaller = -Infinity;
  18622. }
  18623. var intermediateLayer;
  18624. for (var i = 0; i < zlevelList.length; i++) {
  18625. var z = zlevelList[i];
  18626. var layer = self._layers[z];
  18627. if (!layer.__builtin__ && z > smaller && z < larger) {
  18628. intermediateLayer = layer;
  18629. break;
  18630. }
  18631. }
  18632. if (intermediateLayer && intermediateLayer.renderToCanvas) {
  18633. imageLayer.ctx.save();
  18634. intermediateLayer.renderToCanvas(imageLayer.ctx);
  18635. imageLayer.ctx.restore();
  18636. }
  18637. }
  18638. for (var i = 0; i < displayList.length; i++) {
  18639. var el = displayList[i];
  18640. if (el.zlevel !== zlevel) {
  18641. findAndDrawOtherLayer(zlevel, el.zlevel);
  18642. zlevel = el.zlevel;
  18643. }
  18644. this._doPaintEl(el, imageLayer, true, scope);
  18645. }
  18646. findAndDrawOtherLayer(zlevel, Infinity);
  18647. return imageLayer.dom;
  18648. },
  18649. /**
  18650. * 获取绘图区域宽度
  18651. */
  18652. getWidth: function () {
  18653. return this._width;
  18654. },
  18655. /**
  18656. * 获取绘图区域高度
  18657. */
  18658. getHeight: function () {
  18659. return this._height;
  18660. },
  18661. _getSize: function (whIdx) {
  18662. var opts = this._opts;
  18663. var wh = ['width', 'height'][whIdx];
  18664. var cwh = ['clientWidth', 'clientHeight'][whIdx];
  18665. var plt = ['paddingLeft', 'paddingTop'][whIdx];
  18666. var prb = ['paddingRight', 'paddingBottom'][whIdx];
  18667. if (opts[wh] != null && opts[wh] !== 'auto') {
  18668. return parseFloat(opts[wh]);
  18669. }
  18670. var root = this.root;
  18671. var stl = document.defaultView.getComputedStyle(root);
  18672. return (
  18673. (root[cwh] || parseInt10(stl[wh]) || parseInt10(root.style[wh]))
  18674. - (parseInt10(stl[plt]) || 0)
  18675. - (parseInt10(stl[prb]) || 0)
  18676. ) | 0;
  18677. },
  18678. pathToImage: function (path, dpr) {
  18679. dpr = dpr || this.dpr;
  18680. var canvas = document.createElement('canvas');
  18681. var ctx = canvas.getContext('2d');
  18682. var rect = path.getBoundingRect();
  18683. var style = path.style;
  18684. var shadowBlurSize = style.shadowBlur;
  18685. var shadowOffsetX = style.shadowOffsetX;
  18686. var shadowOffsetY = style.shadowOffsetY;
  18687. var lineWidth = style.hasStroke() ? style.lineWidth : 0;
  18688. var leftMargin = Math.max(lineWidth / 2, -shadowOffsetX + shadowBlurSize);
  18689. var rightMargin = Math.max(lineWidth / 2, shadowOffsetX + shadowBlurSize);
  18690. var topMargin = Math.max(lineWidth / 2, -shadowOffsetY + shadowBlurSize);
  18691. var bottomMargin = Math.max(lineWidth / 2, shadowOffsetY + shadowBlurSize);
  18692. var width = rect.width + leftMargin + rightMargin;
  18693. var height = rect.height + topMargin + bottomMargin;
  18694. canvas.width = width * dpr;
  18695. canvas.height = height * dpr;
  18696. ctx.scale(dpr, dpr);
  18697. ctx.clearRect(0, 0, width, height);
  18698. ctx.dpr = dpr;
  18699. var pathTransform = {
  18700. position: path.position,
  18701. rotation: path.rotation,
  18702. scale: path.scale
  18703. };
  18704. path.position = [leftMargin - rect.x, topMargin - rect.y];
  18705. path.rotation = 0;
  18706. path.scale = [1, 1];
  18707. path.updateTransform();
  18708. if (path) {
  18709. path.brush(ctx);
  18710. }
  18711. var ImageShape = __webpack_require__(49);
  18712. var imgShape = new ImageShape({
  18713. style: {
  18714. x: 0,
  18715. y: 0,
  18716. image: canvas
  18717. }
  18718. });
  18719. if (pathTransform.position != null) {
  18720. imgShape.position = path.position = pathTransform.position;
  18721. }
  18722. if (pathTransform.rotation != null) {
  18723. imgShape.rotation = path.rotation = pathTransform.rotation;
  18724. }
  18725. if (pathTransform.scale != null) {
  18726. imgShape.scale = path.scale = pathTransform.scale;
  18727. }
  18728. return imgShape;
  18729. }
  18730. };
  18731. module.exports = Painter;
  18732. /***/ },
  18733. /* 93 */
  18734. /***/ function(module, exports, __webpack_require__) {
  18735. /**
  18736. * @module zrender/Layer
  18737. * @author pissang(https://www.github.com/pissang)
  18738. */
  18739. var util = __webpack_require__(4);
  18740. var config = __webpack_require__(34);
  18741. var Style = __webpack_require__(22);
  18742. var Pattern = __webpack_require__(46);
  18743. function returnFalse() {
  18744. return false;
  18745. }
  18746. /**
  18747. * 创建dom
  18748. *
  18749. * @inner
  18750. * @param {string} id dom id 待用
  18751. * @param {string} type dom type,such as canvas, div etc.
  18752. * @param {Painter} painter painter instance
  18753. * @param {number} number
  18754. */
  18755. function createDom(id, type, painter, dpr) {
  18756. var newDom = document.createElement(type);
  18757. var width = painter.getWidth();
  18758. var height = painter.getHeight();
  18759. var newDomStyle = newDom.style;
  18760. // 没append呢,请原谅我这样写,清晰~
  18761. newDomStyle.position = 'absolute';
  18762. newDomStyle.left = 0;
  18763. newDomStyle.top = 0;
  18764. newDomStyle.width = width + 'px';
  18765. newDomStyle.height = height + 'px';
  18766. newDom.width = width * dpr;
  18767. newDom.height = height * dpr;
  18768. // id不作为索引用,避免可能造成的重名,定义为私有属性
  18769. newDom.setAttribute('data-zr-dom-id', id);
  18770. return newDom;
  18771. }
  18772. /**
  18773. * @alias module:zrender/Layer
  18774. * @constructor
  18775. * @extends module:zrender/mixin/Transformable
  18776. * @param {string} id
  18777. * @param {module:zrender/Painter} painter
  18778. * @param {number} [dpr]
  18779. */
  18780. var Layer = function(id, painter, dpr) {
  18781. var dom;
  18782. dpr = dpr || config.devicePixelRatio;
  18783. if (typeof id === 'string') {
  18784. dom = createDom(id, 'canvas', painter, dpr);
  18785. }
  18786. // Not using isDom because in node it will return false
  18787. else if (util.isObject(id)) {
  18788. dom = id;
  18789. id = dom.id;
  18790. }
  18791. this.id = id;
  18792. this.dom = dom;
  18793. var domStyle = dom.style;
  18794. if (domStyle) { // Not in node
  18795. dom.onselectstart = returnFalse; // 避免页面选中的尴尬
  18796. domStyle['-webkit-user-select'] = 'none';
  18797. domStyle['user-select'] = 'none';
  18798. domStyle['-webkit-touch-callout'] = 'none';
  18799. domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)';
  18800. domStyle['padding'] = 0;
  18801. domStyle['margin'] = 0;
  18802. domStyle['border-width'] = 0;
  18803. }
  18804. this.domBack = null;
  18805. this.ctxBack = null;
  18806. this.painter = painter;
  18807. this.config = null;
  18808. // Configs
  18809. /**
  18810. * 每次清空画布的颜色
  18811. * @type {string}
  18812. * @default 0
  18813. */
  18814. this.clearColor = 0;
  18815. /**
  18816. * 是否开启动态模糊
  18817. * @type {boolean}
  18818. * @default false
  18819. */
  18820. this.motionBlur = false;
  18821. /**
  18822. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  18823. * @type {number}
  18824. * @default 0.7
  18825. */
  18826. this.lastFrameAlpha = 0.7;
  18827. /**
  18828. * Layer dpr
  18829. * @type {number}
  18830. */
  18831. this.dpr = dpr;
  18832. };
  18833. Layer.prototype = {
  18834. constructor: Layer,
  18835. elCount: 0,
  18836. __dirty: true,
  18837. initContext: function () {
  18838. this.ctx = this.dom.getContext('2d');
  18839. this.ctx.dpr = this.dpr;
  18840. },
  18841. createBackBuffer: function () {
  18842. var dpr = this.dpr;
  18843. this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr);
  18844. this.ctxBack = this.domBack.getContext('2d');
  18845. if (dpr != 1) {
  18846. this.ctxBack.scale(dpr, dpr);
  18847. }
  18848. },
  18849. /**
  18850. * @param {number} width
  18851. * @param {number} height
  18852. */
  18853. resize: function (width, height) {
  18854. var dpr = this.dpr;
  18855. var dom = this.dom;
  18856. var domStyle = dom.style;
  18857. var domBack = this.domBack;
  18858. domStyle.width = width + 'px';
  18859. domStyle.height = height + 'px';
  18860. dom.width = width * dpr;
  18861. dom.height = height * dpr;
  18862. if (domBack) {
  18863. domBack.width = width * dpr;
  18864. domBack.height = height * dpr;
  18865. if (dpr != 1) {
  18866. this.ctxBack.scale(dpr, dpr);
  18867. }
  18868. }
  18869. },
  18870. /**
  18871. * 清空该层画布
  18872. * @param {boolean} clearAll Clear all with out motion blur
  18873. */
  18874. clear: function (clearAll) {
  18875. var dom = this.dom;
  18876. var ctx = this.ctx;
  18877. var width = dom.width;
  18878. var height = dom.height;
  18879. var clearColor = this.clearColor;
  18880. var haveMotionBLur = this.motionBlur && !clearAll;
  18881. var lastFrameAlpha = this.lastFrameAlpha;
  18882. var dpr = this.dpr;
  18883. if (haveMotionBLur) {
  18884. if (!this.domBack) {
  18885. this.createBackBuffer();
  18886. }
  18887. this.ctxBack.globalCompositeOperation = 'copy';
  18888. this.ctxBack.drawImage(
  18889. dom, 0, 0,
  18890. width / dpr,
  18891. height / dpr
  18892. );
  18893. }
  18894. ctx.clearRect(0, 0, width, height);
  18895. if (clearColor) {
  18896. var clearColorGradientOrPattern;
  18897. // Gradient
  18898. if (clearColor.colorStops) {
  18899. // Cache canvas gradient
  18900. clearColorGradientOrPattern = clearColor.__canvasGradient || Style.getGradient(ctx, clearColor, {
  18901. x: 0,
  18902. y: 0,
  18903. width: width,
  18904. height: height
  18905. });
  18906. clearColor.__canvasGradient = clearColorGradientOrPattern;
  18907. }
  18908. // Pattern
  18909. else if (clearColor.image) {
  18910. clearColorGradientOrPattern = Pattern.prototype.getCanvasPattern.call(clearColor, ctx);
  18911. }
  18912. ctx.save();
  18913. ctx.fillStyle = clearColorGradientOrPattern || clearColor;
  18914. ctx.fillRect(0, 0, width, height);
  18915. ctx.restore();
  18916. }
  18917. if (haveMotionBLur) {
  18918. var domBack = this.domBack;
  18919. ctx.save();
  18920. ctx.globalAlpha = lastFrameAlpha;
  18921. ctx.drawImage(domBack, 0, 0, width, height);
  18922. ctx.restore();
  18923. }
  18924. }
  18925. };
  18926. module.exports = Layer;
  18927. /***/ },
  18928. /* 94 */
  18929. /***/ function(module, exports, __webpack_require__) {
  18930. var Gradient = __webpack_require__(66);
  18931. module.exports = function (ecModel) {
  18932. function encodeColor(seriesModel) {
  18933. var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.normal.color').split('.');
  18934. var data = seriesModel.getData();
  18935. var color = seriesModel.get(colorAccessPath) // Set in itemStyle
  18936. || seriesModel.getColorFromPalette(seriesModel.get('name')); // Default color
  18937. // FIXME Set color function or use the platte color
  18938. data.setVisual('color', color);
  18939. // Only visible series has each data be visual encoded
  18940. if (!ecModel.isSeriesFiltered(seriesModel)) {
  18941. if (typeof color === 'function' && !(color instanceof Gradient)) {
  18942. data.each(function (idx) {
  18943. data.setItemVisual(
  18944. idx, 'color', color(seriesModel.getDataParams(idx))
  18945. );
  18946. });
  18947. }
  18948. // itemStyle in each data item
  18949. data.each(function (idx) {
  18950. var itemModel = data.getItemModel(idx);
  18951. var color = itemModel.get(colorAccessPath, true);
  18952. if (color != null) {
  18953. data.setItemVisual(idx, 'color', color);
  18954. }
  18955. });
  18956. }
  18957. }
  18958. ecModel.eachRawSeries(encodeColor);
  18959. };
  18960. /***/ },
  18961. /* 95 */
  18962. /***/ function(module, exports, __webpack_require__) {
  18963. // Compatitable with 2.0
  18964. var zrUtil = __webpack_require__(4);
  18965. var compatStyle = __webpack_require__(96);
  18966. function get(opt, path) {
  18967. path = path.split(',');
  18968. var obj = opt;
  18969. for (var i = 0; i < path.length; i++) {
  18970. obj = obj && obj[path[i]];
  18971. if (obj == null) {
  18972. break;
  18973. }
  18974. }
  18975. return obj;
  18976. }
  18977. function set(opt, path, val, overwrite) {
  18978. path = path.split(',');
  18979. var obj = opt;
  18980. var key;
  18981. for (var i = 0; i < path.length - 1; i++) {
  18982. key = path[i];
  18983. if (obj[key] == null) {
  18984. obj[key] = {};
  18985. }
  18986. obj = obj[key];
  18987. }
  18988. if (overwrite || obj[path[i]] == null) {
  18989. obj[path[i]] = val;
  18990. }
  18991. }
  18992. function compatLayoutProperties(option) {
  18993. each(LAYOUT_PROPERTIES, function (prop) {
  18994. if (prop[0] in option && !(prop[1] in option)) {
  18995. option[prop[1]] = option[prop[0]];
  18996. }
  18997. });
  18998. }
  18999. var LAYOUT_PROPERTIES = [
  19000. ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom']
  19001. ];
  19002. var COMPATITABLE_COMPONENTS = [
  19003. 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline'
  19004. ];
  19005. var COMPATITABLE_SERIES = [
  19006. 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter',
  19007. 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel',
  19008. 'pie', 'radar', 'sankey', 'scatter', 'treemap'
  19009. ];
  19010. var each = zrUtil.each;
  19011. module.exports = function (option) {
  19012. each(option.series, function (seriesOpt) {
  19013. if (!zrUtil.isObject(seriesOpt)) {
  19014. return;
  19015. }
  19016. var seriesType = seriesOpt.type;
  19017. compatStyle(seriesOpt);
  19018. if (seriesType === 'pie' || seriesType === 'gauge') {
  19019. if (seriesOpt.clockWise != null) {
  19020. seriesOpt.clockwise = seriesOpt.clockWise;
  19021. }
  19022. }
  19023. if (seriesType === 'gauge') {
  19024. var pointerColor = get(seriesOpt, 'pointer.color');
  19025. pointerColor != null
  19026. && set(seriesOpt, 'itemStyle.normal.color', pointerColor);
  19027. }
  19028. for (var i = 0; i < COMPATITABLE_SERIES.length; i++) {
  19029. if (COMPATITABLE_SERIES[i] === seriesOpt.type) {
  19030. compatLayoutProperties(seriesOpt);
  19031. break;
  19032. }
  19033. }
  19034. });
  19035. // dataRange has changed to visualMap
  19036. if (option.dataRange) {
  19037. option.visualMap = option.dataRange;
  19038. }
  19039. each(COMPATITABLE_COMPONENTS, function (componentName) {
  19040. var options = option[componentName];
  19041. if (options) {
  19042. if (!zrUtil.isArray(options)) {
  19043. options = [options];
  19044. }
  19045. each(options, function (option) {
  19046. compatLayoutProperties(option);
  19047. });
  19048. }
  19049. });
  19050. };
  19051. /***/ },
  19052. /* 96 */
  19053. /***/ function(module, exports, __webpack_require__) {
  19054. var zrUtil = __webpack_require__(4);
  19055. var POSSIBLE_STYLES = [
  19056. 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
  19057. 'chordStyle', 'label', 'labelLine'
  19058. ];
  19059. function compatItemStyle(opt) {
  19060. var itemStyleOpt = opt && opt.itemStyle;
  19061. if (itemStyleOpt) {
  19062. zrUtil.each(POSSIBLE_STYLES, function (styleName) {
  19063. var normalItemStyleOpt = itemStyleOpt.normal;
  19064. var emphasisItemStyleOpt = itemStyleOpt.emphasis;
  19065. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  19066. opt[styleName] = opt[styleName] || {};
  19067. if (!opt[styleName].normal) {
  19068. opt[styleName].normal = normalItemStyleOpt[styleName];
  19069. }
  19070. else {
  19071. zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
  19072. }
  19073. normalItemStyleOpt[styleName] = null;
  19074. }
  19075. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  19076. opt[styleName] = opt[styleName] || {};
  19077. if (!opt[styleName].emphasis) {
  19078. opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
  19079. }
  19080. else {
  19081. zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
  19082. }
  19083. emphasisItemStyleOpt[styleName] = null;
  19084. }
  19085. });
  19086. }
  19087. }
  19088. module.exports = function (seriesOpt) {
  19089. if (!seriesOpt) {
  19090. return;
  19091. }
  19092. compatItemStyle(seriesOpt);
  19093. compatItemStyle(seriesOpt.markPoint);
  19094. compatItemStyle(seriesOpt.markLine);
  19095. var data = seriesOpt.data;
  19096. if (data) {
  19097. for (var i = 0; i < data.length; i++) {
  19098. compatItemStyle(data[i]);
  19099. }
  19100. // mark point data
  19101. var markPoint = seriesOpt.markPoint;
  19102. if (markPoint && markPoint.data) {
  19103. var mpData = markPoint.data;
  19104. for (var i = 0; i < mpData.length; i++) {
  19105. compatItemStyle(mpData[i]);
  19106. }
  19107. }
  19108. // mark line data
  19109. var markLine = seriesOpt.markLine;
  19110. if (markLine && markLine.data) {
  19111. var mlData = markLine.data;
  19112. for (var i = 0; i < mlData.length; i++) {
  19113. if (zrUtil.isArray(mlData[i])) {
  19114. compatItemStyle(mlData[i][0]);
  19115. compatItemStyle(mlData[i][1]);
  19116. }
  19117. else {
  19118. compatItemStyle(mlData[i]);
  19119. }
  19120. }
  19121. }
  19122. }
  19123. };
  19124. /***/ },
  19125. /* 97 */
  19126. /***/ function(module, exports, __webpack_require__) {
  19127. var graphic = __webpack_require__(18);
  19128. var zrUtil = __webpack_require__(4);
  19129. var PI = Math.PI;
  19130. /**
  19131. * @param {module:echarts/ExtensionAPI} api
  19132. * @param {Object} [opts]
  19133. * @param {string} [opts.text]
  19134. * @param {string} [opts.color]
  19135. * @param {string} [opts.textColor]
  19136. * @return {module:zrender/Element}
  19137. */
  19138. module.exports = function (api, opts) {
  19139. opts = opts || {};
  19140. zrUtil.defaults(opts, {
  19141. text: 'loading',
  19142. color: '#c23531',
  19143. textColor: '#000',
  19144. maskColor: 'rgba(255, 255, 255, 0.8)',
  19145. zlevel: 0
  19146. });
  19147. var mask = new graphic.Rect({
  19148. style: {
  19149. fill: opts.maskColor
  19150. },
  19151. zlevel: opts.zlevel,
  19152. z: 10000
  19153. });
  19154. var arc = new graphic.Arc({
  19155. shape: {
  19156. startAngle: -PI / 2,
  19157. endAngle: -PI / 2 + 0.1,
  19158. r: 10
  19159. },
  19160. style: {
  19161. stroke: opts.color,
  19162. lineCap: 'round',
  19163. lineWidth: 5
  19164. },
  19165. zlevel: opts.zlevel,
  19166. z: 10001
  19167. });
  19168. var labelRect = new graphic.Rect({
  19169. style: {
  19170. fill: 'none',
  19171. text: opts.text,
  19172. textPosition: 'right',
  19173. textDistance: 10,
  19174. textFill: opts.textColor
  19175. },
  19176. zlevel: opts.zlevel,
  19177. z: 10001
  19178. });
  19179. arc.animateShape(true)
  19180. .when(1000, {
  19181. endAngle: PI * 3 / 2
  19182. })
  19183. .start('circularInOut');
  19184. arc.animateShape(true)
  19185. .when(1000, {
  19186. startAngle: PI * 3 / 2
  19187. })
  19188. .delay(300)
  19189. .start('circularInOut');
  19190. var group = new graphic.Group();
  19191. group.add(arc);
  19192. group.add(labelRect);
  19193. group.add(mask);
  19194. // Inject resize
  19195. group.resize = function () {
  19196. var cx = api.getWidth() / 2;
  19197. var cy = api.getHeight() / 2;
  19198. arc.setShape({
  19199. cx: cx,
  19200. cy: cy
  19201. });
  19202. var r = arc.shape.r;
  19203. labelRect.setShape({
  19204. x: cx - r,
  19205. y: cy - r,
  19206. width: r * 2,
  19207. height: r * 2
  19208. });
  19209. mask.setShape({
  19210. x: 0,
  19211. y: 0,
  19212. width: api.getWidth(),
  19213. height: api.getHeight()
  19214. });
  19215. };
  19216. group.resize();
  19217. return group;
  19218. };
  19219. /***/ },
  19220. /* 98 */
  19221. /***/ function(module, exports, __webpack_require__) {
  19222. /* WEBPACK VAR INJECTION */(function(global) {/**
  19223. * List for data storage
  19224. * @module echarts/data/List
  19225. */
  19226. var UNDEFINED = 'undefined';
  19227. var globalObj = typeof window === 'undefined' ? global : window;
  19228. var Float64Array = typeof globalObj.Float64Array === UNDEFINED
  19229. ? Array : globalObj.Float64Array;
  19230. var Int32Array = typeof globalObj.Int32Array === UNDEFINED
  19231. ? Array : globalObj.Int32Array;
  19232. var dataCtors = {
  19233. 'float': Float64Array,
  19234. 'int': Int32Array,
  19235. // Ordinal data type can be string or int
  19236. 'ordinal': Array,
  19237. 'number': Array,
  19238. 'time': Array
  19239. };
  19240. var Model = __webpack_require__(12);
  19241. var DataDiffer = __webpack_require__(99);
  19242. var zrUtil = __webpack_require__(4);
  19243. var modelUtil = __webpack_require__(5);
  19244. var isObject = zrUtil.isObject;
  19245. var TRANSFERABLE_PROPERTIES = [
  19246. 'stackedOn', 'hasItemOption', '_nameList', '_idList', '_rawData'
  19247. ];
  19248. function transferProperties(a, b) {
  19249. zrUtil.each(TRANSFERABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
  19250. if (b.hasOwnProperty(propName)) {
  19251. a[propName] = b[propName];
  19252. }
  19253. });
  19254. a.__wrappedMethods = b.__wrappedMethods;
  19255. }
  19256. function DefaultDataProvider(dataArray) {
  19257. this._array = dataArray || [];
  19258. }
  19259. DefaultDataProvider.prototype.pure = false;
  19260. DefaultDataProvider.prototype.count = function () {
  19261. return this._array.length;
  19262. };
  19263. DefaultDataProvider.prototype.getItem = function (idx) {
  19264. return this._array[idx];
  19265. };
  19266. /**
  19267. * @constructor
  19268. * @alias module:echarts/data/List
  19269. *
  19270. * @param {Array.<string|Object>} dimensions
  19271. * For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
  19272. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  19273. * @param {module:echarts/model/Model} hostModel
  19274. */
  19275. var List = function (dimensions, hostModel) {
  19276. dimensions = dimensions || ['x', 'y'];
  19277. var dimensionInfos = {};
  19278. var dimensionNames = [];
  19279. for (var i = 0; i < dimensions.length; i++) {
  19280. var dimensionName;
  19281. var dimensionInfo = {};
  19282. if (typeof dimensions[i] === 'string') {
  19283. dimensionName = dimensions[i];
  19284. dimensionInfo = {
  19285. name: dimensionName,
  19286. coordDim: dimensionName,
  19287. coordDimIndex: 0,
  19288. stackable: false,
  19289. // Type can be 'float', 'int', 'number'
  19290. // Default is number, Precision of float may not enough
  19291. type: 'number'
  19292. };
  19293. }
  19294. else {
  19295. dimensionInfo = dimensions[i];
  19296. dimensionName = dimensionInfo.name;
  19297. dimensionInfo.type = dimensionInfo.type || 'number';
  19298. if (!dimensionInfo.coordDim) {
  19299. dimensionInfo.coordDim = dimensionName;
  19300. dimensionInfo.coordDimIndex = 0;
  19301. }
  19302. }
  19303. dimensionInfo.otherDims = dimensionInfo.otherDims || {};
  19304. dimensionNames.push(dimensionName);
  19305. dimensionInfos[dimensionName] = dimensionInfo;
  19306. }
  19307. /**
  19308. * @readOnly
  19309. * @type {Array.<string>}
  19310. */
  19311. this.dimensions = dimensionNames;
  19312. /**
  19313. * Infomation of each data dimension, like data type.
  19314. * @type {Object}
  19315. */
  19316. this._dimensionInfos = dimensionInfos;
  19317. /**
  19318. * @type {module:echarts/model/Model}
  19319. */
  19320. this.hostModel = hostModel;
  19321. /**
  19322. * @type {module:echarts/model/Model}
  19323. */
  19324. this.dataType;
  19325. /**
  19326. * Indices stores the indices of data subset after filtered.
  19327. * This data subset will be used in chart.
  19328. * @type {Array.<number>}
  19329. * @readOnly
  19330. */
  19331. this.indices = [];
  19332. /**
  19333. * Data storage
  19334. * @type {Object.<key, TypedArray|Array>}
  19335. * @private
  19336. */
  19337. this._storage = {};
  19338. /**
  19339. * @type {Array.<string>}
  19340. */
  19341. this._nameList = [];
  19342. /**
  19343. * @type {Array.<string>}
  19344. */
  19345. this._idList = [];
  19346. /**
  19347. * Models of data option is stored sparse for optimizing memory cost
  19348. * @type {Array.<module:echarts/model/Model>}
  19349. * @private
  19350. */
  19351. this._optionModels = [];
  19352. /**
  19353. * @param {module:echarts/data/List}
  19354. */
  19355. this.stackedOn = null;
  19356. /**
  19357. * Global visual properties after visual coding
  19358. * @type {Object}
  19359. * @private
  19360. */
  19361. this._visual = {};
  19362. /**
  19363. * Globel layout properties.
  19364. * @type {Object}
  19365. * @private
  19366. */
  19367. this._layout = {};
  19368. /**
  19369. * Item visual properties after visual coding
  19370. * @type {Array.<Object>}
  19371. * @private
  19372. */
  19373. this._itemVisuals = [];
  19374. /**
  19375. * Item layout properties after layout
  19376. * @type {Array.<Object>}
  19377. * @private
  19378. */
  19379. this._itemLayouts = [];
  19380. /**
  19381. * Graphic elemnents
  19382. * @type {Array.<module:zrender/Element>}
  19383. * @private
  19384. */
  19385. this._graphicEls = [];
  19386. /**
  19387. * @type {Array.<Array|Object>}
  19388. * @private
  19389. */
  19390. this._rawData;
  19391. /**
  19392. * @type {Object}
  19393. * @private
  19394. */
  19395. this._extent;
  19396. };
  19397. var listProto = List.prototype;
  19398. listProto.type = 'list';
  19399. /**
  19400. * If each data item has it's own option
  19401. * @type {boolean}
  19402. */
  19403. listProto.hasItemOption = true;
  19404. /**
  19405. * Get dimension name
  19406. * @param {string|number} dim
  19407. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  19408. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  19409. * @return {string} Concrete dim name.
  19410. */
  19411. listProto.getDimension = function (dim) {
  19412. if (!isNaN(dim)) {
  19413. dim = this.dimensions[dim] || dim;
  19414. }
  19415. return dim;
  19416. };
  19417. /**
  19418. * Get type and stackable info of particular dimension
  19419. * @param {string|number} dim
  19420. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  19421. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  19422. */
  19423. listProto.getDimensionInfo = function (dim) {
  19424. return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]);
  19425. };
  19426. /**
  19427. * Initialize from data
  19428. * @param {Array.<Object|number|Array>} data
  19429. * @param {Array.<string>} [nameList]
  19430. * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number
  19431. */
  19432. listProto.initData = function (data, nameList, dimValueGetter) {
  19433. data = data || [];
  19434. var isDataArray = zrUtil.isArray(data);
  19435. if (isDataArray) {
  19436. data = new DefaultDataProvider(data);
  19437. }
  19438. if (true) {
  19439. if (!isDataArray && (typeof data.getItem != 'function' || typeof data.count != 'function')) {
  19440. throw new Error('Inavlid data provider.');
  19441. }
  19442. }
  19443. this._rawData = data;
  19444. // Clear
  19445. var storage = this._storage = {};
  19446. var indices = this.indices = [];
  19447. var dimensions = this.dimensions;
  19448. var dimensionInfoMap = this._dimensionInfos;
  19449. var size = data.count();
  19450. var idList = [];
  19451. var nameRepeatCount = {};
  19452. var nameDimIdx;
  19453. nameList = nameList || [];
  19454. // Init storage
  19455. for (var i = 0; i < dimensions.length; i++) {
  19456. var dimInfo = dimensionInfoMap[dimensions[i]];
  19457. dimInfo.otherDims.itemName === 0 && (nameDimIdx = i);
  19458. var DataCtor = dataCtors[dimInfo.type];
  19459. storage[dimensions[i]] = new DataCtor(size);
  19460. }
  19461. var self = this;
  19462. if (!dimValueGetter) {
  19463. self.hasItemOption = false;
  19464. }
  19465. // Default dim value getter
  19466. dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) {
  19467. var value = modelUtil.getDataItemValue(dataItem);
  19468. // If any dataItem is like { value: 10 }
  19469. if (modelUtil.isDataItemOption(dataItem)) {
  19470. self.hasItemOption = true;
  19471. }
  19472. return modelUtil.converDataValue(
  19473. (value instanceof Array)
  19474. ? value[dimIndex]
  19475. // If value is a single number or something else not array.
  19476. : value,
  19477. dimensionInfoMap[dimName]
  19478. );
  19479. };
  19480. for (var i = 0; i < size; i++) {
  19481. // NOTICE: Try not to write things into dataItem
  19482. var dataItem = data.getItem(i);
  19483. // Each data item is value
  19484. // [1, 2]
  19485. // 2
  19486. // Bar chart, line chart which uses category axis
  19487. // only gives the 'y' value. 'x' value is the indices of cateogry
  19488. // Use a tempValue to normalize the value to be a (x, y) value
  19489. // Store the data by dimensions
  19490. for (var k = 0; k < dimensions.length; k++) {
  19491. var dim = dimensions[k];
  19492. var dimStorage = storage[dim];
  19493. // PENDING NULL is empty or zero
  19494. dimStorage[i] = dimValueGetter(dataItem, dim, i, k);
  19495. }
  19496. indices.push(i);
  19497. }
  19498. // Use the name in option and create id
  19499. for (var i = 0; i < size; i++) {
  19500. var dataItem = data.getItem(i);
  19501. if (!nameList[i] && dataItem) {
  19502. if (dataItem.name != null) {
  19503. nameList[i] = dataItem.name;
  19504. }
  19505. else if (nameDimIdx != null) {
  19506. nameList[i] = storage[dimensions[nameDimIdx]][i];
  19507. }
  19508. }
  19509. var name = nameList[i] || '';
  19510. // Try using the id in option
  19511. var id = dataItem && dataItem.id;
  19512. if (!id && name) {
  19513. // Use name as id and add counter to avoid same name
  19514. nameRepeatCount[name] = nameRepeatCount[name] || 0;
  19515. id = name;
  19516. if (nameRepeatCount[name] > 0) {
  19517. id += '__ec__' + nameRepeatCount[name];
  19518. }
  19519. nameRepeatCount[name]++;
  19520. }
  19521. id && (idList[i] = id);
  19522. }
  19523. this._nameList = nameList;
  19524. this._idList = idList;
  19525. };
  19526. /**
  19527. * @return {number}
  19528. */
  19529. listProto.count = function () {
  19530. return this.indices.length;
  19531. };
  19532. /**
  19533. * Get value. Return NaN if idx is out of range.
  19534. * @param {string} dim Dim must be concrete name.
  19535. * @param {number} idx
  19536. * @param {boolean} stack
  19537. * @return {number}
  19538. */
  19539. listProto.get = function (dim, idx, stack) {
  19540. var storage = this._storage;
  19541. var dataIndex = this.indices[idx];
  19542. // If value not exists
  19543. if (dataIndex == null || !storage[dim]) {
  19544. return NaN;
  19545. }
  19546. var value = storage[dim][dataIndex];
  19547. // FIXME ordinal data type is not stackable
  19548. if (stack) {
  19549. var dimensionInfo = this._dimensionInfos[dim];
  19550. if (dimensionInfo && dimensionInfo.stackable) {
  19551. var stackedOn = this.stackedOn;
  19552. while (stackedOn) {
  19553. // Get no stacked data of stacked on
  19554. var stackedValue = stackedOn.get(dim, idx);
  19555. // Considering positive stack, negative stack and empty data
  19556. if ((value >= 0 && stackedValue > 0) // Positive stack
  19557. || (value <= 0 && stackedValue < 0) // Negative stack
  19558. ) {
  19559. value += stackedValue;
  19560. }
  19561. stackedOn = stackedOn.stackedOn;
  19562. }
  19563. }
  19564. }
  19565. return value;
  19566. };
  19567. /**
  19568. * Get value for multi dimensions.
  19569. * @param {Array.<string>} [dimensions] If ignored, using all dimensions.
  19570. * @param {number} idx
  19571. * @param {boolean} stack
  19572. * @return {number}
  19573. */
  19574. listProto.getValues = function (dimensions, idx, stack) {
  19575. var values = [];
  19576. if (!zrUtil.isArray(dimensions)) {
  19577. stack = idx;
  19578. idx = dimensions;
  19579. dimensions = this.dimensions;
  19580. }
  19581. for (var i = 0, len = dimensions.length; i < len; i++) {
  19582. values.push(this.get(dimensions[i], idx, stack));
  19583. }
  19584. return values;
  19585. };
  19586. /**
  19587. * If value is NaN. Inlcuding '-'
  19588. * @param {string} dim
  19589. * @param {number} idx
  19590. * @return {number}
  19591. */
  19592. listProto.hasValue = function (idx) {
  19593. var dimensions = this.dimensions;
  19594. var dimensionInfos = this._dimensionInfos;
  19595. for (var i = 0, len = dimensions.length; i < len; i++) {
  19596. if (
  19597. // Ordinal type can be string or number
  19598. dimensionInfos[dimensions[i]].type !== 'ordinal'
  19599. && isNaN(this.get(dimensions[i], idx))
  19600. ) {
  19601. return false;
  19602. }
  19603. }
  19604. return true;
  19605. };
  19606. /**
  19607. * Get extent of data in one dimension
  19608. * @param {string} dim
  19609. * @param {boolean} stack
  19610. * @param {Function} filter
  19611. */
  19612. listProto.getDataExtent = function (dim, stack, filter) {
  19613. dim = this.getDimension(dim);
  19614. var dimData = this._storage[dim];
  19615. var dimInfo = this.getDimensionInfo(dim);
  19616. stack = (dimInfo && dimInfo.stackable) && stack;
  19617. var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)];
  19618. var value;
  19619. if (dimExtent) {
  19620. return dimExtent;
  19621. }
  19622. // var dimInfo = this._dimensionInfos[dim];
  19623. if (dimData) {
  19624. var min = Infinity;
  19625. var max = -Infinity;
  19626. // var isOrdinal = dimInfo.type === 'ordinal';
  19627. for (var i = 0, len = this.count(); i < len; i++) {
  19628. value = this.get(dim, i, stack);
  19629. // FIXME
  19630. // if (isOrdinal && typeof value === 'string') {
  19631. // value = zrUtil.indexOf(dimData, value);
  19632. // }
  19633. if (!filter || filter(value, dim, i)) {
  19634. value < min && (min = value);
  19635. value > max && (max = value);
  19636. }
  19637. }
  19638. return (this._extent[dim + !!stack] = [min, max]);
  19639. }
  19640. else {
  19641. return [Infinity, -Infinity];
  19642. }
  19643. };
  19644. /**
  19645. * Get sum of data in one dimension
  19646. * @param {string} dim
  19647. * @param {boolean} stack
  19648. */
  19649. listProto.getSum = function (dim, stack) {
  19650. var dimData = this._storage[dim];
  19651. var sum = 0;
  19652. if (dimData) {
  19653. for (var i = 0, len = this.count(); i < len; i++) {
  19654. var value = this.get(dim, i, stack);
  19655. if (!isNaN(value)) {
  19656. sum += value;
  19657. }
  19658. }
  19659. }
  19660. return sum;
  19661. };
  19662. /**
  19663. * Retreive the index with given value
  19664. * @param {number} idx
  19665. * @param {number} value
  19666. * @return {number}
  19667. */
  19668. // FIXME Precision of float value
  19669. listProto.indexOf = function (dim, value) {
  19670. var storage = this._storage;
  19671. var dimData = storage[dim];
  19672. var indices = this.indices;
  19673. if (dimData) {
  19674. for (var i = 0, len = indices.length; i < len; i++) {
  19675. var rawIndex = indices[i];
  19676. if (dimData[rawIndex] === value) {
  19677. return i;
  19678. }
  19679. }
  19680. }
  19681. return -1;
  19682. };
  19683. /**
  19684. * Retreive the index with given name
  19685. * @param {number} idx
  19686. * @param {number} name
  19687. * @return {number}
  19688. */
  19689. listProto.indexOfName = function (name) {
  19690. var indices = this.indices;
  19691. var nameList = this._nameList;
  19692. for (var i = 0, len = indices.length; i < len; i++) {
  19693. var rawIndex = indices[i];
  19694. if (nameList[rawIndex] === name) {
  19695. return i;
  19696. }
  19697. }
  19698. return -1;
  19699. };
  19700. /**
  19701. * Retreive the index with given raw data index
  19702. * @param {number} idx
  19703. * @param {number} name
  19704. * @return {number}
  19705. */
  19706. listProto.indexOfRawIndex = function (rawIndex) {
  19707. // Indices are ascending
  19708. var indices = this.indices;
  19709. // If rawIndex === dataIndex
  19710. var rawDataIndex = indices[rawIndex];
  19711. if (rawDataIndex != null && rawDataIndex === rawIndex) {
  19712. return rawIndex;
  19713. }
  19714. var left = 0;
  19715. var right = indices.length - 1;
  19716. while (left <= right) {
  19717. var mid = (left + right) / 2 | 0;
  19718. if (indices[mid] < rawIndex) {
  19719. left = mid + 1;
  19720. }
  19721. else if (indices[mid] > rawIndex) {
  19722. right = mid - 1;
  19723. }
  19724. else {
  19725. return mid;
  19726. }
  19727. }
  19728. return -1;
  19729. };
  19730. /**
  19731. * Retreive the index of nearest value
  19732. * @param {string} dim
  19733. * @param {number} value
  19734. * @param {boolean} stack If given value is after stacked
  19735. * @param {number} [maxDistance=Infinity]
  19736. * @return {Array.<number>} Considere multiple points has the same value.
  19737. */
  19738. listProto.indicesOfNearest = function (dim, value, stack, maxDistance) {
  19739. var storage = this._storage;
  19740. var dimData = storage[dim];
  19741. var nearestIndices = [];
  19742. if (!dimData) {
  19743. return nearestIndices;
  19744. }
  19745. if (maxDistance == null) {
  19746. maxDistance = Infinity;
  19747. }
  19748. var minDist = Number.MAX_VALUE;
  19749. var minDiff = -1;
  19750. for (var i = 0, len = this.count(); i < len; i++) {
  19751. var diff = value - this.get(dim, i, stack);
  19752. var dist = Math.abs(diff);
  19753. if (diff <= maxDistance && dist <= minDist) {
  19754. // For the case of two data are same on xAxis, which has sequence data.
  19755. // Show the nearest index
  19756. // https://github.com/ecomfe/echarts/issues/2869
  19757. if (dist < minDist || (diff >= 0 && minDiff < 0)) {
  19758. minDist = dist;
  19759. minDiff = diff;
  19760. nearestIndices.length = 0;
  19761. }
  19762. nearestIndices.push(i);
  19763. }
  19764. }
  19765. return nearestIndices;
  19766. };
  19767. /**
  19768. * Get raw data index
  19769. * @param {number} idx
  19770. * @return {number}
  19771. */
  19772. listProto.getRawIndex = function (idx) {
  19773. var rawIdx = this.indices[idx];
  19774. return rawIdx == null ? -1 : rawIdx;
  19775. };
  19776. /**
  19777. * Get raw data item
  19778. * @param {number} idx
  19779. * @return {number}
  19780. */
  19781. listProto.getRawDataItem = function (idx) {
  19782. return this._rawData.getItem(this.getRawIndex(idx));
  19783. };
  19784. /**
  19785. * @param {number} idx
  19786. * @param {boolean} [notDefaultIdx=false]
  19787. * @return {string}
  19788. */
  19789. listProto.getName = function (idx) {
  19790. return this._nameList[this.indices[idx]] || '';
  19791. };
  19792. /**
  19793. * @param {number} idx
  19794. * @param {boolean} [notDefaultIdx=false]
  19795. * @return {string}
  19796. */
  19797. listProto.getId = function (idx) {
  19798. return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + '');
  19799. };
  19800. function normalizeDimensions(dimensions) {
  19801. if (!zrUtil.isArray(dimensions)) {
  19802. dimensions = [dimensions];
  19803. }
  19804. return dimensions;
  19805. }
  19806. /**
  19807. * Data iteration
  19808. * @param {string|Array.<string>}
  19809. * @param {Function} cb
  19810. * @param {boolean} [stack=false]
  19811. * @param {*} [context=this]
  19812. *
  19813. * @example
  19814. * list.each('x', function (x, idx) {});
  19815. * list.each(['x', 'y'], function (x, y, idx) {});
  19816. * list.each(function (idx) {})
  19817. */
  19818. listProto.each = function (dims, cb, stack, context) {
  19819. if (typeof dims === 'function') {
  19820. context = stack;
  19821. stack = cb;
  19822. cb = dims;
  19823. dims = [];
  19824. }
  19825. dims = zrUtil.map(normalizeDimensions(dims), this.getDimension, this);
  19826. var value = [];
  19827. var dimSize = dims.length;
  19828. var indices = this.indices;
  19829. context = context || this;
  19830. for (var i = 0; i < indices.length; i++) {
  19831. // Simple optimization
  19832. switch (dimSize) {
  19833. case 0:
  19834. cb.call(context, i);
  19835. break;
  19836. case 1:
  19837. cb.call(context, this.get(dims[0], i, stack), i);
  19838. break;
  19839. case 2:
  19840. cb.call(context, this.get(dims[0], i, stack), this.get(dims[1], i, stack), i);
  19841. break;
  19842. default:
  19843. for (var k = 0; k < dimSize; k++) {
  19844. value[k] = this.get(dims[k], i, stack);
  19845. }
  19846. // Index
  19847. value[k] = i;
  19848. cb.apply(context, value);
  19849. }
  19850. }
  19851. };
  19852. /**
  19853. * Data filter
  19854. * @param {string|Array.<string>}
  19855. * @param {Function} cb
  19856. * @param {boolean} [stack=false]
  19857. * @param {*} [context=this]
  19858. */
  19859. listProto.filterSelf = function (dimensions, cb, stack, context) {
  19860. if (typeof dimensions === 'function') {
  19861. context = stack;
  19862. stack = cb;
  19863. cb = dimensions;
  19864. dimensions = [];
  19865. }
  19866. dimensions = zrUtil.map(
  19867. normalizeDimensions(dimensions), this.getDimension, this
  19868. );
  19869. var newIndices = [];
  19870. var value = [];
  19871. var dimSize = dimensions.length;
  19872. var indices = this.indices;
  19873. context = context || this;
  19874. for (var i = 0; i < indices.length; i++) {
  19875. var keep;
  19876. // Simple optimization
  19877. if (!dimSize) {
  19878. keep = cb.call(context, i);
  19879. }
  19880. else if (dimSize === 1) {
  19881. keep = cb.call(
  19882. context, this.get(dimensions[0], i, stack), i
  19883. );
  19884. }
  19885. else {
  19886. for (var k = 0; k < dimSize; k++) {
  19887. value[k] = this.get(dimensions[k], i, stack);
  19888. }
  19889. value[k] = i;
  19890. keep = cb.apply(context, value);
  19891. }
  19892. if (keep) {
  19893. newIndices.push(indices[i]);
  19894. }
  19895. }
  19896. this.indices = newIndices;
  19897. // Reset data extent
  19898. this._extent = {};
  19899. return this;
  19900. };
  19901. /**
  19902. * Data mapping to a plain array
  19903. * @param {string|Array.<string>} [dimensions]
  19904. * @param {Function} cb
  19905. * @param {boolean} [stack=false]
  19906. * @param {*} [context=this]
  19907. * @return {Array}
  19908. */
  19909. listProto.mapArray = function (dimensions, cb, stack, context) {
  19910. if (typeof dimensions === 'function') {
  19911. context = stack;
  19912. stack = cb;
  19913. cb = dimensions;
  19914. dimensions = [];
  19915. }
  19916. var result = [];
  19917. this.each(dimensions, function () {
  19918. result.push(cb && cb.apply(this, arguments));
  19919. }, stack, context);
  19920. return result;
  19921. };
  19922. function cloneListForMapAndSample(original, excludeDimensions) {
  19923. var allDimensions = original.dimensions;
  19924. var list = new List(
  19925. zrUtil.map(allDimensions, original.getDimensionInfo, original),
  19926. original.hostModel
  19927. );
  19928. // FIXME If needs stackedOn, value may already been stacked
  19929. transferProperties(list, original);
  19930. var storage = list._storage = {};
  19931. var originalStorage = original._storage;
  19932. // Init storage
  19933. for (var i = 0; i < allDimensions.length; i++) {
  19934. var dim = allDimensions[i];
  19935. var dimStore = originalStorage[dim];
  19936. if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {
  19937. storage[dim] = new dimStore.constructor(
  19938. originalStorage[dim].length
  19939. );
  19940. }
  19941. else {
  19942. // Direct reference for other dimensions
  19943. storage[dim] = originalStorage[dim];
  19944. }
  19945. }
  19946. return list;
  19947. }
  19948. /**
  19949. * Data mapping to a new List with given dimensions
  19950. * @param {string|Array.<string>} dimensions
  19951. * @param {Function} cb
  19952. * @param {boolean} [stack=false]
  19953. * @param {*} [context=this]
  19954. * @return {Array}
  19955. */
  19956. listProto.map = function (dimensions, cb, stack, context) {
  19957. dimensions = zrUtil.map(
  19958. normalizeDimensions(dimensions), this.getDimension, this
  19959. );
  19960. var list = cloneListForMapAndSample(this, dimensions);
  19961. // Following properties are all immutable.
  19962. // So we can reference to the same value
  19963. var indices = list.indices = this.indices;
  19964. var storage = list._storage;
  19965. var tmpRetValue = [];
  19966. this.each(dimensions, function () {
  19967. var idx = arguments[arguments.length - 1];
  19968. var retValue = cb && cb.apply(this, arguments);
  19969. if (retValue != null) {
  19970. // a number
  19971. if (typeof retValue === 'number') {
  19972. tmpRetValue[0] = retValue;
  19973. retValue = tmpRetValue;
  19974. }
  19975. for (var i = 0; i < retValue.length; i++) {
  19976. var dim = dimensions[i];
  19977. var dimStore = storage[dim];
  19978. var rawIdx = indices[idx];
  19979. if (dimStore) {
  19980. dimStore[rawIdx] = retValue[i];
  19981. }
  19982. }
  19983. }
  19984. }, stack, context);
  19985. return list;
  19986. };
  19987. /**
  19988. * Large data down sampling on given dimension
  19989. * @param {string} dimension
  19990. * @param {number} rate
  19991. * @param {Function} sampleValue
  19992. * @param {Function} sampleIndex Sample index for name and id
  19993. */
  19994. listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) {
  19995. var list = cloneListForMapAndSample(this, [dimension]);
  19996. var storage = this._storage;
  19997. var targetStorage = list._storage;
  19998. var originalIndices = this.indices;
  19999. var indices = list.indices = [];
  20000. var frameValues = [];
  20001. var frameIndices = [];
  20002. var frameSize = Math.floor(1 / rate);
  20003. var dimStore = targetStorage[dimension];
  20004. var len = this.count();
  20005. // Copy data from original data
  20006. for (var i = 0; i < storage[dimension].length; i++) {
  20007. targetStorage[dimension][i] = storage[dimension][i];
  20008. }
  20009. for (var i = 0; i < len; i += frameSize) {
  20010. // Last frame
  20011. if (frameSize > len - i) {
  20012. frameSize = len - i;
  20013. frameValues.length = frameSize;
  20014. }
  20015. for (var k = 0; k < frameSize; k++) {
  20016. var idx = originalIndices[i + k];
  20017. frameValues[k] = dimStore[idx];
  20018. frameIndices[k] = idx;
  20019. }
  20020. var value = sampleValue(frameValues);
  20021. var idx = frameIndices[sampleIndex(frameValues, value) || 0];
  20022. // Only write value on the filtered data
  20023. dimStore[idx] = value;
  20024. indices.push(idx);
  20025. }
  20026. return list;
  20027. };
  20028. /**
  20029. * Get model of one data item.
  20030. *
  20031. * @param {number} idx
  20032. */
  20033. // FIXME Model proxy ?
  20034. listProto.getItemModel = function (idx) {
  20035. var hostModel = this.hostModel;
  20036. idx = this.indices[idx];
  20037. return new Model(this._rawData.getItem(idx), hostModel, hostModel && hostModel.ecModel);
  20038. };
  20039. /**
  20040. * Create a data differ
  20041. * @param {module:echarts/data/List} otherList
  20042. * @return {module:echarts/data/DataDiffer}
  20043. */
  20044. listProto.diff = function (otherList) {
  20045. var idList = this._idList;
  20046. var otherIdList = otherList && otherList._idList;
  20047. var val;
  20048. // Use prefix to avoid index to be the same as otherIdList[idx],
  20049. // which will cause weird udpate animation.
  20050. var prefix = 'e\0\0';
  20051. return new DataDiffer(
  20052. otherList ? otherList.indices : [],
  20053. this.indices,
  20054. function (idx) {
  20055. return (val = otherIdList[idx]) != null ? val : prefix + idx;
  20056. },
  20057. function (idx) {
  20058. return (val = idList[idx]) != null ? val : prefix + idx;
  20059. }
  20060. );
  20061. };
  20062. /**
  20063. * Get visual property.
  20064. * @param {string} key
  20065. */
  20066. listProto.getVisual = function (key) {
  20067. var visual = this._visual;
  20068. return visual && visual[key];
  20069. };
  20070. /**
  20071. * Set visual property
  20072. * @param {string|Object} key
  20073. * @param {*} [value]
  20074. *
  20075. * @example
  20076. * setVisual('color', color);
  20077. * setVisual({
  20078. * 'color': color
  20079. * });
  20080. */
  20081. listProto.setVisual = function (key, val) {
  20082. if (isObject(key)) {
  20083. for (var name in key) {
  20084. if (key.hasOwnProperty(name)) {
  20085. this.setVisual(name, key[name]);
  20086. }
  20087. }
  20088. return;
  20089. }
  20090. this._visual = this._visual || {};
  20091. this._visual[key] = val;
  20092. };
  20093. /**
  20094. * Set layout property.
  20095. * @param {string} key
  20096. * @param {*} [val]
  20097. */
  20098. listProto.setLayout = function (key, val) {
  20099. if (isObject(key)) {
  20100. for (var name in key) {
  20101. if (key.hasOwnProperty(name)) {
  20102. this.setLayout(name, key[name]);
  20103. }
  20104. }
  20105. return;
  20106. }
  20107. this._layout[key] = val;
  20108. };
  20109. /**
  20110. * Get layout property.
  20111. * @param {string} key.
  20112. * @return {*}
  20113. */
  20114. listProto.getLayout = function (key) {
  20115. return this._layout[key];
  20116. };
  20117. /**
  20118. * Get layout of single data item
  20119. * @param {number} idx
  20120. */
  20121. listProto.getItemLayout = function (idx) {
  20122. return this._itemLayouts[idx];
  20123. };
  20124. /**
  20125. * Set layout of single data item
  20126. * @param {number} idx
  20127. * @param {Object} layout
  20128. * @param {boolean=} [merge=false]
  20129. */
  20130. listProto.setItemLayout = function (idx, layout, merge) {
  20131. this._itemLayouts[idx] = merge
  20132. ? zrUtil.extend(this._itemLayouts[idx] || {}, layout)
  20133. : layout;
  20134. };
  20135. /**
  20136. * Clear all layout of single data item
  20137. */
  20138. listProto.clearItemLayouts = function () {
  20139. this._itemLayouts.length = 0;
  20140. };
  20141. /**
  20142. * Get visual property of single data item
  20143. * @param {number} idx
  20144. * @param {string} key
  20145. * @param {boolean} [ignoreParent=false]
  20146. */
  20147. listProto.getItemVisual = function (idx, key, ignoreParent) {
  20148. var itemVisual = this._itemVisuals[idx];
  20149. var val = itemVisual && itemVisual[key];
  20150. if (val == null && !ignoreParent) {
  20151. // Use global visual property
  20152. return this.getVisual(key);
  20153. }
  20154. return val;
  20155. };
  20156. /**
  20157. * Set visual property of single data item
  20158. *
  20159. * @param {number} idx
  20160. * @param {string|Object} key
  20161. * @param {*} [value]
  20162. *
  20163. * @example
  20164. * setItemVisual(0, 'color', color);
  20165. * setItemVisual(0, {
  20166. * 'color': color
  20167. * });
  20168. */
  20169. listProto.setItemVisual = function (idx, key, value) {
  20170. var itemVisual = this._itemVisuals[idx] || {};
  20171. this._itemVisuals[idx] = itemVisual;
  20172. if (isObject(key)) {
  20173. for (var name in key) {
  20174. if (key.hasOwnProperty(name)) {
  20175. itemVisual[name] = key[name];
  20176. }
  20177. }
  20178. return;
  20179. }
  20180. itemVisual[key] = value;
  20181. };
  20182. /**
  20183. * Clear itemVisuals and list visual.
  20184. */
  20185. listProto.clearAllVisual = function () {
  20186. this._visual = {};
  20187. this._itemVisuals = [];
  20188. };
  20189. var setItemDataAndSeriesIndex = function (child) {
  20190. child.seriesIndex = this.seriesIndex;
  20191. child.dataIndex = this.dataIndex;
  20192. child.dataType = this.dataType;
  20193. };
  20194. /**
  20195. * Set graphic element relative to data. It can be set as null
  20196. * @param {number} idx
  20197. * @param {module:zrender/Element} [el]
  20198. */
  20199. listProto.setItemGraphicEl = function (idx, el) {
  20200. var hostModel = this.hostModel;
  20201. if (el) {
  20202. // Add data index and series index for indexing the data by element
  20203. // Useful in tooltip
  20204. el.dataIndex = idx;
  20205. el.dataType = this.dataType;
  20206. el.seriesIndex = hostModel && hostModel.seriesIndex;
  20207. if (el.type === 'group') {
  20208. el.traverse(setItemDataAndSeriesIndex, el);
  20209. }
  20210. }
  20211. this._graphicEls[idx] = el;
  20212. };
  20213. /**
  20214. * @param {number} idx
  20215. * @return {module:zrender/Element}
  20216. */
  20217. listProto.getItemGraphicEl = function (idx) {
  20218. return this._graphicEls[idx];
  20219. };
  20220. /**
  20221. * @param {Function} cb
  20222. * @param {*} context
  20223. */
  20224. listProto.eachItemGraphicEl = function (cb, context) {
  20225. zrUtil.each(this._graphicEls, function (el, idx) {
  20226. if (el) {
  20227. cb && cb.call(context, el, idx);
  20228. }
  20229. });
  20230. };
  20231. /**
  20232. * Shallow clone a new list except visual and layout properties, and graph elements.
  20233. * New list only change the indices.
  20234. */
  20235. listProto.cloneShallow = function () {
  20236. var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this);
  20237. var list = new List(dimensionInfoList, this.hostModel);
  20238. // FIXME
  20239. list._storage = this._storage;
  20240. transferProperties(list, this);
  20241. // Clone will not change the data extent and indices
  20242. list.indices = this.indices.slice();
  20243. if (this._extent) {
  20244. list._extent = zrUtil.extend({}, this._extent);
  20245. }
  20246. return list;
  20247. };
  20248. /**
  20249. * Wrap some method to add more feature
  20250. * @param {string} methodName
  20251. * @param {Function} injectFunction
  20252. */
  20253. listProto.wrapMethod = function (methodName, injectFunction) {
  20254. var originalMethod = this[methodName];
  20255. if (typeof originalMethod !== 'function') {
  20256. return;
  20257. }
  20258. this.__wrappedMethods = this.__wrappedMethods || [];
  20259. this.__wrappedMethods.push(methodName);
  20260. this[methodName] = function () {
  20261. var res = originalMethod.apply(this, arguments);
  20262. return injectFunction.apply(this, [res].concat(zrUtil.slice(arguments)));
  20263. };
  20264. };
  20265. // Methods that create a new list based on this list should be listed here.
  20266. // Notice that those method should `RETURN` the new list.
  20267. listProto.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'map'];
  20268. // Methods that change indices of this list should be listed here.
  20269. listProto.CHANGABLE_METHODS = ['filterSelf'];
  20270. module.exports = List;
  20271. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  20272. /***/ },
  20273. /* 99 */
  20274. /***/ function(module, exports) {
  20275. 'use strict';
  20276. function defaultKeyGetter(item) {
  20277. return item;
  20278. }
  20279. function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) {
  20280. this._old = oldArr;
  20281. this._new = newArr;
  20282. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
  20283. this._newKeyGetter = newKeyGetter || defaultKeyGetter;
  20284. }
  20285. DataDiffer.prototype = {
  20286. constructor: DataDiffer,
  20287. /**
  20288. * Callback function when add a data
  20289. */
  20290. add: function (func) {
  20291. this._add = func;
  20292. return this;
  20293. },
  20294. /**
  20295. * Callback function when update a data
  20296. */
  20297. update: function (func) {
  20298. this._update = func;
  20299. return this;
  20300. },
  20301. /**
  20302. * Callback function when remove a data
  20303. */
  20304. remove: function (func) {
  20305. this._remove = func;
  20306. return this;
  20307. },
  20308. execute: function () {
  20309. var oldArr = this._old;
  20310. var newArr = this._new;
  20311. var oldKeyGetter = this._oldKeyGetter;
  20312. var newKeyGetter = this._newKeyGetter;
  20313. var oldDataIndexMap = {};
  20314. var newDataIndexMap = {};
  20315. var oldDataKeyArr = [];
  20316. var newDataKeyArr = [];
  20317. var i;
  20318. initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, oldKeyGetter);
  20319. initIndexMap(newArr, newDataIndexMap, newDataKeyArr, newKeyGetter);
  20320. // Travel by inverted order to make sure order consistency
  20321. // when duplicate keys exists (consider newDataIndex.pop() below).
  20322. // For performance consideration, these code below do not look neat.
  20323. for (i = 0; i < oldArr.length; i++) {
  20324. var key = oldDataKeyArr[i];
  20325. var idx = newDataIndexMap[key];
  20326. // idx can never be empty array here. see 'set null' logic below.
  20327. if (idx != null) {
  20328. // Consider there is duplicate key (for example, use dataItem.name as key).
  20329. // We should make sure every item in newArr and oldArr can be visited.
  20330. var len = idx.length;
  20331. if (len) {
  20332. len === 1 && (newDataIndexMap[key] = null);
  20333. idx = idx.unshift();
  20334. }
  20335. else {
  20336. newDataIndexMap[key] = null;
  20337. }
  20338. this._update && this._update(idx, i);
  20339. }
  20340. else {
  20341. this._remove && this._remove(i);
  20342. }
  20343. }
  20344. for (var i = 0; i < newDataKeyArr.length; i++) {
  20345. var key = newDataKeyArr[i];
  20346. if (newDataIndexMap.hasOwnProperty(key)) {
  20347. var idx = newDataIndexMap[key];
  20348. if (idx == null) {
  20349. continue;
  20350. }
  20351. // idx can never be empty array here. see 'set null' logic above.
  20352. if (!idx.length) {
  20353. this._add && this._add(idx);
  20354. }
  20355. else {
  20356. for (var j = 0, len = idx.length; j < len; j++) {
  20357. this._add && this._add(idx[j]);
  20358. }
  20359. }
  20360. }
  20361. }
  20362. }
  20363. };
  20364. function initIndexMap(arr, map, keyArr, keyGetter) {
  20365. for (var i = 0; i < arr.length; i++) {
  20366. // Add prefix to avoid conflict with Object.prototype.
  20367. var key = '_ec_' + keyGetter(arr[i], i);
  20368. var existence = map[key];
  20369. if (existence == null) {
  20370. keyArr.push(key);
  20371. map[key] = i;
  20372. }
  20373. else {
  20374. if (!existence.length) {
  20375. map[key] = existence = [existence];
  20376. }
  20377. existence.push(i);
  20378. }
  20379. }
  20380. }
  20381. module.exports = DataDiffer;
  20382. /***/ },
  20383. /* 100 */
  20384. /***/ function(module, exports, __webpack_require__) {
  20385. var numberUtil = __webpack_require__(7);
  20386. var linearMap = numberUtil.linearMap;
  20387. var zrUtil = __webpack_require__(4);
  20388. var axisHelper = __webpack_require__(101);
  20389. function fixExtentWithBands(extent, nTick) {
  20390. var size = extent[1] - extent[0];
  20391. var len = nTick;
  20392. var margin = size / len / 2;
  20393. extent[0] += margin;
  20394. extent[1] -= margin;
  20395. }
  20396. var normalizedExtent = [0, 1];
  20397. /**
  20398. * @name module:echarts/coord/CartesianAxis
  20399. * @constructor
  20400. */
  20401. var Axis = function (dim, scale, extent) {
  20402. /**
  20403. * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'
  20404. * @type {string}
  20405. */
  20406. this.dim = dim;
  20407. /**
  20408. * Axis scale
  20409. * @type {module:echarts/coord/scale/*}
  20410. */
  20411. this.scale = scale;
  20412. /**
  20413. * @type {Array.<number>}
  20414. * @private
  20415. */
  20416. this._extent = extent || [0, 0];
  20417. /**
  20418. * @type {boolean}
  20419. */
  20420. this.inverse = false;
  20421. /**
  20422. * Usually true when axis has a ordinal scale
  20423. * @type {boolean}
  20424. */
  20425. this.onBand = false;
  20426. /**
  20427. * @private
  20428. * @type {number}
  20429. */
  20430. this._labelInterval;
  20431. };
  20432. Axis.prototype = {
  20433. constructor: Axis,
  20434. /**
  20435. * If axis extent contain given coord
  20436. * @param {number} coord
  20437. * @return {boolean}
  20438. */
  20439. contain: function (coord) {
  20440. var extent = this._extent;
  20441. var min = Math.min(extent[0], extent[1]);
  20442. var max = Math.max(extent[0], extent[1]);
  20443. return coord >= min && coord <= max;
  20444. },
  20445. /**
  20446. * If axis extent contain given data
  20447. * @param {number} data
  20448. * @return {boolean}
  20449. */
  20450. containData: function (data) {
  20451. return this.contain(this.dataToCoord(data));
  20452. },
  20453. /**
  20454. * Get coord extent.
  20455. * @return {Array.<number>}
  20456. */
  20457. getExtent: function () {
  20458. return this._extent.slice();
  20459. },
  20460. /**
  20461. * Get precision used for formatting
  20462. * @param {Array.<number>} [dataExtent]
  20463. * @return {number}
  20464. */
  20465. getPixelPrecision: function (dataExtent) {
  20466. return numberUtil.getPixelPrecision(
  20467. dataExtent || this.scale.getExtent(),
  20468. this._extent
  20469. );
  20470. },
  20471. /**
  20472. * Set coord extent
  20473. * @param {number} start
  20474. * @param {number} end
  20475. */
  20476. setExtent: function (start, end) {
  20477. var extent = this._extent;
  20478. extent[0] = start;
  20479. extent[1] = end;
  20480. },
  20481. /**
  20482. * Convert data to coord. Data is the rank if it has a ordinal scale
  20483. * @param {number} data
  20484. * @param {boolean} clamp
  20485. * @return {number}
  20486. */
  20487. dataToCoord: function (data, clamp) {
  20488. var extent = this._extent;
  20489. var scale = this.scale;
  20490. data = scale.normalize(data);
  20491. if (this.onBand && scale.type === 'ordinal') {
  20492. extent = extent.slice();
  20493. fixExtentWithBands(extent, scale.count());
  20494. }
  20495. return linearMap(data, normalizedExtent, extent, clamp);
  20496. },
  20497. /**
  20498. * Convert coord to data. Data is the rank if it has a ordinal scale
  20499. * @param {number} coord
  20500. * @param {boolean} clamp
  20501. * @return {number}
  20502. */
  20503. coordToData: function (coord, clamp) {
  20504. var extent = this._extent;
  20505. var scale = this.scale;
  20506. if (this.onBand && scale.type === 'ordinal') {
  20507. extent = extent.slice();
  20508. fixExtentWithBands(extent, scale.count());
  20509. }
  20510. var t = linearMap(coord, extent, normalizedExtent, clamp);
  20511. return this.scale.scale(t);
  20512. },
  20513. /**
  20514. * Convert pixel point to data in axis
  20515. * @param {Array.<number>} point
  20516. * @param {boolean} clamp
  20517. * @return {number} data
  20518. */
  20519. pointToData: function (point, clamp) {
  20520. // Should be implemented in derived class if necessary.
  20521. },
  20522. /**
  20523. * @return {Array.<number>}
  20524. */
  20525. getTicksCoords: function (alignWithLabel) {
  20526. if (this.onBand && !alignWithLabel) {
  20527. var bands = this.getBands();
  20528. var coords = [];
  20529. for (var i = 0; i < bands.length; i++) {
  20530. coords.push(bands[i][0]);
  20531. }
  20532. if (bands[i - 1]) {
  20533. coords.push(bands[i - 1][1]);
  20534. }
  20535. return coords;
  20536. }
  20537. else {
  20538. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  20539. }
  20540. },
  20541. /**
  20542. * Coords of labels are on the ticks or on the middle of bands
  20543. * @return {Array.<number>}
  20544. */
  20545. getLabelsCoords: function () {
  20546. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  20547. },
  20548. /**
  20549. * Get bands.
  20550. *
  20551. * If axis has labels [1, 2, 3, 4]. Bands on the axis are
  20552. * |---1---|---2---|---3---|---4---|.
  20553. *
  20554. * @return {Array}
  20555. */
  20556. // FIXME Situation when labels is on ticks
  20557. getBands: function () {
  20558. var extent = this.getExtent();
  20559. var bands = [];
  20560. var len = this.scale.count();
  20561. var start = extent[0];
  20562. var end = extent[1];
  20563. var span = end - start;
  20564. for (var i = 0; i < len; i++) {
  20565. bands.push([
  20566. span * i / len + start,
  20567. span * (i + 1) / len + start
  20568. ]);
  20569. }
  20570. return bands;
  20571. },
  20572. /**
  20573. * Get width of band
  20574. * @return {number}
  20575. */
  20576. getBandWidth: function () {
  20577. var axisExtent = this._extent;
  20578. var dataExtent = this.scale.getExtent();
  20579. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
  20580. // Fix #2728, avoid NaN when only one data.
  20581. len === 0 && (len = 1);
  20582. var size = Math.abs(axisExtent[1] - axisExtent[0]);
  20583. return Math.abs(size) / len;
  20584. },
  20585. /**
  20586. * Get interval of the axis label.
  20587. * @return {number}
  20588. */
  20589. getLabelInterval: function () {
  20590. var labelInterval = this._labelInterval;
  20591. if (!labelInterval) {
  20592. var axisModel = this.model;
  20593. var labelModel = axisModel.getModel('axisLabel');
  20594. var interval = labelModel.get('interval');
  20595. if (!(this.type === 'category' && interval === 'auto')) {
  20596. labelInterval = interval === 'auto' ? 0 : interval;
  20597. }
  20598. else if (this.isHorizontal){
  20599. labelInterval = axisHelper.getAxisLabelInterval(
  20600. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  20601. axisModel.getFormattedLabels(),
  20602. labelModel.getModel('textStyle').getFont(),
  20603. this.isHorizontal()
  20604. );
  20605. }
  20606. this._labelInterval = labelInterval;
  20607. }
  20608. return labelInterval;
  20609. }
  20610. };
  20611. module.exports = Axis;
  20612. /***/ },
  20613. /* 101 */
  20614. /***/ function(module, exports, __webpack_require__) {
  20615. var OrdinalScale = __webpack_require__(102);
  20616. var IntervalScale = __webpack_require__(104);
  20617. __webpack_require__(106);
  20618. __webpack_require__(107);
  20619. var Scale = __webpack_require__(103);
  20620. var numberUtil = __webpack_require__(7);
  20621. var zrUtil = __webpack_require__(4);
  20622. var textContain = __webpack_require__(8);
  20623. var axisHelper = {};
  20624. /**
  20625. * Get axis scale extent before niced.
  20626. * Item of returned array can only be number (including Infinity and NaN).
  20627. */
  20628. axisHelper.getScaleExtent = function (scale, model) {
  20629. var scaleType = scale.type;
  20630. var min = model.getMin();
  20631. var max = model.getMax();
  20632. var fixMin = min != null;
  20633. var fixMax = max != null;
  20634. var originalExtent = scale.getExtent();
  20635. var axisDataLen;
  20636. var boundaryGap;
  20637. var span;
  20638. if (scaleType === 'ordinal') {
  20639. axisDataLen = (model.get('data') || []).length;
  20640. }
  20641. else {
  20642. boundaryGap = model.get('boundaryGap');
  20643. if (!zrUtil.isArray(boundaryGap)) {
  20644. boundaryGap = [boundaryGap || 0, boundaryGap || 0];
  20645. }
  20646. if (typeof boundaryGap[0] === 'boolean') {
  20647. if (true) {
  20648. console.warn('Boolean type for boundaryGap is only '
  20649. + 'allowed for ordinal axis. Please use string in '
  20650. + 'percentage instead, e.g., "20%". Currently, '
  20651. + 'boundaryGap is set to be 0.');
  20652. }
  20653. boundaryGap = [0, 0];
  20654. }
  20655. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1);
  20656. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1);
  20657. span = (originalExtent[1] - originalExtent[0])
  20658. || Math.abs(originalExtent[0]);
  20659. }
  20660. // Notice: When min/max is not set (that is, when there are null/undefined,
  20661. // which is the most common case), these cases should be ensured:
  20662. // (1) For 'ordinal', show all axis.data.
  20663. // (2) For others:
  20664. // + `boundaryGap` is applied (if min/max set, boundaryGap is
  20665. // disabled).
  20666. // + If `needCrossZero`, min/max should be zero, otherwise, min/max should
  20667. // be the result that originalExtent enlarged by boundaryGap.
  20668. // (3) If no data, it should be ensured that `scale.setBlank` is set.
  20669. // FIXME
  20670. // (1) When min/max is 'dataMin' or 'dataMax', should boundaryGap be able to used?
  20671. // (2) When `needCrossZero` and all data is positive/negative, should it be ensured
  20672. // that the results processed by boundaryGap are positive/negative?
  20673. if (min == null) {
  20674. min = scaleType === 'ordinal'
  20675. ? (axisDataLen ? 0 : NaN)
  20676. : originalExtent[0] - boundaryGap[0] * span;
  20677. }
  20678. if (max == null) {
  20679. max = scaleType === 'ordinal'
  20680. ? (axisDataLen ? axisDataLen - 1 : NaN)
  20681. : originalExtent[1] + boundaryGap[1] * span;
  20682. }
  20683. if (min === 'dataMin') {
  20684. min = originalExtent[0];
  20685. }
  20686. if (max === 'dataMax') {
  20687. max = originalExtent[1];
  20688. }
  20689. (min == null || !isFinite(min)) && (min = NaN);
  20690. (max == null || !isFinite(max)) && (max = NaN);
  20691. scale.setBlank(zrUtil.eqNaN(min) || zrUtil.eqNaN(max));
  20692. // Evaluate if axis needs cross zero
  20693. if (model.getNeedCrossZero()) {
  20694. // Axis is over zero and min is not set
  20695. if (min > 0 && max > 0 && !fixMin) {
  20696. min = 0;
  20697. }
  20698. // Axis is under zero and max is not set
  20699. if (min < 0 && max < 0 && !fixMax) {
  20700. max = 0;
  20701. }
  20702. }
  20703. return [min, max];
  20704. };
  20705. axisHelper.niceScaleExtent = function (scale, model) {
  20706. var extent = axisHelper.getScaleExtent(scale, model);
  20707. var fixMin = model.getMin() != null;
  20708. var fixMax = model.getMax() != null;
  20709. var splitNumber = model.get('splitNumber');
  20710. if (scale.type === 'log') {
  20711. scale.base = model.get('logBase');
  20712. }
  20713. scale.setExtent(extent[0], extent[1]);
  20714. scale.niceExtent({
  20715. splitNumber: splitNumber,
  20716. fixMin: fixMin,
  20717. fixMax: fixMax,
  20718. minInterval: scale.type === 'interval' ? model.get('minInterval') : null
  20719. });
  20720. // If some one specified the min, max. And the default calculated interval
  20721. // is not good enough. He can specify the interval. It is often appeared
  20722. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  20723. // to be 60.
  20724. // FIXME
  20725. var interval = model.get('interval');
  20726. if (interval != null) {
  20727. scale.setInterval && scale.setInterval(interval);
  20728. }
  20729. };
  20730. /**
  20731. * @param {module:echarts/model/Model} model
  20732. * @param {string} [axisType] Default retrieve from model.type
  20733. * @return {module:echarts/scale/*}
  20734. */
  20735. axisHelper.createScaleByModel = function(model, axisType) {
  20736. axisType = axisType || model.get('type');
  20737. if (axisType) {
  20738. switch (axisType) {
  20739. // Buildin scale
  20740. case 'category':
  20741. return new OrdinalScale(
  20742. model.getCategories(), [Infinity, -Infinity]
  20743. );
  20744. case 'value':
  20745. return new IntervalScale();
  20746. // Extended scale, like time and log
  20747. default:
  20748. return (Scale.getClass(axisType) || IntervalScale).create(model);
  20749. }
  20750. }
  20751. };
  20752. /**
  20753. * Check if the axis corss 0
  20754. */
  20755. axisHelper.ifAxisCrossZero = function (axis) {
  20756. var dataExtent = axis.scale.getExtent();
  20757. var min = dataExtent[0];
  20758. var max = dataExtent[1];
  20759. return !((min > 0 && max > 0) || (min < 0 && max < 0));
  20760. };
  20761. /**
  20762. * @param {Array.<number>} tickCoords In axis self coordinate.
  20763. * @param {Array.<string>} labels
  20764. * @param {string} font
  20765. * @param {boolean} isAxisHorizontal
  20766. * @return {number}
  20767. */
  20768. axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) {
  20769. // FIXME
  20770. // 不同角的axis和label,不只是horizontal和vertical.
  20771. var textSpaceTakenRect;
  20772. var autoLabelInterval = 0;
  20773. var accumulatedLabelInterval = 0;
  20774. var step = 1;
  20775. if (labels.length > 40) {
  20776. // Simple optimization for large amount of labels
  20777. step = Math.floor(labels.length / 40);
  20778. }
  20779. for (var i = 0; i < tickCoords.length; i += step) {
  20780. var tickCoord = tickCoords[i];
  20781. var rect = textContain.getBoundingRect(
  20782. labels[i], font, 'center', 'top'
  20783. );
  20784. rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord;
  20785. // FIXME Magic number 1.5
  20786. rect[isAxisHorizontal ? 'width' : 'height'] *= 1.3;
  20787. if (!textSpaceTakenRect) {
  20788. textSpaceTakenRect = rect.clone();
  20789. }
  20790. // There is no space for current label;
  20791. else if (textSpaceTakenRect.intersect(rect)) {
  20792. accumulatedLabelInterval++;
  20793. autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval);
  20794. }
  20795. else {
  20796. textSpaceTakenRect.union(rect);
  20797. // Reset
  20798. accumulatedLabelInterval = 0;
  20799. }
  20800. }
  20801. if (autoLabelInterval === 0 && step > 1) {
  20802. return step;
  20803. }
  20804. return (autoLabelInterval + 1) * step - 1;
  20805. };
  20806. /**
  20807. * @param {Object} axis
  20808. * @param {Function} labelFormatter
  20809. * @return {Array.<string>}
  20810. */
  20811. axisHelper.getFormattedLabels = function (axis, labelFormatter) {
  20812. var scale = axis.scale;
  20813. var labels = scale.getTicksLabels();
  20814. var ticks = scale.getTicks();
  20815. if (typeof labelFormatter === 'string') {
  20816. labelFormatter = (function (tpl) {
  20817. return function (val) {
  20818. return tpl.replace('{value}', val != null ? val : '');
  20819. };
  20820. })(labelFormatter);
  20821. // Consider empty array
  20822. return zrUtil.map(labels, labelFormatter);
  20823. }
  20824. else if (typeof labelFormatter === 'function') {
  20825. return zrUtil.map(ticks, function (tick, idx) {
  20826. return labelFormatter(
  20827. axisHelper.getAxisRawValue(axis, tick),
  20828. idx
  20829. );
  20830. }, this);
  20831. }
  20832. else {
  20833. return labels;
  20834. }
  20835. };
  20836. axisHelper.getAxisRawValue = function (axis, value) {
  20837. // In category axis with data zoom, tick is not the original
  20838. // index of axis.data. So tick should not be exposed to user
  20839. // in category axis.
  20840. return axis.type === 'category' ? axis.scale.getLabel(value) : value;
  20841. };
  20842. module.exports = axisHelper;
  20843. /***/ },
  20844. /* 102 */
  20845. /***/ function(module, exports, __webpack_require__) {
  20846. /**
  20847. * Linear continuous scale
  20848. * @module echarts/coord/scale/Ordinal
  20849. *
  20850. * http://en.wikipedia.org/wiki/Level_of_measurement
  20851. */
  20852. // FIXME only one data
  20853. var zrUtil = __webpack_require__(4);
  20854. var Scale = __webpack_require__(103);
  20855. var scaleProto = Scale.prototype;
  20856. var OrdinalScale = Scale.extend({
  20857. type: 'ordinal',
  20858. init: function (data, extent) {
  20859. this._data = data;
  20860. this._extent = extent || [0, data.length - 1];
  20861. },
  20862. parse: function (val) {
  20863. return typeof val === 'string'
  20864. ? zrUtil.indexOf(this._data, val)
  20865. // val might be float.
  20866. : Math.round(val);
  20867. },
  20868. contain: function (rank) {
  20869. rank = this.parse(rank);
  20870. return scaleProto.contain.call(this, rank)
  20871. && this._data[rank] != null;
  20872. },
  20873. /**
  20874. * Normalize given rank or name to linear [0, 1]
  20875. * @param {number|string} [val]
  20876. * @return {number}
  20877. */
  20878. normalize: function (val) {
  20879. return scaleProto.normalize.call(this, this.parse(val));
  20880. },
  20881. scale: function (val) {
  20882. return Math.round(scaleProto.scale.call(this, val));
  20883. },
  20884. /**
  20885. * @return {Array}
  20886. */
  20887. getTicks: function () {
  20888. var ticks = [];
  20889. var extent = this._extent;
  20890. var rank = extent[0];
  20891. while (rank <= extent[1]) {
  20892. ticks.push(rank);
  20893. rank++;
  20894. }
  20895. return ticks;
  20896. },
  20897. /**
  20898. * Get item on rank n
  20899. * @param {number} n
  20900. * @return {string}
  20901. */
  20902. getLabel: function (n) {
  20903. return this._data[n];
  20904. },
  20905. /**
  20906. * @return {number}
  20907. */
  20908. count: function () {
  20909. return this._extent[1] - this._extent[0] + 1;
  20910. },
  20911. /**
  20912. * @override
  20913. */
  20914. unionExtentFromData: function (data, dim) {
  20915. this.unionExtent(data.getDataExtent(dim, false));
  20916. },
  20917. niceTicks: zrUtil.noop,
  20918. niceExtent: zrUtil.noop
  20919. });
  20920. /**
  20921. * @return {module:echarts/scale/Time}
  20922. */
  20923. OrdinalScale.create = function () {
  20924. return new OrdinalScale();
  20925. };
  20926. module.exports = OrdinalScale;
  20927. /***/ },
  20928. /* 103 */
  20929. /***/ function(module, exports, __webpack_require__) {
  20930. /**
  20931. * // Scale class management
  20932. * @module echarts/scale/Scale
  20933. */
  20934. var clazzUtil = __webpack_require__(13);
  20935. /**
  20936. * @param {Object} [setting]
  20937. */
  20938. function Scale(setting) {
  20939. this._setting = setting || {};
  20940. /**
  20941. * Extent
  20942. * @type {Array.<number>}
  20943. * @protected
  20944. */
  20945. this._extent = [Infinity, -Infinity];
  20946. /**
  20947. * Step is calculated in adjustExtent
  20948. * @type {Array.<number>}
  20949. * @protected
  20950. */
  20951. this._interval = 0;
  20952. this.init && this.init.apply(this, arguments);
  20953. }
  20954. var scaleProto = Scale.prototype;
  20955. /**
  20956. * Parse input val to valid inner number.
  20957. * @param {*} val
  20958. * @return {number}
  20959. */
  20960. scaleProto.parse = function (val) {
  20961. // Notice: This would be a trap here, If the implementation
  20962. // of this method depends on extent, and this method is used
  20963. // before extent set (like in dataZoom), it would be wrong.
  20964. // Nevertheless, parse does not depend on extent generally.
  20965. return val;
  20966. };
  20967. scaleProto.getSetting = function (name) {
  20968. return this._setting[name];
  20969. };
  20970. scaleProto.contain = function (val) {
  20971. var extent = this._extent;
  20972. return val >= extent[0] && val <= extent[1];
  20973. };
  20974. /**
  20975. * Normalize value to linear [0, 1], return 0.5 if extent span is 0
  20976. * @param {number} val
  20977. * @return {number}
  20978. */
  20979. scaleProto.normalize = function (val) {
  20980. var extent = this._extent;
  20981. if (extent[1] === extent[0]) {
  20982. return 0.5;
  20983. }
  20984. return (val - extent[0]) / (extent[1] - extent[0]);
  20985. };
  20986. /**
  20987. * Scale normalized value
  20988. * @param {number} val
  20989. * @return {number}
  20990. */
  20991. scaleProto.scale = function (val) {
  20992. var extent = this._extent;
  20993. return val * (extent[1] - extent[0]) + extent[0];
  20994. };
  20995. /**
  20996. * Set extent from data
  20997. * @param {Array.<number>} other
  20998. */
  20999. scaleProto.unionExtent = function (other) {
  21000. var extent = this._extent;
  21001. other[0] < extent[0] && (extent[0] = other[0]);
  21002. other[1] > extent[1] && (extent[1] = other[1]);
  21003. // not setExtent because in log axis it may transformed to power
  21004. // this.setExtent(extent[0], extent[1]);
  21005. };
  21006. /**
  21007. * Set extent from data
  21008. * @param {module:echarts/data/List} data
  21009. * @param {string} dim
  21010. */
  21011. scaleProto.unionExtentFromData = function (data, dim) {
  21012. this.unionExtent(data.getDataExtent(dim, true));
  21013. };
  21014. /**
  21015. * Get extent
  21016. * @return {Array.<number>}
  21017. */
  21018. scaleProto.getExtent = function () {
  21019. return this._extent.slice();
  21020. };
  21021. /**
  21022. * Set extent
  21023. * @param {number} start
  21024. * @param {number} end
  21025. */
  21026. scaleProto.setExtent = function (start, end) {
  21027. var thisExtent = this._extent;
  21028. if (!isNaN(start)) {
  21029. thisExtent[0] = start;
  21030. }
  21031. if (!isNaN(end)) {
  21032. thisExtent[1] = end;
  21033. }
  21034. };
  21035. /**
  21036. * @return {Array.<string>}
  21037. */
  21038. scaleProto.getTicksLabels = function () {
  21039. var labels = [];
  21040. var ticks = this.getTicks();
  21041. for (var i = 0; i < ticks.length; i++) {
  21042. labels.push(this.getLabel(ticks[i]));
  21043. }
  21044. return labels;
  21045. };
  21046. /**
  21047. * When axis extent depends on data and no data exists,
  21048. * axis ticks should not be drawn, which is named 'blank'.
  21049. */
  21050. scaleProto.isBlank = function () {
  21051. return this._isBlank;
  21052. },
  21053. /**
  21054. * When axis extent depends on data and no data exists,
  21055. * axis ticks should not be drawn, which is named 'blank'.
  21056. */
  21057. scaleProto.setBlank = function (isBlank) {
  21058. this._isBlank = isBlank;
  21059. };
  21060. clazzUtil.enableClassExtend(Scale);
  21061. clazzUtil.enableClassManagement(Scale, {
  21062. registerWhenExtend: true
  21063. });
  21064. module.exports = Scale;
  21065. /***/ },
  21066. /* 104 */
  21067. /***/ function(module, exports, __webpack_require__) {
  21068. /**
  21069. * Interval scale
  21070. * @module echarts/scale/Interval
  21071. */
  21072. var numberUtil = __webpack_require__(7);
  21073. var formatUtil = __webpack_require__(6);
  21074. var Scale = __webpack_require__(103);
  21075. var helper = __webpack_require__(105);
  21076. var roundNumber = numberUtil.round;
  21077. /**
  21078. * @alias module:echarts/coord/scale/Interval
  21079. * @constructor
  21080. */
  21081. var IntervalScale = Scale.extend({
  21082. type: 'interval',
  21083. _interval: 0,
  21084. _intervalPrecision: 2,
  21085. setExtent: function (start, end) {
  21086. var thisExtent = this._extent;
  21087. //start,end may be a Number like '25',so...
  21088. if (!isNaN(start)) {
  21089. thisExtent[0] = parseFloat(start);
  21090. }
  21091. if (!isNaN(end)) {
  21092. thisExtent[1] = parseFloat(end);
  21093. }
  21094. },
  21095. unionExtent: function (other) {
  21096. var extent = this._extent;
  21097. other[0] < extent[0] && (extent[0] = other[0]);
  21098. other[1] > extent[1] && (extent[1] = other[1]);
  21099. // unionExtent may called by it's sub classes
  21100. IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]);
  21101. },
  21102. /**
  21103. * Get interval
  21104. */
  21105. getInterval: function () {
  21106. return this._interval;
  21107. },
  21108. /**
  21109. * Set interval
  21110. */
  21111. setInterval: function (interval) {
  21112. this._interval = interval;
  21113. // Dropped auto calculated niceExtent and use user setted extent
  21114. // We assume user wan't to set both interval, min, max to get a better result
  21115. this._niceExtent = this._extent.slice();
  21116. this._intervalPrecision = helper.getIntervalPrecision(interval);
  21117. },
  21118. /**
  21119. * @return {Array.<number>}
  21120. */
  21121. getTicks: function () {
  21122. return helper.intervalScaleGetTicks(
  21123. this._interval, this._extent, this._niceExtent, this._intervalPrecision
  21124. );
  21125. },
  21126. /**
  21127. * @return {Array.<string>}
  21128. */
  21129. getTicksLabels: function () {
  21130. var labels = [];
  21131. var ticks = this.getTicks();
  21132. for (var i = 0; i < ticks.length; i++) {
  21133. labels.push(this.getLabel(ticks[i]));
  21134. }
  21135. return labels;
  21136. },
  21137. /**
  21138. * @param {number} data
  21139. * @param {Object} [opt]
  21140. * @param {number|string} [opt.precision] If 'auto', use nice presision.
  21141. * @param {boolean} [opt.pad] returns 1.50 but not 1.5 if precision is 2.
  21142. * @return {string}
  21143. */
  21144. getLabel: function (data, opt) {
  21145. if (data == null) {
  21146. return '';
  21147. }
  21148. var precision = opt && opt.precision;
  21149. if (precision == null) {
  21150. precision = numberUtil.getPrecisionSafe(data) || 0;
  21151. }
  21152. else if (precision === 'auto') {
  21153. // Should be more precise then tick.
  21154. precision = this._intervalPrecision;
  21155. }
  21156. // (1) If `precision` is set, 12.005 should be display as '12.00500'.
  21157. // (2) Use roundNumber (toFixed) to avoid scientific notation like '3.5e-7'.
  21158. data = roundNumber(data, precision, true);
  21159. return formatUtil.addCommas(data);
  21160. },
  21161. /**
  21162. * Update interval and extent of intervals for nice ticks
  21163. *
  21164. * @param {number} [splitNumber = 5] Desired number of ticks
  21165. * @param {number} [minInterval]
  21166. */
  21167. niceTicks: function (splitNumber, minInterval) {
  21168. splitNumber = splitNumber || 5;
  21169. var extent = this._extent;
  21170. var span = extent[1] - extent[0];
  21171. if (!isFinite(span)) {
  21172. return;
  21173. }
  21174. // User may set axis min 0 and data are all negative
  21175. // FIXME If it needs to reverse ?
  21176. if (span < 0) {
  21177. span = -span;
  21178. extent.reverse();
  21179. }
  21180. var result = helper.intervalScaleNiceTicks(extent, splitNumber, minInterval);
  21181. this._intervalPrecision = result.intervalPrecision;
  21182. this._interval = result.interval;
  21183. this._niceExtent = result.niceTickExtent;
  21184. },
  21185. /**
  21186. * Nice extent.
  21187. * @param {Object} opt
  21188. * @param {number} [opt.splitNumber = 5] Given approx tick number
  21189. * @param {boolean} [opt.fixMin=false]
  21190. * @param {boolean} [opt.fixMax=false]
  21191. * @param {boolean} [opt.minInterval=false]
  21192. */
  21193. niceExtent: function (opt) {
  21194. var extent = this._extent;
  21195. // If extent start and end are same, expand them
  21196. if (extent[0] === extent[1]) {
  21197. if (extent[0] !== 0) {
  21198. // Expand extent
  21199. var expandSize = extent[0];
  21200. // In the fowllowing case
  21201. // Axis has been fixed max 100
  21202. // Plus data are all 100 and axis extent are [100, 100].
  21203. // Extend to the both side will cause expanded max is larger than fixed max.
  21204. // So only expand to the smaller side.
  21205. if (!opt.fixMax) {
  21206. extent[1] += expandSize / 2;
  21207. extent[0] -= expandSize / 2;
  21208. }
  21209. else {
  21210. extent[0] -= expandSize / 2;
  21211. }
  21212. }
  21213. else {
  21214. extent[1] = 1;
  21215. }
  21216. }
  21217. var span = extent[1] - extent[0];
  21218. // If there are no data and extent are [Infinity, -Infinity]
  21219. if (!isFinite(span)) {
  21220. extent[0] = 0;
  21221. extent[1] = 1;
  21222. }
  21223. this.niceTicks(opt.splitNumber, opt.minInterval);
  21224. // var extent = this._extent;
  21225. var interval = this._interval;
  21226. if (!opt.fixMin) {
  21227. extent[0] = roundNumber(Math.floor(extent[0] / interval) * interval);
  21228. }
  21229. if (!opt.fixMax) {
  21230. extent[1] = roundNumber(Math.ceil(extent[1] / interval) * interval);
  21231. }
  21232. }
  21233. });
  21234. /**
  21235. * @return {module:echarts/scale/Time}
  21236. */
  21237. IntervalScale.create = function () {
  21238. return new IntervalScale();
  21239. };
  21240. module.exports = IntervalScale;
  21241. /***/ },
  21242. /* 105 */
  21243. /***/ function(module, exports, __webpack_require__) {
  21244. /**
  21245. * For testable.
  21246. */
  21247. var numberUtil = __webpack_require__(7);
  21248. var roundNumber = numberUtil.round;
  21249. var helper = {};
  21250. /**
  21251. * @param {Array.<number>} extent Both extent[0] and extent[1] should be valid number.
  21252. * Should be extent[0] < extent[1].
  21253. * @param {number} splitNumber splitNumber should be >= 1.
  21254. * @param {number} [minInterval]
  21255. * @return {Object} {interval, intervalPrecision, niceTickExtent}
  21256. */
  21257. helper.intervalScaleNiceTicks = function (extent, splitNumber, minInterval) {
  21258. var result = {};
  21259. var span = extent[1] - extent[0];
  21260. var interval = result.interval = numberUtil.nice(span / splitNumber, true);
  21261. if (minInterval != null && interval < minInterval) {
  21262. interval = result.interval = minInterval;
  21263. }
  21264. // Tow more digital for tick.
  21265. var precision = result.intervalPrecision = helper.getIntervalPrecision(interval);
  21266. // Niced extent inside original extent
  21267. var niceTickExtent = result.niceTickExtent = [
  21268. roundNumber(Math.ceil(extent[0] / interval) * interval, precision),
  21269. roundNumber(Math.floor(extent[1] / interval) * interval, precision)
  21270. ];
  21271. helper.fixExtent(niceTickExtent, extent);
  21272. return result;
  21273. };
  21274. /**
  21275. * @param {number} interval
  21276. * @return {number} interval precision
  21277. */
  21278. helper.getIntervalPrecision = function (interval) {
  21279. // Tow more digital for tick.
  21280. return numberUtil.getPrecisionSafe(interval) + 2;
  21281. };
  21282. function clamp(niceTickExtent, idx, extent) {
  21283. niceTickExtent[idx] = Math.max(Math.min(niceTickExtent[idx], extent[1]), extent[0]);
  21284. }
  21285. // In some cases (e.g., splitNumber is 1), niceTickExtent may be out of extent.
  21286. helper.fixExtent = function (niceTickExtent, extent) {
  21287. !isFinite(niceTickExtent[0]) && (niceTickExtent[0] = extent[0]);
  21288. !isFinite(niceTickExtent[1]) && (niceTickExtent[1] = extent[1]);
  21289. clamp(niceTickExtent, 0, extent);
  21290. clamp(niceTickExtent, 1, extent);
  21291. if (niceTickExtent[0] > niceTickExtent[1]) {
  21292. niceTickExtent[0] = niceTickExtent[1];
  21293. }
  21294. };
  21295. helper.intervalScaleGetTicks = function (interval, extent, niceTickExtent, intervalPrecision) {
  21296. var ticks = [];
  21297. // If interval is 0, return [];
  21298. if (!interval) {
  21299. return ticks;
  21300. }
  21301. // Consider this case: using dataZoom toolbox, zoom and zoom.
  21302. var safeLimit = 10000;
  21303. if (extent[0] < niceTickExtent[0]) {
  21304. ticks.push(extent[0]);
  21305. }
  21306. var tick = niceTickExtent[0];
  21307. while (tick <= niceTickExtent[1]) {
  21308. ticks.push(tick);
  21309. // Avoid rounding error
  21310. tick = roundNumber(tick + interval, intervalPrecision);
  21311. if (tick === ticks[ticks.length - 1]) {
  21312. // Consider out of safe float point, e.g.,
  21313. // -3711126.9907707 + 2e-10 === -3711126.9907707
  21314. break;
  21315. }
  21316. if (ticks.length > safeLimit) {
  21317. return [];
  21318. }
  21319. }
  21320. // Consider this case: the last item of ticks is smaller
  21321. // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
  21322. if (extent[1] > (ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1])) {
  21323. ticks.push(extent[1]);
  21324. }
  21325. return ticks;
  21326. };
  21327. module.exports = helper;
  21328. /***/ },
  21329. /* 106 */
  21330. /***/ function(module, exports, __webpack_require__) {
  21331. /**
  21332. * Interval scale
  21333. * @module echarts/coord/scale/Time
  21334. */
  21335. // [About UTC and local time zone]:
  21336. // In most cases, `number.parseDate` will treat input data string as local time
  21337. // (except time zone is specified in time string). And `format.formateTime` returns
  21338. // local time by default. option.useUTC is false by default. This design have
  21339. // concidered these common case:
  21340. // (1) Time that is persistent in server is in UTC, but it is needed to be diplayed
  21341. // in local time by default.
  21342. // (2) By default, the input data string (e.g., '2011-01-02') should be displayed
  21343. // as its original time, without any time difference.
  21344. var zrUtil = __webpack_require__(4);
  21345. var numberUtil = __webpack_require__(7);
  21346. var formatUtil = __webpack_require__(6);
  21347. var scaleHelper = __webpack_require__(105);
  21348. var IntervalScale = __webpack_require__(104);
  21349. var intervalScaleProto = IntervalScale.prototype;
  21350. var mathCeil = Math.ceil;
  21351. var mathFloor = Math.floor;
  21352. var ONE_SECOND = 1000;
  21353. var ONE_MINUTE = ONE_SECOND * 60;
  21354. var ONE_HOUR = ONE_MINUTE * 60;
  21355. var ONE_DAY = ONE_HOUR * 24;
  21356. // FIXME 公用?
  21357. var bisect = function (a, x, lo, hi) {
  21358. while (lo < hi) {
  21359. var mid = lo + hi >>> 1;
  21360. if (a[mid][2] < x) {
  21361. lo = mid + 1;
  21362. }
  21363. else {
  21364. hi = mid;
  21365. }
  21366. }
  21367. return lo;
  21368. };
  21369. /**
  21370. * @alias module:echarts/coord/scale/Time
  21371. * @constructor
  21372. */
  21373. var TimeScale = IntervalScale.extend({
  21374. type: 'time',
  21375. /**
  21376. * @override
  21377. */
  21378. getLabel: function (val) {
  21379. var stepLvl = this._stepLvl;
  21380. var date = new Date(val);
  21381. return formatUtil.formatTime(stepLvl[0], date, this.getSetting('useUTC'));
  21382. },
  21383. /**
  21384. * @override
  21385. */
  21386. niceExtent: function (opt) {
  21387. var extent = this._extent;
  21388. // If extent start and end are same, expand them
  21389. if (extent[0] === extent[1]) {
  21390. // Expand extent
  21391. extent[0] -= ONE_DAY;
  21392. extent[1] += ONE_DAY;
  21393. }
  21394. // If there are no data and extent are [Infinity, -Infinity]
  21395. if (extent[1] === -Infinity && extent[0] === Infinity) {
  21396. var d = new Date();
  21397. extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
  21398. extent[0] = extent[1] - ONE_DAY;
  21399. }
  21400. this.niceTicks(opt.splitNumber);
  21401. // var extent = this._extent;
  21402. var interval = this._interval;
  21403. if (!opt.fixMin) {
  21404. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  21405. }
  21406. if (!opt.fixMax) {
  21407. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  21408. }
  21409. },
  21410. /**
  21411. * @override
  21412. */
  21413. niceTicks: function (approxTickNum) {
  21414. var timezoneOffset = this.getSetting('useUTC')
  21415. ? 0 : numberUtil.getTimezoneOffset() * 60 * 1000;
  21416. approxTickNum = approxTickNum || 10;
  21417. var extent = this._extent;
  21418. var span = extent[1] - extent[0];
  21419. var approxInterval = span / approxTickNum;
  21420. var scaleLevelsLen = scaleLevels.length;
  21421. var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen);
  21422. var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)];
  21423. var interval = level[2];
  21424. // Same with interval scale if span is much larger than 1 year
  21425. if (level[0] === 'year') {
  21426. var yearSpan = span / interval;
  21427. // From "Nice Numbers for Graph Labels" of Graphic Gems
  21428. // var niceYearSpan = numberUtil.nice(yearSpan, false);
  21429. var yearStep = numberUtil.nice(yearSpan / approxTickNum, true);
  21430. interval *= yearStep;
  21431. }
  21432. var niceExtent = [
  21433. Math.round(mathCeil((extent[0] - timezoneOffset) / interval) * interval + timezoneOffset),
  21434. Math.round(mathFloor((extent[1] - timezoneOffset)/ interval) * interval + timezoneOffset)
  21435. ];
  21436. scaleHelper.fixExtent(niceExtent, extent);
  21437. this._stepLvl = level;
  21438. // Interval will be used in getTicks
  21439. this._interval = interval;
  21440. this._niceExtent = niceExtent;
  21441. },
  21442. parse: function (val) {
  21443. // val might be float.
  21444. return +numberUtil.parseDate(val);
  21445. }
  21446. });
  21447. zrUtil.each(['contain', 'normalize'], function (methodName) {
  21448. TimeScale.prototype[methodName] = function (val) {
  21449. return intervalScaleProto[methodName].call(this, this.parse(val));
  21450. };
  21451. });
  21452. // Steps from d3
  21453. var scaleLevels = [
  21454. // Format step interval
  21455. ['hh:mm:ss', 1, ONE_SECOND], // 1s
  21456. ['hh:mm:ss', 5, ONE_SECOND * 5], // 5s
  21457. ['hh:mm:ss', 10, ONE_SECOND * 10], // 10s
  21458. ['hh:mm:ss', 15, ONE_SECOND * 15], // 15s
  21459. ['hh:mm:ss', 30, ONE_SECOND * 30], // 30s
  21460. ['hh:mm\nMM-dd',1, ONE_MINUTE], // 1m
  21461. ['hh:mm\nMM-dd',5, ONE_MINUTE * 5], // 5m
  21462. ['hh:mm\nMM-dd',10, ONE_MINUTE * 10], // 10m
  21463. ['hh:mm\nMM-dd',15, ONE_MINUTE * 15], // 15m
  21464. ['hh:mm\nMM-dd',30, ONE_MINUTE * 30], // 30m
  21465. ['hh:mm\nMM-dd',1, ONE_HOUR], // 1h
  21466. ['hh:mm\nMM-dd',2, ONE_HOUR * 2], // 2h
  21467. ['hh:mm\nMM-dd',6, ONE_HOUR * 6], // 6h
  21468. ['hh:mm\nMM-dd',12, ONE_HOUR * 12], // 12h
  21469. ['MM-dd\nyyyy', 1, ONE_DAY], // 1d
  21470. ['week', 7, ONE_DAY * 7], // 7d
  21471. ['month', 1, ONE_DAY * 31], // 1M
  21472. ['quarter', 3, ONE_DAY * 380 / 4], // 3M
  21473. ['half-year', 6, ONE_DAY * 380 / 2], // 6M
  21474. ['year', 1, ONE_DAY * 380] // 1Y
  21475. ];
  21476. /**
  21477. * @param {module:echarts/model/Model}
  21478. * @return {module:echarts/scale/Time}
  21479. */
  21480. TimeScale.create = function (model) {
  21481. return new TimeScale({useUTC: model.ecModel.get('useUTC')});
  21482. };
  21483. module.exports = TimeScale;
  21484. /***/ },
  21485. /* 107 */
  21486. /***/ function(module, exports, __webpack_require__) {
  21487. /**
  21488. * Log scale
  21489. * @module echarts/scale/Log
  21490. */
  21491. var zrUtil = __webpack_require__(4);
  21492. var Scale = __webpack_require__(103);
  21493. var numberUtil = __webpack_require__(7);
  21494. // Use some method of IntervalScale
  21495. var IntervalScale = __webpack_require__(104);
  21496. var scaleProto = Scale.prototype;
  21497. var intervalScaleProto = IntervalScale.prototype;
  21498. var getPrecisionSafe = numberUtil.getPrecisionSafe;
  21499. var roundingErrorFix = numberUtil.round;
  21500. var mathFloor = Math.floor;
  21501. var mathCeil = Math.ceil;
  21502. var mathPow = Math.pow;
  21503. var mathLog = Math.log;
  21504. var LogScale = Scale.extend({
  21505. type: 'log',
  21506. base: 10,
  21507. $constructor: function () {
  21508. Scale.apply(this, arguments);
  21509. this._originalScale = new IntervalScale();
  21510. },
  21511. /**
  21512. * @return {Array.<number>}
  21513. */
  21514. getTicks: function () {
  21515. var originalScale = this._originalScale;
  21516. var extent = this._extent;
  21517. var originalExtent = originalScale.getExtent();
  21518. return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
  21519. var powVal = numberUtil.round(mathPow(this.base, val));
  21520. // Fix #4158
  21521. powVal = (val === extent[0] && originalScale.__fixMin)
  21522. ? fixRoundingError(powVal, originalExtent[0])
  21523. : powVal;
  21524. powVal = (val === extent[1] && originalScale.__fixMax)
  21525. ? fixRoundingError(powVal, originalExtent[1])
  21526. : powVal;
  21527. return powVal;
  21528. }, this);
  21529. },
  21530. /**
  21531. * @param {number} val
  21532. * @return {string}
  21533. */
  21534. getLabel: intervalScaleProto.getLabel,
  21535. /**
  21536. * @param {number} val
  21537. * @return {number}
  21538. */
  21539. scale: function (val) {
  21540. val = scaleProto.scale.call(this, val);
  21541. return mathPow(this.base, val);
  21542. },
  21543. /**
  21544. * @param {number} start
  21545. * @param {number} end
  21546. */
  21547. setExtent: function (start, end) {
  21548. var base = this.base;
  21549. start = mathLog(start) / mathLog(base);
  21550. end = mathLog(end) / mathLog(base);
  21551. intervalScaleProto.setExtent.call(this, start, end);
  21552. },
  21553. /**
  21554. * @return {number} end
  21555. */
  21556. getExtent: function () {
  21557. var base = this.base;
  21558. var extent = scaleProto.getExtent.call(this);
  21559. extent[0] = mathPow(base, extent[0]);
  21560. extent[1] = mathPow(base, extent[1]);
  21561. // Fix #4158
  21562. var originalScale = this._originalScale;
  21563. var originalExtent = originalScale.getExtent();
  21564. originalScale.__fixMin && (extent[0] = fixRoundingError(extent[0], originalExtent[0]));
  21565. originalScale.__fixMax && (extent[1] = fixRoundingError(extent[1], originalExtent[1]));
  21566. return extent;
  21567. },
  21568. /**
  21569. * @param {Array.<number>} extent
  21570. */
  21571. unionExtent: function (extent) {
  21572. this._originalScale.unionExtent(extent);
  21573. var base = this.base;
  21574. extent[0] = mathLog(extent[0]) / mathLog(base);
  21575. extent[1] = mathLog(extent[1]) / mathLog(base);
  21576. scaleProto.unionExtent.call(this, extent);
  21577. },
  21578. /**
  21579. * @override
  21580. */
  21581. unionExtentFromData: function (data, dim) {
  21582. this.unionExtent(data.getDataExtent(dim, true, function (val) {
  21583. return val > 0;
  21584. }));
  21585. },
  21586. /**
  21587. * Update interval and extent of intervals for nice ticks
  21588. * @param {number} [approxTickNum = 10] Given approx tick number
  21589. */
  21590. niceTicks: function (approxTickNum) {
  21591. approxTickNum = approxTickNum || 10;
  21592. var extent = this._extent;
  21593. var span = extent[1] - extent[0];
  21594. if (span === Infinity || span <= 0) {
  21595. return;
  21596. }
  21597. var interval = numberUtil.quantity(span);
  21598. var err = approxTickNum / span * interval;
  21599. // Filter ticks to get closer to the desired count.
  21600. if (err <= 0.5) {
  21601. interval *= 10;
  21602. }
  21603. // Interval should be integer
  21604. while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
  21605. interval *= 10;
  21606. }
  21607. var niceExtent = [
  21608. numberUtil.round(mathCeil(extent[0] / interval) * interval),
  21609. numberUtil.round(mathFloor(extent[1] / interval) * interval)
  21610. ];
  21611. this._interval = interval;
  21612. this._niceExtent = niceExtent;
  21613. },
  21614. /**
  21615. * Nice extent.
  21616. * @override
  21617. */
  21618. niceExtent: function (opt) {
  21619. intervalScaleProto.niceExtent.call(this, opt);
  21620. var originalScale = this._originalScale;
  21621. originalScale.__fixMin = opt.fixMin;
  21622. originalScale.__fixMax = opt.fixMax;
  21623. }
  21624. });
  21625. zrUtil.each(['contain', 'normalize'], function (methodName) {
  21626. LogScale.prototype[methodName] = function (val) {
  21627. val = mathLog(val) / mathLog(this.base);
  21628. return scaleProto[methodName].call(this, val);
  21629. };
  21630. });
  21631. LogScale.create = function () {
  21632. return new LogScale();
  21633. };
  21634. function fixRoundingError(val, originalVal) {
  21635. return roundingErrorFix(val, getPrecisionSafe(originalVal));
  21636. }
  21637. module.exports = LogScale;
  21638. /***/ },
  21639. /* 108 */
  21640. /***/ function(module, exports, __webpack_require__) {
  21641. var createListFromArray = __webpack_require__(109);
  21642. var symbolUtil = __webpack_require__(111);
  21643. var axisHelper = __webpack_require__(101);
  21644. var axisModelCommonMixin = __webpack_require__(112);
  21645. var Model = __webpack_require__(12);
  21646. var util = __webpack_require__(4);
  21647. module.exports = {
  21648. /**
  21649. * Create a muti dimension List structure from seriesModel.
  21650. * @param {module:echarts/model/Model} seriesModel
  21651. * @return {module:echarts/data/List} list
  21652. */
  21653. createList: function (seriesModel) {
  21654. var data = seriesModel.get('data');
  21655. return createListFromArray(data, seriesModel, seriesModel.ecModel);
  21656. },
  21657. /**
  21658. * @see {module:echarts/data/helper/completeDimensions}
  21659. */
  21660. completeDimensions: __webpack_require__(110),
  21661. /**
  21662. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  21663. * @see http://echarts.baidu.com/option.html#series-scatter.symbol
  21664. * @param {string} symbolDesc
  21665. * @param {number} x
  21666. * @param {number} y
  21667. * @param {number} w
  21668. * @param {number} h
  21669. * @param {string} color
  21670. */
  21671. createSymbol: symbolUtil.createSymbol,
  21672. /**
  21673. * Create scale
  21674. * @param {Array.<number>} dataExtent
  21675. * @param {Object|module:echarts/Model} option
  21676. */
  21677. createScale: function (dataExtent, option) {
  21678. var axisModel = option;
  21679. if (!(option instanceof Model)) {
  21680. axisModel = new Model(option);
  21681. util.mixin(axisModel, axisModelCommonMixin);
  21682. }
  21683. var scale = axisHelper.createScaleByModel(axisModel);
  21684. scale.setExtent(dataExtent[0], dataExtent[1]);
  21685. axisHelper.niceScaleExtent(scale, axisModel);
  21686. return scale;
  21687. },
  21688. /**
  21689. * Mixin common methods to axis model,
  21690. *
  21691. * Inlcude methods
  21692. * `getFormattedLabels() => Array.<string>`
  21693. * `getCategories() => Array.<string>`
  21694. * `getMin(origin: boolean) => number`
  21695. * `getMax(origin: boolean) => number`
  21696. * `getNeedCrossZero() => boolean`
  21697. * `setRange(start: number, end: number)`
  21698. * `resetRange()`
  21699. */
  21700. mixinAxisModelCommonMethods: function (Model) {
  21701. util.mixin(Model, axisModelCommonMixin);
  21702. }
  21703. };
  21704. /***/ },
  21705. /* 109 */
  21706. /***/ function(module, exports, __webpack_require__) {
  21707. 'use strict';
  21708. var List = __webpack_require__(98);
  21709. var completeDimensions = __webpack_require__(110);
  21710. var zrUtil = __webpack_require__(4);
  21711. var modelUtil = __webpack_require__(5);
  21712. var CoordinateSystem = __webpack_require__(76);
  21713. var getDataItemValue = modelUtil.getDataItemValue;
  21714. var converDataValue = modelUtil.converDataValue;
  21715. function firstDataNotNull(data) {
  21716. var i = 0;
  21717. while (i < data.length && data[i] == null) {
  21718. i++;
  21719. }
  21720. return data[i];
  21721. }
  21722. function ifNeedCompleteOrdinalData(data) {
  21723. var sampleItem = firstDataNotNull(data);
  21724. return sampleItem != null
  21725. && !zrUtil.isArray(getDataItemValue(sampleItem));
  21726. }
  21727. /**
  21728. * Helper function to create a list from option data
  21729. */
  21730. function createListFromArray(data, seriesModel, ecModel) {
  21731. // If data is undefined
  21732. data = data || [];
  21733. if (true) {
  21734. if (!zrUtil.isArray(data)) {
  21735. throw new Error('Invalid data.');
  21736. }
  21737. }
  21738. var coordSysName = seriesModel.get('coordinateSystem');
  21739. var creator = creators[coordSysName];
  21740. var registeredCoordSys = CoordinateSystem.get(coordSysName);
  21741. var completeDimOpt = {
  21742. encodeDef: seriesModel.get('encode'),
  21743. dimsDef: seriesModel.get('dimensions')
  21744. };
  21745. // FIXME
  21746. var axesInfo = creator && creator(data, seriesModel, ecModel, completeDimOpt);
  21747. var dimensions = axesInfo && axesInfo.dimensions;
  21748. if (!dimensions) {
  21749. // Get dimensions from registered coordinate system
  21750. dimensions = (registeredCoordSys && (
  21751. registeredCoordSys.getDimensionsInfo
  21752. ? registeredCoordSys.getDimensionsInfo()
  21753. : registeredCoordSys.dimensions.slice()
  21754. )) || ['x', 'y'];
  21755. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  21756. }
  21757. var categoryIndex = axesInfo ? axesInfo.categoryIndex : -1;
  21758. var list = new List(dimensions, seriesModel);
  21759. var nameList = createNameList(axesInfo, data);
  21760. var categories = {};
  21761. var dimValueGetter = (categoryIndex >= 0 && ifNeedCompleteOrdinalData(data))
  21762. ? function (itemOpt, dimName, dataIndex, dimIndex) {
  21763. // If any dataItem is like { value: 10 }
  21764. if (modelUtil.isDataItemOption(itemOpt)) {
  21765. list.hasItemOption = true;
  21766. }
  21767. // Use dataIndex as ordinal value in categoryAxis
  21768. return dimIndex === categoryIndex
  21769. ? dataIndex
  21770. : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]);
  21771. }
  21772. : function (itemOpt, dimName, dataIndex, dimIndex) {
  21773. var value = getDataItemValue(itemOpt);
  21774. var val = converDataValue(value && value[dimIndex], dimensions[dimIndex]);
  21775. // If any dataItem is like { value: 10 }
  21776. if (modelUtil.isDataItemOption(itemOpt)) {
  21777. list.hasItemOption = true;
  21778. }
  21779. var categoryAxesModels = axesInfo && axesInfo.categoryAxesModels;
  21780. if (categoryAxesModels && categoryAxesModels[dimName]) {
  21781. // If given value is a category string
  21782. if (typeof val === 'string') {
  21783. // Lazy get categories
  21784. categories[dimName] = categories[dimName]
  21785. || categoryAxesModels[dimName].getCategories();
  21786. val = zrUtil.indexOf(categories[dimName], val);
  21787. if (val < 0 && !isNaN(val)) {
  21788. // In case some one write '1', '2' istead of 1, 2
  21789. val = +val;
  21790. }
  21791. }
  21792. }
  21793. return val;
  21794. };
  21795. list.hasItemOption = false;
  21796. list.initData(data, nameList, dimValueGetter);
  21797. return list;
  21798. }
  21799. function isStackable(axisType) {
  21800. return axisType !== 'category' && axisType !== 'time';
  21801. }
  21802. function getDimTypeByAxis(axisType) {
  21803. return axisType === 'category'
  21804. ? 'ordinal'
  21805. : axisType === 'time'
  21806. ? 'time'
  21807. : 'float';
  21808. }
  21809. /**
  21810. * Creaters for each coord system.
  21811. */
  21812. var creators = {
  21813. cartesian2d: function (data, seriesModel, ecModel, completeDimOpt) {
  21814. var axesModels = zrUtil.map(['xAxis', 'yAxis'], function (name) {
  21815. return ecModel.queryComponents({
  21816. mainType: name,
  21817. index: seriesModel.get(name + 'Index'),
  21818. id: seriesModel.get(name + 'Id')
  21819. })[0];
  21820. });
  21821. var xAxisModel = axesModels[0];
  21822. var yAxisModel = axesModels[1];
  21823. if (true) {
  21824. if (!xAxisModel) {
  21825. throw new Error('xAxis "' + zrUtil.retrieve(
  21826. seriesModel.get('xAxisIndex'),
  21827. seriesModel.get('xAxisId'),
  21828. 0
  21829. ) + '" not found');
  21830. }
  21831. if (!yAxisModel) {
  21832. throw new Error('yAxis "' + zrUtil.retrieve(
  21833. seriesModel.get('xAxisIndex'),
  21834. seriesModel.get('yAxisId'),
  21835. 0
  21836. ) + '" not found');
  21837. }
  21838. }
  21839. var xAxisType = xAxisModel.get('type');
  21840. var yAxisType = yAxisModel.get('type');
  21841. var dimensions = [
  21842. {
  21843. name: 'x',
  21844. type: getDimTypeByAxis(xAxisType),
  21845. stackable: isStackable(xAxisType)
  21846. },
  21847. {
  21848. name: 'y',
  21849. // If two category axes
  21850. type: getDimTypeByAxis(yAxisType),
  21851. stackable: isStackable(yAxisType)
  21852. }
  21853. ];
  21854. var isXAxisCateogry = xAxisType === 'category';
  21855. var isYAxisCategory = yAxisType === 'category';
  21856. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  21857. var categoryAxesModels = {};
  21858. if (isXAxisCateogry) {
  21859. categoryAxesModels.x = xAxisModel;
  21860. }
  21861. if (isYAxisCategory) {
  21862. categoryAxesModels.y = yAxisModel;
  21863. }
  21864. return {
  21865. dimensions: dimensions,
  21866. categoryIndex: isXAxisCateogry ? 0 : (isYAxisCategory ? 1 : -1),
  21867. categoryAxesModels: categoryAxesModels
  21868. };
  21869. },
  21870. singleAxis: function (data, seriesModel, ecModel, completeDimOpt) {
  21871. var singleAxisModel = ecModel.queryComponents({
  21872. mainType: 'singleAxis',
  21873. index: seriesModel.get('singleAxisIndex'),
  21874. id: seriesModel.get('singleAxisId')
  21875. })[0];
  21876. if (true) {
  21877. if (!singleAxisModel) {
  21878. throw new Error('singleAxis should be specified.');
  21879. }
  21880. }
  21881. var singleAxisType = singleAxisModel.get('type');
  21882. var isCategory = singleAxisType === 'category';
  21883. var dimensions = [{
  21884. name: 'single',
  21885. type: getDimTypeByAxis(singleAxisType),
  21886. stackable: isStackable(singleAxisType)
  21887. }];
  21888. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  21889. var categoryAxesModels = {};
  21890. if (isCategory) {
  21891. categoryAxesModels.single = singleAxisModel;
  21892. }
  21893. return {
  21894. dimensions: dimensions,
  21895. categoryIndex: isCategory ? 0 : -1,
  21896. categoryAxesModels: categoryAxesModels
  21897. };
  21898. },
  21899. polar: function (data, seriesModel, ecModel, completeDimOpt) {
  21900. var polarModel = ecModel.queryComponents({
  21901. mainType: 'polar',
  21902. index: seriesModel.get('polarIndex'),
  21903. id: seriesModel.get('polarId')
  21904. })[0];
  21905. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  21906. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  21907. if (true) {
  21908. if (!angleAxisModel) {
  21909. throw new Error('angleAxis option not found');
  21910. }
  21911. if (!radiusAxisModel) {
  21912. throw new Error('radiusAxis option not found');
  21913. }
  21914. }
  21915. var radiusAxisType = radiusAxisModel.get('type');
  21916. var angleAxisType = angleAxisModel.get('type');
  21917. var dimensions = [
  21918. {
  21919. name: 'radius',
  21920. type: getDimTypeByAxis(radiusAxisType),
  21921. stackable: isStackable(radiusAxisType)
  21922. },
  21923. {
  21924. name: 'angle',
  21925. type: getDimTypeByAxis(angleAxisType),
  21926. stackable: isStackable(angleAxisType)
  21927. }
  21928. ];
  21929. var isAngleAxisCateogry = angleAxisType === 'category';
  21930. var isRadiusAxisCateogry = radiusAxisType === 'category';
  21931. dimensions = completeDimensions(dimensions, data, completeDimOpt);
  21932. var categoryAxesModels = {};
  21933. if (isRadiusAxisCateogry) {
  21934. categoryAxesModels.radius = radiusAxisModel;
  21935. }
  21936. if (isAngleAxisCateogry) {
  21937. categoryAxesModels.angle = angleAxisModel;
  21938. }
  21939. return {
  21940. dimensions: dimensions,
  21941. categoryIndex: isAngleAxisCateogry ? 1 : (isRadiusAxisCateogry ? 0 : -1),
  21942. categoryAxesModels: categoryAxesModels
  21943. };
  21944. },
  21945. geo: function (data, seriesModel, ecModel, completeDimOpt) {
  21946. // TODO Region
  21947. // 多个散点图系列在同一个地区的时候
  21948. return {
  21949. dimensions: completeDimensions([
  21950. {name: 'lng'},
  21951. {name: 'lat'}
  21952. ], data, completeDimOpt)
  21953. };
  21954. }
  21955. };
  21956. function createNameList(result, data) {
  21957. var nameList = [];
  21958. var categoryDim = result && result.dimensions[result.categoryIndex];
  21959. var categoryAxisModel;
  21960. if (categoryDim) {
  21961. categoryAxisModel = result.categoryAxesModels[categoryDim.name];
  21962. }
  21963. if (categoryAxisModel) {
  21964. // FIXME Two category axis
  21965. var categories = categoryAxisModel.getCategories();
  21966. if (categories) {
  21967. var dataLen = data.length;
  21968. // Ordered data is given explicitly like
  21969. // [[3, 0.2], [1, 0.3], [2, 0.15]]
  21970. // or given scatter data,
  21971. // pick the category
  21972. if (zrUtil.isArray(data[0]) && data[0].length > 1) {
  21973. nameList = [];
  21974. for (var i = 0; i < dataLen; i++) {
  21975. nameList[i] = categories[data[i][result.categoryIndex || 0]];
  21976. }
  21977. }
  21978. else {
  21979. nameList = categories.slice(0);
  21980. }
  21981. }
  21982. }
  21983. return nameList;
  21984. }
  21985. module.exports = createListFromArray;
  21986. /***/ },
  21987. /* 110 */
  21988. /***/ function(module, exports, __webpack_require__) {
  21989. /**
  21990. * Complete dimensions by data (guess dimension).
  21991. */
  21992. var zrUtil = __webpack_require__(4);
  21993. var modelUtil = __webpack_require__(5);
  21994. var each = zrUtil.each;
  21995. var isString = zrUtil.isString;
  21996. var defaults = zrUtil.defaults;
  21997. var normalizeToArray = modelUtil.normalizeToArray;
  21998. var OTHER_DIMS = {tooltip: 1, label: 1, itemName: 1};
  21999. /**
  22000. * Complete the dimensions array, by user defined `dimension` and `encode`,
  22001. * and guessing from the data structure.
  22002. * If no 'value' dimension specified, the first no-named dimension will be
  22003. * named as 'value'.
  22004. *
  22005. * @param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
  22006. * provides not only dim template, but also default order.
  22007. * `name` of each item provides default coord name.
  22008. * [{dimsDef: []}, ...] can be specified to give names.
  22009. * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]].
  22010. * @param {Object} [opt]
  22011. * @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
  22012. * For example: ['asdf', {name, type}, ...].
  22013. * @param {Object} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
  22014. * @param {string} [opt.extraPrefix] Prefix of name when filling the left dimensions.
  22015. * @param {string} [opt.extraFromZero] If specified, extra dim names will be:
  22016. * extraPrefix + 0, extraPrefix + extraBaseIndex + 1 ...
  22017. * If not specified, extra dim names will be:
  22018. * extraPrefix, extraPrefix + 0, extraPrefix + 1 ...
  22019. * @param {number} [opt.dimCount] If not specified, guess by the first data item.
  22020. * @return {Array.<Object>} [{
  22021. * name: string mandatory,
  22022. * coordDim: string mandatory,
  22023. * coordDimIndex: number mandatory,
  22024. * type: string optional,
  22025. * tooltipName: string optional,
  22026. * otherDims: {
  22027. * tooltip: number optional,
  22028. * label: number optional
  22029. * },
  22030. * isExtraCoord: boolean true or undefined.
  22031. * other props ...
  22032. * }]
  22033. */
  22034. function completeDimensions(sysDims, data, opt) {
  22035. data = data || [];
  22036. opt = opt || {};
  22037. sysDims = (sysDims || []).slice();
  22038. var dimsDef = (opt.dimsDef || []).slice();
  22039. var encodeDef = zrUtil.createHashMap(opt.encodeDef);
  22040. var dataDimNameMap = zrUtil.createHashMap();
  22041. var coordDimNameMap = zrUtil.createHashMap();
  22042. // var valueCandidate;
  22043. var result = [];
  22044. var dimCount = opt.dimCount;
  22045. if (dimCount == null) {
  22046. var value0 = retrieveValue(data[0]);
  22047. dimCount = Math.max(
  22048. zrUtil.isArray(value0) && value0.length || 1,
  22049. sysDims.length,
  22050. dimsDef.length
  22051. );
  22052. each(sysDims, function (sysDimItem) {
  22053. var sysDimItemDimsDef = sysDimItem.dimsDef;
  22054. sysDimItemDimsDef && (dimCount = Math.max(dimCount, sysDimItemDimsDef.length));
  22055. });
  22056. }
  22057. // Apply user defined dims (`name` and `type`) and init result.
  22058. for (var i = 0; i < dimCount; i++) {
  22059. var dimDefItem = isString(dimsDef[i]) ? {name: dimsDef[i]} : (dimsDef[i] || {});
  22060. var userDimName = dimDefItem.name;
  22061. var resultItem = result[i] = {otherDims: {}};
  22062. // Name will be applied later for avoiding duplication.
  22063. if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
  22064. // Only if `series.dimensions` is defined in option, tooltipName
  22065. // will be set, and dimension will be diplayed vertically in
  22066. // tooltip by default.
  22067. resultItem.name = resultItem.tooltipName = userDimName;
  22068. dataDimNameMap.set(userDimName, i);
  22069. }
  22070. dimDefItem.type != null && (resultItem.type = dimDefItem.type);
  22071. }
  22072. // Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
  22073. encodeDef.each(function (dataDims, coordDim) {
  22074. dataDims = encodeDef.set(coordDim, normalizeToArray(dataDims).slice());
  22075. each(dataDims, function (resultDimIdx, coordDimIndex) {
  22076. // The input resultDimIdx can be dim name or index.
  22077. isString(resultDimIdx) && (resultDimIdx = dataDimNameMap.get(resultDimIdx));
  22078. if (resultDimIdx != null && resultDimIdx < dimCount) {
  22079. dataDims[coordDimIndex] = resultDimIdx;
  22080. applyDim(result[resultDimIdx], coordDim, coordDimIndex);
  22081. }
  22082. });
  22083. });
  22084. // Apply templetes and default order from `sysDims`.
  22085. var availDimIdx = 0;
  22086. each(sysDims, function (sysDimItem, sysDimIndex) {
  22087. var coordDim;
  22088. var sysDimItem;
  22089. var sysDimItemDimsDef;
  22090. var sysDimItemOtherDims;
  22091. if (isString(sysDimItem)) {
  22092. coordDim = sysDimItem;
  22093. sysDimItem = {};
  22094. }
  22095. else {
  22096. coordDim = sysDimItem.name;
  22097. sysDimItem = zrUtil.clone(sysDimItem);
  22098. // `coordDimIndex` should not be set directly.
  22099. sysDimItemDimsDef = sysDimItem.dimsDef;
  22100. sysDimItemOtherDims = sysDimItem.otherDims;
  22101. sysDimItem.name = sysDimItem.coordDim = sysDimItem.coordDimIndex
  22102. = sysDimItem.dimsDef = sysDimItem.otherDims = null;
  22103. }
  22104. var dataDims = normalizeToArray(encodeDef.get(coordDim));
  22105. // dimensions provides default dim sequences.
  22106. if (!dataDims.length) {
  22107. for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
  22108. while (availDimIdx < result.length && result[availDimIdx].coordDim != null) {
  22109. availDimIdx++;
  22110. }
  22111. availDimIdx < result.length && dataDims.push(availDimIdx++);
  22112. }
  22113. }
  22114. // Apply templates.
  22115. each(dataDims, function (resultDimIdx, coordDimIndex) {
  22116. var resultItem = result[resultDimIdx];
  22117. applyDim(defaults(resultItem, sysDimItem), coordDim, coordDimIndex);
  22118. if (resultItem.name == null && sysDimItemDimsDef) {
  22119. resultItem.name = resultItem.tooltipName = sysDimItemDimsDef[coordDimIndex];
  22120. }
  22121. sysDimItemOtherDims && defaults(resultItem.otherDims, sysDimItemOtherDims);
  22122. });
  22123. });
  22124. // Make sure the first extra dim is 'value'.
  22125. var extra = opt.extraPrefix || 'value';
  22126. // Set dim `name` and other `coordDim` and other props.
  22127. for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
  22128. var resultItem = result[resultDimIdx] = result[resultDimIdx] || {};
  22129. var coordDim = resultItem.coordDim;
  22130. coordDim == null && (
  22131. resultItem.coordDim = genName(extra, coordDimNameMap, opt.extraFromZero),
  22132. resultItem.coordDimIndex = 0,
  22133. resultItem.isExtraCoord = true
  22134. );
  22135. resultItem.name == null && (resultItem.name = genName(
  22136. resultItem.coordDim,
  22137. dataDimNameMap
  22138. ));
  22139. resultItem.type == null && guessOrdinal(data, resultDimIdx)
  22140. && (resultItem.type = 'ordinal');
  22141. }
  22142. return result;
  22143. function applyDim(resultItem, coordDim, coordDimIndex) {
  22144. if (OTHER_DIMS[coordDim]) {
  22145. resultItem.otherDims[coordDim] = coordDimIndex;
  22146. }
  22147. else {
  22148. resultItem.coordDim = coordDim;
  22149. resultItem.coordDimIndex = coordDimIndex;
  22150. coordDimNameMap.set(coordDim, true);
  22151. }
  22152. }
  22153. function genName(name, map, fromZero) {
  22154. if (fromZero || map.get(name) != null) {
  22155. var i = 0;
  22156. while (map.get(name + i) != null) {
  22157. i++;
  22158. }
  22159. name += i;
  22160. }
  22161. map.set(name, true);
  22162. return name;
  22163. }
  22164. }
  22165. // The rule should not be complex, otherwise user might not
  22166. // be able to known where the data is wrong.
  22167. var guessOrdinal = completeDimensions.guessOrdinal = function (data, dimIndex) {
  22168. for (var i = 0, len = data.length; i < len; i++) {
  22169. var value = retrieveValue(data[i]);
  22170. if (!zrUtil.isArray(value)) {
  22171. return false;
  22172. }
  22173. var value = value[dimIndex];
  22174. // Consider usage convenience, '1', '2' will be treated as "number".
  22175. if (value != null && isFinite(value)) {
  22176. return false;
  22177. }
  22178. else if (isString(value) && value !== '-') {
  22179. return true;
  22180. }
  22181. }
  22182. return false;
  22183. };
  22184. function retrieveValue(o) {
  22185. return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o;
  22186. }
  22187. module.exports = completeDimensions;
  22188. /***/ },
  22189. /* 111 */
  22190. /***/ function(module, exports, __webpack_require__) {
  22191. 'use strict';
  22192. // Symbol factory
  22193. var graphic = __webpack_require__(18);
  22194. var BoundingRect = __webpack_require__(9);
  22195. /**
  22196. * Triangle shape
  22197. * @inner
  22198. */
  22199. var Triangle = graphic.extendShape({
  22200. type: 'triangle',
  22201. shape: {
  22202. cx: 0,
  22203. cy: 0,
  22204. width: 0,
  22205. height: 0
  22206. },
  22207. buildPath: function (path, shape) {
  22208. var cx = shape.cx;
  22209. var cy = shape.cy;
  22210. var width = shape.width / 2;
  22211. var height = shape.height / 2;
  22212. path.moveTo(cx, cy - height);
  22213. path.lineTo(cx + width, cy + height);
  22214. path.lineTo(cx - width, cy + height);
  22215. path.closePath();
  22216. }
  22217. });
  22218. /**
  22219. * Diamond shape
  22220. * @inner
  22221. */
  22222. var Diamond = graphic.extendShape({
  22223. type: 'diamond',
  22224. shape: {
  22225. cx: 0,
  22226. cy: 0,
  22227. width: 0,
  22228. height: 0
  22229. },
  22230. buildPath: function (path, shape) {
  22231. var cx = shape.cx;
  22232. var cy = shape.cy;
  22233. var width = shape.width / 2;
  22234. var height = shape.height / 2;
  22235. path.moveTo(cx, cy - height);
  22236. path.lineTo(cx + width, cy);
  22237. path.lineTo(cx, cy + height);
  22238. path.lineTo(cx - width, cy);
  22239. path.closePath();
  22240. }
  22241. });
  22242. /**
  22243. * Pin shape
  22244. * @inner
  22245. */
  22246. var Pin = graphic.extendShape({
  22247. type: 'pin',
  22248. shape: {
  22249. // x, y on the cusp
  22250. x: 0,
  22251. y: 0,
  22252. width: 0,
  22253. height: 0
  22254. },
  22255. buildPath: function (path, shape) {
  22256. var x = shape.x;
  22257. var y = shape.y;
  22258. var w = shape.width / 5 * 3;
  22259. // Height must be larger than width
  22260. var h = Math.max(w, shape.height);
  22261. var r = w / 2;
  22262. // Dist on y with tangent point and circle center
  22263. var dy = r * r / (h - r);
  22264. var cy = y - h + r + dy;
  22265. var angle = Math.asin(dy / r);
  22266. // Dist on x with tangent point and circle center
  22267. var dx = Math.cos(angle) * r;
  22268. var tanX = Math.sin(angle);
  22269. var tanY = Math.cos(angle);
  22270. path.arc(
  22271. x, cy, r,
  22272. Math.PI - angle,
  22273. Math.PI * 2 + angle
  22274. );
  22275. var cpLen = r * 0.6;
  22276. var cpLen2 = r * 0.7;
  22277. path.bezierCurveTo(
  22278. x + dx - tanX * cpLen, cy + dy + tanY * cpLen,
  22279. x, y - cpLen2,
  22280. x, y
  22281. );
  22282. path.bezierCurveTo(
  22283. x, y - cpLen2,
  22284. x - dx + tanX * cpLen, cy + dy + tanY * cpLen,
  22285. x - dx, cy + dy
  22286. );
  22287. path.closePath();
  22288. }
  22289. });
  22290. /**
  22291. * Arrow shape
  22292. * @inner
  22293. */
  22294. var Arrow = graphic.extendShape({
  22295. type: 'arrow',
  22296. shape: {
  22297. x: 0,
  22298. y: 0,
  22299. width: 0,
  22300. height: 0
  22301. },
  22302. buildPath: function (ctx, shape) {
  22303. var height = shape.height;
  22304. var width = shape.width;
  22305. var x = shape.x;
  22306. var y = shape.y;
  22307. var dx = width / 3 * 2;
  22308. ctx.moveTo(x, y);
  22309. ctx.lineTo(x + dx, y + height);
  22310. ctx.lineTo(x, y + height / 4 * 3);
  22311. ctx.lineTo(x - dx, y + height);
  22312. ctx.lineTo(x, y);
  22313. ctx.closePath();
  22314. }
  22315. });
  22316. /**
  22317. * Map of path contructors
  22318. * @type {Object.<string, module:zrender/graphic/Path>}
  22319. */
  22320. var symbolCtors = {
  22321. line: graphic.Line,
  22322. rect: graphic.Rect,
  22323. roundRect: graphic.Rect,
  22324. square: graphic.Rect,
  22325. circle: graphic.Circle,
  22326. diamond: Diamond,
  22327. pin: Pin,
  22328. arrow: Arrow,
  22329. triangle: Triangle
  22330. };
  22331. var symbolShapeMakers = {
  22332. line: function (x, y, w, h, shape) {
  22333. // FIXME
  22334. shape.x1 = x;
  22335. shape.y1 = y + h / 2;
  22336. shape.x2 = x + w;
  22337. shape.y2 = y + h / 2;
  22338. },
  22339. rect: function (x, y, w, h, shape) {
  22340. shape.x = x;
  22341. shape.y = y;
  22342. shape.width = w;
  22343. shape.height = h;
  22344. },
  22345. roundRect: function (x, y, w, h, shape) {
  22346. shape.x = x;
  22347. shape.y = y;
  22348. shape.width = w;
  22349. shape.height = h;
  22350. shape.r = Math.min(w, h) / 4;
  22351. },
  22352. square: function (x, y, w, h, shape) {
  22353. var size = Math.min(w, h);
  22354. shape.x = x;
  22355. shape.y = y;
  22356. shape.width = size;
  22357. shape.height = size;
  22358. },
  22359. circle: function (x, y, w, h, shape) {
  22360. // Put circle in the center of square
  22361. shape.cx = x + w / 2;
  22362. shape.cy = y + h / 2;
  22363. shape.r = Math.min(w, h) / 2;
  22364. },
  22365. diamond: function (x, y, w, h, shape) {
  22366. shape.cx = x + w / 2;
  22367. shape.cy = y + h / 2;
  22368. shape.width = w;
  22369. shape.height = h;
  22370. },
  22371. pin: function (x, y, w, h, shape) {
  22372. shape.x = x + w / 2;
  22373. shape.y = y + h / 2;
  22374. shape.width = w;
  22375. shape.height = h;
  22376. },
  22377. arrow: function (x, y, w, h, shape) {
  22378. shape.x = x + w / 2;
  22379. shape.y = y + h / 2;
  22380. shape.width = w;
  22381. shape.height = h;
  22382. },
  22383. triangle: function (x, y, w, h, shape) {
  22384. shape.cx = x + w / 2;
  22385. shape.cy = y + h / 2;
  22386. shape.width = w;
  22387. shape.height = h;
  22388. }
  22389. };
  22390. var symbolBuildProxies = {};
  22391. for (var name in symbolCtors) {
  22392. if (symbolCtors.hasOwnProperty(name)) {
  22393. symbolBuildProxies[name] = new symbolCtors[name]();
  22394. }
  22395. }
  22396. var Symbol = graphic.extendShape({
  22397. type: 'symbol',
  22398. shape: {
  22399. symbolType: '',
  22400. x: 0,
  22401. y: 0,
  22402. width: 0,
  22403. height: 0
  22404. },
  22405. beforeBrush: function () {
  22406. var style = this.style;
  22407. var shape = this.shape;
  22408. // FIXME
  22409. if (shape.symbolType === 'pin' && style.textPosition === 'inside') {
  22410. style.textPosition = ['50%', '40%'];
  22411. style.textAlign = 'center';
  22412. style.textVerticalAlign = 'middle';
  22413. }
  22414. },
  22415. buildPath: function (ctx, shape, inBundle) {
  22416. var symbolType = shape.symbolType;
  22417. var proxySymbol = symbolBuildProxies[symbolType];
  22418. if (shape.symbolType !== 'none') {
  22419. if (!proxySymbol) {
  22420. // Default rect
  22421. symbolType = 'rect';
  22422. proxySymbol = symbolBuildProxies[symbolType];
  22423. }
  22424. symbolShapeMakers[symbolType](
  22425. shape.x, shape.y, shape.width, shape.height, proxySymbol.shape
  22426. );
  22427. proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle);
  22428. }
  22429. }
  22430. });
  22431. // Provide setColor helper method to avoid determine if set the fill or stroke outside
  22432. var symbolPathSetColor = function (color) {
  22433. if (this.type !== 'image') {
  22434. var symbolStyle = this.style;
  22435. var symbolShape = this.shape;
  22436. if (symbolShape && symbolShape.symbolType === 'line') {
  22437. symbolStyle.stroke = color;
  22438. }
  22439. else if (this.__isEmptyBrush) {
  22440. symbolStyle.stroke = color;
  22441. symbolStyle.fill = '#fff';
  22442. }
  22443. else {
  22444. // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
  22445. symbolStyle.fill && (symbolStyle.fill = color);
  22446. symbolStyle.stroke && (symbolStyle.stroke = color);
  22447. }
  22448. this.dirty(false);
  22449. }
  22450. };
  22451. var symbolUtil = {
  22452. /**
  22453. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  22454. * @param {string} symbolType
  22455. * @param {number} x
  22456. * @param {number} y
  22457. * @param {number} w
  22458. * @param {number} h
  22459. * @param {string} color
  22460. */
  22461. createSymbol: function (symbolType, x, y, w, h, color) {
  22462. // TODO Support image object, DynamicImage.
  22463. var isEmpty = symbolType.indexOf('empty') === 0;
  22464. if (isEmpty) {
  22465. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  22466. }
  22467. var symbolPath;
  22468. if (symbolType.indexOf('image://') === 0) {
  22469. symbolPath = new graphic.Image({
  22470. style: {
  22471. image: symbolType.slice(8),
  22472. x: x,
  22473. y: y,
  22474. width: w,
  22475. height: h
  22476. }
  22477. });
  22478. }
  22479. else if (symbolType.indexOf('path://') === 0) {
  22480. symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
  22481. }
  22482. else {
  22483. symbolPath = new Symbol({
  22484. shape: {
  22485. symbolType: symbolType,
  22486. x: x,
  22487. y: y,
  22488. width: w,
  22489. height: h
  22490. }
  22491. });
  22492. }
  22493. symbolPath.__isEmptyBrush = isEmpty;
  22494. symbolPath.setColor = symbolPathSetColor;
  22495. symbolPath.setColor(color);
  22496. return symbolPath;
  22497. }
  22498. };
  22499. module.exports = symbolUtil;
  22500. /***/ },
  22501. /* 112 */
  22502. /***/ function(module, exports, __webpack_require__) {
  22503. var zrUtil = __webpack_require__(4);
  22504. var axisHelper = __webpack_require__(101);
  22505. function getName(obj) {
  22506. if (zrUtil.isObject(obj) && obj.value != null) {
  22507. return obj.value;
  22508. }
  22509. else {
  22510. return obj + '';
  22511. }
  22512. }
  22513. module.exports = {
  22514. /**
  22515. * Format labels
  22516. * @return {Array.<string>}
  22517. */
  22518. getFormattedLabels: function () {
  22519. return axisHelper.getFormattedLabels(
  22520. this.axis,
  22521. this.get('axisLabel.formatter')
  22522. );
  22523. },
  22524. /**
  22525. * Get categories
  22526. */
  22527. getCategories: function () {
  22528. return this.get('type') === 'category'
  22529. && zrUtil.map(this.get('data'), getName);
  22530. },
  22531. /**
  22532. * @param {boolean} origin
  22533. * @return {number|string} min value or 'dataMin' or null/undefined (means auto) or NaN
  22534. */
  22535. getMin: function (origin) {
  22536. var option = this.option;
  22537. var min = (!origin && option.rangeStart != null)
  22538. ? option.rangeStart : option.min;
  22539. if (this.axis && min != null && min !== 'dataMin' && !zrUtil.eqNaN(min)) {
  22540. min = this.axis.scale.parse(min);
  22541. }
  22542. return min;
  22543. },
  22544. /**
  22545. * @param {boolean} origin
  22546. * @return {number|string} max value or 'dataMax' or null/undefined (means auto) or NaN
  22547. */
  22548. getMax: function (origin) {
  22549. var option = this.option;
  22550. var max = (!origin && option.rangeEnd != null)
  22551. ? option.rangeEnd : option.max;
  22552. if (this.axis && max != null && max !== 'dataMax' && !zrUtil.eqNaN(max)) {
  22553. max = this.axis.scale.parse(max);
  22554. }
  22555. return max;
  22556. },
  22557. /**
  22558. * @return {boolean}
  22559. */
  22560. getNeedCrossZero: function () {
  22561. var option = this.option;
  22562. return (option.rangeStart != null || option.rangeEnd != null)
  22563. ? false : !option.scale;
  22564. },
  22565. /**
  22566. * Should be implemented by each axis model if necessary.
  22567. * @return {module:echarts/model/Component} coordinate system model
  22568. */
  22569. getCoordSysModel: zrUtil.noop,
  22570. /**
  22571. * @param {number} rangeStart Can only be finite number or null/undefined or NaN.
  22572. * @param {number} rangeEnd Can only be finite number or null/undefined or NaN.
  22573. */
  22574. setRange: function (rangeStart, rangeEnd) {
  22575. this.option.rangeStart = rangeStart;
  22576. this.option.rangeEnd = rangeEnd;
  22577. },
  22578. /**
  22579. * Reset range
  22580. */
  22581. resetRange: function () {
  22582. // rangeStart and rangeEnd is readonly.
  22583. this.option.rangeStart = this.option.rangeEnd = null;
  22584. }
  22585. };
  22586. /***/ },
  22587. /* 113 */
  22588. /***/ function(module, exports, __webpack_require__) {
  22589. var zrUtil = __webpack_require__(4);
  22590. var echarts = __webpack_require__(1);
  22591. var PRIORITY = echarts.PRIORITY;
  22592. __webpack_require__(114);
  22593. __webpack_require__(115);
  22594. echarts.registerVisual(zrUtil.curry(
  22595. __webpack_require__(121), 'line', 'circle', 'line'
  22596. ));
  22597. echarts.registerLayout(zrUtil.curry(
  22598. __webpack_require__(122), 'line'
  22599. ));
  22600. // Down sample after filter
  22601. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, zrUtil.curry(
  22602. __webpack_require__(123), 'line'
  22603. ));
  22604. // In case developer forget to include grid component
  22605. __webpack_require__(124);
  22606. /***/ },
  22607. /* 114 */
  22608. /***/ function(module, exports, __webpack_require__) {
  22609. 'use strict';
  22610. var createListFromArray = __webpack_require__(109);
  22611. var SeriesModel = __webpack_require__(78);
  22612. module.exports = SeriesModel.extend({
  22613. type: 'series.line',
  22614. dependencies: ['grid', 'polar'],
  22615. getInitialData: function (option, ecModel) {
  22616. if (true) {
  22617. var coordSys = option.coordinateSystem;
  22618. if (coordSys !== 'polar' && coordSys !== 'cartesian2d') {
  22619. throw new Error('Line not support coordinateSystem besides cartesian and polar');
  22620. }
  22621. }
  22622. return createListFromArray(option.data, this, ecModel);
  22623. },
  22624. defaultOption: {
  22625. zlevel: 0, // 一级层叠
  22626. z: 2, // 二级层叠
  22627. coordinateSystem: 'cartesian2d',
  22628. legendHoverLink: true,
  22629. hoverAnimation: true,
  22630. // stack: null
  22631. // xAxisIndex: 0,
  22632. // yAxisIndex: 0,
  22633. // polarIndex: 0,
  22634. // If clip the overflow value
  22635. clipOverflow: true,
  22636. // cursor: null,
  22637. label: {
  22638. normal: {
  22639. position: 'top'
  22640. }
  22641. },
  22642. // itemStyle: {
  22643. // normal: {},
  22644. // emphasis: {}
  22645. // },
  22646. lineStyle: {
  22647. normal: {
  22648. width: 2,
  22649. type: 'solid'
  22650. }
  22651. },
  22652. // areaStyle: {},
  22653. // false, 'start', 'end', 'middle'
  22654. step: false,
  22655. // Disabled if step is true
  22656. smooth: false,
  22657. smoothMonotone: null,
  22658. // 拐点图形类型
  22659. symbol: 'emptyCircle',
  22660. // 拐点图形大小
  22661. symbolSize: 4,
  22662. // 拐点图形旋转控制
  22663. symbolRotate: null,
  22664. // 是否显示 symbol, 只有在 tooltip hover 的时候显示
  22665. showSymbol: true,
  22666. // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略)
  22667. showAllSymbol: false,
  22668. // 是否连接断点
  22669. connectNulls: false,
  22670. // 数据过滤,'average', 'max', 'min', 'sum'
  22671. sampling: 'none',
  22672. animationEasing: 'linear',
  22673. // Disable progressive
  22674. progressive: 0,
  22675. hoverLayerThreshold: Infinity
  22676. }
  22677. });
  22678. /***/ },
  22679. /* 115 */
  22680. /***/ function(module, exports, __webpack_require__) {
  22681. 'use strict';
  22682. // FIXME step not support polar
  22683. var zrUtil = __webpack_require__(4);
  22684. var SymbolDraw = __webpack_require__(116);
  22685. var Symbol = __webpack_require__(117);
  22686. var lineAnimationDiff = __webpack_require__(119);
  22687. var graphic = __webpack_require__(18);
  22688. var modelUtil = __webpack_require__(5);
  22689. var polyHelper = __webpack_require__(120);
  22690. var ChartView = __webpack_require__(80);
  22691. function isPointsSame(points1, points2) {
  22692. if (points1.length !== points2.length) {
  22693. return;
  22694. }
  22695. for (var i = 0; i < points1.length; i++) {
  22696. var p1 = points1[i];
  22697. var p2 = points2[i];
  22698. if (p1[0] !== p2[0] || p1[1] !== p2[1]) {
  22699. return;
  22700. }
  22701. }
  22702. return true;
  22703. }
  22704. function getSmooth(smooth) {
  22705. return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0);
  22706. }
  22707. function getAxisExtentWithGap(axis) {
  22708. var extent = axis.getGlobalExtent();
  22709. if (axis.onBand) {
  22710. // Remove extra 1px to avoid line miter in clipped edge
  22711. var halfBandWidth = axis.getBandWidth() / 2 - 1;
  22712. var dir = extent[1] > extent[0] ? 1 : -1;
  22713. extent[0] += dir * halfBandWidth;
  22714. extent[1] -= dir * halfBandWidth;
  22715. }
  22716. return extent;
  22717. }
  22718. function sign(val) {
  22719. return val >= 0 ? 1 : -1;
  22720. }
  22721. /**
  22722. * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
  22723. * @param {module:echarts/data/List} data
  22724. * @param {Array.<Array.<number>>} points
  22725. * @private
  22726. */
  22727. function getStackedOnPoints(coordSys, data) {
  22728. var baseAxis = coordSys.getBaseAxis();
  22729. var valueAxis = coordSys.getOtherAxis(baseAxis);
  22730. var valueStart = baseAxis.onZero
  22731. ? 0 : valueAxis.scale.getExtent()[0];
  22732. var valueDim = valueAxis.dim;
  22733. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  22734. return data.mapArray([valueDim], function (val, idx) {
  22735. var stackedOnSameSign;
  22736. var stackedOn = data.stackedOn;
  22737. // Find first stacked value with same sign
  22738. while (stackedOn &&
  22739. sign(stackedOn.get(valueDim, idx)) === sign(val)
  22740. ) {
  22741. stackedOnSameSign = stackedOn;
  22742. break;
  22743. }
  22744. var stackedData = [];
  22745. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  22746. stackedData[1 - baseDataOffset] = stackedOnSameSign
  22747. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  22748. return coordSys.dataToPoint(stackedData);
  22749. }, true);
  22750. }
  22751. function createGridClipShape(cartesian, hasAnimation, seriesModel) {
  22752. var xExtent = getAxisExtentWithGap(cartesian.getAxis('x'));
  22753. var yExtent = getAxisExtentWithGap(cartesian.getAxis('y'));
  22754. var isHorizontal = cartesian.getBaseAxis().isHorizontal();
  22755. var x = Math.min(xExtent[0], xExtent[1]);
  22756. var y = Math.min(yExtent[0], yExtent[1]);
  22757. var width = Math.max(xExtent[0], xExtent[1]) - x;
  22758. var height = Math.max(yExtent[0], yExtent[1]) - y;
  22759. var lineWidth = seriesModel.get('lineStyle.normal.width') || 2;
  22760. // Expand clip shape to avoid clipping when line value exceeds axis
  22761. var expandSize = seriesModel.get('clipOverflow') ? lineWidth / 2 : Math.max(width, height);
  22762. if (isHorizontal) {
  22763. y -= expandSize;
  22764. height += expandSize * 2;
  22765. }
  22766. else {
  22767. x -= expandSize;
  22768. width += expandSize * 2;
  22769. }
  22770. var clipPath = new graphic.Rect({
  22771. shape: {
  22772. x: x,
  22773. y: y,
  22774. width: width,
  22775. height: height
  22776. }
  22777. });
  22778. if (hasAnimation) {
  22779. clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
  22780. graphic.initProps(clipPath, {
  22781. shape: {
  22782. width: width,
  22783. height: height
  22784. }
  22785. }, seriesModel);
  22786. }
  22787. return clipPath;
  22788. }
  22789. function createPolarClipShape(polar, hasAnimation, seriesModel) {
  22790. var angleAxis = polar.getAngleAxis();
  22791. var radiusAxis = polar.getRadiusAxis();
  22792. var radiusExtent = radiusAxis.getExtent();
  22793. var angleExtent = angleAxis.getExtent();
  22794. var RADIAN = Math.PI / 180;
  22795. var clipPath = new graphic.Sector({
  22796. shape: {
  22797. cx: polar.cx,
  22798. cy: polar.cy,
  22799. r0: radiusExtent[0],
  22800. r: radiusExtent[1],
  22801. startAngle: -angleExtent[0] * RADIAN,
  22802. endAngle: -angleExtent[1] * RADIAN,
  22803. clockwise: angleAxis.inverse
  22804. }
  22805. });
  22806. if (hasAnimation) {
  22807. clipPath.shape.endAngle = -angleExtent[0] * RADIAN;
  22808. graphic.initProps(clipPath, {
  22809. shape: {
  22810. endAngle: -angleExtent[1] * RADIAN
  22811. }
  22812. }, seriesModel);
  22813. }
  22814. return clipPath;
  22815. }
  22816. function createClipShape(coordSys, hasAnimation, seriesModel) {
  22817. return coordSys.type === 'polar'
  22818. ? createPolarClipShape(coordSys, hasAnimation, seriesModel)
  22819. : createGridClipShape(coordSys, hasAnimation, seriesModel);
  22820. }
  22821. function turnPointsIntoStep(points, coordSys, stepTurnAt) {
  22822. var baseAxis = coordSys.getBaseAxis();
  22823. var baseIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
  22824. var stepPoints = [];
  22825. for (var i = 0; i < points.length - 1; i++) {
  22826. var nextPt = points[i + 1];
  22827. var pt = points[i];
  22828. stepPoints.push(pt);
  22829. var stepPt = [];
  22830. switch (stepTurnAt) {
  22831. case 'end':
  22832. stepPt[baseIndex] = nextPt[baseIndex];
  22833. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  22834. // default is start
  22835. stepPoints.push(stepPt);
  22836. break;
  22837. case 'middle':
  22838. // default is start
  22839. var middle = (pt[baseIndex] + nextPt[baseIndex]) / 2;
  22840. var stepPt2 = [];
  22841. stepPt[baseIndex] = stepPt2[baseIndex] = middle;
  22842. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  22843. stepPt2[1 - baseIndex] = nextPt[1 - baseIndex];
  22844. stepPoints.push(stepPt);
  22845. stepPoints.push(stepPt2);
  22846. break;
  22847. default:
  22848. stepPt[baseIndex] = pt[baseIndex];
  22849. stepPt[1 - baseIndex] = nextPt[1 - baseIndex];
  22850. // default is start
  22851. stepPoints.push(stepPt);
  22852. }
  22853. }
  22854. // Last points
  22855. points[i] && stepPoints.push(points[i]);
  22856. return stepPoints;
  22857. }
  22858. function getVisualGradient(data, coordSys) {
  22859. var visualMetaList = data.getVisual('visualMeta');
  22860. if (!visualMetaList || !visualMetaList.length || !data.count()) {
  22861. // When data.count() is 0, gradient range can not be calculated.
  22862. return;
  22863. }
  22864. var visualMeta;
  22865. for (var i = visualMetaList.length - 1; i >= 0; i--) {
  22866. // Can only be x or y
  22867. if (visualMetaList[i].dimension < 2) {
  22868. visualMeta = visualMetaList[i];
  22869. break;
  22870. }
  22871. }
  22872. if (!visualMeta || coordSys.type !== 'cartesian2d') {
  22873. if (true) {
  22874. console.warn('Visual map on line style only support x or y dimension.');
  22875. }
  22876. return;
  22877. }
  22878. // If the area to be rendered is bigger than area defined by LinearGradient,
  22879. // the canvas spec prescribes that the color of the first stop and the last
  22880. // stop should be used. But if two stops are added at offset 0, in effect
  22881. // browsers use the color of the second stop to render area outside
  22882. // LinearGradient. So we can only infinitesimally extend area defined in
  22883. // LinearGradient to render `outerColors`.
  22884. var dimension = visualMeta.dimension;
  22885. var dimName = data.dimensions[dimension];
  22886. var axis = coordSys.getAxis(dimName);
  22887. // dataToCoor mapping may not be linear, but must be monotonic.
  22888. var colorStops = zrUtil.map(visualMeta.stops, function (stop) {
  22889. return {
  22890. coord: axis.toGlobalCoord(axis.dataToCoord(stop.value)),
  22891. color: stop.color
  22892. };
  22893. });
  22894. var stopLen = colorStops.length;
  22895. var outerColors = visualMeta.outerColors.slice();
  22896. if (stopLen && colorStops[0].coord > colorStops[stopLen - 1].coord) {
  22897. colorStops.reverse();
  22898. outerColors.reverse();
  22899. }
  22900. var tinyExtent = 10; // Arbitrary value: 10px
  22901. var minCoord = colorStops[0].coord - tinyExtent;
  22902. var maxCoord = colorStops[stopLen - 1].coord + tinyExtent;
  22903. var coordSpan = maxCoord - minCoord;
  22904. if (coordSpan < 1e-3) {
  22905. return 'transparent';
  22906. }
  22907. zrUtil.each(colorStops, function (stop) {
  22908. stop.offset = (stop.coord - minCoord) / coordSpan;
  22909. });
  22910. colorStops.push({
  22911. offset: stopLen ? colorStops[stopLen - 1].offset : 0.5,
  22912. color: outerColors[1] || 'transparent'
  22913. });
  22914. colorStops.unshift({ // notice colorStops.length have been changed.
  22915. offset: stopLen ? colorStops[0].offset : 0.5,
  22916. color: outerColors[0] || 'transparent'
  22917. });
  22918. // zrUtil.each(colorStops, function (colorStop) {
  22919. // // Make sure each offset has rounded px to avoid not sharp edge
  22920. // colorStop.offset = (Math.round(colorStop.offset * (end - start) + start) - start) / (end - start);
  22921. // });
  22922. var gradient = new graphic.LinearGradient(0, 0, 0, 0, colorStops, true);
  22923. gradient[dimName] = minCoord;
  22924. gradient[dimName + '2'] = maxCoord;
  22925. return gradient;
  22926. }
  22927. module.exports = ChartView.extend({
  22928. type: 'line',
  22929. init: function () {
  22930. var lineGroup = new graphic.Group();
  22931. var symbolDraw = new SymbolDraw();
  22932. this.group.add(symbolDraw.group);
  22933. this._symbolDraw = symbolDraw;
  22934. this._lineGroup = lineGroup;
  22935. },
  22936. render: function (seriesModel, ecModel, api) {
  22937. var coordSys = seriesModel.coordinateSystem;
  22938. var group = this.group;
  22939. var data = seriesModel.getData();
  22940. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  22941. var areaStyleModel = seriesModel.getModel('areaStyle.normal');
  22942. var points = data.mapArray(data.getItemLayout, true);
  22943. var isCoordSysPolar = coordSys.type === 'polar';
  22944. var prevCoordSys = this._coordSys;
  22945. var symbolDraw = this._symbolDraw;
  22946. var polyline = this._polyline;
  22947. var polygon = this._polygon;
  22948. var lineGroup = this._lineGroup;
  22949. var hasAnimation = seriesModel.get('animation');
  22950. var isAreaChart = !areaStyleModel.isEmpty();
  22951. var stackedOnPoints = getStackedOnPoints(coordSys, data);
  22952. var showSymbol = seriesModel.get('showSymbol');
  22953. var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol')
  22954. && this._getSymbolIgnoreFunc(data, coordSys);
  22955. // Remove temporary symbols
  22956. var oldData = this._data;
  22957. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  22958. if (el.__temp) {
  22959. group.remove(el);
  22960. oldData.setItemGraphicEl(idx, null);
  22961. }
  22962. });
  22963. // Remove previous created symbols if showSymbol changed to false
  22964. if (!showSymbol) {
  22965. symbolDraw.remove();
  22966. }
  22967. group.add(lineGroup);
  22968. // FIXME step not support polar
  22969. var step = !isCoordSysPolar && seriesModel.get('step');
  22970. // Initialization animation or coordinate system changed
  22971. if (
  22972. !(polyline && prevCoordSys.type === coordSys.type && step === this._step)
  22973. ) {
  22974. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  22975. if (step) {
  22976. // TODO If stacked series is not step
  22977. points = turnPointsIntoStep(points, coordSys, step);
  22978. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  22979. }
  22980. polyline = this._newPolyline(points, coordSys, hasAnimation);
  22981. if (isAreaChart) {
  22982. polygon = this._newPolygon(
  22983. points, stackedOnPoints,
  22984. coordSys, hasAnimation
  22985. );
  22986. }
  22987. lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel));
  22988. }
  22989. else {
  22990. if (isAreaChart && !polygon) {
  22991. // If areaStyle is added
  22992. polygon = this._newPolygon(
  22993. points, stackedOnPoints,
  22994. coordSys, hasAnimation
  22995. );
  22996. }
  22997. else if (polygon && !isAreaChart) {
  22998. // If areaStyle is removed
  22999. lineGroup.remove(polygon);
  23000. polygon = this._polygon = null;
  23001. }
  23002. // Update clipPath
  23003. lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel));
  23004. // Always update, or it is wrong in the case turning on legend
  23005. // because points are not changed
  23006. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  23007. // Stop symbol animation and sync with line points
  23008. // FIXME performance?
  23009. data.eachItemGraphicEl(function (el) {
  23010. el.stopAnimation(true);
  23011. });
  23012. // In the case data zoom triggerred refreshing frequently
  23013. // Data may not change if line has a category axis. So it should animate nothing
  23014. if (!isPointsSame(this._stackedOnPoints, stackedOnPoints)
  23015. || !isPointsSame(this._points, points)
  23016. ) {
  23017. if (hasAnimation) {
  23018. this._updateAnimation(
  23019. data, stackedOnPoints, coordSys, api, step
  23020. );
  23021. }
  23022. else {
  23023. // Not do it in update with animation
  23024. if (step) {
  23025. // TODO If stacked series is not step
  23026. points = turnPointsIntoStep(points, coordSys, step);
  23027. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  23028. }
  23029. polyline.setShape({
  23030. points: points
  23031. });
  23032. polygon && polygon.setShape({
  23033. points: points,
  23034. stackedOnPoints: stackedOnPoints
  23035. });
  23036. }
  23037. }
  23038. }
  23039. var visualColor = getVisualGradient(data, coordSys) || data.getVisual('color');
  23040. polyline.useStyle(zrUtil.defaults(
  23041. // Use color in lineStyle first
  23042. lineStyleModel.getLineStyle(),
  23043. {
  23044. fill: 'none',
  23045. stroke: visualColor,
  23046. lineJoin: 'bevel'
  23047. }
  23048. ));
  23049. var smooth = seriesModel.get('smooth');
  23050. smooth = getSmooth(seriesModel.get('smooth'));
  23051. polyline.setShape({
  23052. smooth: smooth,
  23053. smoothMonotone: seriesModel.get('smoothMonotone'),
  23054. connectNulls: seriesModel.get('connectNulls')
  23055. });
  23056. if (polygon) {
  23057. var stackedOn = data.stackedOn;
  23058. var stackedOnSmooth = 0;
  23059. polygon.useStyle(zrUtil.defaults(
  23060. areaStyleModel.getAreaStyle(),
  23061. {
  23062. fill: visualColor,
  23063. opacity: 0.7,
  23064. lineJoin: 'bevel'
  23065. }
  23066. ));
  23067. if (stackedOn) {
  23068. var stackedOnSeries = stackedOn.hostModel;
  23069. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'));
  23070. }
  23071. polygon.setShape({
  23072. smooth: smooth,
  23073. stackedOnSmooth: stackedOnSmooth,
  23074. smoothMonotone: seriesModel.get('smoothMonotone'),
  23075. connectNulls: seriesModel.get('connectNulls')
  23076. });
  23077. }
  23078. this._data = data;
  23079. // Save the coordinate system for transition animation when data changed
  23080. this._coordSys = coordSys;
  23081. this._stackedOnPoints = stackedOnPoints;
  23082. this._points = points;
  23083. this._step = step;
  23084. },
  23085. dispose: function () {},
  23086. highlight: function (seriesModel, ecModel, api, payload) {
  23087. var data = seriesModel.getData();
  23088. var dataIndex = modelUtil.queryDataIndex(data, payload);
  23089. if (!(dataIndex instanceof Array) && dataIndex != null && dataIndex >= 0) {
  23090. var symbol = data.getItemGraphicEl(dataIndex);
  23091. if (!symbol) {
  23092. // Create a temporary symbol if it is not exists
  23093. var pt = data.getItemLayout(dataIndex);
  23094. if (!pt) {
  23095. // Null data
  23096. return;
  23097. }
  23098. symbol = new Symbol(data, dataIndex);
  23099. symbol.position = pt;
  23100. symbol.setZ(
  23101. seriesModel.get('zlevel'),
  23102. seriesModel.get('z')
  23103. );
  23104. symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]);
  23105. symbol.__temp = true;
  23106. data.setItemGraphicEl(dataIndex, symbol);
  23107. // Stop scale animation
  23108. symbol.stopSymbolAnimation(true);
  23109. this.group.add(symbol);
  23110. }
  23111. symbol.highlight();
  23112. }
  23113. else {
  23114. // Highlight whole series
  23115. ChartView.prototype.highlight.call(
  23116. this, seriesModel, ecModel, api, payload
  23117. );
  23118. }
  23119. },
  23120. downplay: function (seriesModel, ecModel, api, payload) {
  23121. var data = seriesModel.getData();
  23122. var dataIndex = modelUtil.queryDataIndex(data, payload);
  23123. if (dataIndex != null && dataIndex >= 0) {
  23124. var symbol = data.getItemGraphicEl(dataIndex);
  23125. if (symbol) {
  23126. if (symbol.__temp) {
  23127. data.setItemGraphicEl(dataIndex, null);
  23128. this.group.remove(symbol);
  23129. }
  23130. else {
  23131. symbol.downplay();
  23132. }
  23133. }
  23134. }
  23135. else {
  23136. // FIXME
  23137. // can not downplay completely.
  23138. // Downplay whole series
  23139. ChartView.prototype.downplay.call(
  23140. this, seriesModel, ecModel, api, payload
  23141. );
  23142. }
  23143. },
  23144. /**
  23145. * @param {module:zrender/container/Group} group
  23146. * @param {Array.<Array.<number>>} points
  23147. * @private
  23148. */
  23149. _newPolyline: function (points) {
  23150. var polyline = this._polyline;
  23151. // Remove previous created polyline
  23152. if (polyline) {
  23153. this._lineGroup.remove(polyline);
  23154. }
  23155. polyline = new polyHelper.Polyline({
  23156. shape: {
  23157. points: points
  23158. },
  23159. silent: true,
  23160. z2: 10
  23161. });
  23162. this._lineGroup.add(polyline);
  23163. this._polyline = polyline;
  23164. return polyline;
  23165. },
  23166. /**
  23167. * @param {module:zrender/container/Group} group
  23168. * @param {Array.<Array.<number>>} stackedOnPoints
  23169. * @param {Array.<Array.<number>>} points
  23170. * @private
  23171. */
  23172. _newPolygon: function (points, stackedOnPoints) {
  23173. var polygon = this._polygon;
  23174. // Remove previous created polygon
  23175. if (polygon) {
  23176. this._lineGroup.remove(polygon);
  23177. }
  23178. polygon = new polyHelper.Polygon({
  23179. shape: {
  23180. points: points,
  23181. stackedOnPoints: stackedOnPoints
  23182. },
  23183. silent: true
  23184. });
  23185. this._lineGroup.add(polygon);
  23186. this._polygon = polygon;
  23187. return polygon;
  23188. },
  23189. /**
  23190. * @private
  23191. */
  23192. _getSymbolIgnoreFunc: function (data, coordSys) {
  23193. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  23194. // `getLabelInterval` is provided by echarts/component/axis
  23195. if (categoryAxis && categoryAxis.isLabelIgnored) {
  23196. return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis);
  23197. }
  23198. },
  23199. /**
  23200. * @private
  23201. */
  23202. // FIXME Two value axis
  23203. _updateAnimation: function (data, stackedOnPoints, coordSys, api, step) {
  23204. var polyline = this._polyline;
  23205. var polygon = this._polygon;
  23206. var seriesModel = data.hostModel;
  23207. var diff = lineAnimationDiff(
  23208. this._data, data,
  23209. this._stackedOnPoints, stackedOnPoints,
  23210. this._coordSys, coordSys
  23211. );
  23212. var current = diff.current;
  23213. var stackedOnCurrent = diff.stackedOnCurrent;
  23214. var next = diff.next;
  23215. var stackedOnNext = diff.stackedOnNext;
  23216. if (step) {
  23217. // TODO If stacked series is not step
  23218. current = turnPointsIntoStep(diff.current, coordSys, step);
  23219. stackedOnCurrent = turnPointsIntoStep(diff.stackedOnCurrent, coordSys, step);
  23220. next = turnPointsIntoStep(diff.next, coordSys, step);
  23221. stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step);
  23222. }
  23223. // `diff.current` is subset of `current` (which should be ensured by
  23224. // turnPointsIntoStep), so points in `__points` can be updated when
  23225. // points in `current` are update during animation.
  23226. polyline.shape.__points = diff.current;
  23227. polyline.shape.points = current;
  23228. graphic.updateProps(polyline, {
  23229. shape: {
  23230. points: next
  23231. }
  23232. }, seriesModel);
  23233. if (polygon) {
  23234. polygon.setShape({
  23235. points: current,
  23236. stackedOnPoints: stackedOnCurrent
  23237. });
  23238. graphic.updateProps(polygon, {
  23239. shape: {
  23240. points: next,
  23241. stackedOnPoints: stackedOnNext
  23242. }
  23243. }, seriesModel);
  23244. }
  23245. var updatedDataInfo = [];
  23246. var diffStatus = diff.status;
  23247. for (var i = 0; i < diffStatus.length; i++) {
  23248. var cmd = diffStatus[i].cmd;
  23249. if (cmd === '=') {
  23250. var el = data.getItemGraphicEl(diffStatus[i].idx1);
  23251. if (el) {
  23252. updatedDataInfo.push({
  23253. el: el,
  23254. ptIdx: i // Index of points
  23255. });
  23256. }
  23257. }
  23258. }
  23259. if (polyline.animators && polyline.animators.length) {
  23260. polyline.animators[0].during(function () {
  23261. for (var i = 0; i < updatedDataInfo.length; i++) {
  23262. var el = updatedDataInfo[i].el;
  23263. el.attr('position', polyline.shape.__points[updatedDataInfo[i].ptIdx]);
  23264. }
  23265. });
  23266. }
  23267. },
  23268. remove: function (ecModel) {
  23269. var group = this.group;
  23270. var oldData = this._data;
  23271. this._lineGroup.removeAll();
  23272. this._symbolDraw.remove(true);
  23273. // Remove temporary created elements when highlighting
  23274. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  23275. if (el.__temp) {
  23276. group.remove(el);
  23277. oldData.setItemGraphicEl(idx, null);
  23278. }
  23279. });
  23280. this._polyline =
  23281. this._polygon =
  23282. this._coordSys =
  23283. this._points =
  23284. this._stackedOnPoints =
  23285. this._data = null;
  23286. }
  23287. });
  23288. /***/ },
  23289. /* 116 */
  23290. /***/ function(module, exports, __webpack_require__) {
  23291. /**
  23292. * @module echarts/chart/helper/SymbolDraw
  23293. */
  23294. var graphic = __webpack_require__(18);
  23295. var Symbol = __webpack_require__(117);
  23296. /**
  23297. * @constructor
  23298. * @alias module:echarts/chart/helper/SymbolDraw
  23299. * @param {module:zrender/graphic/Group} [symbolCtor]
  23300. */
  23301. function SymbolDraw(symbolCtor) {
  23302. this.group = new graphic.Group();
  23303. this._symbolCtor = symbolCtor || Symbol;
  23304. }
  23305. var symbolDrawProto = SymbolDraw.prototype;
  23306. function symbolNeedsDraw(data, idx, isIgnore) {
  23307. var point = data.getItemLayout(idx);
  23308. // Is an object
  23309. // if (point && point.hasOwnProperty('point')) {
  23310. // point = point.point;
  23311. // }
  23312. return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx))
  23313. && data.getItemVisual(idx, 'symbol') !== 'none';
  23314. }
  23315. /**
  23316. * Update symbols draw by new data
  23317. * @param {module:echarts/data/List} data
  23318. * @param {Array.<boolean>} [isIgnore]
  23319. */
  23320. symbolDrawProto.updateData = function (data, isIgnore) {
  23321. var group = this.group;
  23322. var seriesModel = data.hostModel;
  23323. var oldData = this._data;
  23324. var SymbolCtor = this._symbolCtor;
  23325. var seriesScope = {
  23326. itemStyle: seriesModel.getModel('itemStyle.normal').getItemStyle(['color']),
  23327. hoverItemStyle: seriesModel.getModel('itemStyle.emphasis').getItemStyle(),
  23328. symbolRotate: seriesModel.get('symbolRotate'),
  23329. symbolOffset: seriesModel.get('symbolOffset'),
  23330. hoverAnimation: seriesModel.get('hoverAnimation'),
  23331. labelModel: seriesModel.getModel('label.normal'),
  23332. hoverLabelModel: seriesModel.getModel('label.emphasis'),
  23333. cursorStyle: seriesModel.get('cursor')
  23334. };
  23335. data.diff(oldData)
  23336. .add(function (newIdx) {
  23337. var point = data.getItemLayout(newIdx);
  23338. if (symbolNeedsDraw(data, newIdx, isIgnore)) {
  23339. var symbolEl = new SymbolCtor(data, newIdx, seriesScope);
  23340. symbolEl.attr('position', point);
  23341. data.setItemGraphicEl(newIdx, symbolEl);
  23342. group.add(symbolEl);
  23343. }
  23344. })
  23345. .update(function (newIdx, oldIdx) {
  23346. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  23347. var point = data.getItemLayout(newIdx);
  23348. if (!symbolNeedsDraw(data, newIdx, isIgnore)) {
  23349. group.remove(symbolEl);
  23350. return;
  23351. }
  23352. if (!symbolEl) {
  23353. symbolEl = new SymbolCtor(data, newIdx);
  23354. symbolEl.attr('position', point);
  23355. }
  23356. else {
  23357. symbolEl.updateData(data, newIdx, seriesScope);
  23358. graphic.updateProps(symbolEl, {
  23359. position: point
  23360. }, seriesModel);
  23361. }
  23362. // Add back
  23363. group.add(symbolEl);
  23364. data.setItemGraphicEl(newIdx, symbolEl);
  23365. })
  23366. .remove(function (oldIdx) {
  23367. var el = oldData.getItemGraphicEl(oldIdx);
  23368. el && el.fadeOut(function () {
  23369. group.remove(el);
  23370. });
  23371. })
  23372. .execute();
  23373. this._data = data;
  23374. };
  23375. symbolDrawProto.updateLayout = function () {
  23376. var data = this._data;
  23377. if (data) {
  23378. // Not use animation
  23379. data.eachItemGraphicEl(function (el, idx) {
  23380. var point = data.getItemLayout(idx);
  23381. el.attr('position', point);
  23382. });
  23383. }
  23384. };
  23385. symbolDrawProto.remove = function (enableAnimation) {
  23386. var group = this.group;
  23387. var data = this._data;
  23388. if (data) {
  23389. if (enableAnimation) {
  23390. data.eachItemGraphicEl(function (el) {
  23391. el.fadeOut(function () {
  23392. group.remove(el);
  23393. });
  23394. });
  23395. }
  23396. else {
  23397. group.removeAll();
  23398. }
  23399. }
  23400. };
  23401. module.exports = SymbolDraw;
  23402. /***/ },
  23403. /* 117 */
  23404. /***/ function(module, exports, __webpack_require__) {
  23405. /**
  23406. * @module echarts/chart/helper/Symbol
  23407. */
  23408. var zrUtil = __webpack_require__(4);
  23409. var symbolUtil = __webpack_require__(111);
  23410. var graphic = __webpack_require__(18);
  23411. var numberUtil = __webpack_require__(7);
  23412. var labelHelper = __webpack_require__(118);
  23413. function getSymbolSize(data, idx) {
  23414. var symbolSize = data.getItemVisual(idx, 'symbolSize');
  23415. return symbolSize instanceof Array
  23416. ? symbolSize.slice()
  23417. : [+symbolSize, +symbolSize];
  23418. }
  23419. function getScale(symbolSize) {
  23420. return [symbolSize[0] / 2, symbolSize[1] / 2];
  23421. }
  23422. /**
  23423. * @constructor
  23424. * @alias {module:echarts/chart/helper/Symbol}
  23425. * @param {module:echarts/data/List} data
  23426. * @param {number} idx
  23427. * @extends {module:zrender/graphic/Group}
  23428. */
  23429. function Symbol(data, idx, seriesScope) {
  23430. graphic.Group.call(this);
  23431. this.updateData(data, idx, seriesScope);
  23432. }
  23433. var symbolProto = Symbol.prototype;
  23434. function driftSymbol(dx, dy) {
  23435. this.parent.drift(dx, dy);
  23436. }
  23437. symbolProto._createSymbol = function (symbolType, data, idx, symbolSize) {
  23438. // Remove paths created before
  23439. this.removeAll();
  23440. var seriesModel = data.hostModel;
  23441. var color = data.getItemVisual(idx, 'color');
  23442. // var symbolPath = symbolUtil.createSymbol(
  23443. // symbolType, -0.5, -0.5, 1, 1, color
  23444. // );
  23445. // If width/height are set too small (e.g., set to 1) on ios10
  23446. // and macOS Sierra, a circle stroke become a rect, no matter what
  23447. // the scale is set. So we set width/height as 2. See #4150.
  23448. var symbolPath = symbolUtil.createSymbol(
  23449. symbolType, -1, -1, 2, 2, color
  23450. );
  23451. symbolPath.attr({
  23452. z2: 100,
  23453. culling: true,
  23454. scale: [0, 0]
  23455. });
  23456. // Rewrite drift method
  23457. symbolPath.drift = driftSymbol;
  23458. graphic.initProps(symbolPath, {
  23459. scale: getScale(symbolSize)
  23460. }, seriesModel, idx);
  23461. this._symbolType = symbolType;
  23462. this.add(symbolPath);
  23463. };
  23464. /**
  23465. * Stop animation
  23466. * @param {boolean} toLastFrame
  23467. */
  23468. symbolProto.stopSymbolAnimation = function (toLastFrame) {
  23469. this.childAt(0).stopAnimation(toLastFrame);
  23470. };
  23471. /**
  23472. * Get symbol path element
  23473. */
  23474. symbolProto.getSymbolPath = function () {
  23475. return this.childAt(0);
  23476. };
  23477. /**
  23478. * Get scale(aka, current symbol size).
  23479. * Including the change caused by animation
  23480. */
  23481. symbolProto.getScale = function () {
  23482. return this.childAt(0).scale;
  23483. };
  23484. /**
  23485. * Highlight symbol
  23486. */
  23487. symbolProto.highlight = function () {
  23488. this.childAt(0).trigger('emphasis');
  23489. };
  23490. /**
  23491. * Downplay symbol
  23492. */
  23493. symbolProto.downplay = function () {
  23494. this.childAt(0).trigger('normal');
  23495. };
  23496. /**
  23497. * @param {number} zlevel
  23498. * @param {number} z
  23499. */
  23500. symbolProto.setZ = function (zlevel, z) {
  23501. var symbolPath = this.childAt(0);
  23502. symbolPath.zlevel = zlevel;
  23503. symbolPath.z = z;
  23504. };
  23505. symbolProto.setDraggable = function (draggable) {
  23506. var symbolPath = this.childAt(0);
  23507. symbolPath.draggable = draggable;
  23508. symbolPath.cursor = draggable ? 'move' : 'pointer';
  23509. };
  23510. /**
  23511. * Update symbol properties
  23512. * @param {module:echarts/data/List} data
  23513. * @param {number} idx
  23514. */
  23515. symbolProto.updateData = function (data, idx, seriesScope) {
  23516. this.silent = false;
  23517. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  23518. var seriesModel = data.hostModel;
  23519. var symbolSize = getSymbolSize(data, idx);
  23520. if (symbolType !== this._symbolType) {
  23521. this._createSymbol(symbolType, data, idx, symbolSize);
  23522. }
  23523. else {
  23524. var symbolPath = this.childAt(0);
  23525. symbolPath.silent = false;
  23526. graphic.updateProps(symbolPath, {
  23527. scale: getScale(symbolSize)
  23528. }, seriesModel, idx);
  23529. }
  23530. this._updateCommon(data, idx, symbolSize, seriesScope);
  23531. this._seriesModel = seriesModel;
  23532. };
  23533. // Update common properties
  23534. var normalStyleAccessPath = ['itemStyle', 'normal'];
  23535. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  23536. var normalLabelAccessPath = ['label', 'normal'];
  23537. var emphasisLabelAccessPath = ['label', 'emphasis'];
  23538. symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
  23539. var symbolPath = this.childAt(0);
  23540. var seriesModel = data.hostModel;
  23541. var color = data.getItemVisual(idx, 'color');
  23542. // Reset style
  23543. if (symbolPath.type !== 'image') {
  23544. symbolPath.useStyle({
  23545. strokeNoScale: true
  23546. });
  23547. }
  23548. seriesScope = seriesScope || null;
  23549. var itemStyle = seriesScope && seriesScope.itemStyle;
  23550. var hoverItemStyle = seriesScope && seriesScope.hoverItemStyle;
  23551. var symbolRotate = seriesScope && seriesScope.symbolRotate;
  23552. var symbolOffset = seriesScope && seriesScope.symbolOffset;
  23553. var labelModel = seriesScope && seriesScope.labelModel;
  23554. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  23555. var hoverAnimation = seriesScope && seriesScope.hoverAnimation;
  23556. var cursorStyle = seriesScope && seriesScope.cursorStyle;
  23557. if (!seriesScope || data.hasItemOption) {
  23558. var itemModel = data.getItemModel(idx);
  23559. // Color must be excluded.
  23560. // Because symbol provide setColor individually to set fill and stroke
  23561. itemStyle = itemModel.getModel(normalStyleAccessPath).getItemStyle(['color']);
  23562. hoverItemStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  23563. symbolRotate = itemModel.getShallow('symbolRotate');
  23564. symbolOffset = itemModel.getShallow('symbolOffset');
  23565. labelModel = itemModel.getModel(normalLabelAccessPath);
  23566. hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath);
  23567. hoverAnimation = itemModel.getShallow('hoverAnimation');
  23568. cursorStyle = itemModel.getShallow('cursor');
  23569. }
  23570. else {
  23571. hoverItemStyle = zrUtil.extend({}, hoverItemStyle);
  23572. }
  23573. var elStyle = symbolPath.style;
  23574. symbolPath.attr('rotation', (symbolRotate || 0) * Math.PI / 180 || 0);
  23575. if (symbolOffset) {
  23576. symbolPath.attr('position', [
  23577. numberUtil.parsePercent(symbolOffset[0], symbolSize[0]),
  23578. numberUtil.parsePercent(symbolOffset[1], symbolSize[1])
  23579. ]);
  23580. }
  23581. cursorStyle && symbolPath.attr('cursor', cursorStyle);
  23582. // PENDING setColor before setStyle!!!
  23583. symbolPath.setColor(color);
  23584. symbolPath.setStyle(itemStyle);
  23585. var opacity = data.getItemVisual(idx, 'opacity');
  23586. if (opacity != null) {
  23587. elStyle.opacity = opacity;
  23588. }
  23589. var valueDim = labelHelper.findLabelValueDim(data);
  23590. labelHelper.setTextToStyle(
  23591. data, idx, valueDim, elStyle, seriesModel, labelModel, color
  23592. );
  23593. labelHelper.setTextToStyle(
  23594. data, idx, valueDim, hoverItemStyle, seriesModel, hoverLabelModel, color
  23595. );
  23596. symbolPath.off('mouseover')
  23597. .off('mouseout')
  23598. .off('emphasis')
  23599. .off('normal');
  23600. symbolPath.hoverStyle = hoverItemStyle;
  23601. graphic.setHoverStyle(symbolPath);
  23602. var scale = getScale(symbolSize);
  23603. if (hoverAnimation && seriesModel.isAnimationEnabled()) {
  23604. var onEmphasis = function() {
  23605. var ratio = scale[1] / scale[0];
  23606. this.animateTo({
  23607. scale: [
  23608. Math.max(scale[0] * 1.1, scale[0] + 3),
  23609. Math.max(scale[1] * 1.1, scale[1] + 3 * ratio)
  23610. ]
  23611. }, 400, 'elasticOut');
  23612. };
  23613. var onNormal = function() {
  23614. this.animateTo({
  23615. scale: scale
  23616. }, 400, 'elasticOut');
  23617. };
  23618. symbolPath.on('mouseover', onEmphasis)
  23619. .on('mouseout', onNormal)
  23620. .on('emphasis', onEmphasis)
  23621. .on('normal', onNormal);
  23622. }
  23623. };
  23624. symbolProto.fadeOut = function (cb) {
  23625. var symbolPath = this.childAt(0);
  23626. // Avoid mistaken hover when fading out
  23627. this.silent = symbolPath.silent = true;
  23628. // Not show text when animating
  23629. symbolPath.style.text = '';
  23630. graphic.updateProps(symbolPath, {
  23631. scale: [0, 0]
  23632. }, this._seriesModel, this.dataIndex, cb);
  23633. };
  23634. zrUtil.inherits(Symbol, graphic.Group);
  23635. module.exports = Symbol;
  23636. /***/ },
  23637. /* 118 */
  23638. /***/ function(module, exports, __webpack_require__) {
  23639. /**
  23640. * @module echarts/chart/helper/Symbol
  23641. */
  23642. var graphic = __webpack_require__(18);
  23643. var zrUtil = __webpack_require__(4);
  23644. var modelUtil = __webpack_require__(5);
  23645. var helper = {};
  23646. helper.findLabelValueDim = function (data) {
  23647. var valueDim;
  23648. var labelDims = modelUtil.otherDimToDataDim(data, 'label');
  23649. if (labelDims.length) {
  23650. valueDim = labelDims[0];
  23651. }
  23652. else {
  23653. // Get last value dim
  23654. var dimensions = data.dimensions.slice();
  23655. var dataType;
  23656. while (dimensions.length && (
  23657. valueDim = dimensions.pop(),
  23658. dataType = data.getDimensionInfo(valueDim).type,
  23659. dataType === 'ordinal' || dataType === 'time'
  23660. )) {} // jshint ignore:line
  23661. }
  23662. return valueDim;
  23663. };
  23664. helper.setTextToStyle = function (
  23665. data, dataIndex, valueDim, elStyle, seriesModel, labelModel, color
  23666. ) {
  23667. if (valueDim != null && labelModel.getShallow('show')) {
  23668. graphic.setText(elStyle, labelModel, color);
  23669. elStyle.text = zrUtil.retrieve(
  23670. seriesModel.getFormattedLabel(dataIndex, 'normal'),
  23671. data.get(valueDim, dataIndex)
  23672. );
  23673. }
  23674. else {
  23675. elStyle.text = '';
  23676. }
  23677. };
  23678. module.exports = helper;
  23679. /***/ },
  23680. /* 119 */
  23681. /***/ function(module, exports) {
  23682. // var arrayDiff = require('zrender/lib/core/arrayDiff');
  23683. // 'zrender/core/arrayDiff' has been used before, but it did
  23684. // not do well in performance when roam with fixed dataZoom window.
  23685. function sign(val) {
  23686. return val >= 0 ? 1 : -1;
  23687. }
  23688. function getStackedOnPoint(coordSys, data, idx) {
  23689. var baseAxis = coordSys.getBaseAxis();
  23690. var valueAxis = coordSys.getOtherAxis(baseAxis);
  23691. var valueStart = baseAxis.onZero
  23692. ? 0 : valueAxis.scale.getExtent()[0];
  23693. var valueDim = valueAxis.dim;
  23694. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  23695. var stackedOnSameSign;
  23696. var stackedOn = data.stackedOn;
  23697. var val = data.get(valueDim, idx);
  23698. // Find first stacked value with same sign
  23699. while (stackedOn &&
  23700. sign(stackedOn.get(valueDim, idx)) === sign(val)
  23701. ) {
  23702. stackedOnSameSign = stackedOn;
  23703. break;
  23704. }
  23705. var stackedData = [];
  23706. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  23707. stackedData[1 - baseDataOffset] = stackedOnSameSign
  23708. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  23709. return coordSys.dataToPoint(stackedData);
  23710. }
  23711. // function convertToIntId(newIdList, oldIdList) {
  23712. // // Generate int id instead of string id.
  23713. // // Compare string maybe slow in score function of arrDiff
  23714. // // Assume id in idList are all unique
  23715. // var idIndicesMap = {};
  23716. // var idx = 0;
  23717. // for (var i = 0; i < newIdList.length; i++) {
  23718. // idIndicesMap[newIdList[i]] = idx;
  23719. // newIdList[i] = idx++;
  23720. // }
  23721. // for (var i = 0; i < oldIdList.length; i++) {
  23722. // var oldId = oldIdList[i];
  23723. // // Same with newIdList
  23724. // if (idIndicesMap[oldId]) {
  23725. // oldIdList[i] = idIndicesMap[oldId];
  23726. // }
  23727. // else {
  23728. // oldIdList[i] = idx++;
  23729. // }
  23730. // }
  23731. // }
  23732. function diffData(oldData, newData) {
  23733. var diffResult = [];
  23734. newData.diff(oldData)
  23735. .add(function (idx) {
  23736. diffResult.push({cmd: '+', idx: idx});
  23737. })
  23738. .update(function (newIdx, oldIdx) {
  23739. diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx});
  23740. })
  23741. .remove(function (idx) {
  23742. diffResult.push({cmd: '-', idx: idx});
  23743. })
  23744. .execute();
  23745. return diffResult;
  23746. }
  23747. module.exports = function (
  23748. oldData, newData,
  23749. oldStackedOnPoints, newStackedOnPoints,
  23750. oldCoordSys, newCoordSys
  23751. ) {
  23752. var diff = diffData(oldData, newData);
  23753. // var newIdList = newData.mapArray(newData.getId);
  23754. // var oldIdList = oldData.mapArray(oldData.getId);
  23755. // convertToIntId(newIdList, oldIdList);
  23756. // // FIXME One data ?
  23757. // diff = arrayDiff(oldIdList, newIdList);
  23758. var currPoints = [];
  23759. var nextPoints = [];
  23760. // Points for stacking base line
  23761. var currStackedPoints = [];
  23762. var nextStackedPoints = [];
  23763. var status = [];
  23764. var sortedIndices = [];
  23765. var rawIndices = [];
  23766. var dims = newCoordSys.dimensions;
  23767. for (var i = 0; i < diff.length; i++) {
  23768. var diffItem = diff[i];
  23769. var pointAdded = true;
  23770. // FIXME, animation is not so perfect when dataZoom window moves fast
  23771. // Which is in case remvoing or add more than one data in the tail or head
  23772. switch (diffItem.cmd) {
  23773. case '=':
  23774. var currentPt = oldData.getItemLayout(diffItem.idx);
  23775. var nextPt = newData.getItemLayout(diffItem.idx1);
  23776. // If previous data is NaN, use next point directly
  23777. if (isNaN(currentPt[0]) || isNaN(currentPt[1])) {
  23778. currentPt = nextPt.slice();
  23779. }
  23780. currPoints.push(currentPt);
  23781. nextPoints.push(nextPt);
  23782. currStackedPoints.push(oldStackedOnPoints[diffItem.idx]);
  23783. nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]);
  23784. rawIndices.push(newData.getRawIndex(diffItem.idx1));
  23785. break;
  23786. case '+':
  23787. var idx = diffItem.idx;
  23788. currPoints.push(
  23789. oldCoordSys.dataToPoint([
  23790. newData.get(dims[0], idx, true), newData.get(dims[1], idx, true)
  23791. ])
  23792. );
  23793. nextPoints.push(newData.getItemLayout(idx).slice());
  23794. currStackedPoints.push(
  23795. getStackedOnPoint(oldCoordSys, newData, idx)
  23796. );
  23797. nextStackedPoints.push(newStackedOnPoints[idx]);
  23798. rawIndices.push(newData.getRawIndex(idx));
  23799. break;
  23800. case '-':
  23801. var idx = diffItem.idx;
  23802. var rawIndex = oldData.getRawIndex(idx);
  23803. // Data is replaced. In the case of dynamic data queue
  23804. // FIXME FIXME FIXME
  23805. if (rawIndex !== idx) {
  23806. currPoints.push(oldData.getItemLayout(idx));
  23807. nextPoints.push(newCoordSys.dataToPoint([
  23808. oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true)
  23809. ]));
  23810. currStackedPoints.push(oldStackedOnPoints[idx]);
  23811. nextStackedPoints.push(
  23812. getStackedOnPoint(
  23813. newCoordSys, oldData, idx
  23814. )
  23815. );
  23816. rawIndices.push(rawIndex);
  23817. }
  23818. else {
  23819. pointAdded = false;
  23820. }
  23821. }
  23822. // Original indices
  23823. if (pointAdded) {
  23824. status.push(diffItem);
  23825. sortedIndices.push(sortedIndices.length);
  23826. }
  23827. }
  23828. // Diff result may be crossed if all items are changed
  23829. // Sort by data index
  23830. sortedIndices.sort(function (a, b) {
  23831. return rawIndices[a] - rawIndices[b];
  23832. });
  23833. var sortedCurrPoints = [];
  23834. var sortedNextPoints = [];
  23835. var sortedCurrStackedPoints = [];
  23836. var sortedNextStackedPoints = [];
  23837. var sortedStatus = [];
  23838. for (var i = 0; i < sortedIndices.length; i++) {
  23839. var idx = sortedIndices[i];
  23840. sortedCurrPoints[i] = currPoints[idx];
  23841. sortedNextPoints[i] = nextPoints[idx];
  23842. sortedCurrStackedPoints[i] = currStackedPoints[idx];
  23843. sortedNextStackedPoints[i] = nextStackedPoints[idx];
  23844. sortedStatus[i] = status[idx];
  23845. }
  23846. return {
  23847. current: sortedCurrPoints,
  23848. next: sortedNextPoints,
  23849. stackedOnCurrent: sortedCurrStackedPoints,
  23850. stackedOnNext: sortedNextStackedPoints,
  23851. status: sortedStatus
  23852. };
  23853. };
  23854. /***/ },
  23855. /* 120 */
  23856. /***/ function(module, exports, __webpack_require__) {
  23857. // Poly path support NaN point
  23858. var Path = __webpack_require__(20);
  23859. var vec2 = __webpack_require__(10);
  23860. var vec2Min = vec2.min;
  23861. var vec2Max = vec2.max;
  23862. var scaleAndAdd = vec2.scaleAndAdd;
  23863. var v2Copy = vec2.copy;
  23864. // Temporary variable
  23865. var v = [];
  23866. var cp0 = [];
  23867. var cp1 = [];
  23868. function isPointNull(p) {
  23869. return isNaN(p[0]) || isNaN(p[1]);
  23870. }
  23871. function drawSegment(
  23872. ctx, points, start, segLen, allLen,
  23873. dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
  23874. ) {
  23875. var prevIdx = 0;
  23876. var idx = start;
  23877. for (var k = 0; k < segLen; k++) {
  23878. var p = points[idx];
  23879. if (idx >= allLen || idx < 0) {
  23880. break;
  23881. }
  23882. if (isPointNull(p)) {
  23883. if (connectNulls) {
  23884. idx += dir;
  23885. continue;
  23886. }
  23887. break;
  23888. }
  23889. if (idx === start) {
  23890. ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
  23891. v2Copy(cp0, p);
  23892. }
  23893. else {
  23894. if (smooth > 0) {
  23895. var nextIdx = idx + dir;
  23896. var nextP = points[nextIdx];
  23897. if (connectNulls) {
  23898. // Find next point not null
  23899. while (nextP && isPointNull(points[nextIdx])) {
  23900. nextIdx += dir;
  23901. nextP = points[nextIdx];
  23902. }
  23903. }
  23904. var ratioNextSeg = 0.5;
  23905. var prevP = points[prevIdx];
  23906. var nextP = points[nextIdx];
  23907. // Last point
  23908. if (!nextP || isPointNull(nextP)) {
  23909. v2Copy(cp1, p);
  23910. }
  23911. else {
  23912. // If next data is null in not connect case
  23913. if (isPointNull(nextP) && !connectNulls) {
  23914. nextP = p;
  23915. }
  23916. vec2.sub(v, nextP, prevP);
  23917. var lenPrevSeg;
  23918. var lenNextSeg;
  23919. if (smoothMonotone === 'x' || smoothMonotone === 'y') {
  23920. var dim = smoothMonotone === 'x' ? 0 : 1;
  23921. lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
  23922. lenNextSeg = Math.abs(p[dim] - nextP[dim]);
  23923. }
  23924. else {
  23925. lenPrevSeg = vec2.dist(p, prevP);
  23926. lenNextSeg = vec2.dist(p, nextP);
  23927. }
  23928. // Use ratio of seg length
  23929. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
  23930. scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg));
  23931. }
  23932. // Smooth constraint
  23933. vec2Min(cp0, cp0, smoothMax);
  23934. vec2Max(cp0, cp0, smoothMin);
  23935. vec2Min(cp1, cp1, smoothMax);
  23936. vec2Max(cp1, cp1, smoothMin);
  23937. ctx.bezierCurveTo(
  23938. cp0[0], cp0[1],
  23939. cp1[0], cp1[1],
  23940. p[0], p[1]
  23941. );
  23942. // cp0 of next segment
  23943. scaleAndAdd(cp0, p, v, smooth * ratioNextSeg);
  23944. }
  23945. else {
  23946. ctx.lineTo(p[0], p[1]);
  23947. }
  23948. }
  23949. prevIdx = idx;
  23950. idx += dir;
  23951. }
  23952. return k;
  23953. }
  23954. function getBoundingBox(points, smoothConstraint) {
  23955. var ptMin = [Infinity, Infinity];
  23956. var ptMax = [-Infinity, -Infinity];
  23957. if (smoothConstraint) {
  23958. for (var i = 0; i < points.length; i++) {
  23959. var pt = points[i];
  23960. if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; }
  23961. if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; }
  23962. if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; }
  23963. if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; }
  23964. }
  23965. }
  23966. return {
  23967. min: smoothConstraint ? ptMin : ptMax,
  23968. max: smoothConstraint ? ptMax : ptMin
  23969. };
  23970. }
  23971. module.exports = {
  23972. Polyline: Path.extend({
  23973. type: 'ec-polyline',
  23974. shape: {
  23975. points: [],
  23976. smooth: 0,
  23977. smoothConstraint: true,
  23978. smoothMonotone: null,
  23979. connectNulls: false
  23980. },
  23981. style: {
  23982. fill: null,
  23983. stroke: '#000'
  23984. },
  23985. buildPath: function (ctx, shape) {
  23986. var points = shape.points;
  23987. var i = 0;
  23988. var len = points.length;
  23989. var result = getBoundingBox(points, shape.smoothConstraint);
  23990. if (shape.connectNulls) {
  23991. // Must remove first and last null values avoid draw error in polygon
  23992. for (; len > 0; len--) {
  23993. if (!isPointNull(points[len - 1])) {
  23994. break;
  23995. }
  23996. }
  23997. for (; i < len; i++) {
  23998. if (!isPointNull(points[i])) {
  23999. break;
  24000. }
  24001. }
  24002. }
  24003. while (i < len) {
  24004. i += drawSegment(
  24005. ctx, points, i, len, len,
  24006. 1, result.min, result.max, shape.smooth,
  24007. shape.smoothMonotone, shape.connectNulls
  24008. ) + 1;
  24009. }
  24010. }
  24011. }),
  24012. Polygon: Path.extend({
  24013. type: 'ec-polygon',
  24014. shape: {
  24015. points: [],
  24016. // Offset between stacked base points and points
  24017. stackedOnPoints: [],
  24018. smooth: 0,
  24019. stackedOnSmooth: 0,
  24020. smoothConstraint: true,
  24021. smoothMonotone: null,
  24022. connectNulls: false
  24023. },
  24024. buildPath: function (ctx, shape) {
  24025. var points = shape.points;
  24026. var stackedOnPoints = shape.stackedOnPoints;
  24027. var i = 0;
  24028. var len = points.length;
  24029. var smoothMonotone = shape.smoothMonotone;
  24030. var bbox = getBoundingBox(points, shape.smoothConstraint);
  24031. var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint);
  24032. if (shape.connectNulls) {
  24033. // Must remove first and last null values avoid draw error in polygon
  24034. for (; len > 0; len--) {
  24035. if (!isPointNull(points[len - 1])) {
  24036. break;
  24037. }
  24038. }
  24039. for (; i < len; i++) {
  24040. if (!isPointNull(points[i])) {
  24041. break;
  24042. }
  24043. }
  24044. }
  24045. while (i < len) {
  24046. var k = drawSegment(
  24047. ctx, points, i, len, len,
  24048. 1, bbox.min, bbox.max, shape.smooth,
  24049. smoothMonotone, shape.connectNulls
  24050. );
  24051. drawSegment(
  24052. ctx, stackedOnPoints, i + k - 1, k, len,
  24053. -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth,
  24054. smoothMonotone, shape.connectNulls
  24055. );
  24056. i += k + 1;
  24057. ctx.closePath();
  24058. }
  24059. }
  24060. })
  24061. };
  24062. /***/ },
  24063. /* 121 */
  24064. /***/ function(module, exports) {
  24065. module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) {
  24066. // Encoding visual for all series include which is filtered for legend drawing
  24067. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  24068. var data = seriesModel.getData();
  24069. var symbolType = seriesModel.get('symbol') || defaultSymbolType;
  24070. var symbolSize = seriesModel.get('symbolSize');
  24071. data.setVisual({
  24072. legendSymbol: legendSymbol || symbolType,
  24073. symbol: symbolType,
  24074. symbolSize: symbolSize
  24075. });
  24076. // Only visible series has each data be visual encoded
  24077. if (!ecModel.isSeriesFiltered(seriesModel)) {
  24078. if (typeof symbolSize === 'function') {
  24079. data.each(function (idx) {
  24080. var rawValue = seriesModel.getRawValue(idx);
  24081. // FIXME
  24082. var params = seriesModel.getDataParams(idx);
  24083. data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
  24084. });
  24085. }
  24086. data.each(function (idx) {
  24087. var itemModel = data.getItemModel(idx);
  24088. var itemSymbolType = itemModel.getShallow('symbol', true);
  24089. var itemSymbolSize = itemModel.getShallow('symbolSize', true);
  24090. // If has item symbol
  24091. if (itemSymbolType != null) {
  24092. data.setItemVisual(idx, 'symbol', itemSymbolType);
  24093. }
  24094. if (itemSymbolSize != null) {
  24095. // PENDING Transform symbolSize ?
  24096. data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
  24097. }
  24098. });
  24099. }
  24100. });
  24101. };
  24102. /***/ },
  24103. /* 122 */
  24104. /***/ function(module, exports) {
  24105. module.exports = function (seriesType, ecModel) {
  24106. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  24107. var data = seriesModel.getData();
  24108. var coordSys = seriesModel.coordinateSystem;
  24109. if (!coordSys) {
  24110. return;
  24111. }
  24112. var dims = [];
  24113. var coordDims = coordSys.dimensions;
  24114. for (var i = 0; i < coordDims.length; i++) {
  24115. dims.push(seriesModel.coordDimToDataDim(coordSys.dimensions[i])[0]);
  24116. }
  24117. if (dims.length === 1) {
  24118. data.each(dims[0], function (x, idx) {
  24119. // Also {Array.<number>}, not undefined to avoid if...else... statement
  24120. data.setItemLayout(idx, isNaN(x) ? [NaN, NaN] : coordSys.dataToPoint(x));
  24121. });
  24122. }
  24123. else if (dims.length === 2) {
  24124. data.each(dims, function (x, y, idx) {
  24125. // Also {Array.<number>}, not undefined to avoid if...else... statement
  24126. data.setItemLayout(
  24127. idx, (isNaN(x) || isNaN(y)) ? [NaN, NaN] : coordSys.dataToPoint([x, y])
  24128. );
  24129. }, true);
  24130. }
  24131. });
  24132. };
  24133. /***/ },
  24134. /* 123 */
  24135. /***/ function(module, exports) {
  24136. var samplers = {
  24137. average: function (frame) {
  24138. var sum = 0;
  24139. var count = 0;
  24140. for (var i = 0; i < frame.length; i++) {
  24141. if (!isNaN(frame[i])) {
  24142. sum += frame[i];
  24143. count++;
  24144. }
  24145. }
  24146. // Return NaN if count is 0
  24147. return count === 0 ? NaN : sum / count;
  24148. },
  24149. sum: function (frame) {
  24150. var sum = 0;
  24151. for (var i = 0; i < frame.length; i++) {
  24152. // Ignore NaN
  24153. sum += frame[i] || 0;
  24154. }
  24155. return sum;
  24156. },
  24157. max: function (frame) {
  24158. var max = -Infinity;
  24159. for (var i = 0; i < frame.length; i++) {
  24160. frame[i] > max && (max = frame[i]);
  24161. }
  24162. return max;
  24163. },
  24164. min: function (frame) {
  24165. var min = Infinity;
  24166. for (var i = 0; i < frame.length; i++) {
  24167. frame[i] < min && (min = frame[i]);
  24168. }
  24169. return min;
  24170. },
  24171. // TODO
  24172. // Median
  24173. nearest: function (frame) {
  24174. return frame[0];
  24175. }
  24176. };
  24177. var indexSampler = function (frame, value) {
  24178. return Math.round(frame.length / 2);
  24179. };
  24180. module.exports = function (seriesType, ecModel, api) {
  24181. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  24182. var data = seriesModel.getData();
  24183. var sampling = seriesModel.get('sampling');
  24184. var coordSys = seriesModel.coordinateSystem;
  24185. // Only cartesian2d support down sampling
  24186. if (coordSys.type === 'cartesian2d' && sampling) {
  24187. var baseAxis = coordSys.getBaseAxis();
  24188. var valueAxis = coordSys.getOtherAxis(baseAxis);
  24189. var extent = baseAxis.getExtent();
  24190. // Coordinste system has been resized
  24191. var size = extent[1] - extent[0];
  24192. var rate = Math.round(data.count() / size);
  24193. if (rate > 1) {
  24194. var sampler;
  24195. if (typeof sampling === 'string') {
  24196. sampler = samplers[sampling];
  24197. }
  24198. else if (typeof sampling === 'function') {
  24199. sampler = sampling;
  24200. }
  24201. if (sampler) {
  24202. data = data.downSample(
  24203. valueAxis.dim, 1 / rate, sampler, indexSampler
  24204. );
  24205. seriesModel.setData(data);
  24206. }
  24207. }
  24208. }
  24209. }, this);
  24210. };
  24211. /***/ },
  24212. /* 124 */
  24213. /***/ function(module, exports, __webpack_require__) {
  24214. 'use strict';
  24215. var graphic = __webpack_require__(18);
  24216. var zrUtil = __webpack_require__(4);
  24217. var echarts = __webpack_require__(1);
  24218. __webpack_require__(125);
  24219. __webpack_require__(133);
  24220. // Grid view
  24221. echarts.extendComponentView({
  24222. type: 'grid',
  24223. render: function (gridModel, ecModel) {
  24224. this.group.removeAll();
  24225. if (gridModel.get('show')) {
  24226. this.group.add(new graphic.Rect({
  24227. shape: gridModel.coordinateSystem.getRect(),
  24228. style: zrUtil.defaults({
  24229. fill: gridModel.get('backgroundColor')
  24230. }, gridModel.getItemStyle()),
  24231. silent: true,
  24232. z2: -1
  24233. }));
  24234. }
  24235. }
  24236. });
  24237. echarts.registerPreprocessor(function (option) {
  24238. // Only create grid when need
  24239. if (option.xAxis && option.yAxis && !option.grid) {
  24240. option.grid = {};
  24241. }
  24242. });
  24243. /***/ },
  24244. /* 125 */
  24245. /***/ function(module, exports, __webpack_require__) {
  24246. /**
  24247. * Grid is a region which contains at most 4 cartesian systems
  24248. *
  24249. * TODO Default cartesian
  24250. */
  24251. var factory = exports;
  24252. var layout = __webpack_require__(71);
  24253. var axisHelper = __webpack_require__(101);
  24254. var zrUtil = __webpack_require__(4);
  24255. var Cartesian2D = __webpack_require__(126);
  24256. var Axis2D = __webpack_require__(128);
  24257. var each = zrUtil.each;
  24258. var ifAxisCrossZero = axisHelper.ifAxisCrossZero;
  24259. var niceScaleExtent = axisHelper.niceScaleExtent;
  24260. // 依赖 GridModel, AxisModel 做预处理
  24261. __webpack_require__(129);
  24262. /**
  24263. * Check if the axis is used in the specified grid
  24264. * @inner
  24265. */
  24266. function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) {
  24267. return axisModel.getCoordSysModel() === gridModel;
  24268. }
  24269. function getLabelUnionRect(axis) {
  24270. var axisModel = axis.model;
  24271. var labels = axisModel.getFormattedLabels();
  24272. var textStyleModel = axisModel.getModel('axisLabel.textStyle');
  24273. var rect;
  24274. var step = 1;
  24275. var labelCount = labels.length;
  24276. if (labelCount > 40) {
  24277. // Simple optimization for large amount of labels
  24278. step = Math.ceil(labelCount / 40);
  24279. }
  24280. for (var i = 0; i < labelCount; i += step) {
  24281. if (!axis.isLabelIgnored(i)) {
  24282. var singleRect = textStyleModel.getTextRect(labels[i]);
  24283. // FIXME consider label rotate
  24284. rect ? rect.union(singleRect) : (rect = singleRect);
  24285. }
  24286. }
  24287. return rect;
  24288. }
  24289. function Grid(gridModel, ecModel, api) {
  24290. /**
  24291. * @type {Object.<string, module:echarts/coord/cartesian/Cartesian2D>}
  24292. * @private
  24293. */
  24294. this._coordsMap = {};
  24295. /**
  24296. * @type {Array.<module:echarts/coord/cartesian/Cartesian>}
  24297. * @private
  24298. */
  24299. this._coordsList = [];
  24300. /**
  24301. * @type {Object.<string, module:echarts/coord/cartesian/Axis2D>}
  24302. * @private
  24303. */
  24304. this._axesMap = {};
  24305. /**
  24306. * @type {Array.<module:echarts/coord/cartesian/Axis2D>}
  24307. * @private
  24308. */
  24309. this._axesList = [];
  24310. this._initCartesian(gridModel, ecModel, api);
  24311. this.model = gridModel;
  24312. }
  24313. var gridProto = Grid.prototype;
  24314. gridProto.type = 'grid';
  24315. gridProto.axisPointerEnabled = true;
  24316. gridProto.getRect = function () {
  24317. return this._rect;
  24318. };
  24319. gridProto.update = function (ecModel, api) {
  24320. var axesMap = this._axesMap;
  24321. this._updateScale(ecModel, this.model);
  24322. function ifAxisCanNotOnZero(otherAxisDim) {
  24323. var axes = axesMap[otherAxisDim];
  24324. for (var idx in axes) {
  24325. if (axes.hasOwnProperty(idx)) {
  24326. var axis = axes[idx];
  24327. if (axis && (
  24328. axis.type === 'category' || axis.type === 'time' || !ifAxisCrossZero(axis)
  24329. )) {
  24330. return true;
  24331. }
  24332. }
  24333. }
  24334. return false;
  24335. }
  24336. each(axesMap.x, function (xAxis) {
  24337. niceScaleExtent(xAxis.scale, xAxis.model);
  24338. });
  24339. each(axesMap.y, function (yAxis) {
  24340. niceScaleExtent(yAxis.scale, yAxis.model);
  24341. });
  24342. // Fix configuration
  24343. each(axesMap.x, function (xAxis) {
  24344. // onZero can not be enabled in these two situations
  24345. // 1. When any other axis is a category axis
  24346. // 2. When any other axis not across 0 point
  24347. if (ifAxisCanNotOnZero('y')) {
  24348. xAxis.onZero = false;
  24349. }
  24350. });
  24351. each(axesMap.y, function (yAxis) {
  24352. if (ifAxisCanNotOnZero('x')) {
  24353. yAxis.onZero = false;
  24354. }
  24355. });
  24356. // Resize again if containLabel is enabled
  24357. // FIXME It may cause getting wrong grid size in data processing stage
  24358. this.resize(this.model, api);
  24359. };
  24360. /**
  24361. * Resize the grid
  24362. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  24363. * @param {module:echarts/ExtensionAPI} api
  24364. */
  24365. gridProto.resize = function (gridModel, api, ignoreContainLabel) {
  24366. var gridRect = layout.getLayoutRect(
  24367. gridModel.getBoxLayoutParams(), {
  24368. width: api.getWidth(),
  24369. height: api.getHeight()
  24370. });
  24371. this._rect = gridRect;
  24372. var axesList = this._axesList;
  24373. adjustAxes();
  24374. // Minus label size
  24375. if (!ignoreContainLabel && gridModel.get('containLabel')) {
  24376. each(axesList, function (axis) {
  24377. if (!axis.model.get('axisLabel.inside')) {
  24378. var labelUnionRect = getLabelUnionRect(axis);
  24379. if (labelUnionRect) {
  24380. var dim = axis.isHorizontal() ? 'height' : 'width';
  24381. var margin = axis.model.get('axisLabel.margin');
  24382. gridRect[dim] -= labelUnionRect[dim] + margin;
  24383. if (axis.position === 'top') {
  24384. gridRect.y += labelUnionRect.height + margin;
  24385. }
  24386. else if (axis.position === 'left') {
  24387. gridRect.x += labelUnionRect.width + margin;
  24388. }
  24389. }
  24390. }
  24391. });
  24392. adjustAxes();
  24393. }
  24394. function adjustAxes() {
  24395. each(axesList, function (axis) {
  24396. var isHorizontal = axis.isHorizontal();
  24397. var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
  24398. var idx = axis.inverse ? 1 : 0;
  24399. axis.setExtent(extent[idx], extent[1 - idx]);
  24400. updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y);
  24401. });
  24402. }
  24403. };
  24404. /**
  24405. * @param {string} axisType
  24406. * @param {ndumber} [axisIndex]
  24407. */
  24408. gridProto.getAxis = function (axisType, axisIndex) {
  24409. var axesMapOnDim = this._axesMap[axisType];
  24410. if (axesMapOnDim != null) {
  24411. if (axisIndex == null) {
  24412. // Find first axis
  24413. for (var name in axesMapOnDim) {
  24414. if (axesMapOnDim.hasOwnProperty(name)) {
  24415. return axesMapOnDim[name];
  24416. }
  24417. }
  24418. }
  24419. return axesMapOnDim[axisIndex];
  24420. }
  24421. };
  24422. /**
  24423. * @return {Array.<module:echarts/coord/Axis>}
  24424. */
  24425. gridProto.getAxes = function () {
  24426. return this._axesList.slice();
  24427. };
  24428. /**
  24429. * Usage:
  24430. * grid.getCartesian(xAxisIndex, yAxisIndex);
  24431. * grid.getCartesian(xAxisIndex);
  24432. * grid.getCartesian(null, yAxisIndex);
  24433. * grid.getCartesian({xAxisIndex: ..., yAxisIndex: ...});
  24434. *
  24435. * @param {number|Object} [xAxisIndex]
  24436. * @param {number} [yAxisIndex]
  24437. */
  24438. gridProto.getCartesian = function (xAxisIndex, yAxisIndex) {
  24439. if (xAxisIndex != null && yAxisIndex != null) {
  24440. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  24441. return this._coordsMap[key];
  24442. }
  24443. if (zrUtil.isObject(xAxisIndex)) {
  24444. yAxisIndex = xAxisIndex.yAxisIndex;
  24445. xAxisIndex = xAxisIndex.xAxisIndex;
  24446. }
  24447. // When only xAxisIndex or yAxisIndex given, find its first cartesian.
  24448. for (var i = 0, coordList = this._coordsList; i < coordList.length; i++) {
  24449. if (coordList[i].getAxis('x').index === xAxisIndex
  24450. || coordList[i].getAxis('y').index === yAxisIndex
  24451. ) {
  24452. return coordList[i];
  24453. }
  24454. }
  24455. };
  24456. gridProto.getCartesians = function () {
  24457. return this._coordsList.slice();
  24458. };
  24459. /**
  24460. * @implements
  24461. * see {module:echarts/CoodinateSystem}
  24462. */
  24463. gridProto.convertToPixel = function (ecModel, finder, value) {
  24464. var target = this._findConvertTarget(ecModel, finder);
  24465. return target.cartesian
  24466. ? target.cartesian.dataToPoint(value)
  24467. : target.axis
  24468. ? target.axis.toGlobalCoord(target.axis.dataToCoord(value))
  24469. : null;
  24470. };
  24471. /**
  24472. * @implements
  24473. * see {module:echarts/CoodinateSystem}
  24474. */
  24475. gridProto.convertFromPixel = function (ecModel, finder, value) {
  24476. var target = this._findConvertTarget(ecModel, finder);
  24477. return target.cartesian
  24478. ? target.cartesian.pointToData(value)
  24479. : target.axis
  24480. ? target.axis.coordToData(target.axis.toLocalCoord(value))
  24481. : null;
  24482. };
  24483. /**
  24484. * @inner
  24485. */
  24486. gridProto._findConvertTarget = function (ecModel, finder) {
  24487. var seriesModel = finder.seriesModel;
  24488. var xAxisModel = finder.xAxisModel
  24489. || (seriesModel && seriesModel.getReferringComponents('xAxis')[0]);
  24490. var yAxisModel = finder.yAxisModel
  24491. || (seriesModel && seriesModel.getReferringComponents('yAxis')[0]);
  24492. var gridModel = finder.gridModel;
  24493. var coordsList = this._coordsList;
  24494. var cartesian;
  24495. var axis;
  24496. if (seriesModel) {
  24497. cartesian = seriesModel.coordinateSystem;
  24498. zrUtil.indexOf(coordsList, cartesian) < 0 && (cartesian = null);
  24499. }
  24500. else if (xAxisModel && yAxisModel) {
  24501. cartesian = this.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
  24502. }
  24503. else if (xAxisModel) {
  24504. axis = this.getAxis('x', xAxisModel.componentIndex);
  24505. }
  24506. else if (yAxisModel) {
  24507. axis = this.getAxis('y', yAxisModel.componentIndex);
  24508. }
  24509. // Lowest priority.
  24510. else if (gridModel) {
  24511. var grid = gridModel.coordinateSystem;
  24512. if (grid === this) {
  24513. cartesian = this._coordsList[0];
  24514. }
  24515. }
  24516. return {cartesian: cartesian, axis: axis};
  24517. };
  24518. /**
  24519. * @implements
  24520. * see {module:echarts/CoodinateSystem}
  24521. */
  24522. gridProto.containPoint = function (point) {
  24523. var coord = this._coordsList[0];
  24524. if (coord) {
  24525. return coord.containPoint(point);
  24526. }
  24527. };
  24528. /**
  24529. * Initialize cartesian coordinate systems
  24530. * @private
  24531. */
  24532. gridProto._initCartesian = function (gridModel, ecModel, api) {
  24533. var axisPositionUsed = {
  24534. left: false,
  24535. right: false,
  24536. top: false,
  24537. bottom: false
  24538. };
  24539. var axesMap = {
  24540. x: {},
  24541. y: {}
  24542. };
  24543. var axesCount = {
  24544. x: 0,
  24545. y: 0
  24546. };
  24547. /// Create axis
  24548. ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
  24549. ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
  24550. if (!axesCount.x || !axesCount.y) {
  24551. // Roll back when there no either x or y axis
  24552. this._axesMap = {};
  24553. this._axesList = [];
  24554. return;
  24555. }
  24556. this._axesMap = axesMap;
  24557. /// Create cartesian2d
  24558. each(axesMap.x, function (xAxis, xAxisIndex) {
  24559. each(axesMap.y, function (yAxis, yAxisIndex) {
  24560. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  24561. var cartesian = new Cartesian2D(key);
  24562. cartesian.grid = this;
  24563. cartesian.model = gridModel;
  24564. this._coordsMap[key] = cartesian;
  24565. this._coordsList.push(cartesian);
  24566. cartesian.addAxis(xAxis);
  24567. cartesian.addAxis(yAxis);
  24568. }, this);
  24569. }, this);
  24570. function createAxisCreator(axisType) {
  24571. return function (axisModel, idx) {
  24572. if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) {
  24573. return;
  24574. }
  24575. var axisPosition = axisModel.get('position');
  24576. if (axisType === 'x') {
  24577. // Fix position
  24578. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  24579. // Default bottom of X
  24580. axisPosition = 'bottom';
  24581. if (axisPositionUsed[axisPosition]) {
  24582. axisPosition = axisPosition === 'top' ? 'bottom' : 'top';
  24583. }
  24584. }
  24585. }
  24586. else {
  24587. // Fix position
  24588. if (axisPosition !== 'left' && axisPosition !== 'right') {
  24589. // Default left of Y
  24590. axisPosition = 'left';
  24591. if (axisPositionUsed[axisPosition]) {
  24592. axisPosition = axisPosition === 'left' ? 'right' : 'left';
  24593. }
  24594. }
  24595. }
  24596. axisPositionUsed[axisPosition] = true;
  24597. var axis = new Axis2D(
  24598. axisType, axisHelper.createScaleByModel(axisModel),
  24599. [0, 0],
  24600. axisModel.get('type'),
  24601. axisPosition
  24602. );
  24603. var isCategory = axis.type === 'category';
  24604. axis.onBand = isCategory && axisModel.get('boundaryGap');
  24605. axis.inverse = axisModel.get('inverse');
  24606. axis.onZero = axisModel.get('axisLine.onZero');
  24607. // Inject axis into axisModel
  24608. axisModel.axis = axis;
  24609. // Inject axisModel into axis
  24610. axis.model = axisModel;
  24611. // Inject grid info axis
  24612. axis.grid = this;
  24613. // Index of axis, can be used as key
  24614. axis.index = idx;
  24615. this._axesList.push(axis);
  24616. axesMap[axisType][idx] = axis;
  24617. axesCount[axisType]++;
  24618. };
  24619. }
  24620. };
  24621. /**
  24622. * Update cartesian properties from series
  24623. * @param {module:echarts/model/Option} option
  24624. * @private
  24625. */
  24626. gridProto._updateScale = function (ecModel, gridModel) {
  24627. // Reset scale
  24628. zrUtil.each(this._axesList, function (axis) {
  24629. axis.scale.setExtent(Infinity, -Infinity);
  24630. });
  24631. ecModel.eachSeries(function (seriesModel) {
  24632. if (isCartesian2D(seriesModel)) {
  24633. var axesModels = findAxesModels(seriesModel, ecModel);
  24634. var xAxisModel = axesModels[0];
  24635. var yAxisModel = axesModels[1];
  24636. if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel)
  24637. || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel)
  24638. ) {
  24639. return;
  24640. }
  24641. var cartesian = this.getCartesian(
  24642. xAxisModel.componentIndex, yAxisModel.componentIndex
  24643. );
  24644. var data = seriesModel.getData();
  24645. var xAxis = cartesian.getAxis('x');
  24646. var yAxis = cartesian.getAxis('y');
  24647. if (data.type === 'list') {
  24648. unionExtent(data, xAxis, seriesModel);
  24649. unionExtent(data, yAxis, seriesModel);
  24650. }
  24651. }
  24652. }, this);
  24653. function unionExtent(data, axis, seriesModel) {
  24654. each(seriesModel.coordDimToDataDim(axis.dim), function (dim) {
  24655. axis.scale.unionExtentFromData(data, dim);
  24656. });
  24657. }
  24658. };
  24659. /**
  24660. * @param {string} [dim] 'x' or 'y' or 'auto' or null/undefined
  24661. * @return {Object} {baseAxes: [], otherAxes: []}
  24662. */
  24663. gridProto.getTooltipAxes = function (dim) {
  24664. var baseAxes = [];
  24665. var otherAxes = [];
  24666. each(this.getCartesians(), function (cartesian) {
  24667. var baseAxis = (dim != null && dim !== 'auto')
  24668. ? cartesian.getAxis(dim) : cartesian.getBaseAxis();
  24669. var otherAxis = cartesian.getOtherAxis(baseAxis);
  24670. zrUtil.indexOf(baseAxes, baseAxis) < 0 && baseAxes.push(baseAxis);
  24671. zrUtil.indexOf(otherAxes, otherAxis) < 0 && otherAxes.push(otherAxis);
  24672. });
  24673. return {baseAxes: baseAxes, otherAxes: otherAxes};
  24674. };
  24675. /**
  24676. * @inner
  24677. */
  24678. function updateAxisTransfrom(axis, coordBase) {
  24679. var axisExtent = axis.getExtent();
  24680. var axisExtentSum = axisExtent[0] + axisExtent[1];
  24681. // Fast transform
  24682. axis.toGlobalCoord = axis.dim === 'x'
  24683. ? function (coord) {
  24684. return coord + coordBase;
  24685. }
  24686. : function (coord) {
  24687. return axisExtentSum - coord + coordBase;
  24688. };
  24689. axis.toLocalCoord = axis.dim === 'x'
  24690. ? function (coord) {
  24691. return coord - coordBase;
  24692. }
  24693. : function (coord) {
  24694. return axisExtentSum - coord + coordBase;
  24695. };
  24696. }
  24697. var axesTypes = ['xAxis', 'yAxis'];
  24698. /**
  24699. * @inner
  24700. */
  24701. function findAxesModels(seriesModel, ecModel) {
  24702. return zrUtil.map(axesTypes, function (axisType) {
  24703. var axisModel = seriesModel.getReferringComponents(axisType)[0];
  24704. if (true) {
  24705. if (!axisModel) {
  24706. throw new Error(axisType + ' "' + zrUtil.retrieve(
  24707. seriesModel.get(axisType + 'Index'),
  24708. seriesModel.get(axisType + 'Id'),
  24709. 0
  24710. ) + '" not found');
  24711. }
  24712. }
  24713. return axisModel;
  24714. });
  24715. }
  24716. /**
  24717. * @inner
  24718. */
  24719. function isCartesian2D(seriesModel) {
  24720. return seriesModel.get('coordinateSystem') === 'cartesian2d';
  24721. }
  24722. Grid.create = function (ecModel, api) {
  24723. var grids = [];
  24724. ecModel.eachComponent('grid', function (gridModel, idx) {
  24725. var grid = new Grid(gridModel, ecModel, api);
  24726. grid.name = 'grid_' + idx;
  24727. // dataSampling requires axis extent, so resize
  24728. // should be performed in create stage.
  24729. grid.resize(gridModel, api, true);
  24730. gridModel.coordinateSystem = grid;
  24731. grids.push(grid);
  24732. });
  24733. // Inject the coordinateSystems into seriesModel
  24734. ecModel.eachSeries(function (seriesModel) {
  24735. if (!isCartesian2D(seriesModel)) {
  24736. return;
  24737. }
  24738. var axesModels = findAxesModels(seriesModel, ecModel);
  24739. var xAxisModel = axesModels[0];
  24740. var yAxisModel = axesModels[1];
  24741. var gridModel = xAxisModel.getCoordSysModel();
  24742. if (true) {
  24743. if (!gridModel) {
  24744. throw new Error(
  24745. 'Grid "' + zrUtil.retrieve(
  24746. xAxisModel.get('gridIndex'),
  24747. xAxisModel.get('gridId'),
  24748. 0
  24749. ) + '" not found'
  24750. );
  24751. }
  24752. if (xAxisModel.getCoordSysModel() !== yAxisModel.getCoordSysModel()) {
  24753. throw new Error('xAxis and yAxis must use the same grid');
  24754. }
  24755. }
  24756. var grid = gridModel.coordinateSystem;
  24757. seriesModel.coordinateSystem = grid.getCartesian(
  24758. xAxisModel.componentIndex, yAxisModel.componentIndex
  24759. );
  24760. });
  24761. return grids;
  24762. };
  24763. // For deciding which dimensions to use when creating list data
  24764. Grid.dimensions = Grid.prototype.dimensions = Cartesian2D.prototype.dimensions;
  24765. __webpack_require__(76).register('cartesian2d', Grid);
  24766. module.exports = Grid;
  24767. /***/ },
  24768. /* 126 */
  24769. /***/ function(module, exports, __webpack_require__) {
  24770. 'use strict';
  24771. var zrUtil = __webpack_require__(4);
  24772. var Cartesian = __webpack_require__(127);
  24773. function Cartesian2D(name) {
  24774. Cartesian.call(this, name);
  24775. }
  24776. Cartesian2D.prototype = {
  24777. constructor: Cartesian2D,
  24778. type: 'cartesian2d',
  24779. /**
  24780. * @type {Array.<string>}
  24781. * @readOnly
  24782. */
  24783. dimensions: ['x', 'y'],
  24784. /**
  24785. * Base axis will be used on stacking.
  24786. *
  24787. * @return {module:echarts/coord/cartesian/Axis2D}
  24788. */
  24789. getBaseAxis: function () {
  24790. return this.getAxesByScale('ordinal')[0]
  24791. || this.getAxesByScale('time')[0]
  24792. || this.getAxis('x');
  24793. },
  24794. /**
  24795. * If contain point
  24796. * @param {Array.<number>} point
  24797. * @return {boolean}
  24798. */
  24799. containPoint: function (point) {
  24800. var axisX = this.getAxis('x');
  24801. var axisY = this.getAxis('y');
  24802. return axisX.contain(axisX.toLocalCoord(point[0]))
  24803. && axisY.contain(axisY.toLocalCoord(point[1]));
  24804. },
  24805. /**
  24806. * If contain data
  24807. * @param {Array.<number>} data
  24808. * @return {boolean}
  24809. */
  24810. containData: function (data) {
  24811. return this.getAxis('x').containData(data[0])
  24812. && this.getAxis('y').containData(data[1]);
  24813. },
  24814. /**
  24815. * Convert series data to an array of points
  24816. * @param {module:echarts/data/List} data
  24817. * @param {boolean} stack
  24818. * @return {Array}
  24819. * Return array of points. For example:
  24820. * `[[10, 10], [20, 20], [30, 30]]`
  24821. */
  24822. dataToPoints: function (data, stack) {
  24823. return data.mapArray(['x', 'y'], function (x, y) {
  24824. return this.dataToPoint([x, y]);
  24825. }, stack, this);
  24826. },
  24827. /**
  24828. * @param {Array.<number>} data
  24829. * @param {boolean} [clamp=false]
  24830. * @return {Array.<number>}
  24831. */
  24832. dataToPoint: function (data, clamp) {
  24833. var xAxis = this.getAxis('x');
  24834. var yAxis = this.getAxis('y');
  24835. return [
  24836. xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)),
  24837. yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp))
  24838. ];
  24839. },
  24840. /**
  24841. * @param {Array.<number>} point
  24842. * @param {boolean} [clamp=false]
  24843. * @return {Array.<number>}
  24844. */
  24845. pointToData: function (point, clamp) {
  24846. var xAxis = this.getAxis('x');
  24847. var yAxis = this.getAxis('y');
  24848. return [
  24849. xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp),
  24850. yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp)
  24851. ];
  24852. },
  24853. /**
  24854. * Get other axis
  24855. * @param {module:echarts/coord/cartesian/Axis2D} axis
  24856. */
  24857. getOtherAxis: function (axis) {
  24858. return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
  24859. }
  24860. };
  24861. zrUtil.inherits(Cartesian2D, Cartesian);
  24862. module.exports = Cartesian2D;
  24863. /***/ },
  24864. /* 127 */
  24865. /***/ function(module, exports, __webpack_require__) {
  24866. 'use strict';
  24867. /**
  24868. * Cartesian coordinate system
  24869. * @module echarts/coord/Cartesian
  24870. *
  24871. */
  24872. var zrUtil = __webpack_require__(4);
  24873. function dimAxisMapper(dim) {
  24874. return this._axes[dim];
  24875. }
  24876. /**
  24877. * @alias module:echarts/coord/Cartesian
  24878. * @constructor
  24879. */
  24880. var Cartesian = function (name) {
  24881. this._axes = {};
  24882. this._dimList = [];
  24883. /**
  24884. * @type {string}
  24885. */
  24886. this.name = name || '';
  24887. };
  24888. Cartesian.prototype = {
  24889. constructor: Cartesian,
  24890. type: 'cartesian',
  24891. /**
  24892. * Get axis
  24893. * @param {number|string} dim
  24894. * @return {module:echarts/coord/Cartesian~Axis}
  24895. */
  24896. getAxis: function (dim) {
  24897. return this._axes[dim];
  24898. },
  24899. /**
  24900. * Get axes list
  24901. * @return {Array.<module:echarts/coord/Cartesian~Axis>}
  24902. */
  24903. getAxes: function () {
  24904. return zrUtil.map(this._dimList, dimAxisMapper, this);
  24905. },
  24906. /**
  24907. * Get axes list by given scale type
  24908. */
  24909. getAxesByScale: function (scaleType) {
  24910. scaleType = scaleType.toLowerCase();
  24911. return zrUtil.filter(
  24912. this.getAxes(),
  24913. function (axis) {
  24914. return axis.scale.type === scaleType;
  24915. }
  24916. );
  24917. },
  24918. /**
  24919. * Add axis
  24920. * @param {module:echarts/coord/Cartesian.Axis}
  24921. */
  24922. addAxis: function (axis) {
  24923. var dim = axis.dim;
  24924. this._axes[dim] = axis;
  24925. this._dimList.push(dim);
  24926. },
  24927. /**
  24928. * Convert data to coord in nd space
  24929. * @param {Array.<number>|Object.<string, number>} val
  24930. * @return {Array.<number>|Object.<string, number>}
  24931. */
  24932. dataToCoord: function (val) {
  24933. return this._dataCoordConvert(val, 'dataToCoord');
  24934. },
  24935. /**
  24936. * Convert coord in nd space to data
  24937. * @param {Array.<number>|Object.<string, number>} val
  24938. * @return {Array.<number>|Object.<string, number>}
  24939. */
  24940. coordToData: function (val) {
  24941. return this._dataCoordConvert(val, 'coordToData');
  24942. },
  24943. _dataCoordConvert: function (input, method) {
  24944. var dimList = this._dimList;
  24945. var output = input instanceof Array ? [] : {};
  24946. for (var i = 0; i < dimList.length; i++) {
  24947. var dim = dimList[i];
  24948. var axis = this._axes[dim];
  24949. output[dim] = axis[method](input[dim]);
  24950. }
  24951. return output;
  24952. }
  24953. };
  24954. module.exports = Cartesian;
  24955. /***/ },
  24956. /* 128 */
  24957. /***/ function(module, exports, __webpack_require__) {
  24958. var zrUtil = __webpack_require__(4);
  24959. var Axis = __webpack_require__(100);
  24960. /**
  24961. * Extend axis 2d
  24962. * @constructor module:echarts/coord/cartesian/Axis2D
  24963. * @extends {module:echarts/coord/cartesian/Axis}
  24964. * @param {string} dim
  24965. * @param {*} scale
  24966. * @param {Array.<number>} coordExtent
  24967. * @param {string} axisType
  24968. * @param {string} position
  24969. */
  24970. var Axis2D = function (dim, scale, coordExtent, axisType, position) {
  24971. Axis.call(this, dim, scale, coordExtent);
  24972. /**
  24973. * Axis type
  24974. * - 'category'
  24975. * - 'value'
  24976. * - 'time'
  24977. * - 'log'
  24978. * @type {string}
  24979. */
  24980. this.type = axisType || 'value';
  24981. /**
  24982. * Axis position
  24983. * - 'top'
  24984. * - 'bottom'
  24985. * - 'left'
  24986. * - 'right'
  24987. */
  24988. this.position = position || 'bottom';
  24989. };
  24990. Axis2D.prototype = {
  24991. constructor: Axis2D,
  24992. /**
  24993. * Index of axis, can be used as key
  24994. */
  24995. index: 0,
  24996. /**
  24997. * If axis is on the zero position of the other axis
  24998. * @type {boolean}
  24999. */
  25000. onZero: false,
  25001. /**
  25002. * Axis model
  25003. * @param {module:echarts/coord/cartesian/AxisModel}
  25004. */
  25005. model: null,
  25006. isHorizontal: function () {
  25007. var position = this.position;
  25008. return position === 'top' || position === 'bottom';
  25009. },
  25010. /**
  25011. * Each item cooresponds to this.getExtent(), which
  25012. * means globalExtent[0] may greater than globalExtent[1],
  25013. * unless `asc` is input.
  25014. *
  25015. * @param {boolean} [asc]
  25016. * @return {Array.<number>}
  25017. */
  25018. getGlobalExtent: function (asc) {
  25019. var ret = this.getExtent();
  25020. ret[0] = this.toGlobalCoord(ret[0]);
  25021. ret[1] = this.toGlobalCoord(ret[1]);
  25022. asc && ret[0] > ret[1] && ret.reverse();
  25023. return ret;
  25024. },
  25025. getOtherAxis: function () {
  25026. this.grid.getOtherAxis();
  25027. },
  25028. /**
  25029. * If label is ignored.
  25030. * Automatically used when axis is category and label can not be all shown
  25031. * @param {number} idx
  25032. * @return {boolean}
  25033. */
  25034. isLabelIgnored: function (idx) {
  25035. if (this.type === 'category') {
  25036. var labelInterval = this.getLabelInterval();
  25037. return ((typeof labelInterval === 'function')
  25038. && !labelInterval(idx, this.scale.getLabel(idx)))
  25039. || idx % (labelInterval + 1);
  25040. }
  25041. },
  25042. /**
  25043. * @override
  25044. */
  25045. pointToData: function (point, clamp) {
  25046. return this.coordToData(this.toLocalCoord(point[this.dim === 'x' ? 0 : 1]), clamp);
  25047. },
  25048. /**
  25049. * Transform global coord to local coord,
  25050. * i.e. var localCoord = axis.toLocalCoord(80);
  25051. * designate by module:echarts/coord/cartesian/Grid.
  25052. * @type {Function}
  25053. */
  25054. toLocalCoord: null,
  25055. /**
  25056. * Transform global coord to local coord,
  25057. * i.e. var globalCoord = axis.toLocalCoord(40);
  25058. * designate by module:echarts/coord/cartesian/Grid.
  25059. * @type {Function}
  25060. */
  25061. toGlobalCoord: null
  25062. };
  25063. zrUtil.inherits(Axis2D, Axis);
  25064. module.exports = Axis2D;
  25065. /***/ },
  25066. /* 129 */
  25067. /***/ function(module, exports, __webpack_require__) {
  25068. 'use strict';
  25069. // Grid 是在有直角坐标系的时候必须要存在的
  25070. // 所以这里也要被 Cartesian2D 依赖
  25071. __webpack_require__(130);
  25072. var ComponentModel = __webpack_require__(69);
  25073. module.exports = ComponentModel.extend({
  25074. type: 'grid',
  25075. dependencies: ['xAxis', 'yAxis'],
  25076. layoutMode: 'box',
  25077. /**
  25078. * @type {module:echarts/coord/cartesian/Grid}
  25079. */
  25080. coordinateSystem: null,
  25081. defaultOption: {
  25082. show: false,
  25083. zlevel: 0,
  25084. z: 0,
  25085. left: '10%',
  25086. top: 60,
  25087. right: '10%',
  25088. bottom: 60,
  25089. // If grid size contain label
  25090. containLabel: false,
  25091. // width: {totalWidth} - left - right,
  25092. // height: {totalHeight} - top - bottom,
  25093. backgroundColor: 'rgba(0,0,0,0)',
  25094. borderWidth: 1,
  25095. borderColor: '#ccc'
  25096. }
  25097. });
  25098. /***/ },
  25099. /* 130 */
  25100. /***/ function(module, exports, __webpack_require__) {
  25101. 'use strict';
  25102. var ComponentModel = __webpack_require__(69);
  25103. var zrUtil = __webpack_require__(4);
  25104. var axisModelCreator = __webpack_require__(131);
  25105. var AxisModel = ComponentModel.extend({
  25106. type: 'cartesian2dAxis',
  25107. /**
  25108. * @type {module:echarts/coord/cartesian/Axis2D}
  25109. */
  25110. axis: null,
  25111. /**
  25112. * @override
  25113. */
  25114. init: function () {
  25115. AxisModel.superApply(this, 'init', arguments);
  25116. this.resetRange();
  25117. },
  25118. /**
  25119. * @override
  25120. */
  25121. mergeOption: function () {
  25122. AxisModel.superApply(this, 'mergeOption', arguments);
  25123. this.resetRange();
  25124. },
  25125. /**
  25126. * @override
  25127. */
  25128. restoreData: function () {
  25129. AxisModel.superApply(this, 'restoreData', arguments);
  25130. this.resetRange();
  25131. },
  25132. /**
  25133. * @override
  25134. * @return {module:echarts/model/Component}
  25135. */
  25136. getCoordSysModel: function () {
  25137. return this.ecModel.queryComponents({
  25138. mainType: 'grid',
  25139. index: this.option.gridIndex,
  25140. id: this.option.gridId
  25141. })[0];
  25142. }
  25143. });
  25144. function getAxisType(axisDim, option) {
  25145. // Default axis with data is category axis
  25146. return option.type || (option.data ? 'category' : 'value');
  25147. }
  25148. zrUtil.merge(AxisModel.prototype, __webpack_require__(112));
  25149. var extraOption = {
  25150. // gridIndex: 0,
  25151. // gridId: '',
  25152. // Offset is for multiple axis on the same position
  25153. offset: 0
  25154. };
  25155. axisModelCreator('x', AxisModel, getAxisType, extraOption);
  25156. axisModelCreator('y', AxisModel, getAxisType, extraOption);
  25157. module.exports = AxisModel;
  25158. /***/ },
  25159. /* 131 */
  25160. /***/ function(module, exports, __webpack_require__) {
  25161. var axisDefault = __webpack_require__(132);
  25162. var zrUtil = __webpack_require__(4);
  25163. var ComponentModel = __webpack_require__(69);
  25164. var layout = __webpack_require__(71);
  25165. // FIXME axisType is fixed ?
  25166. var AXIS_TYPES = ['value', 'category', 'time', 'log'];
  25167. /**
  25168. * Generate sub axis model class
  25169. * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel'
  25170. * @param {module:echarts/model/Component} BaseAxisModelClass
  25171. * @param {Function} axisTypeDefaulter
  25172. * @param {Object} [extraDefaultOption]
  25173. */
  25174. module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
  25175. zrUtil.each(AXIS_TYPES, function (axisType) {
  25176. BaseAxisModelClass.extend({
  25177. type: axisName + 'Axis.' + axisType,
  25178. mergeDefaultAndTheme: function (option, ecModel) {
  25179. var layoutMode = this.layoutMode;
  25180. var inputPositionParams = layoutMode
  25181. ? layout.getLayoutParams(option) : {};
  25182. var themeModel = ecModel.getTheme();
  25183. zrUtil.merge(option, themeModel.get(axisType + 'Axis'));
  25184. zrUtil.merge(option, this.getDefaultOption());
  25185. option.type = axisTypeDefaulter(axisName, option);
  25186. if (layoutMode) {
  25187. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  25188. }
  25189. },
  25190. defaultOption: zrUtil.mergeAll(
  25191. [
  25192. {},
  25193. axisDefault[axisType + 'Axis'],
  25194. extraDefaultOption
  25195. ],
  25196. true
  25197. )
  25198. });
  25199. });
  25200. ComponentModel.registerSubTypeDefaulter(
  25201. axisName + 'Axis',
  25202. zrUtil.curry(axisTypeDefaulter, axisName)
  25203. );
  25204. };
  25205. /***/ },
  25206. /* 132 */
  25207. /***/ function(module, exports, __webpack_require__) {
  25208. var zrUtil = __webpack_require__(4);
  25209. var defaultOption = {
  25210. show: true,
  25211. zlevel: 0, // 一级层叠
  25212. z: 0, // 二级层叠
  25213. // 反向坐标轴
  25214. inverse: false,
  25215. // 坐标轴名字,默认为空
  25216. name: '',
  25217. // 坐标轴名字位置,支持'start' | 'middle' | 'end'
  25218. nameLocation: 'end',
  25219. // 坐标轴名字旋转,degree。
  25220. nameRotate: null, // Adapt to axis rotate, when nameLocation is 'middle'.
  25221. nameTruncate: {
  25222. maxWidth: null,
  25223. ellipsis: '...',
  25224. placeholder: '.'
  25225. },
  25226. // 坐标轴文字样式,默认取全局样式
  25227. nameTextStyle: {},
  25228. // 文字与轴线距离
  25229. nameGap: 15,
  25230. silent: false, // Default false to support tooltip.
  25231. triggerEvent: false, // Default false to avoid legacy user event listener fail.
  25232. tooltip: {
  25233. show: false
  25234. },
  25235. axisPointer: {},
  25236. // 坐标轴线
  25237. axisLine: {
  25238. // 默认显示,属性show控制显示与否
  25239. show: true,
  25240. onZero: true,
  25241. // 属性lineStyle控制线条样式
  25242. lineStyle: {
  25243. color: '#333',
  25244. width: 1,
  25245. type: 'solid'
  25246. }
  25247. },
  25248. // 坐标轴小标记
  25249. axisTick: {
  25250. // 属性show控制显示与否,默认显示
  25251. show: true,
  25252. // 控制小标记是否在grid里
  25253. inside: false,
  25254. // 属性length控制线长
  25255. length: 5,
  25256. // 属性lineStyle控制线条样式
  25257. lineStyle: {
  25258. width: 1
  25259. }
  25260. },
  25261. // 坐标轴文本标签,详见axis.axisLabel
  25262. axisLabel: {
  25263. show: true,
  25264. // 控制文本标签是否在grid里
  25265. inside: false,
  25266. rotate: 0,
  25267. showMinLabel: null, // true | false | null (auto)
  25268. showMaxLabel: null, // true | false | null (auto)
  25269. margin: 8,
  25270. // formatter: null,
  25271. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  25272. textStyle: {
  25273. fontSize: 12
  25274. }
  25275. },
  25276. // 分隔线
  25277. splitLine: {
  25278. // 默认显示,属性show控制显示与否
  25279. show: true,
  25280. // 属性lineStyle(详见lineStyle)控制线条样式
  25281. lineStyle: {
  25282. color: ['#ccc'],
  25283. width: 1,
  25284. type: 'solid'
  25285. }
  25286. },
  25287. // 分隔区域
  25288. splitArea: {
  25289. // 默认不显示,属性show控制显示与否
  25290. show: false,
  25291. // 属性areaStyle(详见areaStyle)控制区域样式
  25292. areaStyle: {
  25293. color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)']
  25294. }
  25295. }
  25296. };
  25297. var categoryAxis = zrUtil.merge({
  25298. // 类目起始和结束两端空白策略
  25299. boundaryGap: true,
  25300. // splitArea: {
  25301. // show: false
  25302. // },
  25303. splitLine: {
  25304. show: false
  25305. },
  25306. // 坐标轴小标记
  25307. axisTick: {
  25308. // If tick is align with label when boundaryGap is true
  25309. alignWithLabel: false,
  25310. interval: 'auto'
  25311. },
  25312. // 坐标轴文本标签,详见axis.axisLabel
  25313. axisLabel: {
  25314. interval: 'auto'
  25315. }
  25316. }, defaultOption);
  25317. var valueAxis = zrUtil.merge({
  25318. // 数值起始和结束两端空白策略
  25319. boundaryGap: [0, 0],
  25320. // 最小值, 设置成 'dataMin' 则从数据中计算最小值
  25321. // min: null,
  25322. // 最大值,设置成 'dataMax' 则从数据中计算最大值
  25323. // max: null,
  25324. // Readonly prop, specifies start value of the range when using data zoom.
  25325. // rangeStart: null
  25326. // Readonly prop, specifies end value of the range when using data zoom.
  25327. // rangeEnd: null
  25328. // 脱离0值比例,放大聚焦到最终_min,_max区间
  25329. // scale: false,
  25330. // 分割段数,默认为5
  25331. splitNumber: 5
  25332. // Minimum interval
  25333. // minInterval: null
  25334. }, defaultOption);
  25335. // FIXME
  25336. var timeAxis = zrUtil.defaults({
  25337. scale: true,
  25338. min: 'dataMin',
  25339. max: 'dataMax'
  25340. }, valueAxis);
  25341. var logAxis = zrUtil.defaults({
  25342. scale: true,
  25343. logBase: 10
  25344. }, valueAxis);
  25345. module.exports = {
  25346. categoryAxis: categoryAxis,
  25347. valueAxis: valueAxis,
  25348. timeAxis: timeAxis,
  25349. logAxis: logAxis
  25350. };
  25351. /***/ },
  25352. /* 133 */
  25353. /***/ function(module, exports, __webpack_require__) {
  25354. 'use strict';
  25355. // TODO boundaryGap
  25356. __webpack_require__(130);
  25357. __webpack_require__(134);
  25358. /***/ },
  25359. /* 134 */
  25360. /***/ function(module, exports, __webpack_require__) {
  25361. var zrUtil = __webpack_require__(4);
  25362. var graphic = __webpack_require__(18);
  25363. var AxisBuilder = __webpack_require__(135);
  25364. var AxisView = __webpack_require__(136);
  25365. var cartesianAxisHelper = __webpack_require__(138);
  25366. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  25367. var getInterval = AxisBuilder.getInterval;
  25368. var axisBuilderAttrs = [
  25369. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  25370. ];
  25371. var selfBuilderAttrs = [
  25372. 'splitArea', 'splitLine'
  25373. ];
  25374. // function getAlignWithLabel(model, axisModel) {
  25375. // var alignWithLabel = model.get('alignWithLabel');
  25376. // if (alignWithLabel === 'auto') {
  25377. // alignWithLabel = axisModel.get('axisTick.alignWithLabel');
  25378. // }
  25379. // return alignWithLabel;
  25380. // }
  25381. var CartesianAxisView = AxisView.extend({
  25382. type: 'cartesianAxis',
  25383. axisPointerClass: 'CartesianAxisPointer',
  25384. /**
  25385. * @override
  25386. */
  25387. render: function (axisModel, ecModel, api, payload) {
  25388. this.group.removeAll();
  25389. var oldAxisGroup = this._axisGroup;
  25390. this._axisGroup = new graphic.Group();
  25391. this.group.add(this._axisGroup);
  25392. if (!axisModel.get('show')) {
  25393. return;
  25394. }
  25395. var gridModel = axisModel.getCoordSysModel();
  25396. var layout = cartesianAxisHelper.layout(gridModel, axisModel);
  25397. var axisBuilder = new AxisBuilder(axisModel, layout);
  25398. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  25399. this._axisGroup.add(axisBuilder.getGroup());
  25400. zrUtil.each(selfBuilderAttrs, function (name) {
  25401. if (axisModel.get(name + '.show')) {
  25402. this['_' + name](axisModel, gridModel, layout.labelInterval);
  25403. }
  25404. }, this);
  25405. graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  25406. CartesianAxisView.superCall(this, 'render', axisModel, ecModel, api, payload);
  25407. },
  25408. /**
  25409. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  25410. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  25411. * @param {number|Function} labelInterval
  25412. * @private
  25413. */
  25414. _splitLine: function (axisModel, gridModel, labelInterval) {
  25415. var axis = axisModel.axis;
  25416. if (axis.scale.isBlank()) {
  25417. return;
  25418. }
  25419. var splitLineModel = axisModel.getModel('splitLine');
  25420. var lineStyleModel = splitLineModel.getModel('lineStyle');
  25421. var lineColors = lineStyleModel.get('color');
  25422. var lineInterval = getInterval(splitLineModel, labelInterval);
  25423. lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];
  25424. var gridRect = gridModel.coordinateSystem.getRect();
  25425. var isHorizontal = axis.isHorizontal();
  25426. var lineCount = 0;
  25427. var ticksCoords = axis.getTicksCoords(
  25428. // splitLineModel.get('alignWithLabel')
  25429. );
  25430. var ticks = axis.scale.getTicks();
  25431. var p1 = [];
  25432. var p2 = [];
  25433. // Simple optimization
  25434. // Batching the lines if color are the same
  25435. var lineStyle = lineStyleModel.getLineStyle();
  25436. for (var i = 0; i < ticksCoords.length; i++) {
  25437. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  25438. continue;
  25439. }
  25440. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  25441. if (isHorizontal) {
  25442. p1[0] = tickCoord;
  25443. p1[1] = gridRect.y;
  25444. p2[0] = tickCoord;
  25445. p2[1] = gridRect.y + gridRect.height;
  25446. }
  25447. else {
  25448. p1[0] = gridRect.x;
  25449. p1[1] = tickCoord;
  25450. p2[0] = gridRect.x + gridRect.width;
  25451. p2[1] = tickCoord;
  25452. }
  25453. var colorIndex = (lineCount++) % lineColors.length;
  25454. this._axisGroup.add(new graphic.Line(graphic.subPixelOptimizeLine({
  25455. anid: 'line_' + ticks[i],
  25456. shape: {
  25457. x1: p1[0],
  25458. y1: p1[1],
  25459. x2: p2[0],
  25460. y2: p2[1]
  25461. },
  25462. style: zrUtil.defaults({
  25463. stroke: lineColors[colorIndex]
  25464. }, lineStyle),
  25465. silent: true
  25466. })));
  25467. }
  25468. },
  25469. /**
  25470. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  25471. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  25472. * @param {number|Function} labelInterval
  25473. * @private
  25474. */
  25475. _splitArea: function (axisModel, gridModel, labelInterval) {
  25476. var axis = axisModel.axis;
  25477. if (axis.scale.isBlank()) {
  25478. return;
  25479. }
  25480. var splitAreaModel = axisModel.getModel('splitArea');
  25481. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  25482. var areaColors = areaStyleModel.get('color');
  25483. var gridRect = gridModel.coordinateSystem.getRect();
  25484. var ticksCoords = axis.getTicksCoords(
  25485. // splitAreaModel.get('alignWithLabel')
  25486. );
  25487. var ticks = axis.scale.getTicks();
  25488. var prevX = axis.toGlobalCoord(ticksCoords[0]);
  25489. var prevY = axis.toGlobalCoord(ticksCoords[0]);
  25490. var count = 0;
  25491. var areaInterval = getInterval(splitAreaModel, labelInterval);
  25492. var areaStyle = areaStyleModel.getAreaStyle();
  25493. areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
  25494. for (var i = 1; i < ticksCoords.length; i++) {
  25495. if (ifIgnoreOnTick(axis, i, areaInterval)) {
  25496. continue;
  25497. }
  25498. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  25499. var x;
  25500. var y;
  25501. var width;
  25502. var height;
  25503. if (axis.isHorizontal()) {
  25504. x = prevX;
  25505. y = gridRect.y;
  25506. width = tickCoord - x;
  25507. height = gridRect.height;
  25508. }
  25509. else {
  25510. x = gridRect.x;
  25511. y = prevY;
  25512. width = gridRect.width;
  25513. height = tickCoord - y;
  25514. }
  25515. var colorIndex = (count++) % areaColors.length;
  25516. this._axisGroup.add(new graphic.Rect({
  25517. anid: 'area_' + ticks[i],
  25518. shape: {
  25519. x: x,
  25520. y: y,
  25521. width: width,
  25522. height: height
  25523. },
  25524. style: zrUtil.defaults({
  25525. fill: areaColors[colorIndex]
  25526. }, areaStyle),
  25527. silent: true
  25528. }));
  25529. prevX = x + width;
  25530. prevY = y + height;
  25531. }
  25532. }
  25533. });
  25534. CartesianAxisView.extend({
  25535. type: 'xAxis'
  25536. });
  25537. CartesianAxisView.extend({
  25538. type: 'yAxis'
  25539. });
  25540. /***/ },
  25541. /* 135 */
  25542. /***/ function(module, exports, __webpack_require__) {
  25543. var zrUtil = __webpack_require__(4);
  25544. var formatUtil = __webpack_require__(6);
  25545. var graphic = __webpack_require__(18);
  25546. var Model = __webpack_require__(12);
  25547. var numberUtil = __webpack_require__(7);
  25548. var remRadian = numberUtil.remRadian;
  25549. var isRadianAroundZero = numberUtil.isRadianAroundZero;
  25550. var vec2 = __webpack_require__(10);
  25551. var matrix = __webpack_require__(11);
  25552. var v2ApplyTransform = vec2.applyTransform;
  25553. var retrieve = zrUtil.retrieve;
  25554. var PI = Math.PI;
  25555. function makeAxisEventDataBase(axisModel) {
  25556. var eventData = {
  25557. componentType: axisModel.mainType
  25558. };
  25559. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex;
  25560. return eventData;
  25561. }
  25562. /**
  25563. * A final axis is translated and rotated from a "standard axis".
  25564. * So opt.position and opt.rotation is required.
  25565. *
  25566. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  25567. * for example: (0, 0) ------------> (0, 50)
  25568. *
  25569. * nameDirection or tickDirection or labelDirection is 1 means tick
  25570. * or label is below the standard axis, whereas is -1 means above
  25571. * the standard axis. labelOffset means offset between label and axis,
  25572. * which is useful when 'onZero', where axisLabel is in the grid and
  25573. * label in outside grid.
  25574. *
  25575. * Tips: like always,
  25576. * positive rotation represents anticlockwise, and negative rotation
  25577. * represents clockwise.
  25578. * The direction of position coordinate is the same as the direction
  25579. * of screen coordinate.
  25580. *
  25581. * Do not need to consider axis 'inverse', which is auto processed by
  25582. * axis extent.
  25583. *
  25584. * @param {module:zrender/container/Group} group
  25585. * @param {Object} axisModel
  25586. * @param {Object} opt Standard axis parameters.
  25587. * @param {Array.<number>} opt.position [x, y]
  25588. * @param {number} opt.rotation by radian
  25589. * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
  25590. * @param {number} [opt.tickDirection=1] 1 or -1
  25591. * @param {number} [opt.labelDirection=1] 1 or -1
  25592. * @param {number} [opt.labelOffset=0] Usefull when onZero.
  25593. * @param {string} [opt.axisLabelShow] default get from axisModel.
  25594. * @param {string} [opt.axisName] default get from axisModel.
  25595. * @param {number} [opt.axisNameAvailableWidth]
  25596. * @param {number} [opt.labelRotate] by degree, default get from axisModel.
  25597. * @param {number} [opt.labelInterval] Default label interval when label
  25598. * interval from model is null or 'auto'.
  25599. * @param {number} [opt.strokeContainThreshold] Default label interval when label
  25600. * @param {number} [opt.nameTruncateMaxWidth]
  25601. */
  25602. var AxisBuilder = function (axisModel, opt) {
  25603. /**
  25604. * @readOnly
  25605. */
  25606. this.opt = opt;
  25607. /**
  25608. * @readOnly
  25609. */
  25610. this.axisModel = axisModel;
  25611. // Default value
  25612. zrUtil.defaults(
  25613. opt,
  25614. {
  25615. labelOffset: 0,
  25616. nameDirection: 1,
  25617. tickDirection: 1,
  25618. labelDirection: 1,
  25619. silent: true
  25620. }
  25621. );
  25622. /**
  25623. * @readOnly
  25624. */
  25625. this.group = new graphic.Group();
  25626. // FIXME Not use a seperate text group?
  25627. var dumbGroup = new graphic.Group({
  25628. position: opt.position.slice(),
  25629. rotation: opt.rotation
  25630. });
  25631. // this.group.add(dumbGroup);
  25632. // this._dumbGroup = dumbGroup;
  25633. dumbGroup.updateTransform();
  25634. this._transform = dumbGroup.transform;
  25635. this._dumbGroup = dumbGroup;
  25636. };
  25637. AxisBuilder.prototype = {
  25638. constructor: AxisBuilder,
  25639. hasBuilder: function (name) {
  25640. return !!builders[name];
  25641. },
  25642. add: function (name) {
  25643. builders[name].call(this);
  25644. },
  25645. getGroup: function () {
  25646. return this.group;
  25647. }
  25648. };
  25649. var builders = {
  25650. /**
  25651. * @private
  25652. */
  25653. axisLine: function () {
  25654. var opt = this.opt;
  25655. var axisModel = this.axisModel;
  25656. if (!axisModel.get('axisLine.show')) {
  25657. return;
  25658. }
  25659. var extent = this.axisModel.axis.getExtent();
  25660. var matrix = this._transform;
  25661. var pt1 = [extent[0], 0];
  25662. var pt2 = [extent[1], 0];
  25663. if (matrix) {
  25664. v2ApplyTransform(pt1, pt1, matrix);
  25665. v2ApplyTransform(pt2, pt2, matrix);
  25666. }
  25667. this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
  25668. // Id for animation
  25669. anid: 'line',
  25670. shape: {
  25671. x1: pt1[0],
  25672. y1: pt1[1],
  25673. x2: pt2[0],
  25674. y2: pt2[1]
  25675. },
  25676. style: zrUtil.extend(
  25677. {lineCap: 'round'},
  25678. axisModel.getModel('axisLine.lineStyle').getLineStyle()
  25679. ),
  25680. strokeContainThreshold: opt.strokeContainThreshold || 5,
  25681. silent: true,
  25682. z2: 1
  25683. })));
  25684. },
  25685. /**
  25686. * @private
  25687. */
  25688. axisTick: function () {
  25689. var axisModel = this.axisModel;
  25690. var axis = axisModel.axis;
  25691. if (!axisModel.get('axisTick.show') || axis.scale.isBlank()) {
  25692. return;
  25693. }
  25694. var tickModel = axisModel.getModel('axisTick');
  25695. var opt = this.opt;
  25696. var lineStyleModel = tickModel.getModel('lineStyle');
  25697. var tickLen = tickModel.get('length');
  25698. var tickInterval = getInterval(tickModel, opt.labelInterval);
  25699. var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
  25700. var ticks = axis.scale.getTicks();
  25701. var pt1 = [];
  25702. var pt2 = [];
  25703. var matrix = this._transform;
  25704. for (var i = 0; i < ticksCoords.length; i++) {
  25705. // Only ordinal scale support tick interval
  25706. if (ifIgnoreOnTick(axis, i, tickInterval)) {
  25707. continue;
  25708. }
  25709. var tickCoord = ticksCoords[i];
  25710. pt1[0] = tickCoord;
  25711. pt1[1] = 0;
  25712. pt2[0] = tickCoord;
  25713. pt2[1] = opt.tickDirection * tickLen;
  25714. if (matrix) {
  25715. v2ApplyTransform(pt1, pt1, matrix);
  25716. v2ApplyTransform(pt2, pt2, matrix);
  25717. }
  25718. // Tick line, Not use group transform to have better line draw
  25719. this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
  25720. // Id for animation
  25721. anid: 'tick_' + ticks[i],
  25722. shape: {
  25723. x1: pt1[0],
  25724. y1: pt1[1],
  25725. x2: pt2[0],
  25726. y2: pt2[1]
  25727. },
  25728. style: zrUtil.defaults(
  25729. lineStyleModel.getLineStyle(),
  25730. {
  25731. stroke: axisModel.get('axisLine.lineStyle.color')
  25732. }
  25733. ),
  25734. z2: 2,
  25735. silent: true
  25736. })));
  25737. }
  25738. },
  25739. /**
  25740. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  25741. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  25742. * @private
  25743. */
  25744. axisLabel: function () {
  25745. var opt = this.opt;
  25746. var axisModel = this.axisModel;
  25747. var axis = axisModel.axis;
  25748. var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
  25749. if (!show || axis.scale.isBlank()) {
  25750. return;
  25751. }
  25752. var labelModel = axisModel.getModel('axisLabel');
  25753. var textStyleModel = labelModel.getModel('textStyle');
  25754. var labelMargin = labelModel.get('margin');
  25755. var ticks = axis.scale.getTicks();
  25756. var labels = axisModel.getFormattedLabels();
  25757. // Special label rotate.
  25758. var labelRotation = (
  25759. retrieve(opt.labelRotate, labelModel.get('rotate')) || 0
  25760. ) * PI / 180;
  25761. var labelLayout = innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
  25762. var categoryData = axisModel.get('data');
  25763. var textEls = [];
  25764. var silent = isSilent(axisModel);
  25765. var triggerEvent = axisModel.get('triggerEvent');
  25766. zrUtil.each(ticks, function (tickVal, index) {
  25767. if (ifIgnoreOnTick(axis, index, opt.labelInterval)) {
  25768. return;
  25769. }
  25770. var itemTextStyleModel = textStyleModel;
  25771. if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
  25772. itemTextStyleModel = new Model(
  25773. categoryData[tickVal].textStyle, textStyleModel, axisModel.ecModel
  25774. );
  25775. }
  25776. var textColor = itemTextStyleModel.getTextColor()
  25777. || axisModel.get('axisLine.lineStyle.color');
  25778. var tickCoord = axis.dataToCoord(tickVal);
  25779. var pos = [
  25780. tickCoord,
  25781. opt.labelOffset + opt.labelDirection * labelMargin
  25782. ];
  25783. var labelStr = axis.scale.getLabel(tickVal);
  25784. var textEl = new graphic.Text({
  25785. // Id for animation
  25786. anid: 'label_' + tickVal,
  25787. style: {
  25788. text: labels[index],
  25789. textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign,
  25790. textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.textVerticalAlign,
  25791. textFont: itemTextStyleModel.getFont(),
  25792. fill: typeof textColor === 'function'
  25793. ? textColor(
  25794. // (1) In category axis with data zoom, tick is not the original
  25795. // index of axis.data. So tick should not be exposed to user
  25796. // in category axis.
  25797. // (2) Compatible with previous version, which always returns labelStr.
  25798. // But in interval scale labelStr is like '223,445', which maked
  25799. // user repalce ','. So we modify it to return original val but remain
  25800. // it as 'string' to avoid error in replacing.
  25801. axis.type === 'category' ? labelStr : axis.type === 'value' ? tickVal + '' : tickVal,
  25802. index
  25803. )
  25804. : textColor
  25805. },
  25806. position: pos,
  25807. rotation: labelLayout.rotation,
  25808. silent: silent,
  25809. z2: 10
  25810. });
  25811. // Pack data for mouse event
  25812. if (triggerEvent) {
  25813. textEl.eventData = makeAxisEventDataBase(axisModel);
  25814. textEl.eventData.targetType = 'axisLabel';
  25815. textEl.eventData.value = labelStr;
  25816. }
  25817. // FIXME
  25818. this._dumbGroup.add(textEl);
  25819. textEl.updateTransform();
  25820. textEls.push(textEl);
  25821. this.group.add(textEl);
  25822. textEl.decomposeTransform();
  25823. }, this);
  25824. fixMinMaxLabelShow(axisModel, textEls);
  25825. },
  25826. /**
  25827. * @private
  25828. */
  25829. axisName: function () {
  25830. var opt = this.opt;
  25831. var axisModel = this.axisModel;
  25832. var name = retrieve(opt.axisName, axisModel.get('name'));
  25833. if (!name) {
  25834. return;
  25835. }
  25836. var nameLocation = axisModel.get('nameLocation');
  25837. var nameDirection = opt.nameDirection;
  25838. var textStyleModel = axisModel.getModel('nameTextStyle');
  25839. var gap = axisModel.get('nameGap') || 0;
  25840. var extent = this.axisModel.axis.getExtent();
  25841. var gapSignal = extent[0] > extent[1] ? -1 : 1;
  25842. var pos = [
  25843. nameLocation === 'start'
  25844. ? extent[0] - gapSignal * gap
  25845. : nameLocation === 'end'
  25846. ? extent[1] + gapSignal * gap
  25847. : (extent[0] + extent[1]) / 2, // 'middle'
  25848. // Reuse labelOffset.
  25849. nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0
  25850. ];
  25851. var labelLayout;
  25852. var nameRotation = axisModel.get('nameRotate');
  25853. if (nameRotation != null) {
  25854. nameRotation = nameRotation * PI / 180; // To radian.
  25855. }
  25856. var axisNameAvailableWidth;
  25857. if (nameLocation === 'middle') {
  25858. labelLayout = innerTextLayout(
  25859. opt.rotation,
  25860. nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
  25861. nameDirection
  25862. );
  25863. }
  25864. else {
  25865. labelLayout = endTextLayout(
  25866. opt, nameLocation, nameRotation || 0, extent
  25867. );
  25868. axisNameAvailableWidth = opt.axisNameAvailableWidth;
  25869. if (axisNameAvailableWidth != null) {
  25870. axisNameAvailableWidth = Math.abs(
  25871. axisNameAvailableWidth / Math.sin(labelLayout.rotation)
  25872. );
  25873. !isFinite(axisNameAvailableWidth) && (axisNameAvailableWidth = null);
  25874. }
  25875. }
  25876. var textFont = textStyleModel.getFont();
  25877. var truncateOpt = axisModel.get('nameTruncate', true) || {};
  25878. var ellipsis = truncateOpt.ellipsis;
  25879. var maxWidth = retrieve(
  25880. opt.nameTruncateMaxWidth, truncateOpt.maxWidth, axisNameAvailableWidth
  25881. );
  25882. var truncatedText = (ellipsis != null && maxWidth != null)
  25883. ? formatUtil.truncateText(
  25884. name, maxWidth, textFont, ellipsis,
  25885. {minChar: 2, placeholder: truncateOpt.placeholder}
  25886. )
  25887. : name;
  25888. var tooltipOpt = axisModel.get('tooltip', true);
  25889. var mainType = axisModel.mainType;
  25890. var formatterParams = {
  25891. componentType: mainType,
  25892. name: name,
  25893. $vars: ['name']
  25894. };
  25895. formatterParams[mainType + 'Index'] = axisModel.componentIndex;
  25896. var textEl = new graphic.Text({
  25897. // Id for animation
  25898. anid: 'name',
  25899. __fullText: name,
  25900. __truncatedText: truncatedText,
  25901. style: {
  25902. text: truncatedText,
  25903. textFont: textFont,
  25904. fill: textStyleModel.getTextColor()
  25905. || axisModel.get('axisLine.lineStyle.color'),
  25906. textAlign: labelLayout.textAlign,
  25907. textVerticalAlign: labelLayout.textVerticalAlign
  25908. },
  25909. position: pos,
  25910. rotation: labelLayout.rotation,
  25911. silent: isSilent(axisModel),
  25912. z2: 1,
  25913. tooltip: (tooltipOpt && tooltipOpt.show)
  25914. ? zrUtil.extend({
  25915. content: name,
  25916. formatter: function () {
  25917. return name;
  25918. },
  25919. formatterParams: formatterParams
  25920. }, tooltipOpt)
  25921. : null
  25922. });
  25923. if (axisModel.get('triggerEvent')) {
  25924. textEl.eventData = makeAxisEventDataBase(axisModel);
  25925. textEl.eventData.targetType = 'axisName';
  25926. textEl.eventData.name = name;
  25927. }
  25928. // FIXME
  25929. this._dumbGroup.add(textEl);
  25930. textEl.updateTransform();
  25931. this.group.add(textEl);
  25932. textEl.decomposeTransform();
  25933. }
  25934. };
  25935. /**
  25936. * @public
  25937. * @static
  25938. * @param {Object} opt
  25939. * @param {number} axisRotation in radian
  25940. * @param {number} textRotation in radian
  25941. * @param {number} direction
  25942. * @return {Object} {
  25943. * rotation, // according to axis
  25944. * textAlign,
  25945. * textVerticalAlign
  25946. * }
  25947. */
  25948. var innerTextLayout = AxisBuilder.innerTextLayout = function (axisRotation, textRotation, direction) {
  25949. var rotationDiff = remRadian(textRotation - axisRotation);
  25950. var textAlign;
  25951. var textVerticalAlign;
  25952. if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line.
  25953. textVerticalAlign = direction > 0 ? 'top' : 'bottom';
  25954. textAlign = 'center';
  25955. }
  25956. else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line.
  25957. textVerticalAlign = direction > 0 ? 'bottom' : 'top';
  25958. textAlign = 'center';
  25959. }
  25960. else {
  25961. textVerticalAlign = 'middle';
  25962. if (rotationDiff > 0 && rotationDiff < PI) {
  25963. textAlign = direction > 0 ? 'right' : 'left';
  25964. }
  25965. else {
  25966. textAlign = direction > 0 ? 'left' : 'right';
  25967. }
  25968. }
  25969. return {
  25970. rotation: rotationDiff,
  25971. textAlign: textAlign,
  25972. textVerticalAlign: textVerticalAlign
  25973. };
  25974. };
  25975. function endTextLayout(opt, textPosition, textRotate, extent) {
  25976. var rotationDiff = remRadian(textRotate - opt.rotation);
  25977. var textAlign;
  25978. var textVerticalAlign;
  25979. var inverse = extent[0] > extent[1];
  25980. var onLeft = (textPosition === 'start' && !inverse)
  25981. || (textPosition !== 'start' && inverse);
  25982. if (isRadianAroundZero(rotationDiff - PI / 2)) {
  25983. textVerticalAlign = onLeft ? 'bottom' : 'top';
  25984. textAlign = 'center';
  25985. }
  25986. else if (isRadianAroundZero(rotationDiff - PI * 1.5)) {
  25987. textVerticalAlign = onLeft ? 'top' : 'bottom';
  25988. textAlign = 'center';
  25989. }
  25990. else {
  25991. textVerticalAlign = 'middle';
  25992. if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) {
  25993. textAlign = onLeft ? 'left' : 'right';
  25994. }
  25995. else {
  25996. textAlign = onLeft ? 'right' : 'left';
  25997. }
  25998. }
  25999. return {
  26000. rotation: rotationDiff,
  26001. textAlign: textAlign,
  26002. textVerticalAlign: textVerticalAlign
  26003. };
  26004. }
  26005. function isSilent(axisModel) {
  26006. var tooltipOpt = axisModel.get('tooltip');
  26007. return axisModel.get('silent')
  26008. // Consider mouse cursor, add these restrictions.
  26009. || !(
  26010. axisModel.get('triggerEvent') || (tooltipOpt && tooltipOpt.show)
  26011. );
  26012. }
  26013. function fixMinMaxLabelShow(axisModel, textEls) {
  26014. // If min or max are user set, we need to check
  26015. // If the tick on min(max) are overlap on their neighbour tick
  26016. // If they are overlapped, we need to hide the min(max) tick label
  26017. var showMinLabel = axisModel.get('axisLabel.showMinLabel');
  26018. var showMaxLabel = axisModel.get('axisLabel.showMaxLabel');
  26019. var firstLabel = textEls[0];
  26020. var nextLabel = textEls[1];
  26021. var lastLabel = textEls[textEls.length - 1];
  26022. var prevLabel = textEls[textEls.length - 2];
  26023. if (showMinLabel === false) {
  26024. firstLabel.ignore = true;
  26025. }
  26026. else if (axisModel.getMin() != null && isTwoLabelOverlapped(firstLabel, nextLabel)) {
  26027. showMinLabel ? (nextLabel.ignore = true) : (firstLabel.ignore = true);
  26028. }
  26029. if (showMaxLabel === false) {
  26030. lastLabel.ignore = true;
  26031. }
  26032. else if (axisModel.getMax() != null && isTwoLabelOverlapped(prevLabel, lastLabel)) {
  26033. showMaxLabel ? (prevLabel.ignore = true) : (lastLabel.ignore = true);
  26034. }
  26035. }
  26036. function isTwoLabelOverlapped(current, next, labelLayout) {
  26037. // current and next has the same rotation.
  26038. var firstRect = current && current.getBoundingRect().clone();
  26039. var nextRect = next && next.getBoundingRect().clone();
  26040. if (!firstRect || !nextRect) {
  26041. return;
  26042. }
  26043. // When checking intersect of two rotated labels, we use mRotationBack
  26044. // to avoid that boundingRect is enlarge when using `boundingRect.applyTransform`.
  26045. var mRotationBack = matrix.identity([]);
  26046. matrix.rotate(mRotationBack, mRotationBack, -current.rotation);
  26047. firstRect.applyTransform(matrix.mul([], mRotationBack, current.getLocalTransform()));
  26048. nextRect.applyTransform(matrix.mul([], mRotationBack, next.getLocalTransform()));
  26049. return firstRect.intersect(nextRect);
  26050. }
  26051. /**
  26052. * @static
  26053. */
  26054. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) {
  26055. var rawTick;
  26056. var scale = axis.scale;
  26057. return scale.type === 'ordinal'
  26058. && (
  26059. typeof interval === 'function'
  26060. ? (
  26061. rawTick = scale.getTicks()[i],
  26062. !interval(rawTick, scale.getLabel(rawTick))
  26063. )
  26064. : i % (interval + 1)
  26065. );
  26066. };
  26067. /**
  26068. * @static
  26069. */
  26070. var getInterval = AxisBuilder.getInterval = function (model, labelInterval) {
  26071. var interval = model.get('interval');
  26072. if (interval == null || interval == 'auto') {
  26073. interval = labelInterval;
  26074. }
  26075. return interval;
  26076. };
  26077. module.exports = AxisBuilder;
  26078. /***/ },
  26079. /* 136 */
  26080. /***/ function(module, exports, __webpack_require__) {
  26081. var axisPointerModelHelper = __webpack_require__(137);
  26082. /**
  26083. * Base class of AxisView.
  26084. */
  26085. var AxisView = __webpack_require__(1).extendComponentView({
  26086. type: 'axis',
  26087. /**
  26088. * @private
  26089. */
  26090. _axisPointer: null,
  26091. /**
  26092. * @protected
  26093. * @type {string}
  26094. */
  26095. axisPointerClass: null,
  26096. /**
  26097. * @override
  26098. */
  26099. render: function (axisModel, ecModel, api, payload) {
  26100. // FIXME
  26101. // This process should proformed after coordinate systems updated
  26102. // (axis scale updated), and should be performed each time update.
  26103. // So put it here temporarily, although it is not appropriate to
  26104. // put a model-writing procedure in `view`.
  26105. this.axisPointerClass && axisPointerModelHelper.fixValue(axisModel);
  26106. AxisView.superApply(this, 'render', arguments);
  26107. updateAxisPointer(this, axisModel, ecModel, api, payload, true);
  26108. },
  26109. /**
  26110. * Action handler.
  26111. * @public
  26112. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  26113. * @param {module:echarts/model/Global} ecModel
  26114. * @param {module:echarts/ExtensionAPI} api
  26115. * @param {Object} payload
  26116. */
  26117. updateAxisPointer: function (axisModel, ecModel, api, payload, force) {
  26118. updateAxisPointer(this, axisModel, ecModel, api, payload, false);
  26119. },
  26120. /**
  26121. * @override
  26122. */
  26123. remove: function (ecModel, api) {
  26124. var axisPointer = this._axisPointer;
  26125. axisPointer && axisPointer.remove(api);
  26126. AxisView.superApply(this, 'remove', arguments);
  26127. },
  26128. /**
  26129. * @override
  26130. */
  26131. dispose: function (ecModel, api) {
  26132. disposeAxisPointer(this, api);
  26133. AxisView.superApply(this, 'dispose', arguments);
  26134. }
  26135. });
  26136. function updateAxisPointer(axisView, axisModel, ecModel, api, payload, forceRender) {
  26137. var Clazz = AxisView.getAxisPointerClass(axisView.axisPointerClass);
  26138. if (!Clazz) {
  26139. return;
  26140. }
  26141. var axisPointerModel = axisPointerModelHelper.getAxisPointerModel(axisModel);
  26142. axisPointerModel
  26143. ? (axisView._axisPointer || (axisView._axisPointer = new Clazz()))
  26144. .render(axisModel, axisPointerModel, api, forceRender)
  26145. : disposeAxisPointer(axisView, api);
  26146. }
  26147. function disposeAxisPointer(axisView, ecModel, api) {
  26148. var axisPointer = axisView._axisPointer;
  26149. axisPointer && axisPointer.dispose(ecModel, api);
  26150. axisView._axisPointer = null;
  26151. }
  26152. var axisPointerClazz = [];
  26153. AxisView.registerAxisPointerClass = function (type, clazz) {
  26154. if (true) {
  26155. if (axisPointerClazz[type]) {
  26156. throw new Error('axisPointer ' + type + ' exists');
  26157. }
  26158. }
  26159. axisPointerClazz[type] = clazz;
  26160. };
  26161. AxisView.getAxisPointerClass = function (type) {
  26162. return type && axisPointerClazz[type];
  26163. };
  26164. module.exports = AxisView;
  26165. /***/ },
  26166. /* 137 */
  26167. /***/ function(module, exports, __webpack_require__) {
  26168. var zrUtil = __webpack_require__(4);
  26169. var Model = __webpack_require__(12);
  26170. var each = zrUtil.each;
  26171. var curry = zrUtil.curry;
  26172. var helper = {};
  26173. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  26174. // allAxesInfo should be updated when setOption performed.
  26175. helper.collect = function (ecModel, api) {
  26176. var result = {
  26177. /**
  26178. * key: makeKey(axis.model)
  26179. * value: {
  26180. * axis,
  26181. * coordSys,
  26182. * axisPointerModel,
  26183. * triggerTooltip,
  26184. * involveSeries,
  26185. * snap,
  26186. * seriesModels,
  26187. * seriesDataCount
  26188. * }
  26189. */
  26190. axesInfo: {},
  26191. seriesInvolved: false,
  26192. /**
  26193. * key: makeKey(coordSys.model)
  26194. * value: Object: key makeKey(axis.model), value: axisInfo
  26195. */
  26196. coordSysAxesInfo: {},
  26197. coordSysMap: {}
  26198. };
  26199. collectAxesInfo(result, ecModel, api);
  26200. // Check seriesInvolved for performance, in case too many series in some chart.
  26201. result.seriesInvolved && collectSeriesInfo(result, ecModel);
  26202. return result;
  26203. };
  26204. function collectAxesInfo(result, ecModel, api) {
  26205. var globalTooltipModel = ecModel.getComponent('tooltip');
  26206. var globalAxisPointerModel = ecModel.getComponent('axisPointer');
  26207. // links can only be set on global.
  26208. var linksOption = globalAxisPointerModel.get('link', true) || [];
  26209. var linkGroups = [];
  26210. // Collect axes info.
  26211. each(api.getCoordinateSystems(), function (coordSys) {
  26212. // Some coordinate system do not support axes, like geo.
  26213. if (!coordSys.axisPointerEnabled) {
  26214. return;
  26215. }
  26216. var coordSysKey = makeKey(coordSys.model);
  26217. var axesInfoInCoordSys = result.coordSysAxesInfo[coordSysKey] = {};
  26218. result.coordSysMap[coordSysKey] = coordSys;
  26219. // Set tooltip (like 'cross') is a convienent way to show axisPointer
  26220. // for user. So we enable seting tooltip on coordSys model.
  26221. var coordSysModel = coordSys.model;
  26222. var baseTooltipModel = coordSysModel.getModel('tooltip', globalTooltipModel);
  26223. each(coordSys.getAxes(), curry(saveTooltipAxisInfo, false, null));
  26224. // If axis tooltip used, choose tooltip axis for each coordSys.
  26225. // Notice this case: coordSys is `grid` but not `cartesian2D` here.
  26226. if (coordSys.getTooltipAxes
  26227. && globalTooltipModel
  26228. // If tooltip.showContent is set as false, tooltip will not
  26229. // show but axisPointer will show as normal.
  26230. && baseTooltipModel.get('show')
  26231. ) {
  26232. // Compatible with previous logic. But series.tooltip.trigger: 'axis'
  26233. // or series.data[n].tooltip.trigger: 'axis' are not support any more.
  26234. var triggerAxis = baseTooltipModel.get('trigger') === 'axis';
  26235. var cross = baseTooltipModel.get('axisPointer.type') === 'cross';
  26236. var tooltipAxes = coordSys.getTooltipAxes(baseTooltipModel.get('axisPointer.axis'));
  26237. if (triggerAxis || cross) {
  26238. each(tooltipAxes.baseAxes, curry(
  26239. saveTooltipAxisInfo, cross ? 'cross' : true, triggerAxis
  26240. ));
  26241. }
  26242. if (cross) {
  26243. each(tooltipAxes.otherAxes, curry(saveTooltipAxisInfo, 'cross', false));
  26244. }
  26245. }
  26246. // fromTooltip: true | false | 'cross'
  26247. // triggerTooltip: true | false | null
  26248. function saveTooltipAxisInfo(fromTooltip, triggerTooltip, axis) {
  26249. var axisPointerModel = axis.model.getModel('axisPointer', globalAxisPointerModel);
  26250. var axisPointerShow = axisPointerModel.get('show');
  26251. if (!axisPointerShow || (
  26252. axisPointerShow === 'auto'
  26253. && !fromTooltip
  26254. && !isHandleTrigger(axisPointerModel)
  26255. )) {
  26256. return;
  26257. }
  26258. if (triggerTooltip == null) {
  26259. triggerTooltip = axisPointerModel.get('triggerTooltip');
  26260. }
  26261. axisPointerModel = fromTooltip
  26262. ? makeAxisPointerModel(
  26263. axis, baseTooltipModel, globalAxisPointerModel, ecModel,
  26264. fromTooltip, triggerTooltip
  26265. )
  26266. : axisPointerModel;
  26267. var snap = axisPointerModel.get('snap');
  26268. var key = makeKey(axis.model);
  26269. var involveSeries = triggerTooltip || snap || axis.type === 'category';
  26270. // If result.axesInfo[key] exist, override it (tooltip has higher priority).
  26271. var axisInfo = result.axesInfo[key] = {
  26272. key: key,
  26273. axis: axis,
  26274. coordSys: coordSys,
  26275. axisPointerModel: axisPointerModel,
  26276. triggerTooltip: triggerTooltip,
  26277. involveSeries: involveSeries,
  26278. snap: snap,
  26279. useHandle: isHandleTrigger(axisPointerModel),
  26280. seriesModels: []
  26281. };
  26282. axesInfoInCoordSys[key] = axisInfo;
  26283. result.seriesInvolved |= involveSeries;
  26284. var groupIndex = getLinkGroupIndex(linksOption, axis);
  26285. if (groupIndex != null) {
  26286. var linkGroup = linkGroups[groupIndex] || (linkGroups[groupIndex] = {axesInfo: {}});
  26287. linkGroup.axesInfo[key] = axisInfo;
  26288. linkGroup.mapper = linksOption[groupIndex].mapper;
  26289. axisInfo.linkGroup = linkGroup;
  26290. }
  26291. }
  26292. });
  26293. }
  26294. function makeAxisPointerModel(
  26295. axis, baseTooltipModel, globalAxisPointerModel, ecModel, fromTooltip, triggerTooltip
  26296. ) {
  26297. var tooltipAxisPointerModel = baseTooltipModel.getModel('axisPointer');
  26298. var volatileOption = {};
  26299. each(
  26300. [
  26301. 'type', 'snap', 'lineStyle', 'shadowStyle', 'label',
  26302. 'animation', 'animationDurationUpdate', 'animationEasingUpdate', 'z'
  26303. ],
  26304. function (field) {
  26305. volatileOption[field] = zrUtil.clone(tooltipAxisPointerModel.get(field));
  26306. }
  26307. );
  26308. // category axis do not auto snap, otherwise some tick that do not
  26309. // has value can not be hovered. value/time/log axis default snap if
  26310. // triggered from tooltip and trigger tooltip.
  26311. volatileOption.snap = axis.type !== 'category' && !!triggerTooltip;
  26312. // Compatibel with previous behavior, tooltip axis do not show label by default.
  26313. // Only these properties can be overrided from tooltip to axisPointer.
  26314. if (tooltipAxisPointerModel.get('type') === 'cross') {
  26315. volatileOption.type = 'line';
  26316. }
  26317. var labelOption = volatileOption.label || (volatileOption.label = {});
  26318. // Follow the convention, do not show label when triggered by tooltip by default.
  26319. labelOption.show == null && (labelOption.show = false);
  26320. if (fromTooltip === 'cross') {
  26321. // When 'cross', both axes show labels.
  26322. labelOption.show = true;
  26323. // If triggerTooltip, this is a base axis, which should better not use cross style
  26324. // (cross style is dashed by default)
  26325. if (!triggerTooltip) {
  26326. var crossStyle = volatileOption.lineStyle = tooltipAxisPointerModel.get('crossStyle');
  26327. crossStyle && zrUtil.defaults(
  26328. labelOption.textStyle || (labelOption.textStyle = {}),
  26329. crossStyle.textStyle
  26330. );
  26331. }
  26332. }
  26333. return axis.model.getModel(
  26334. 'axisPointer',
  26335. new Model(volatileOption, globalAxisPointerModel, ecModel)
  26336. );
  26337. }
  26338. function collectSeriesInfo(result, ecModel) {
  26339. // Prepare data for axis trigger
  26340. ecModel.eachSeries(function (seriesModel) {
  26341. // Notice this case: this coordSys is `cartesian2D` but not `grid`.
  26342. var coordSys = seriesModel.coordinateSystem;
  26343. var seriesTooltipTrigger = seriesModel.get('tooltip.trigger', true);
  26344. var seriesTooltipShow = seriesModel.get('tooltip.show', true);
  26345. if (!coordSys
  26346. || seriesTooltipTrigger === 'none'
  26347. || seriesTooltipTrigger === false
  26348. || seriesTooltipTrigger === 'item'
  26349. || seriesTooltipShow === false
  26350. || seriesModel.get('axisPointer.show', true) === false
  26351. ) {
  26352. return;
  26353. }
  26354. each(result.coordSysAxesInfo[makeKey(coordSys.model)], function (axisInfo) {
  26355. var axis = axisInfo.axis;
  26356. if (coordSys.getAxis(axis.dim) === axis) {
  26357. axisInfo.seriesModels.push(seriesModel);
  26358. axisInfo.seriesDataCount == null && (axisInfo.seriesDataCount = 0);
  26359. axisInfo.seriesDataCount += seriesModel.getData().count();
  26360. }
  26361. });
  26362. }, this);
  26363. }
  26364. /**
  26365. * For example:
  26366. * {
  26367. * axisPointer: {
  26368. * links: [{
  26369. * xAxisIndex: [2, 4],
  26370. * yAxisIndex: 'all'
  26371. * }, {
  26372. * xAxisId: ['a5', 'a7'],
  26373. * xAxisName: 'xxx'
  26374. * }]
  26375. * }
  26376. * }
  26377. */
  26378. function getLinkGroupIndex(linksOption, axis) {
  26379. var axisModel = axis.model;
  26380. var dim = axis.dim;
  26381. for (var i = 0; i < linksOption.length; i++) {
  26382. var linkOption = linksOption[i] || {};
  26383. if (checkPropInLink(linkOption[dim + 'AxisId'], axisModel.id)
  26384. || checkPropInLink(linkOption[dim + 'AxisIndex'], axisModel.componentIndex)
  26385. || checkPropInLink(linkOption[dim + 'AxisName'], axisModel.name)
  26386. ) {
  26387. return i;
  26388. }
  26389. }
  26390. }
  26391. function checkPropInLink(linkPropValue, axisPropValue) {
  26392. return linkPropValue === 'all'
  26393. || (zrUtil.isArray(linkPropValue) && zrUtil.indexOf(linkPropValue, axisPropValue) >= 0)
  26394. || linkPropValue === axisPropValue;
  26395. }
  26396. helper.fixValue = function (axisModel) {
  26397. var axisInfo = helper.getAxisInfo(axisModel);
  26398. if (!axisInfo) {
  26399. return;
  26400. }
  26401. var axisPointerModel = axisInfo.axisPointerModel;
  26402. var scale = axisInfo.axis.scale;
  26403. var option = axisPointerModel.option;
  26404. var status = axisPointerModel.get('status');
  26405. var value = axisPointerModel.get('value');
  26406. // Parse init value for category and time axis.
  26407. if (value != null) {
  26408. value = scale.parse(value);
  26409. }
  26410. var useHandle = isHandleTrigger(axisPointerModel);
  26411. // If `handle` used, `axisPointer` will always be displayed, so value
  26412. // and status should be initialized.
  26413. if (status == null) {
  26414. option.status = useHandle ? 'show' : 'hide';
  26415. }
  26416. var extent = scale.getExtent().slice();
  26417. extent[0] > extent[1] && extent.reverse();
  26418. if (// Pick a value on axis when initializing.
  26419. value == null
  26420. // If both `handle` and `dataZoom` are used, value may be out of axis extent,
  26421. // where we should re-pick a value to keep `handle` displaying normally.
  26422. || value > extent[1]
  26423. ) {
  26424. // Make handle displayed on the end of the axis when init, which looks better.
  26425. value = extent[1];
  26426. }
  26427. if (value < extent[0]) {
  26428. value = extent[0];
  26429. }
  26430. option.value = value;
  26431. if (useHandle) {
  26432. option.status = axisInfo.axis.scale.isBlank() ? 'hide' : 'show';
  26433. }
  26434. };
  26435. helper.getAxisInfo = function (axisModel) {
  26436. var coordSysAxesInfo = (axisModel.ecModel.getComponent('axisPointer') || {}).coordSysAxesInfo;
  26437. return coordSysAxesInfo && coordSysAxesInfo.axesInfo[makeKey(axisModel)];
  26438. };
  26439. helper.getAxisPointerModel = function (axisModel) {
  26440. var axisInfo = helper.getAxisInfo(axisModel);
  26441. return axisInfo && axisInfo.axisPointerModel;
  26442. };
  26443. function isHandleTrigger(axisPointerModel) {
  26444. return !!axisPointerModel.get('handle.show');
  26445. }
  26446. /**
  26447. * @param {module:echarts/model/Model} model
  26448. * @return {string} unique key
  26449. */
  26450. var makeKey = helper.makeKey = function (model) {
  26451. return model.type + '||' + model.id;
  26452. };
  26453. module.exports = helper;
  26454. /***/ },
  26455. /* 138 */
  26456. /***/ function(module, exports, __webpack_require__) {
  26457. var zrUtil = __webpack_require__(4);
  26458. var helper = {};
  26459. /**
  26460. * @param {Object} opt {labelInside}
  26461. * @return {Object} {
  26462. * position, rotation, labelDirection, labelOffset,
  26463. * tickDirection, labelRotate, labelInterval, z2
  26464. * }
  26465. */
  26466. helper.layout = function (gridModel, axisModel, opt) {
  26467. opt = opt || {};
  26468. var grid = gridModel.coordinateSystem;
  26469. var axis = axisModel.axis;
  26470. var layout = {};
  26471. var rawAxisPosition = axis.position;
  26472. var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition;
  26473. var axisDim = axis.dim;
  26474. // [left, right, top, bottom]
  26475. var rect = grid.getRect();
  26476. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  26477. var axisOffset = axisModel.get('offset') || 0;
  26478. var posMap = {
  26479. x: { top: rectBound[2] - axisOffset, bottom: rectBound[3] + axisOffset },
  26480. y: { left: rectBound[0] - axisOffset, right: rectBound[1] + axisOffset }
  26481. };
  26482. posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top);
  26483. posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left);
  26484. function getZero(dim, val) {
  26485. var theAxis = grid.getAxis(dim);
  26486. return theAxis.toGlobalCoord(theAxis.dataToCoord(0));
  26487. }
  26488. // Axis position
  26489. layout.position = [
  26490. axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0],
  26491. axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3]
  26492. ];
  26493. // Axis rotation
  26494. layout.rotation = Math.PI / 2 * (axisDim === 'x' ? 0 : 1);
  26495. // Tick and label direction, x y is axisDim
  26496. var dirMap = {top: -1, bottom: 1, left: -1, right: 1};
  26497. layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition];
  26498. layout.labelOffset = axis.onZero ? posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero : 0;
  26499. if (axisModel.get('axisTick.inside')) {
  26500. layout.tickDirection = -layout.tickDirection;
  26501. }
  26502. if (zrUtil.retrieve(opt.labelInside, axisModel.get('axisLabel.inside'))) {
  26503. layout.labelDirection = -layout.labelDirection;
  26504. }
  26505. // Special label rotation
  26506. var labelRotate = axisModel.get('axisLabel.rotate');
  26507. layout.labelRotate = axisPosition === 'top' ? -labelRotate : labelRotate;
  26508. // label interval when auto mode.
  26509. layout.labelInterval = axis.getLabelInterval();
  26510. // Over splitLine and splitArea
  26511. layout.z2 = 1;
  26512. return layout;
  26513. };
  26514. module.exports = helper;
  26515. /***/ },
  26516. /* 139 */
  26517. /***/ function(module, exports, __webpack_require__) {
  26518. var zrUtil = __webpack_require__(4);
  26519. __webpack_require__(125);
  26520. __webpack_require__(140);
  26521. __webpack_require__(142);
  26522. var barLayoutGrid = __webpack_require__(145);
  26523. var echarts = __webpack_require__(1);
  26524. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
  26525. // Visual coding for legend
  26526. echarts.registerVisual(function (ecModel) {
  26527. ecModel.eachSeriesByType('bar', function (seriesModel) {
  26528. var data = seriesModel.getData();
  26529. data.setVisual('legendSymbol', 'roundRect');
  26530. });
  26531. });
  26532. // In case developer forget to include grid component
  26533. __webpack_require__(124);
  26534. /***/ },
  26535. /* 140 */
  26536. /***/ function(module, exports, __webpack_require__) {
  26537. module.exports = __webpack_require__(141).extend({
  26538. type: 'series.bar',
  26539. dependencies: ['grid', 'polar'],
  26540. brushSelector: 'rect'
  26541. });
  26542. /***/ },
  26543. /* 141 */
  26544. /***/ function(module, exports, __webpack_require__) {
  26545. 'use strict';
  26546. var SeriesModel = __webpack_require__(78);
  26547. var createListFromArray = __webpack_require__(109);
  26548. module.exports = SeriesModel.extend({
  26549. type: 'series.__base_bar__',
  26550. getInitialData: function (option, ecModel) {
  26551. return createListFromArray(option.data, this, ecModel);
  26552. },
  26553. getMarkerPosition: function (value) {
  26554. var coordSys = this.coordinateSystem;
  26555. if (coordSys) {
  26556. // PENDING if clamp ?
  26557. var pt = coordSys.dataToPoint(value, true);
  26558. var data = this.getData();
  26559. var offset = data.getLayout('offset');
  26560. var size = data.getLayout('size');
  26561. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
  26562. pt[offsetIndex] += offset + size / 2;
  26563. return pt;
  26564. }
  26565. return [NaN, NaN];
  26566. },
  26567. defaultOption: {
  26568. zlevel: 0, // 一级层叠
  26569. z: 2, // 二级层叠
  26570. coordinateSystem: 'cartesian2d',
  26571. legendHoverLink: true,
  26572. // stack: null
  26573. // Cartesian coordinate system
  26574. // xAxisIndex: 0,
  26575. // yAxisIndex: 0,
  26576. // 最小高度改为0
  26577. barMinHeight: 0,
  26578. // 最小角度为0,仅对极坐标系下的柱状图有效
  26579. barMinAngle: 0,
  26580. // cursor: null,
  26581. // barMaxWidth: null,
  26582. // 默认自适应
  26583. // barWidth: null,
  26584. // 柱间距离,默认为柱形宽度的30%,可设固定值
  26585. // barGap: '30%',
  26586. // 类目间柱形距离,默认为类目间距的20%,可设固定值
  26587. // barCategoryGap: '20%',
  26588. // label: {
  26589. // normal: {
  26590. // show: false
  26591. // }
  26592. // },
  26593. itemStyle: {
  26594. normal: {
  26595. // color: '各异'
  26596. },
  26597. emphasis: {}
  26598. }
  26599. }
  26600. });
  26601. /***/ },
  26602. /* 142 */
  26603. /***/ function(module, exports, __webpack_require__) {
  26604. 'use strict';
  26605. var zrUtil = __webpack_require__(4);
  26606. var graphic = __webpack_require__(18);
  26607. var helper = __webpack_require__(143);
  26608. var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'normal', 'barBorderWidth'];
  26609. // FIXME
  26610. // Just for compatible with ec2.
  26611. zrUtil.extend(__webpack_require__(12).prototype, __webpack_require__(144));
  26612. var BarView = __webpack_require__(1).extendChartView({
  26613. type: 'bar',
  26614. render: function (seriesModel, ecModel, api) {
  26615. var coordinateSystemType = seriesModel.get('coordinateSystem');
  26616. if (coordinateSystemType === 'cartesian2d'
  26617. || coordinateSystemType === 'polar'
  26618. ) {
  26619. this._render(seriesModel, ecModel, api);
  26620. }
  26621. else if (true) {
  26622. console.warn('Only cartesian2d and polar supported for bar.');
  26623. }
  26624. return this.group;
  26625. },
  26626. dispose: zrUtil.noop,
  26627. _render: function (seriesModel, ecModel, api) {
  26628. var group = this.group;
  26629. var data = seriesModel.getData();
  26630. var oldData = this._data;
  26631. var coord = seriesModel.coordinateSystem;
  26632. var baseAxis = coord.getBaseAxis();
  26633. var isHorizontalOrRadial;
  26634. if (coord.type === 'cartesian2d') {
  26635. isHorizontalOrRadial = baseAxis.isHorizontal();
  26636. }
  26637. else if (coord.type === 'polar') {
  26638. isHorizontalOrRadial = baseAxis.dim === 'angle';
  26639. }
  26640. var animationModel = seriesModel.isAnimationEnabled() ? seriesModel : null;
  26641. data.diff(oldData)
  26642. .add(function (dataIndex) {
  26643. if (!data.hasValue(dataIndex)) {
  26644. return;
  26645. }
  26646. var itemModel = data.getItemModel(dataIndex);
  26647. var layout = getLayout[coord.type](data, dataIndex, itemModel);
  26648. var el = elementCreator[coord.type](
  26649. data, dataIndex, itemModel, layout, isHorizontalOrRadial, animationModel
  26650. );
  26651. data.setItemGraphicEl(dataIndex, el);
  26652. group.add(el);
  26653. updateStyle(
  26654. el, data, dataIndex, itemModel, layout,
  26655. seriesModel, isHorizontalOrRadial, coord.type === 'polar'
  26656. );
  26657. })
  26658. .update(function (newIndex, oldIndex) {
  26659. var el = oldData.getItemGraphicEl(oldIndex);
  26660. if (!data.hasValue(newIndex)) {
  26661. group.remove(el);
  26662. return;
  26663. }
  26664. var itemModel = data.getItemModel(newIndex);
  26665. var layout = getLayout[coord.type](data, newIndex, itemModel);
  26666. if (el) {
  26667. graphic.updateProps(el, {shape: layout}, animationModel, newIndex);
  26668. }
  26669. else {
  26670. el = elementCreator[coord.type](
  26671. data, newIndex, itemModel, layout, isHorizontalOrRadial, animationModel, true
  26672. );
  26673. }
  26674. data.setItemGraphicEl(newIndex, el);
  26675. // Add back
  26676. group.add(el);
  26677. updateStyle(
  26678. el, data, newIndex, itemModel, layout,
  26679. seriesModel, isHorizontalOrRadial, coord.type === 'polar'
  26680. );
  26681. })
  26682. .remove(function (dataIndex) {
  26683. var el = oldData.getItemGraphicEl(dataIndex);
  26684. if (coord.type === 'cartesian2d') {
  26685. el && removeRect(dataIndex, animationModel, el);
  26686. }
  26687. else {
  26688. el && removeSector(dataIndex, animationModel, el);
  26689. }
  26690. })
  26691. .execute();
  26692. this._data = data;
  26693. },
  26694. remove: function (ecModel, api) {
  26695. var group = this.group;
  26696. var data = this._data;
  26697. if (ecModel.get('animation')) {
  26698. if (data) {
  26699. data.eachItemGraphicEl(function (el) {
  26700. if (el.type === 'sector') {
  26701. removeSector(el.dataIndex, ecModel, el);
  26702. }
  26703. else {
  26704. removeRect(el.dataIndex, ecModel, el);
  26705. }
  26706. });
  26707. }
  26708. }
  26709. else {
  26710. group.removeAll();
  26711. }
  26712. }
  26713. });
  26714. var elementCreator = {
  26715. cartesian2d: function (
  26716. data, dataIndex, itemModel, layout, isHorizontal,
  26717. animationModel, isUpdate
  26718. ) {
  26719. var rect = new graphic.Rect({shape: zrUtil.extend({}, layout)});
  26720. // Animation
  26721. if (animationModel) {
  26722. var rectShape = rect.shape;
  26723. var animateProperty = isHorizontal ? 'height' : 'width';
  26724. var animateTarget = {};
  26725. rectShape[animateProperty] = 0;
  26726. animateTarget[animateProperty] = layout[animateProperty];
  26727. graphic[isUpdate ? 'updateProps' : 'initProps'](rect, {
  26728. shape: animateTarget
  26729. }, animationModel, dataIndex);
  26730. }
  26731. return rect;
  26732. },
  26733. polar: function (
  26734. data, dataIndex, itemModel, layout, isRadial,
  26735. animationModel, isUpdate
  26736. ) {
  26737. var sector = new graphic.Sector({shape: zrUtil.extend({}, layout)});
  26738. // Animation
  26739. if (animationModel) {
  26740. var sectorShape = sector.shape;
  26741. var animateProperty = isRadial ? 'r' : 'endAngle';
  26742. var animateTarget = {};
  26743. sectorShape[animateProperty] = isRadial ? 0 : layout.startAngle;
  26744. animateTarget[animateProperty] = layout[animateProperty];
  26745. graphic[isUpdate ? 'updateProps' : 'initProps'](sector, {
  26746. shape: animateTarget
  26747. }, animationModel, dataIndex);
  26748. }
  26749. return sector;
  26750. }
  26751. };
  26752. function removeRect(dataIndex, animationModel, el) {
  26753. // Not show text when animating
  26754. el.style.text = '';
  26755. graphic.updateProps(el, {
  26756. shape: {
  26757. width: 0
  26758. }
  26759. }, animationModel, dataIndex, function () {
  26760. el.parent && el.parent.remove(el);
  26761. });
  26762. }
  26763. function removeSector(dataIndex, animationModel, el) {
  26764. // Not show text when animating
  26765. el.style.text = '';
  26766. graphic.updateProps(el, {
  26767. shape: {
  26768. r: el.shape.r0
  26769. }
  26770. }, animationModel, dataIndex, function () {
  26771. el.parent && el.parent.remove(el);
  26772. });
  26773. }
  26774. var getLayout = {
  26775. cartesian2d: function (data, dataIndex, itemModel) {
  26776. var layout = data.getItemLayout(dataIndex);
  26777. var fixedLineWidth = getLineWidth(itemModel, layout);
  26778. // fix layout with lineWidth
  26779. var signX = layout.width > 0 ? 1 : -1;
  26780. var signY = layout.height > 0 ? 1 : -1;
  26781. return {
  26782. x: layout.x + signX * fixedLineWidth / 2,
  26783. y: layout.y + signY * fixedLineWidth / 2,
  26784. width: layout.width - signX * fixedLineWidth,
  26785. height: layout.height - signY * fixedLineWidth
  26786. };
  26787. },
  26788. polar: function (data, dataIndex, itemModel) {
  26789. var layout = data.getItemLayout(dataIndex);
  26790. return {
  26791. cx: layout.cx,
  26792. cy: layout.cy,
  26793. r0: layout.r0,
  26794. r: layout.r,
  26795. startAngle: layout.startAngle,
  26796. endAngle: layout.endAngle
  26797. };
  26798. }
  26799. };
  26800. function updateStyle(
  26801. el, data, dataIndex, itemModel, layout, seriesModel, isHorizontal, isPolar
  26802. ) {
  26803. var color = data.getItemVisual(dataIndex, 'color');
  26804. var opacity = data.getItemVisual(dataIndex, 'opacity');
  26805. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  26806. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
  26807. if (!isPolar) {
  26808. el.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
  26809. }
  26810. el.useStyle(zrUtil.defaults(
  26811. {
  26812. fill: color,
  26813. opacity: opacity
  26814. },
  26815. itemStyleModel.getBarItemStyle()
  26816. ));
  26817. var cursorStyle = itemModel.getShallow('cursor');
  26818. cursorStyle && el.attr('cursor', cursorStyle);
  26819. var labelPositionOutside = isHorizontal
  26820. ? (layout.height > 0 ? 'bottom' : 'top')
  26821. : (layout.width > 0 ? 'left' : 'right');
  26822. if (!isPolar) {
  26823. helper.setLabel(
  26824. el.style, hoverStyle, itemModel, color,
  26825. seriesModel, dataIndex, labelPositionOutside
  26826. );
  26827. }
  26828. graphic.setHoverStyle(el, hoverStyle);
  26829. }
  26830. // In case width or height are too small.
  26831. function getLineWidth(itemModel, rawLayout) {
  26832. var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
  26833. return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
  26834. }
  26835. module.exports = BarView;
  26836. /***/ },
  26837. /* 143 */
  26838. /***/ function(module, exports, __webpack_require__) {
  26839. var zrUtil = __webpack_require__(4);
  26840. var graphic = __webpack_require__(18);
  26841. var helper = {};
  26842. helper.setLabel = function (
  26843. normalStyle, hoverStyle, itemModel, color, seriesModel, dataIndex, labelPositionOutside
  26844. ) {
  26845. var labelModel = itemModel.getModel('label.normal');
  26846. var hoverLabelModel = itemModel.getModel('label.emphasis');
  26847. if (labelModel.get('show')) {
  26848. setLabel(
  26849. normalStyle, labelModel, color,
  26850. zrUtil.retrieve(
  26851. seriesModel.getFormattedLabel(dataIndex, 'normal'),
  26852. seriesModel.getRawValue(dataIndex)
  26853. ),
  26854. labelPositionOutside
  26855. );
  26856. }
  26857. else {
  26858. normalStyle.text = '';
  26859. }
  26860. if (hoverLabelModel.get('show')) {
  26861. setLabel(
  26862. hoverStyle, hoverLabelModel, color,
  26863. zrUtil.retrieve(
  26864. seriesModel.getFormattedLabel(dataIndex, 'emphasis'),
  26865. seriesModel.getRawValue(dataIndex)
  26866. ),
  26867. labelPositionOutside
  26868. );
  26869. }
  26870. else {
  26871. hoverStyle.text = '';
  26872. }
  26873. };
  26874. function setLabel(style, model, color, labelText, labelPositionOutside) {
  26875. graphic.setText(style, model, color);
  26876. style.text = labelText;
  26877. if (style.textPosition === 'outside') {
  26878. style.textPosition = labelPositionOutside;
  26879. }
  26880. }
  26881. module.exports = helper;
  26882. /***/ },
  26883. /* 144 */
  26884. /***/ function(module, exports, __webpack_require__) {
  26885. var getBarItemStyle = __webpack_require__(15)(
  26886. [
  26887. ['fill', 'color'],
  26888. ['stroke', 'borderColor'],
  26889. ['lineWidth', 'borderWidth'],
  26890. // Compatitable with 2
  26891. ['stroke', 'barBorderColor'],
  26892. ['lineWidth', 'barBorderWidth'],
  26893. ['opacity'],
  26894. ['shadowBlur'],
  26895. ['shadowOffsetX'],
  26896. ['shadowOffsetY'],
  26897. ['shadowColor']
  26898. ]
  26899. );
  26900. module.exports = {
  26901. getBarItemStyle: function (excludes) {
  26902. var style = getBarItemStyle.call(this, excludes);
  26903. if (this.getBorderLineDash) {
  26904. var lineDash = this.getBorderLineDash();
  26905. lineDash && (style.lineDash = lineDash);
  26906. }
  26907. return style;
  26908. }
  26909. };
  26910. /***/ },
  26911. /* 145 */
  26912. /***/ function(module, exports, __webpack_require__) {
  26913. 'use strict';
  26914. var zrUtil = __webpack_require__(4);
  26915. var numberUtil = __webpack_require__(7);
  26916. var parsePercent = numberUtil.parsePercent;
  26917. var STACK_PREFIX = '__ec_stack_';
  26918. function getSeriesStackId(seriesModel) {
  26919. return seriesModel.get('stack') || STACK_PREFIX + seriesModel.seriesIndex;
  26920. }
  26921. function getAxisKey(axis) {
  26922. return axis.dim + axis.index;
  26923. }
  26924. /**
  26925. * @param {Object} opt
  26926. * @param {module:echarts/coord/Axis} opt.axis Only support category axis currently.
  26927. * @param {number} opt.count Positive interger.
  26928. * @param {number} [opt.barWidth]
  26929. * @param {number} [opt.barMaxWidth]
  26930. * @param {number} [opt.barGap]
  26931. * @param {number} [opt.barCategoryGap]
  26932. * @return {Object} {width, offset, offsetCenter} If axis.type is not 'category', return undefined.
  26933. */
  26934. function getLayoutOnAxis(opt, api) {
  26935. var params = [];
  26936. var baseAxis = opt.axis;
  26937. var axisKey = 'axis0';
  26938. if (baseAxis.type !== 'category') {
  26939. return;
  26940. }
  26941. var bandWidth = baseAxis.getBandWidth();
  26942. for (var i = 0; i < opt.count || 0; i++) {
  26943. params.push(zrUtil.defaults({
  26944. bandWidth: bandWidth,
  26945. axisKey: axisKey,
  26946. stackId: STACK_PREFIX + i
  26947. }, opt));
  26948. }
  26949. var widthAndOffsets = doCalBarWidthAndOffset(params, api);
  26950. var result = [];
  26951. for (var i = 0; i < opt.count; i++) {
  26952. var item = widthAndOffsets[axisKey][STACK_PREFIX + i];
  26953. item.offsetCenter = item.offset + item.width / 2;
  26954. result.push(item);
  26955. }
  26956. return result;
  26957. }
  26958. function calBarWidthAndOffset(barSeries, api) {
  26959. var seriesInfoList = zrUtil.map(barSeries, function (seriesModel) {
  26960. var data = seriesModel.getData();
  26961. var cartesian = seriesModel.coordinateSystem;
  26962. var baseAxis = cartesian.getBaseAxis();
  26963. var axisExtent = baseAxis.getExtent();
  26964. var bandWidth = baseAxis.type === 'category'
  26965. ? baseAxis.getBandWidth()
  26966. : (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
  26967. var barWidth = parsePercent(
  26968. seriesModel.get('barWidth'), bandWidth
  26969. );
  26970. var barMaxWidth = parsePercent(
  26971. seriesModel.get('barMaxWidth'), bandWidth
  26972. );
  26973. var barGap = seriesModel.get('barGap');
  26974. var barCategoryGap = seriesModel.get('barCategoryGap');
  26975. return {
  26976. bandWidth: bandWidth,
  26977. barWidth: barWidth,
  26978. barMaxWidth: barMaxWidth,
  26979. barGap: barGap,
  26980. barCategoryGap: barCategoryGap,
  26981. axisKey: getAxisKey(baseAxis),
  26982. stackId: getSeriesStackId(seriesModel)
  26983. };
  26984. });
  26985. return doCalBarWidthAndOffset(seriesInfoList, api);
  26986. }
  26987. function doCalBarWidthAndOffset(seriesInfoList, api) {
  26988. // Columns info on each category axis. Key is cartesian name
  26989. var columnsMap = {};
  26990. zrUtil.each(seriesInfoList, function (seriesInfo, idx) {
  26991. var axisKey = seriesInfo.axisKey;
  26992. var bandWidth = seriesInfo.bandWidth;
  26993. var columnsOnAxis = columnsMap[axisKey] || {
  26994. bandWidth: bandWidth,
  26995. remainedWidth: bandWidth,
  26996. autoWidthCount: 0,
  26997. categoryGap: '20%',
  26998. gap: '30%',
  26999. stacks: {}
  27000. };
  27001. var stacks = columnsOnAxis.stacks;
  27002. columnsMap[axisKey] = columnsOnAxis;
  27003. var stackId = seriesInfo.stackId;
  27004. if (!stacks[stackId]) {
  27005. columnsOnAxis.autoWidthCount++;
  27006. }
  27007. stacks[stackId] = stacks[stackId] || {
  27008. width: 0,
  27009. maxWidth: 0
  27010. };
  27011. // Caution: In a single coordinate system, these barGrid attributes
  27012. // will be shared by series. Consider that they have default values,
  27013. // only the attributes set on the last series will work.
  27014. // Do not change this fact unless there will be a break change.
  27015. // TODO
  27016. var barWidth = seriesInfo.barWidth;
  27017. if (barWidth && !stacks[stackId].width) {
  27018. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  27019. stacks[stackId].width = barWidth;
  27020. columnsOnAxis.remainedWidth -= barWidth;
  27021. }
  27022. var barMaxWidth = seriesInfo.barMaxWidth;
  27023. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  27024. var barGap = seriesInfo.barGap;
  27025. (barGap != null) && (columnsOnAxis.gap = barGap);
  27026. var barCategoryGap = seriesInfo.barCategoryGap;
  27027. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  27028. });
  27029. var result = {};
  27030. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  27031. result[coordSysName] = {};
  27032. var stacks = columnsOnAxis.stacks;
  27033. var bandWidth = columnsOnAxis.bandWidth;
  27034. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  27035. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  27036. var remainedWidth = columnsOnAxis.remainedWidth;
  27037. var autoWidthCount = columnsOnAxis.autoWidthCount;
  27038. var autoWidth = (remainedWidth - categoryGap)
  27039. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  27040. autoWidth = Math.max(autoWidth, 0);
  27041. // Find if any auto calculated bar exceeded maxBarWidth
  27042. zrUtil.each(stacks, function (column, stack) {
  27043. var maxWidth = column.maxWidth;
  27044. if (maxWidth && maxWidth < autoWidth) {
  27045. maxWidth = Math.min(maxWidth, remainedWidth);
  27046. if (column.width) {
  27047. maxWidth = Math.min(maxWidth, column.width);
  27048. }
  27049. remainedWidth -= maxWidth;
  27050. column.width = maxWidth;
  27051. autoWidthCount--;
  27052. }
  27053. });
  27054. // Recalculate width again
  27055. autoWidth = (remainedWidth - categoryGap)
  27056. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  27057. autoWidth = Math.max(autoWidth, 0);
  27058. var widthSum = 0;
  27059. var lastColumn;
  27060. zrUtil.each(stacks, function (column, idx) {
  27061. if (!column.width) {
  27062. column.width = autoWidth;
  27063. }
  27064. lastColumn = column;
  27065. widthSum += column.width * (1 + barGapPercent);
  27066. });
  27067. if (lastColumn) {
  27068. widthSum -= lastColumn.width * barGapPercent;
  27069. }
  27070. var offset = -widthSum / 2;
  27071. zrUtil.each(stacks, function (column, stackId) {
  27072. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  27073. offset: offset,
  27074. width: column.width
  27075. };
  27076. offset += column.width * (1 + barGapPercent);
  27077. });
  27078. });
  27079. return result;
  27080. }
  27081. /**
  27082. * @param {string} seriesType
  27083. * @param {module:echarts/model/Global} ecModel
  27084. * @param {module:echarts/ExtensionAPI} api
  27085. */
  27086. function barLayoutGrid(seriesType, ecModel, api) {
  27087. var barWidthAndOffset = calBarWidthAndOffset(
  27088. zrUtil.filter(
  27089. ecModel.getSeriesByType(seriesType),
  27090. function (seriesModel) {
  27091. return !ecModel.isSeriesFiltered(seriesModel)
  27092. && seriesModel.coordinateSystem
  27093. && seriesModel.coordinateSystem.type === 'cartesian2d';
  27094. }
  27095. )
  27096. );
  27097. var lastStackCoords = {};
  27098. var lastStackCoordsOrigin = {};
  27099. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  27100. // Check series coordinate, do layout for cartesian2d only
  27101. if (seriesModel.coordinateSystem.type !== 'cartesian2d') {
  27102. return;
  27103. }
  27104. var data = seriesModel.getData();
  27105. var cartesian = seriesModel.coordinateSystem;
  27106. var baseAxis = cartesian.getBaseAxis();
  27107. var stackId = getSeriesStackId(seriesModel);
  27108. var columnLayoutInfo = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
  27109. var columnOffset = columnLayoutInfo.offset;
  27110. var columnWidth = columnLayoutInfo.width;
  27111. var valueAxis = cartesian.getOtherAxis(baseAxis);
  27112. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  27113. var valueAxisStart = baseAxis.onZero
  27114. ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0))
  27115. : valueAxis.getGlobalExtent()[0];
  27116. var coords = cartesian.dataToPoints(data, true);
  27117. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  27118. lastStackCoordsOrigin[stackId] = lastStackCoordsOrigin[stackId] || []; // Fix #4243
  27119. data.setLayout({
  27120. offset: columnOffset,
  27121. size: columnWidth
  27122. });
  27123. data.each(valueAxis.dim, function (value, idx) {
  27124. if (isNaN(value)) {
  27125. return;
  27126. }
  27127. if (!lastStackCoords[stackId][idx]) {
  27128. lastStackCoords[stackId][idx] = {
  27129. p: valueAxisStart, // Positive stack
  27130. n: valueAxisStart // Negative stack
  27131. };
  27132. lastStackCoordsOrigin[stackId][idx] = {
  27133. p: valueAxisStart, // Positive stack
  27134. n: valueAxisStart // Negative stack
  27135. };
  27136. }
  27137. var sign = value >= 0 ? 'p' : 'n';
  27138. var coord = coords[idx];
  27139. var lastCoord = lastStackCoords[stackId][idx][sign];
  27140. var lastCoordOrigin = lastStackCoordsOrigin[stackId][idx][sign];
  27141. var x;
  27142. var y;
  27143. var width;
  27144. var height;
  27145. if (valueAxis.isHorizontal()) {
  27146. x = lastCoord;
  27147. y = coord[1] + columnOffset;
  27148. width = coord[0] - lastCoordOrigin;
  27149. height = columnWidth;
  27150. lastStackCoordsOrigin[stackId][idx][sign] += width;
  27151. if (Math.abs(width) < barMinHeight) {
  27152. width = (width < 0 ? -1 : 1) * barMinHeight;
  27153. }
  27154. lastStackCoords[stackId][idx][sign] += width;
  27155. }
  27156. else {
  27157. x = coord[0] + columnOffset;
  27158. y = lastCoord;
  27159. width = columnWidth;
  27160. height = coord[1] - lastCoordOrigin;
  27161. lastStackCoordsOrigin[stackId][idx][sign] += height;
  27162. if (Math.abs(height) < barMinHeight) {
  27163. // Include zero to has a positive bar
  27164. height = (height <= 0 ? -1 : 1) * barMinHeight;
  27165. }
  27166. lastStackCoords[stackId][idx][sign] += height;
  27167. }
  27168. data.setItemLayout(idx, {
  27169. x: x,
  27170. y: y,
  27171. width: width,
  27172. height: height
  27173. });
  27174. }, true);
  27175. }, this);
  27176. }
  27177. barLayoutGrid.getLayoutOnAxis = getLayoutOnAxis;
  27178. module.exports = barLayoutGrid;
  27179. /***/ },
  27180. /* 146 */
  27181. /***/ function(module, exports, __webpack_require__) {
  27182. var zrUtil = __webpack_require__(4);
  27183. var echarts = __webpack_require__(1);
  27184. __webpack_require__(147);
  27185. __webpack_require__(149);
  27186. __webpack_require__(150)('pie', [{
  27187. type: 'pieToggleSelect',
  27188. event: 'pieselectchanged',
  27189. method: 'toggleSelected'
  27190. }, {
  27191. type: 'pieSelect',
  27192. event: 'pieselected',
  27193. method: 'select'
  27194. }, {
  27195. type: 'pieUnSelect',
  27196. event: 'pieunselected',
  27197. method: 'unSelect'
  27198. }]);
  27199. echarts.registerVisual(zrUtil.curry(__webpack_require__(151), 'pie'));
  27200. echarts.registerLayout(zrUtil.curry(
  27201. __webpack_require__(152), 'pie'
  27202. ));
  27203. echarts.registerProcessor(zrUtil.curry(__webpack_require__(154), 'pie'));
  27204. /***/ },
  27205. /* 147 */
  27206. /***/ function(module, exports, __webpack_require__) {
  27207. 'use strict';
  27208. var List = __webpack_require__(98);
  27209. var zrUtil = __webpack_require__(4);
  27210. var modelUtil = __webpack_require__(5);
  27211. var numberUtil = __webpack_require__(7);
  27212. var completeDimensions = __webpack_require__(110);
  27213. var dataSelectableMixin = __webpack_require__(148);
  27214. var PieSeries = __webpack_require__(1).extendSeriesModel({
  27215. type: 'series.pie',
  27216. // Overwrite
  27217. init: function (option) {
  27218. PieSeries.superApply(this, 'init', arguments);
  27219. // Enable legend selection for each data item
  27220. // Use a function instead of direct access because data reference may changed
  27221. this.legendDataProvider = function () {
  27222. return this.getRawData();
  27223. };
  27224. this.updateSelectedMap(option.data);
  27225. this._defaultLabelLine(option);
  27226. },
  27227. // Overwrite
  27228. mergeOption: function (newOption) {
  27229. PieSeries.superCall(this, 'mergeOption', newOption);
  27230. this.updateSelectedMap(this.option.data);
  27231. },
  27232. getInitialData: function (option, ecModel) {
  27233. var dimensions = completeDimensions(['value'], option.data);
  27234. var list = new List(dimensions, this);
  27235. list.initData(option.data);
  27236. return list;
  27237. },
  27238. // Overwrite
  27239. getDataParams: function (dataIndex) {
  27240. var data = this.getData();
  27241. var params = PieSeries.superCall(this, 'getDataParams', dataIndex);
  27242. // FIXME toFixed?
  27243. var valueList = [];
  27244. data.each('value', function (value) {
  27245. valueList.push(value);
  27246. });
  27247. params.percent = numberUtil.getPercentWithPrecision(
  27248. valueList,
  27249. dataIndex,
  27250. data.hostModel.get('percentPrecision')
  27251. );
  27252. params.$vars.push('percent');
  27253. return params;
  27254. },
  27255. _defaultLabelLine: function (option) {
  27256. // Extend labelLine emphasis
  27257. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  27258. var labelLineNormalOpt = option.labelLine.normal;
  27259. var labelLineEmphasisOpt = option.labelLine.emphasis;
  27260. // Not show label line if `label.normal.show = false`
  27261. labelLineNormalOpt.show = labelLineNormalOpt.show
  27262. && option.label.normal.show;
  27263. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  27264. && option.label.emphasis.show;
  27265. },
  27266. defaultOption: {
  27267. zlevel: 0,
  27268. z: 2,
  27269. legendHoverLink: true,
  27270. hoverAnimation: true,
  27271. // 默认全局居中
  27272. center: ['50%', '50%'],
  27273. radius: [0, '75%'],
  27274. // 默认顺时针
  27275. clockwise: true,
  27276. startAngle: 90,
  27277. // 最小角度改为0
  27278. minAngle: 0,
  27279. // 选中是扇区偏移量
  27280. selectedOffset: 10,
  27281. // If use strategy to avoid label overlapping
  27282. avoidLabelOverlap: true,
  27283. // 选择模式,默认关闭,可选single,multiple
  27284. // selectedMode: false,
  27285. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  27286. // roseType: null,
  27287. percentPrecision: 2,
  27288. // If still show when all data zero.
  27289. stillShowZeroSum: true,
  27290. // cursor: null,
  27291. label: {
  27292. normal: {
  27293. // If rotate around circle
  27294. rotate: false,
  27295. show: true,
  27296. // 'outer', 'inside', 'center'
  27297. position: 'outer'
  27298. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  27299. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  27300. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  27301. },
  27302. emphasis: {}
  27303. },
  27304. // Enabled when label.normal.position is 'outer'
  27305. labelLine: {
  27306. normal: {
  27307. show: true,
  27308. // 引导线两段中的第一段长度
  27309. length: 15,
  27310. // 引导线两段中的第二段长度
  27311. length2: 15,
  27312. smooth: false,
  27313. lineStyle: {
  27314. // color: 各异,
  27315. width: 1,
  27316. type: 'solid'
  27317. }
  27318. }
  27319. },
  27320. itemStyle: {
  27321. normal: {
  27322. borderWidth: 1
  27323. },
  27324. emphasis: {}
  27325. },
  27326. // Animation type canbe expansion, scale
  27327. animationType: 'expansion',
  27328. animationEasing: 'cubicOut',
  27329. data: []
  27330. }
  27331. });
  27332. zrUtil.mixin(PieSeries, dataSelectableMixin);
  27333. module.exports = PieSeries;
  27334. /***/ },
  27335. /* 148 */
  27336. /***/ function(module, exports, __webpack_require__) {
  27337. /**
  27338. * Data selectable mixin for chart series.
  27339. * To eanble data select, option of series must have `selectedMode`.
  27340. * And each data item will use `selected` to toggle itself selected status
  27341. *
  27342. * @module echarts/chart/helper/DataSelectable
  27343. */
  27344. var zrUtil = __webpack_require__(4);
  27345. module.exports = {
  27346. updateSelectedMap: function (targetList) {
  27347. this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
  27348. targetMap.set(target.name, target);
  27349. return targetMap;
  27350. }, zrUtil.createHashMap());
  27351. },
  27352. /**
  27353. * @param {string} name
  27354. */
  27355. // PENGING If selectedMode is null ?
  27356. select: function (name) {
  27357. var targetMap = this._selectTargetMap;
  27358. var target = targetMap.get(name);
  27359. var selectedMode = this.get('selectedMode');
  27360. if (selectedMode === 'single') {
  27361. targetMap.each(function (target) {
  27362. target.selected = false;
  27363. });
  27364. }
  27365. target && (target.selected = true);
  27366. },
  27367. /**
  27368. * @param {string} name
  27369. */
  27370. unSelect: function (name) {
  27371. var target = this._selectTargetMap.get(name);
  27372. // var selectedMode = this.get('selectedMode');
  27373. // selectedMode !== 'single' && target && (target.selected = false);
  27374. target && (target.selected = false);
  27375. },
  27376. /**
  27377. * @param {string} name
  27378. */
  27379. toggleSelected: function (name) {
  27380. var target = this._selectTargetMap.get(name);
  27381. if (target != null) {
  27382. this[target.selected ? 'unSelect' : 'select'](name);
  27383. return target.selected;
  27384. }
  27385. },
  27386. /**
  27387. * @param {string} name
  27388. */
  27389. isSelected: function (name) {
  27390. var target = this._selectTargetMap.get(name);
  27391. return target && target.selected;
  27392. }
  27393. };
  27394. /***/ },
  27395. /* 149 */
  27396. /***/ function(module, exports, __webpack_require__) {
  27397. var graphic = __webpack_require__(18);
  27398. var zrUtil = __webpack_require__(4);
  27399. /**
  27400. * @param {module:echarts/model/Series} seriesModel
  27401. * @param {boolean} hasAnimation
  27402. * @inner
  27403. */
  27404. function updateDataSelected(uid, seriesModel, hasAnimation, api) {
  27405. var data = seriesModel.getData();
  27406. var dataIndex = this.dataIndex;
  27407. var name = data.getName(dataIndex);
  27408. var selectedOffset = seriesModel.get('selectedOffset');
  27409. api.dispatchAction({
  27410. type: 'pieToggleSelect',
  27411. from: uid,
  27412. name: name,
  27413. seriesId: seriesModel.id
  27414. });
  27415. data.each(function (idx) {
  27416. toggleItemSelected(
  27417. data.getItemGraphicEl(idx),
  27418. data.getItemLayout(idx),
  27419. seriesModel.isSelected(data.getName(idx)),
  27420. selectedOffset,
  27421. hasAnimation
  27422. );
  27423. });
  27424. }
  27425. /**
  27426. * @param {module:zrender/graphic/Sector} el
  27427. * @param {Object} layout
  27428. * @param {boolean} isSelected
  27429. * @param {number} selectedOffset
  27430. * @param {boolean} hasAnimation
  27431. * @inner
  27432. */
  27433. function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) {
  27434. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  27435. var dx = Math.cos(midAngle);
  27436. var dy = Math.sin(midAngle);
  27437. var offset = isSelected ? selectedOffset : 0;
  27438. var position = [dx * offset, dy * offset];
  27439. hasAnimation
  27440. // animateTo will stop revious animation like update transition
  27441. ? el.animate()
  27442. .when(200, {
  27443. position: position
  27444. })
  27445. .start('bounceOut')
  27446. : el.attr('position', position);
  27447. }
  27448. /**
  27449. * Piece of pie including Sector, Label, LabelLine
  27450. * @constructor
  27451. * @extends {module:zrender/graphic/Group}
  27452. */
  27453. function PiePiece(data, idx) {
  27454. graphic.Group.call(this);
  27455. var sector = new graphic.Sector({
  27456. z2: 2
  27457. });
  27458. var polyline = new graphic.Polyline();
  27459. var text = new graphic.Text();
  27460. this.add(sector);
  27461. this.add(polyline);
  27462. this.add(text);
  27463. this.updateData(data, idx, true);
  27464. // Hover to change label and labelLine
  27465. function onEmphasis() {
  27466. polyline.ignore = polyline.hoverIgnore;
  27467. text.ignore = text.hoverIgnore;
  27468. }
  27469. function onNormal() {
  27470. polyline.ignore = polyline.normalIgnore;
  27471. text.ignore = text.normalIgnore;
  27472. }
  27473. this.on('emphasis', onEmphasis)
  27474. .on('normal', onNormal)
  27475. .on('mouseover', onEmphasis)
  27476. .on('mouseout', onNormal);
  27477. }
  27478. var piePieceProto = PiePiece.prototype;
  27479. function getLabelStyle(data, idx, state, labelModel, labelPosition) {
  27480. var textStyleModel = labelModel.getModel('textStyle');
  27481. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  27482. return {
  27483. fill: textStyleModel.getTextColor()
  27484. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  27485. opacity: data.getItemVisual(idx, 'opacity'),
  27486. textFont: textStyleModel.getFont(),
  27487. text: zrUtil.retrieve(
  27488. data.hostModel.getFormattedLabel(idx, state), data.getName(idx)
  27489. )
  27490. };
  27491. }
  27492. piePieceProto.updateData = function (data, idx, firstCreate) {
  27493. var sector = this.childAt(0);
  27494. var seriesModel = data.hostModel;
  27495. var itemModel = data.getItemModel(idx);
  27496. var layout = data.getItemLayout(idx);
  27497. var sectorShape = zrUtil.extend({}, layout);
  27498. sectorShape.label = null;
  27499. if (firstCreate) {
  27500. sector.setShape(sectorShape);
  27501. var animationType = seriesModel.getShallow('animationType');
  27502. if (animationType === 'scale') {
  27503. sector.shape.r = layout.r0;
  27504. graphic.initProps(sector, {
  27505. shape: {
  27506. r: layout.r
  27507. }
  27508. }, seriesModel, idx);
  27509. }
  27510. // Expansion
  27511. else {
  27512. sector.shape.endAngle = layout.startAngle;
  27513. graphic.updateProps(sector, {
  27514. shape: {
  27515. endAngle: layout.endAngle
  27516. }
  27517. }, seriesModel, idx);
  27518. }
  27519. }
  27520. else {
  27521. graphic.updateProps(sector, {
  27522. shape: sectorShape
  27523. }, seriesModel, idx);
  27524. }
  27525. // Update common style
  27526. var itemStyleModel = itemModel.getModel('itemStyle');
  27527. var visualColor = data.getItemVisual(idx, 'color');
  27528. sector.useStyle(
  27529. zrUtil.defaults(
  27530. {
  27531. lineJoin: 'bevel',
  27532. fill: visualColor
  27533. },
  27534. itemStyleModel.getModel('normal').getItemStyle()
  27535. )
  27536. );
  27537. sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  27538. var cursorStyle = itemModel.getShallow('cursor');
  27539. cursorStyle && sector.attr('cursor', cursorStyle);
  27540. // Toggle selected
  27541. toggleItemSelected(
  27542. this,
  27543. data.getItemLayout(idx),
  27544. itemModel.get('selected'),
  27545. seriesModel.get('selectedOffset'),
  27546. seriesModel.get('animation')
  27547. );
  27548. function onEmphasis() {
  27549. // Sector may has animation of updating data. Force to move to the last frame
  27550. // Or it may stopped on the wrong shape
  27551. sector.stopAnimation(true);
  27552. sector.animateTo({
  27553. shape: {
  27554. r: layout.r + 10
  27555. }
  27556. }, 300, 'elasticOut');
  27557. }
  27558. function onNormal() {
  27559. sector.stopAnimation(true);
  27560. sector.animateTo({
  27561. shape: {
  27562. r: layout.r
  27563. }
  27564. }, 300, 'elasticOut');
  27565. }
  27566. sector.off('mouseover').off('mouseout').off('emphasis').off('normal');
  27567. if (itemModel.get('hoverAnimation') && seriesModel.isAnimationEnabled()) {
  27568. sector
  27569. .on('mouseover', onEmphasis)
  27570. .on('mouseout', onNormal)
  27571. .on('emphasis', onEmphasis)
  27572. .on('normal', onNormal);
  27573. }
  27574. this._updateLabel(data, idx);
  27575. graphic.setHoverStyle(this);
  27576. };
  27577. piePieceProto._updateLabel = function (data, idx) {
  27578. var labelLine = this.childAt(1);
  27579. var labelText = this.childAt(2);
  27580. var seriesModel = data.hostModel;
  27581. var itemModel = data.getItemModel(idx);
  27582. var layout = data.getItemLayout(idx);
  27583. var labelLayout = layout.label;
  27584. var visualColor = data.getItemVisual(idx, 'color');
  27585. graphic.updateProps(labelLine, {
  27586. shape: {
  27587. points: labelLayout.linePoints || [
  27588. [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y]
  27589. ]
  27590. }
  27591. }, seriesModel, idx);
  27592. graphic.updateProps(labelText, {
  27593. style: {
  27594. x: labelLayout.x,
  27595. y: labelLayout.y
  27596. }
  27597. }, seriesModel, idx);
  27598. labelText.attr({
  27599. style: {
  27600. textVerticalAlign: labelLayout.verticalAlign,
  27601. textAlign: labelLayout.textAlign,
  27602. textFont: labelLayout.font
  27603. },
  27604. rotation: labelLayout.rotation,
  27605. origin: [labelLayout.x, labelLayout.y],
  27606. z2: 10
  27607. });
  27608. var labelModel = itemModel.getModel('label.normal');
  27609. var labelHoverModel = itemModel.getModel('label.emphasis');
  27610. var labelLineModel = itemModel.getModel('labelLine.normal');
  27611. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  27612. var labelPosition = labelModel.get('position') || labelHoverModel.get('position');
  27613. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition));
  27614. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  27615. labelText.hoverIgnore = !labelHoverModel.get('show');
  27616. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  27617. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  27618. // Default use item visual color
  27619. labelLine.setStyle({
  27620. stroke: visualColor,
  27621. opacity: data.getItemVisual(idx, 'opacity')
  27622. });
  27623. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  27624. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition);
  27625. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  27626. var smooth = labelLineModel.get('smooth');
  27627. if (smooth && smooth === true) {
  27628. smooth = 0.4;
  27629. }
  27630. labelLine.setShape({
  27631. smooth: smooth
  27632. });
  27633. };
  27634. zrUtil.inherits(PiePiece, graphic.Group);
  27635. // Pie view
  27636. var Pie = __webpack_require__(80).extend({
  27637. type: 'pie',
  27638. init: function () {
  27639. var sectorGroup = new graphic.Group();
  27640. this._sectorGroup = sectorGroup;
  27641. },
  27642. render: function (seriesModel, ecModel, api, payload) {
  27643. if (payload && (payload.from === this.uid)) {
  27644. return;
  27645. }
  27646. var data = seriesModel.getData();
  27647. var oldData = this._data;
  27648. var group = this.group;
  27649. var hasAnimation = ecModel.get('animation');
  27650. var isFirstRender = !oldData;
  27651. var animationType = seriesModel.get('animationType');
  27652. var onSectorClick = zrUtil.curry(
  27653. updateDataSelected, this.uid, seriesModel, hasAnimation, api
  27654. );
  27655. var selectedMode = seriesModel.get('selectedMode');
  27656. data.diff(oldData)
  27657. .add(function (idx) {
  27658. var piePiece = new PiePiece(data, idx);
  27659. // Default expansion animation
  27660. if (isFirstRender && animationType !== 'scale') {
  27661. piePiece.eachChild(function (child) {
  27662. child.stopAnimation(true);
  27663. });
  27664. }
  27665. selectedMode && piePiece.on('click', onSectorClick);
  27666. data.setItemGraphicEl(idx, piePiece);
  27667. group.add(piePiece);
  27668. })
  27669. .update(function (newIdx, oldIdx) {
  27670. var piePiece = oldData.getItemGraphicEl(oldIdx);
  27671. piePiece.updateData(data, newIdx);
  27672. piePiece.off('click');
  27673. selectedMode && piePiece.on('click', onSectorClick);
  27674. group.add(piePiece);
  27675. data.setItemGraphicEl(newIdx, piePiece);
  27676. })
  27677. .remove(function (idx) {
  27678. var piePiece = oldData.getItemGraphicEl(idx);
  27679. group.remove(piePiece);
  27680. })
  27681. .execute();
  27682. if (
  27683. hasAnimation && isFirstRender && data.count() > 0
  27684. // Default expansion animation
  27685. && animationType !== 'scale'
  27686. ) {
  27687. var shape = data.getItemLayout(0);
  27688. var r = Math.max(api.getWidth(), api.getHeight()) / 2;
  27689. var removeClipPath = zrUtil.bind(group.removeClipPath, group);
  27690. group.setClipPath(this._createClipPath(
  27691. shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel
  27692. ));
  27693. }
  27694. this._data = data;
  27695. },
  27696. dispose: function () {},
  27697. _createClipPath: function (
  27698. cx, cy, r, startAngle, clockwise, cb, seriesModel
  27699. ) {
  27700. var clipPath = new graphic.Sector({
  27701. shape: {
  27702. cx: cx,
  27703. cy: cy,
  27704. r0: 0,
  27705. r: r,
  27706. startAngle: startAngle,
  27707. endAngle: startAngle,
  27708. clockwise: clockwise
  27709. }
  27710. });
  27711. graphic.initProps(clipPath, {
  27712. shape: {
  27713. endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2
  27714. }
  27715. }, seriesModel, cb);
  27716. return clipPath;
  27717. },
  27718. /**
  27719. * @implement
  27720. */
  27721. containPoint: function (point, seriesModel) {
  27722. var data = seriesModel.getData();
  27723. var itemLayout = data.getItemLayout(0);
  27724. if (itemLayout) {
  27725. var dx = point[0] - itemLayout.cx;
  27726. var dy = point[1] - itemLayout.cy;
  27727. var radius = Math.sqrt(dx * dx + dy * dy);
  27728. return radius <= itemLayout.r && radius >= itemLayout.r0;
  27729. }
  27730. }
  27731. });
  27732. module.exports = Pie;
  27733. /***/ },
  27734. /* 150 */
  27735. /***/ function(module, exports, __webpack_require__) {
  27736. var echarts = __webpack_require__(1);
  27737. var zrUtil = __webpack_require__(4);
  27738. module.exports = function (seriesType, actionInfos) {
  27739. zrUtil.each(actionInfos, function (actionInfo) {
  27740. actionInfo.update = 'updateView';
  27741. /**
  27742. * @payload
  27743. * @property {string} seriesName
  27744. * @property {string} name
  27745. */
  27746. echarts.registerAction(actionInfo, function (payload, ecModel) {
  27747. var selected = {};
  27748. ecModel.eachComponent(
  27749. {mainType: 'series', subType: seriesType, query: payload},
  27750. function (seriesModel) {
  27751. if (seriesModel[actionInfo.method]) {
  27752. seriesModel[actionInfo.method](payload.name);
  27753. }
  27754. var data = seriesModel.getData();
  27755. // Create selected map
  27756. data.each(function (idx) {
  27757. var name = data.getName(idx);
  27758. selected[name] = seriesModel.isSelected(name) || false;
  27759. });
  27760. }
  27761. );
  27762. return {
  27763. name: payload.name,
  27764. selected: selected
  27765. };
  27766. });
  27767. });
  27768. };
  27769. /***/ },
  27770. /* 151 */
  27771. /***/ function(module, exports) {
  27772. // Pick color from palette for each data item.
  27773. // Applicable for charts that require applying color palette
  27774. // in data level (like pie, funnel, chord).
  27775. module.exports = function (seriesType, ecModel) {
  27776. // Pie and funnel may use diferrent scope
  27777. var paletteScope = {};
  27778. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  27779. var dataAll = seriesModel.getRawData();
  27780. var idxMap = {};
  27781. if (!ecModel.isSeriesFiltered(seriesModel)) {
  27782. var data = seriesModel.getData();
  27783. data.each(function (idx) {
  27784. var rawIdx = data.getRawIndex(idx);
  27785. idxMap[rawIdx] = idx;
  27786. });
  27787. dataAll.each(function (rawIdx) {
  27788. var filteredIdx = idxMap[rawIdx];
  27789. // If series.itemStyle.normal.color is a function. itemVisual may be encoded
  27790. var singleDataColor = filteredIdx != null
  27791. && data.getItemVisual(filteredIdx, 'color', true);
  27792. if (!singleDataColor) {
  27793. // FIXME Performance
  27794. var itemModel = dataAll.getItemModel(rawIdx);
  27795. var color = itemModel.get('itemStyle.normal.color')
  27796. || seriesModel.getColorFromPalette(dataAll.getName(rawIdx), paletteScope);
  27797. // Legend may use the visual info in data before processed
  27798. dataAll.setItemVisual(rawIdx, 'color', color);
  27799. // Data is not filtered
  27800. if (filteredIdx != null) {
  27801. data.setItemVisual(filteredIdx, 'color', color);
  27802. }
  27803. }
  27804. else {
  27805. // Set data all color for legend
  27806. dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
  27807. }
  27808. });
  27809. }
  27810. });
  27811. };
  27812. /***/ },
  27813. /* 152 */
  27814. /***/ function(module, exports, __webpack_require__) {
  27815. var numberUtil = __webpack_require__(7);
  27816. var parsePercent = numberUtil.parsePercent;
  27817. var labelLayout = __webpack_require__(153);
  27818. var zrUtil = __webpack_require__(4);
  27819. var PI2 = Math.PI * 2;
  27820. var RADIAN = Math.PI / 180;
  27821. module.exports = function (seriesType, ecModel, api, payload) {
  27822. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  27823. var center = seriesModel.get('center');
  27824. var radius = seriesModel.get('radius');
  27825. if (!zrUtil.isArray(radius)) {
  27826. radius = [0, radius];
  27827. }
  27828. if (!zrUtil.isArray(center)) {
  27829. center = [center, center];
  27830. }
  27831. var width = api.getWidth();
  27832. var height = api.getHeight();
  27833. var size = Math.min(width, height);
  27834. var cx = parsePercent(center[0], width);
  27835. var cy = parsePercent(center[1], height);
  27836. var r0 = parsePercent(radius[0], size / 2);
  27837. var r = parsePercent(radius[1], size / 2);
  27838. var data = seriesModel.getData();
  27839. var startAngle = -seriesModel.get('startAngle') * RADIAN;
  27840. var minAngle = seriesModel.get('minAngle') * RADIAN;
  27841. var validDataCount = 0;
  27842. data.each('value', function (value) {
  27843. !isNaN(value) && validDataCount++;
  27844. });
  27845. var sum = data.getSum('value');
  27846. // Sum may be 0
  27847. var unitRadian = Math.PI / (sum || validDataCount) * 2;
  27848. var clockwise = seriesModel.get('clockwise');
  27849. var roseType = seriesModel.get('roseType');
  27850. var stillShowZeroSum = seriesModel.get('stillShowZeroSum');
  27851. // [0...max]
  27852. var extent = data.getDataExtent('value');
  27853. extent[0] = 0;
  27854. // In the case some sector angle is smaller than minAngle
  27855. var restAngle = PI2;
  27856. var valueSumLargerThanMinAngle = 0;
  27857. var currentAngle = startAngle;
  27858. var dir = clockwise ? 1 : -1;
  27859. data.each('value', function (value, idx) {
  27860. var angle;
  27861. if (isNaN(value)) {
  27862. data.setItemLayout(idx, {
  27863. angle: NaN,
  27864. startAngle: NaN,
  27865. endAngle: NaN,
  27866. clockwise: clockwise,
  27867. cx: cx,
  27868. cy: cy,
  27869. r0: r0,
  27870. r: roseType
  27871. ? NaN
  27872. : r
  27873. });
  27874. return;
  27875. }
  27876. // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  27877. if (roseType !== 'area') {
  27878. angle = (sum === 0 && stillShowZeroSum)
  27879. ? unitRadian : (value * unitRadian);
  27880. }
  27881. else {
  27882. angle = PI2 / validDataCount;
  27883. }
  27884. if (angle < minAngle) {
  27885. angle = minAngle;
  27886. restAngle -= minAngle;
  27887. }
  27888. else {
  27889. valueSumLargerThanMinAngle += value;
  27890. }
  27891. var endAngle = currentAngle + dir * angle;
  27892. data.setItemLayout(idx, {
  27893. angle: angle,
  27894. startAngle: currentAngle,
  27895. endAngle: endAngle,
  27896. clockwise: clockwise,
  27897. cx: cx,
  27898. cy: cy,
  27899. r0: r0,
  27900. r: roseType
  27901. ? numberUtil.linearMap(value, extent, [r0, r])
  27902. : r
  27903. });
  27904. currentAngle = endAngle;
  27905. }, true);
  27906. // Some sector is constrained by minAngle
  27907. // Rest sectors needs recalculate angle
  27908. if (restAngle < PI2 && validDataCount) {
  27909. // Average the angle if rest angle is not enough after all angles is
  27910. // Constrained by minAngle
  27911. if (restAngle <= 1e-3) {
  27912. var angle = PI2 / validDataCount;
  27913. data.each('value', function (value, idx) {
  27914. if (!isNaN(value)) {
  27915. var layout = data.getItemLayout(idx);
  27916. layout.angle = angle;
  27917. layout.startAngle = startAngle + dir * idx * angle;
  27918. layout.endAngle = startAngle + dir * (idx + 1) * angle;
  27919. }
  27920. });
  27921. }
  27922. else {
  27923. unitRadian = restAngle / valueSumLargerThanMinAngle;
  27924. currentAngle = startAngle;
  27925. data.each('value', function (value, idx) {
  27926. if (!isNaN(value)) {
  27927. var layout = data.getItemLayout(idx);
  27928. var angle = layout.angle === minAngle
  27929. ? minAngle : value * unitRadian;
  27930. layout.startAngle = currentAngle;
  27931. layout.endAngle = currentAngle + dir * angle;
  27932. currentAngle += dir * angle;
  27933. }
  27934. });
  27935. }
  27936. }
  27937. labelLayout(seriesModel, r, width, height);
  27938. });
  27939. };
  27940. /***/ },
  27941. /* 153 */
  27942. /***/ function(module, exports, __webpack_require__) {
  27943. 'use strict';
  27944. // FIXME emphasis label position is not same with normal label position
  27945. var textContain = __webpack_require__(8);
  27946. function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
  27947. list.sort(function (a, b) {
  27948. return a.y - b.y;
  27949. });
  27950. // 压
  27951. function shiftDown(start, end, delta, dir) {
  27952. for (var j = start; j < end; j++) {
  27953. list[j].y += delta;
  27954. if (j > start
  27955. && j + 1 < end
  27956. && list[j + 1].y > list[j].y + list[j].height
  27957. ) {
  27958. shiftUp(j, delta / 2);
  27959. return;
  27960. }
  27961. }
  27962. shiftUp(end - 1, delta / 2);
  27963. }
  27964. // 弹
  27965. function shiftUp(end, delta) {
  27966. for (var j = end; j >= 0; j--) {
  27967. list[j].y -= delta;
  27968. if (j > 0
  27969. && list[j].y > list[j - 1].y + list[j - 1].height
  27970. ) {
  27971. break;
  27972. }
  27973. }
  27974. }
  27975. function changeX(list, isDownList, cx, cy, r, dir) {
  27976. var lastDeltaX = dir > 0
  27977. ? isDownList // 右侧
  27978. ? Number.MAX_VALUE // 下
  27979. : 0 // 上
  27980. : isDownList // 左侧
  27981. ? Number.MAX_VALUE // 下
  27982. : 0; // 上
  27983. for (var i = 0, l = list.length; i < l; i++) {
  27984. // Not change x for center label
  27985. if (list[i].position === 'center') {
  27986. continue;
  27987. }
  27988. var deltaY = Math.abs(list[i].y - cy);
  27989. var length = list[i].len;
  27990. var length2 = list[i].len2;
  27991. var deltaX = (deltaY < r + length)
  27992. ? Math.sqrt(
  27993. (r + length + length2) * (r + length + length2)
  27994. - deltaY * deltaY
  27995. )
  27996. : Math.abs(list[i].x - cx);
  27997. if (isDownList && deltaX >= lastDeltaX) {
  27998. // 右下,左下
  27999. deltaX = lastDeltaX - 10;
  28000. }
  28001. if (!isDownList && deltaX <= lastDeltaX) {
  28002. // 右上,左上
  28003. deltaX = lastDeltaX + 10;
  28004. }
  28005. list[i].x = cx + deltaX * dir;
  28006. lastDeltaX = deltaX;
  28007. }
  28008. }
  28009. var lastY = 0;
  28010. var delta;
  28011. var len = list.length;
  28012. var upList = [];
  28013. var downList = [];
  28014. for (var i = 0; i < len; i++) {
  28015. delta = list[i].y - lastY;
  28016. if (delta < 0) {
  28017. shiftDown(i, len, -delta, dir);
  28018. }
  28019. lastY = list[i].y + list[i].height;
  28020. }
  28021. if (viewHeight - lastY < 0) {
  28022. shiftUp(len - 1, lastY - viewHeight);
  28023. }
  28024. for (var i = 0; i < len; i++) {
  28025. if (list[i].y >= cy) {
  28026. downList.push(list[i]);
  28027. }
  28028. else {
  28029. upList.push(list[i]);
  28030. }
  28031. }
  28032. changeX(upList, false, cx, cy, r, dir);
  28033. changeX(downList, true, cx, cy, r, dir);
  28034. }
  28035. function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
  28036. var leftList = [];
  28037. var rightList = [];
  28038. for (var i = 0; i < labelLayoutList.length; i++) {
  28039. if (labelLayoutList[i].x < cx) {
  28040. leftList.push(labelLayoutList[i]);
  28041. }
  28042. else {
  28043. rightList.push(labelLayoutList[i]);
  28044. }
  28045. }
  28046. adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
  28047. adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
  28048. for (var i = 0; i < labelLayoutList.length; i++) {
  28049. var linePoints = labelLayoutList[i].linePoints;
  28050. if (linePoints) {
  28051. var dist = linePoints[1][0] - linePoints[2][0];
  28052. if (labelLayoutList[i].x < cx) {
  28053. linePoints[2][0] = labelLayoutList[i].x + 3;
  28054. }
  28055. else {
  28056. linePoints[2][0] = labelLayoutList[i].x - 3;
  28057. }
  28058. linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
  28059. linePoints[1][0] = linePoints[2][0] + dist;
  28060. }
  28061. }
  28062. }
  28063. module.exports = function (seriesModel, r, viewWidth, viewHeight) {
  28064. var data = seriesModel.getData();
  28065. var labelLayoutList = [];
  28066. var cx;
  28067. var cy;
  28068. var hasLabelRotate = false;
  28069. data.each(function (idx) {
  28070. var layout = data.getItemLayout(idx);
  28071. var itemModel = data.getItemModel(idx);
  28072. var labelModel = itemModel.getModel('label.normal');
  28073. // Use position in normal or emphasis
  28074. var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position');
  28075. var labelLineModel = itemModel.getModel('labelLine.normal');
  28076. var labelLineLen = labelLineModel.get('length');
  28077. var labelLineLen2 = labelLineModel.get('length2');
  28078. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  28079. var dx = Math.cos(midAngle);
  28080. var dy = Math.sin(midAngle);
  28081. var textX;
  28082. var textY;
  28083. var linePoints;
  28084. var textAlign;
  28085. cx = layout.cx;
  28086. cy = layout.cy;
  28087. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  28088. if (labelPosition === 'center') {
  28089. textX = layout.cx;
  28090. textY = layout.cy;
  28091. textAlign = 'center';
  28092. }
  28093. else {
  28094. var x1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dx : layout.r * dx) + cx;
  28095. var y1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dy : layout.r * dy) + cy;
  28096. textX = x1 + dx * 3;
  28097. textY = y1 + dy * 3;
  28098. if (!isLabelInside) {
  28099. // For roseType
  28100. var x2 = x1 + dx * (labelLineLen + r - layout.r);
  28101. var y2 = y1 + dy * (labelLineLen + r - layout.r);
  28102. var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
  28103. var y3 = y2;
  28104. textX = x3 + (dx < 0 ? -5 : 5);
  28105. textY = y3;
  28106. linePoints = [[x1, y1], [x2, y2], [x3, y3]];
  28107. }
  28108. textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
  28109. }
  28110. var font = labelModel.getModel('textStyle').getFont();
  28111. var labelRotate = labelModel.get('rotate')
  28112. ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0;
  28113. var text = seriesModel.getFormattedLabel(idx, 'normal')
  28114. || data.getName(idx);
  28115. var textRect = textContain.getBoundingRect(
  28116. text, font, textAlign, 'top'
  28117. );
  28118. hasLabelRotate = !!labelRotate;
  28119. layout.label = {
  28120. x: textX,
  28121. y: textY,
  28122. position: labelPosition,
  28123. height: textRect.height,
  28124. len: labelLineLen,
  28125. len2: labelLineLen2,
  28126. linePoints: linePoints,
  28127. textAlign: textAlign,
  28128. verticalAlign: 'middle',
  28129. font: font,
  28130. rotation: labelRotate
  28131. };
  28132. // Not layout the inside label
  28133. if (!isLabelInside) {
  28134. labelLayoutList.push(layout.label);
  28135. }
  28136. });
  28137. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  28138. avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
  28139. }
  28140. };
  28141. /***/ },
  28142. /* 154 */
  28143. /***/ function(module, exports) {
  28144. module.exports = function (seriesType, ecModel) {
  28145. var legendModels = ecModel.findComponents({
  28146. mainType: 'legend'
  28147. });
  28148. if (!legendModels || !legendModels.length) {
  28149. return;
  28150. }
  28151. ecModel.eachSeriesByType(seriesType, function (series) {
  28152. var data = series.getData();
  28153. data.filterSelf(function (idx) {
  28154. var name = data.getName(idx);
  28155. // If in any legend component the status is not selected.
  28156. for (var i = 0; i < legendModels.length; i++) {
  28157. if (!legendModels[i].isSelected(name)) {
  28158. return false;
  28159. }
  28160. }
  28161. return true;
  28162. }, this);
  28163. }, this);
  28164. };
  28165. /***/ },
  28166. /* 155 */
  28167. /***/ function(module, exports, __webpack_require__) {
  28168. var zrUtil = __webpack_require__(4);
  28169. var echarts = __webpack_require__(1);
  28170. __webpack_require__(156);
  28171. __webpack_require__(157);
  28172. echarts.registerVisual(zrUtil.curry(
  28173. __webpack_require__(121), 'scatter', 'circle', null
  28174. ));
  28175. echarts.registerLayout(zrUtil.curry(
  28176. __webpack_require__(122), 'scatter'
  28177. ));
  28178. // In case developer forget to include grid component
  28179. __webpack_require__(124);
  28180. /***/ },
  28181. /* 156 */
  28182. /***/ function(module, exports, __webpack_require__) {
  28183. 'use strict';
  28184. var createListFromArray = __webpack_require__(109);
  28185. var SeriesModel = __webpack_require__(78);
  28186. module.exports = SeriesModel.extend({
  28187. type: 'series.scatter',
  28188. dependencies: ['grid', 'polar', 'geo', 'singleAxis', 'calendar'],
  28189. getInitialData: function (option, ecModel) {
  28190. return createListFromArray(option.data, this, ecModel);
  28191. },
  28192. brushSelector: 'point',
  28193. defaultOption: {
  28194. coordinateSystem: 'cartesian2d',
  28195. zlevel: 0,
  28196. z: 2,
  28197. legendHoverLink: true,
  28198. hoverAnimation: true,
  28199. // Cartesian coordinate system
  28200. // xAxisIndex: 0,
  28201. // yAxisIndex: 0,
  28202. // Polar coordinate system
  28203. // polarIndex: 0,
  28204. // Geo coordinate system
  28205. // geoIndex: 0,
  28206. // symbol: null, // 图形类型
  28207. symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  28208. // symbolRotate: null, // 图形旋转控制
  28209. large: false,
  28210. // Available when large is true
  28211. largeThreshold: 2000,
  28212. // cursor: null,
  28213. // label: {
  28214. // normal: {
  28215. // show: false
  28216. // distance: 5,
  28217. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  28218. // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
  28219. // 'inside'|'left'|'right'|'top'|'bottom'
  28220. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  28221. // }
  28222. // },
  28223. itemStyle: {
  28224. normal: {
  28225. opacity: 0.8
  28226. // color: 各异
  28227. }
  28228. }
  28229. }
  28230. });
  28231. /***/ },
  28232. /* 157 */
  28233. /***/ function(module, exports, __webpack_require__) {
  28234. var SymbolDraw = __webpack_require__(116);
  28235. var LargeSymbolDraw = __webpack_require__(158);
  28236. __webpack_require__(1).extendChartView({
  28237. type: 'scatter',
  28238. init: function () {
  28239. this._normalSymbolDraw = new SymbolDraw();
  28240. this._largeSymbolDraw = new LargeSymbolDraw();
  28241. },
  28242. render: function (seriesModel, ecModel, api) {
  28243. var data = seriesModel.getData();
  28244. var largeSymbolDraw = this._largeSymbolDraw;
  28245. var normalSymbolDraw = this._normalSymbolDraw;
  28246. var group = this.group;
  28247. var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold')
  28248. ? largeSymbolDraw : normalSymbolDraw;
  28249. this._symbolDraw = symbolDraw;
  28250. symbolDraw.updateData(data);
  28251. group.add(symbolDraw.group);
  28252. group.remove(
  28253. symbolDraw === largeSymbolDraw
  28254. ? normalSymbolDraw.group : largeSymbolDraw.group
  28255. );
  28256. },
  28257. updateLayout: function (seriesModel) {
  28258. this._symbolDraw.updateLayout(seriesModel);
  28259. },
  28260. remove: function (ecModel, api) {
  28261. this._symbolDraw && this._symbolDraw.remove(api, true);
  28262. },
  28263. dispose: function () {}
  28264. });
  28265. /***/ },
  28266. /* 158 */
  28267. /***/ function(module, exports, __webpack_require__) {
  28268. // TODO Batch by color
  28269. var graphic = __webpack_require__(18);
  28270. var symbolUtil = __webpack_require__(111);
  28271. var LargeSymbolPath = graphic.extendShape({
  28272. shape: {
  28273. points: null,
  28274. sizes: null
  28275. },
  28276. symbolProxy: null,
  28277. buildPath: function (path, shape) {
  28278. var points = shape.points;
  28279. var sizes = shape.sizes;
  28280. var symbolProxy = this.symbolProxy;
  28281. var symbolProxyShape = symbolProxy.shape;
  28282. for (var i = 0; i < points.length; i++) {
  28283. var pt = points[i];
  28284. if (isNaN(pt[0]) || isNaN(pt[1])) {
  28285. continue;
  28286. }
  28287. var size = sizes[i];
  28288. if (size[0] < 4) {
  28289. // Optimize for small symbol
  28290. path.rect(
  28291. pt[0] - size[0] / 2, pt[1] - size[1] / 2,
  28292. size[0], size[1]
  28293. );
  28294. }
  28295. else {
  28296. symbolProxyShape.x = pt[0] - size[0] / 2;
  28297. symbolProxyShape.y = pt[1] - size[1] / 2;
  28298. symbolProxyShape.width = size[0];
  28299. symbolProxyShape.height = size[1];
  28300. symbolProxy.buildPath(path, symbolProxyShape, true);
  28301. }
  28302. }
  28303. },
  28304. findDataIndex: function (x, y) {
  28305. var shape = this.shape;
  28306. var points = shape.points;
  28307. var sizes = shape.sizes;
  28308. // Not consider transform
  28309. // Treat each element as a rect
  28310. // top down traverse
  28311. for (var i = points.length - 1; i >= 0; i--) {
  28312. var pt = points[i];
  28313. var size = sizes[i];
  28314. var x0 = pt[0] - size[0] / 2;
  28315. var y0 = pt[1] - size[1] / 2;
  28316. if (x >= x0 && y >= y0 && x <= x0 + size[0] && y <= y0 + size[1]) {
  28317. // i is dataIndex
  28318. return i;
  28319. }
  28320. }
  28321. return -1;
  28322. }
  28323. });
  28324. function LargeSymbolDraw() {
  28325. this.group = new graphic.Group();
  28326. this._symbolEl = new LargeSymbolPath({
  28327. // rectHover: true,
  28328. // cursor: 'default'
  28329. });
  28330. }
  28331. var largeSymbolProto = LargeSymbolDraw.prototype;
  28332. /**
  28333. * Update symbols draw by new data
  28334. * @param {module:echarts/data/List} data
  28335. */
  28336. largeSymbolProto.updateData = function (data) {
  28337. this.group.removeAll();
  28338. var symbolEl = this._symbolEl;
  28339. var seriesModel = data.hostModel;
  28340. symbolEl.setShape({
  28341. points: data.mapArray(data.getItemLayout),
  28342. sizes: data.mapArray(
  28343. function (idx) {
  28344. var size = data.getItemVisual(idx, 'symbolSize');
  28345. if (!(size instanceof Array)) {
  28346. size = [size, size];
  28347. }
  28348. return size;
  28349. }
  28350. )
  28351. });
  28352. // Create symbolProxy to build path for each data
  28353. symbolEl.symbolProxy = symbolUtil.createSymbol(
  28354. data.getVisual('symbol'), 0, 0, 0, 0
  28355. );
  28356. // Use symbolProxy setColor method
  28357. symbolEl.setColor = symbolEl.symbolProxy.setColor;
  28358. symbolEl.useStyle(
  28359. seriesModel.getModel('itemStyle.normal').getItemStyle(['color'])
  28360. );
  28361. var visualColor = data.getVisual('color');
  28362. if (visualColor) {
  28363. symbolEl.setColor(visualColor);
  28364. }
  28365. // Enable tooltip
  28366. // PENDING May have performance issue when path is extremely large
  28367. symbolEl.seriesIndex = seriesModel.seriesIndex;
  28368. symbolEl.on('mousemove', function (e) {
  28369. symbolEl.dataIndex = null;
  28370. var dataIndex = symbolEl.findDataIndex(e.offsetX, e.offsetY);
  28371. if (dataIndex >= 0) {
  28372. // Provide dataIndex for tooltip
  28373. symbolEl.dataIndex = dataIndex;
  28374. }
  28375. });
  28376. // Add back
  28377. this.group.add(symbolEl);
  28378. };
  28379. largeSymbolProto.updateLayout = function (seriesModel) {
  28380. var data = seriesModel.getData();
  28381. this._symbolEl.setShape({
  28382. points: data.mapArray(data.getItemLayout)
  28383. });
  28384. };
  28385. largeSymbolProto.remove = function () {
  28386. this.group.removeAll();
  28387. };
  28388. module.exports = LargeSymbolDraw;
  28389. /***/ },
  28390. /* 159 */
  28391. /***/ function(module, exports, __webpack_require__) {
  28392. var zrUtil = __webpack_require__(4);
  28393. var echarts = __webpack_require__(1);
  28394. // Must use radar component
  28395. __webpack_require__(160);
  28396. __webpack_require__(165);
  28397. __webpack_require__(166);
  28398. echarts.registerVisual(zrUtil.curry(__webpack_require__(151), 'radar'));
  28399. echarts.registerVisual(zrUtil.curry(
  28400. __webpack_require__(121), 'radar', 'circle', null
  28401. ));
  28402. echarts.registerLayout(__webpack_require__(167));
  28403. echarts.registerProcessor(
  28404. zrUtil.curry(__webpack_require__(154), 'radar')
  28405. );
  28406. echarts.registerPreprocessor(__webpack_require__(168));
  28407. /***/ },
  28408. /* 160 */
  28409. /***/ function(module, exports, __webpack_require__) {
  28410. __webpack_require__(161);
  28411. __webpack_require__(163);
  28412. __webpack_require__(164);
  28413. /***/ },
  28414. /* 161 */
  28415. /***/ function(module, exports, __webpack_require__) {
  28416. // TODO clockwise
  28417. var zrUtil = __webpack_require__(4);
  28418. var IndicatorAxis = __webpack_require__(162);
  28419. var IntervalScale = __webpack_require__(104);
  28420. var numberUtil = __webpack_require__(7);
  28421. var axisHelper = __webpack_require__(101);
  28422. function Radar(radarModel, ecModel, api) {
  28423. this._model = radarModel;
  28424. /**
  28425. * Radar dimensions
  28426. * @type {Array.<string>}
  28427. */
  28428. this.dimensions = [];
  28429. this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
  28430. var dim = 'indicator_' + idx;
  28431. var indicatorAxis = new IndicatorAxis(dim, new IntervalScale());
  28432. indicatorAxis.name = indicatorModel.get('name');
  28433. // Inject model and axis
  28434. indicatorAxis.model = indicatorModel;
  28435. indicatorModel.axis = indicatorAxis;
  28436. this.dimensions.push(dim);
  28437. return indicatorAxis;
  28438. }, this);
  28439. this.resize(radarModel, api);
  28440. /**
  28441. * @type {number}
  28442. * @readOnly
  28443. */
  28444. this.cx;
  28445. /**
  28446. * @type {number}
  28447. * @readOnly
  28448. */
  28449. this.cy;
  28450. /**
  28451. * @type {number}
  28452. * @readOnly
  28453. */
  28454. this.r;
  28455. /**
  28456. * @type {number}
  28457. * @readOnly
  28458. */
  28459. this.startAngle;
  28460. }
  28461. Radar.prototype.getIndicatorAxes = function () {
  28462. return this._indicatorAxes;
  28463. };
  28464. Radar.prototype.dataToPoint = function (value, indicatorIndex) {
  28465. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  28466. return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
  28467. };
  28468. Radar.prototype.coordToPoint = function (coord, indicatorIndex) {
  28469. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  28470. var angle = indicatorAxis.angle;
  28471. var x = this.cx + coord * Math.cos(angle);
  28472. var y = this.cy - coord * Math.sin(angle);
  28473. return [x, y];
  28474. };
  28475. Radar.prototype.pointToData = function (pt) {
  28476. var dx = pt[0] - this.cx;
  28477. var dy = pt[1] - this.cy;
  28478. var radius = Math.sqrt(dx * dx + dy * dy);
  28479. dx /= radius;
  28480. dy /= radius;
  28481. var radian = Math.atan2(-dy, dx);
  28482. // Find the closest angle
  28483. // FIXME index can calculated directly
  28484. var minRadianDiff = Infinity;
  28485. var closestAxis;
  28486. var closestAxisIdx = -1;
  28487. for (var i = 0; i < this._indicatorAxes.length; i++) {
  28488. var indicatorAxis = this._indicatorAxes[i];
  28489. var diff = Math.abs(radian - indicatorAxis.angle);
  28490. if (diff < minRadianDiff) {
  28491. closestAxis = indicatorAxis;
  28492. closestAxisIdx = i;
  28493. minRadianDiff = diff;
  28494. }
  28495. }
  28496. return [closestAxisIdx, +(closestAxis && closestAxis.coodToData(radius))];
  28497. };
  28498. Radar.prototype.resize = function (radarModel, api) {
  28499. var center = radarModel.get('center');
  28500. var viewWidth = api.getWidth();
  28501. var viewHeight = api.getHeight();
  28502. var viewSize = Math.min(viewWidth, viewHeight) / 2;
  28503. this.cx = numberUtil.parsePercent(center[0], viewWidth);
  28504. this.cy = numberUtil.parsePercent(center[1], viewHeight);
  28505. this.startAngle = radarModel.get('startAngle') * Math.PI / 180;
  28506. this.r = numberUtil.parsePercent(radarModel.get('radius'), viewSize);
  28507. zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) {
  28508. indicatorAxis.setExtent(0, this.r);
  28509. var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
  28510. // Normalize to [-PI, PI]
  28511. angle = Math.atan2(Math.sin(angle), Math.cos(angle));
  28512. indicatorAxis.angle = angle;
  28513. }, this);
  28514. };
  28515. Radar.prototype.update = function (ecModel, api) {
  28516. var indicatorAxes = this._indicatorAxes;
  28517. var radarModel = this._model;
  28518. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  28519. indicatorAxis.scale.setExtent(Infinity, -Infinity);
  28520. });
  28521. ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
  28522. if (radarSeries.get('coordinateSystem') !== 'radar'
  28523. || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel
  28524. ) {
  28525. return;
  28526. }
  28527. var data = radarSeries.getData();
  28528. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  28529. indicatorAxis.scale.unionExtentFromData(data, indicatorAxis.dim);
  28530. });
  28531. }, this);
  28532. var splitNumber = radarModel.get('splitNumber');
  28533. function increaseInterval(interval) {
  28534. var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10));
  28535. // Increase interval
  28536. var f = interval / exp10;
  28537. if (f === 2) {
  28538. f = 5;
  28539. }
  28540. else { // f is 2 or 5
  28541. f *= 2;
  28542. }
  28543. return f * exp10;
  28544. }
  28545. // Force all the axis fixing the maxSplitNumber.
  28546. zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
  28547. var rawExtent = axisHelper.getScaleExtent(indicatorAxis.scale, indicatorAxis.model);
  28548. axisHelper.niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);
  28549. var axisModel = indicatorAxis.model;
  28550. var scale = indicatorAxis.scale;
  28551. var fixedMin = axisModel.getMin();
  28552. var fixedMax = axisModel.getMax();
  28553. var interval = scale.getInterval();
  28554. if (fixedMin != null && fixedMax != null) {
  28555. // User set min, max, divide to get new interval
  28556. scale.setExtent(+fixedMin, +fixedMax);
  28557. scale.setInterval(
  28558. (fixedMax - fixedMin) / splitNumber
  28559. );
  28560. }
  28561. else if (fixedMin != null) {
  28562. var max;
  28563. // User set min, expand extent on the other side
  28564. do {
  28565. max = fixedMin + interval * splitNumber;
  28566. scale.setExtent(+fixedMin, max);
  28567. // Interval must been set after extent
  28568. // FIXME
  28569. scale.setInterval(interval);
  28570. interval = increaseInterval(interval);
  28571. } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
  28572. }
  28573. else if (fixedMax != null) {
  28574. var min;
  28575. // User set min, expand extent on the other side
  28576. do {
  28577. min = fixedMax - interval * splitNumber;
  28578. scale.setExtent(min, +fixedMax);
  28579. scale.setInterval(interval);
  28580. interval = increaseInterval(interval);
  28581. } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
  28582. }
  28583. else {
  28584. var nicedSplitNumber = scale.getTicks().length - 1;
  28585. if (nicedSplitNumber > splitNumber) {
  28586. interval = increaseInterval(interval);
  28587. }
  28588. // PENDING
  28589. var center = Math.round((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
  28590. var halfSplitNumber = Math.round(splitNumber / 2);
  28591. scale.setExtent(
  28592. numberUtil.round(center - halfSplitNumber * interval),
  28593. numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
  28594. );
  28595. scale.setInterval(interval);
  28596. }
  28597. });
  28598. };
  28599. /**
  28600. * Radar dimensions is based on the data
  28601. * @type {Array}
  28602. */
  28603. Radar.dimensions = [];
  28604. Radar.create = function (ecModel, api) {
  28605. var radarList = [];
  28606. ecModel.eachComponent('radar', function (radarModel) {
  28607. var radar = new Radar(radarModel, ecModel, api);
  28608. radarList.push(radar);
  28609. radarModel.coordinateSystem = radar;
  28610. });
  28611. ecModel.eachSeriesByType('radar', function (radarSeries) {
  28612. if (radarSeries.get('coordinateSystem') === 'radar') {
  28613. // Inject coordinate system
  28614. radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
  28615. }
  28616. });
  28617. return radarList;
  28618. };
  28619. __webpack_require__(76).register('radar', Radar);
  28620. module.exports = Radar;
  28621. /***/ },
  28622. /* 162 */
  28623. /***/ function(module, exports, __webpack_require__) {
  28624. var zrUtil = __webpack_require__(4);
  28625. var Axis = __webpack_require__(100);
  28626. function IndicatorAxis(dim, scale, radiusExtent) {
  28627. Axis.call(this, dim, scale, radiusExtent);
  28628. /**
  28629. * Axis type
  28630. * - 'category'
  28631. * - 'value'
  28632. * - 'time'
  28633. * - 'log'
  28634. * @type {string}
  28635. */
  28636. this.type = 'value';
  28637. this.angle = 0;
  28638. /**
  28639. * Indicator name
  28640. * @type {string}
  28641. */
  28642. this.name = '';
  28643. /**
  28644. * @type {module:echarts/model/Model}
  28645. */
  28646. this.model;
  28647. }
  28648. zrUtil.inherits(IndicatorAxis, Axis);
  28649. module.exports = IndicatorAxis;
  28650. /***/ },
  28651. /* 163 */
  28652. /***/ function(module, exports, __webpack_require__) {
  28653. var axisDefault = __webpack_require__(132);
  28654. var valueAxisDefault = axisDefault.valueAxis;
  28655. var Model = __webpack_require__(12);
  28656. var zrUtil = __webpack_require__(4);
  28657. var axisModelCommonMixin = __webpack_require__(112);
  28658. function defaultsShow(opt, show) {
  28659. return zrUtil.defaults({
  28660. show: show
  28661. }, opt);
  28662. }
  28663. var RadarModel = __webpack_require__(1).extendComponentModel({
  28664. type: 'radar',
  28665. optionUpdated: function () {
  28666. var boundaryGap = this.get('boundaryGap');
  28667. var splitNumber = this.get('splitNumber');
  28668. var scale = this.get('scale');
  28669. var axisLine = this.get('axisLine');
  28670. var axisTick = this.get('axisTick');
  28671. var axisLabel = this.get('axisLabel');
  28672. var nameTextStyle = this.get('name.textStyle');
  28673. var showName = this.get('name.show');
  28674. var nameFormatter = this.get('name.formatter');
  28675. var nameGap = this.get('nameGap');
  28676. var triggerEvent = this.get('triggerEvent');
  28677. var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
  28678. // PENDING
  28679. if (indicatorOpt.max != null && indicatorOpt.max > 0 && !indicatorOpt.min) {
  28680. indicatorOpt.min = 0;
  28681. }
  28682. else if (indicatorOpt.min != null && indicatorOpt.min < 0 && !indicatorOpt.max) {
  28683. indicatorOpt.max = 0;
  28684. }
  28685. // Use same configuration
  28686. indicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
  28687. boundaryGap: boundaryGap,
  28688. splitNumber: splitNumber,
  28689. scale: scale,
  28690. axisLine: axisLine,
  28691. axisTick: axisTick,
  28692. axisLabel: axisLabel,
  28693. // Competitable with 2 and use text
  28694. name: indicatorOpt.text,
  28695. nameLocation: 'end',
  28696. nameGap: nameGap,
  28697. // min: 0,
  28698. nameTextStyle: nameTextStyle,
  28699. triggerEvent: triggerEvent
  28700. }, false);
  28701. if (!showName) {
  28702. indicatorOpt.name = '';
  28703. }
  28704. if (typeof nameFormatter === 'string') {
  28705. var indName = indicatorOpt.name;
  28706. indicatorOpt.name = nameFormatter.replace('{value}', indName != null ? indName : '');
  28707. }
  28708. else if (typeof nameFormatter === 'function') {
  28709. indicatorOpt.name = nameFormatter(
  28710. indicatorOpt.name, indicatorOpt
  28711. );
  28712. }
  28713. var model = zrUtil.extend(
  28714. new Model(indicatorOpt, null, this.ecModel),
  28715. axisModelCommonMixin
  28716. );
  28717. // For triggerEvent.
  28718. model.mainType = 'radar';
  28719. model.componentIndex = this.componentIndex;
  28720. return model;
  28721. }, this);
  28722. this.getIndicatorModels = function () {
  28723. return indicatorModels;
  28724. };
  28725. },
  28726. defaultOption: {
  28727. zlevel: 0,
  28728. z: 0,
  28729. center: ['50%', '50%'],
  28730. radius: '75%',
  28731. startAngle: 90,
  28732. name: {
  28733. show: true
  28734. // formatter: null
  28735. // textStyle: {}
  28736. },
  28737. boundaryGap: [0, 0],
  28738. splitNumber: 5,
  28739. nameGap: 15,
  28740. scale: false,
  28741. // Polygon or circle
  28742. shape: 'polygon',
  28743. axisLine: zrUtil.merge(
  28744. {
  28745. lineStyle: {
  28746. color: '#bbb'
  28747. }
  28748. },
  28749. valueAxisDefault.axisLine
  28750. ),
  28751. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  28752. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  28753. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  28754. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  28755. // {text, min, max}
  28756. indicator: []
  28757. }
  28758. });
  28759. module.exports = RadarModel;
  28760. /***/ },
  28761. /* 164 */
  28762. /***/ function(module, exports, __webpack_require__) {
  28763. var AxisBuilder = __webpack_require__(135);
  28764. var zrUtil = __webpack_require__(4);
  28765. var graphic = __webpack_require__(18);
  28766. var axisBuilderAttrs = [
  28767. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  28768. ];
  28769. module.exports = __webpack_require__(1).extendComponentView({
  28770. type: 'radar',
  28771. render: function (radarModel, ecModel, api) {
  28772. var group = this.group;
  28773. group.removeAll();
  28774. this._buildAxes(radarModel);
  28775. this._buildSplitLineAndArea(radarModel);
  28776. },
  28777. _buildAxes: function (radarModel) {
  28778. var radar = radarModel.coordinateSystem;
  28779. var indicatorAxes = radar.getIndicatorAxes();
  28780. var axisBuilders = zrUtil.map(indicatorAxes, function (indicatorAxis) {
  28781. var axisBuilder = new AxisBuilder(indicatorAxis.model, {
  28782. position: [radar.cx, radar.cy],
  28783. rotation: indicatorAxis.angle,
  28784. labelDirection: -1,
  28785. tickDirection: -1,
  28786. nameDirection: 1
  28787. });
  28788. return axisBuilder;
  28789. });
  28790. zrUtil.each(axisBuilders, function (axisBuilder) {
  28791. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  28792. this.group.add(axisBuilder.getGroup());
  28793. }, this);
  28794. },
  28795. _buildSplitLineAndArea: function (radarModel) {
  28796. var radar = radarModel.coordinateSystem;
  28797. var indicatorAxes = radar.getIndicatorAxes();
  28798. if (!indicatorAxes.length) {
  28799. return;
  28800. }
  28801. var shape = radarModel.get('shape');
  28802. var splitLineModel = radarModel.getModel('splitLine');
  28803. var splitAreaModel = radarModel.getModel('splitArea');
  28804. var lineStyleModel = splitLineModel.getModel('lineStyle');
  28805. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  28806. var showSplitLine = splitLineModel.get('show');
  28807. var showSplitArea = splitAreaModel.get('show');
  28808. var splitLineColors = lineStyleModel.get('color');
  28809. var splitAreaColors = areaStyleModel.get('color');
  28810. splitLineColors = zrUtil.isArray(splitLineColors) ? splitLineColors : [splitLineColors];
  28811. splitAreaColors = zrUtil.isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors];
  28812. var splitLines = [];
  28813. var splitAreas = [];
  28814. function getColorIndex(areaOrLine, areaOrLineColorList, idx) {
  28815. var colorIndex = idx % areaOrLineColorList.length;
  28816. areaOrLine[colorIndex] = areaOrLine[colorIndex] || [];
  28817. return colorIndex;
  28818. }
  28819. if (shape === 'circle') {
  28820. var ticksRadius = indicatorAxes[0].getTicksCoords();
  28821. var cx = radar.cx;
  28822. var cy = radar.cy;
  28823. for (var i = 0; i < ticksRadius.length; i++) {
  28824. if (showSplitLine) {
  28825. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  28826. splitLines[colorIndex].push(new graphic.Circle({
  28827. shape: {
  28828. cx: cx,
  28829. cy: cy,
  28830. r: ticksRadius[i]
  28831. }
  28832. }));
  28833. }
  28834. if (showSplitArea && i < ticksRadius.length - 1) {
  28835. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i);
  28836. splitAreas[colorIndex].push(new graphic.Ring({
  28837. shape: {
  28838. cx: cx,
  28839. cy: cy,
  28840. r0: ticksRadius[i],
  28841. r: ticksRadius[i + 1]
  28842. }
  28843. }));
  28844. }
  28845. }
  28846. }
  28847. // Polyyon
  28848. else {
  28849. var realSplitNumber;
  28850. var axesTicksPoints = zrUtil.map(indicatorAxes, function (indicatorAxis, idx) {
  28851. var ticksCoords = indicatorAxis.getTicksCoords();
  28852. realSplitNumber = realSplitNumber == null
  28853. ? ticksCoords.length - 1
  28854. : Math.min(ticksCoords.length - 1, realSplitNumber);
  28855. return zrUtil.map(ticksCoords, function (tickCoord) {
  28856. return radar.coordToPoint(tickCoord, idx);
  28857. });
  28858. });
  28859. var prevPoints = [];
  28860. for (var i = 0; i <= realSplitNumber; i++) {
  28861. var points = [];
  28862. for (var j = 0; j < indicatorAxes.length; j++) {
  28863. points.push(axesTicksPoints[j][i]);
  28864. }
  28865. // Close
  28866. if (points[0]) {
  28867. points.push(points[0].slice());
  28868. }
  28869. else {
  28870. if (true) {
  28871. console.error('Can\'t draw value axis ' + i);
  28872. }
  28873. }
  28874. if (showSplitLine) {
  28875. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  28876. splitLines[colorIndex].push(new graphic.Polyline({
  28877. shape: {
  28878. points: points
  28879. }
  28880. }));
  28881. }
  28882. if (showSplitArea && prevPoints) {
  28883. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i - 1);
  28884. splitAreas[colorIndex].push(new graphic.Polygon({
  28885. shape: {
  28886. points: points.concat(prevPoints)
  28887. }
  28888. }));
  28889. }
  28890. prevPoints = points.slice().reverse();
  28891. }
  28892. }
  28893. var lineStyle = lineStyleModel.getLineStyle();
  28894. var areaStyle = areaStyleModel.getAreaStyle();
  28895. // Add splitArea before splitLine
  28896. zrUtil.each(splitAreas, function (splitAreas, idx) {
  28897. this.group.add(graphic.mergePath(
  28898. splitAreas, {
  28899. style: zrUtil.defaults({
  28900. stroke: 'none',
  28901. fill: splitAreaColors[idx % splitAreaColors.length]
  28902. }, areaStyle),
  28903. silent: true
  28904. }
  28905. ));
  28906. }, this);
  28907. zrUtil.each(splitLines, function (splitLines, idx) {
  28908. this.group.add(graphic.mergePath(
  28909. splitLines, {
  28910. style: zrUtil.defaults({
  28911. fill: 'none',
  28912. stroke: splitLineColors[idx % splitLineColors.length]
  28913. }, lineStyle),
  28914. silent: true
  28915. }
  28916. ));
  28917. }, this);
  28918. }
  28919. });
  28920. /***/ },
  28921. /* 165 */
  28922. /***/ function(module, exports, __webpack_require__) {
  28923. 'use strict';
  28924. var SeriesModel = __webpack_require__(78);
  28925. var List = __webpack_require__(98);
  28926. var completeDimensions = __webpack_require__(110);
  28927. var zrUtil = __webpack_require__(4);
  28928. var encodeHTML = __webpack_require__(6).encodeHTML;
  28929. var RadarSeries = SeriesModel.extend({
  28930. type: 'series.radar',
  28931. dependencies: ['radar'],
  28932. // Overwrite
  28933. init: function (option) {
  28934. RadarSeries.superApply(this, 'init', arguments);
  28935. // Enable legend selection for each data item
  28936. // Use a function instead of direct access because data reference may changed
  28937. this.legendDataProvider = function () {
  28938. return this.getRawData();
  28939. };
  28940. },
  28941. getInitialData: function (option, ecModel) {
  28942. var data = option.data || [];
  28943. var dimensions = completeDimensions(
  28944. [], data, {extraPrefix: 'indicator_', extraFromZero: true}
  28945. );
  28946. var list = new List(dimensions, this);
  28947. list.initData(data);
  28948. return list;
  28949. },
  28950. formatTooltip: function (dataIndex) {
  28951. var value = this.getRawValue(dataIndex);
  28952. var coordSys = this.coordinateSystem;
  28953. var indicatorAxes = coordSys.getIndicatorAxes();
  28954. var name = this.getData().getName(dataIndex);
  28955. return encodeHTML(name === '' ? this.name : name) + '<br/>'
  28956. + zrUtil.map(indicatorAxes, function (axis, idx) {
  28957. return encodeHTML(axis.name + ' : ' + value[idx]);
  28958. }).join('<br />');
  28959. },
  28960. defaultOption: {
  28961. zlevel: 0,
  28962. z: 2,
  28963. coordinateSystem: 'radar',
  28964. legendHoverLink: true,
  28965. radarIndex: 0,
  28966. lineStyle: {
  28967. normal: {
  28968. width: 2,
  28969. type: 'solid'
  28970. }
  28971. },
  28972. label: {
  28973. normal: {
  28974. position: 'top'
  28975. }
  28976. },
  28977. // areaStyle: {
  28978. // },
  28979. // itemStyle: {}
  28980. symbol: 'emptyCircle',
  28981. symbolSize: 4
  28982. // symbolRotate: null
  28983. }
  28984. });
  28985. module.exports = RadarSeries;
  28986. /***/ },
  28987. /* 166 */
  28988. /***/ function(module, exports, __webpack_require__) {
  28989. var graphic = __webpack_require__(18);
  28990. var zrUtil = __webpack_require__(4);
  28991. var symbolUtil = __webpack_require__(111);
  28992. function normalizeSymbolSize(symbolSize) {
  28993. if (!zrUtil.isArray(symbolSize)) {
  28994. symbolSize = [+symbolSize, +symbolSize];
  28995. }
  28996. return symbolSize;
  28997. }
  28998. module.exports = __webpack_require__(1).extendChartView({
  28999. type: 'radar',
  29000. render: function (seriesModel, ecModel, api) {
  29001. var polar = seriesModel.coordinateSystem;
  29002. var group = this.group;
  29003. var data = seriesModel.getData();
  29004. var oldData = this._data;
  29005. function createSymbol(data, idx) {
  29006. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  29007. var color = data.getItemVisual(idx, 'color');
  29008. if (symbolType === 'none') {
  29009. return;
  29010. }
  29011. var symbolPath = symbolUtil.createSymbol(
  29012. symbolType, -0.5, -0.5, 1, 1, color
  29013. );
  29014. symbolPath.attr({
  29015. style: {
  29016. strokeNoScale: true
  29017. },
  29018. z2: 100,
  29019. scale: normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'))
  29020. });
  29021. return symbolPath;
  29022. }
  29023. function updateSymbols(oldPoints, newPoints, symbolGroup, data, idx, isInit) {
  29024. // Simply rerender all
  29025. symbolGroup.removeAll();
  29026. for (var i = 0; i < newPoints.length - 1; i++) {
  29027. var symbolPath = createSymbol(data, idx);
  29028. if (symbolPath) {
  29029. symbolPath.__dimIdx = i;
  29030. if (oldPoints[i]) {
  29031. symbolPath.attr('position', oldPoints[i]);
  29032. graphic[isInit ? 'initProps' : 'updateProps'](
  29033. symbolPath, {
  29034. position: newPoints[i]
  29035. }, seriesModel, idx
  29036. );
  29037. }
  29038. else {
  29039. symbolPath.attr('position', newPoints[i]);
  29040. }
  29041. symbolGroup.add(symbolPath);
  29042. }
  29043. }
  29044. }
  29045. function getInitialPoints(points) {
  29046. return zrUtil.map(points, function (pt) {
  29047. return [polar.cx, polar.cy];
  29048. });
  29049. }
  29050. data.diff(oldData)
  29051. .add(function (idx) {
  29052. var points = data.getItemLayout(idx);
  29053. if (!points) {
  29054. return;
  29055. }
  29056. var polygon = new graphic.Polygon();
  29057. var polyline = new graphic.Polyline();
  29058. var target = {
  29059. shape: {
  29060. points: points
  29061. }
  29062. };
  29063. polygon.shape.points = getInitialPoints(points);
  29064. polyline.shape.points = getInitialPoints(points);
  29065. graphic.initProps(polygon, target, seriesModel, idx);
  29066. graphic.initProps(polyline, target, seriesModel, idx);
  29067. var itemGroup = new graphic.Group();
  29068. var symbolGroup = new graphic.Group();
  29069. itemGroup.add(polyline);
  29070. itemGroup.add(polygon);
  29071. itemGroup.add(symbolGroup);
  29072. updateSymbols(
  29073. polyline.shape.points, points, symbolGroup, data, idx, true
  29074. );
  29075. data.setItemGraphicEl(idx, itemGroup);
  29076. })
  29077. .update(function (newIdx, oldIdx) {
  29078. var itemGroup = oldData.getItemGraphicEl(oldIdx);
  29079. var polyline = itemGroup.childAt(0);
  29080. var polygon = itemGroup.childAt(1);
  29081. var symbolGroup = itemGroup.childAt(2);
  29082. var target = {
  29083. shape: {
  29084. points: data.getItemLayout(newIdx)
  29085. }
  29086. };
  29087. if (!target.shape.points) {
  29088. return;
  29089. }
  29090. updateSymbols(
  29091. polyline.shape.points, target.shape.points, symbolGroup, data, newIdx, false
  29092. );
  29093. graphic.updateProps(polyline, target, seriesModel);
  29094. graphic.updateProps(polygon, target, seriesModel);
  29095. data.setItemGraphicEl(newIdx, itemGroup);
  29096. })
  29097. .remove(function (idx) {
  29098. group.remove(oldData.getItemGraphicEl(idx));
  29099. })
  29100. .execute();
  29101. data.eachItemGraphicEl(function (itemGroup, idx) {
  29102. var itemModel = data.getItemModel(idx);
  29103. var polyline = itemGroup.childAt(0);
  29104. var polygon = itemGroup.childAt(1);
  29105. var symbolGroup = itemGroup.childAt(2);
  29106. var color = data.getItemVisual(idx, 'color');
  29107. group.add(itemGroup);
  29108. polyline.useStyle(
  29109. zrUtil.defaults(
  29110. itemModel.getModel('lineStyle.normal').getLineStyle(),
  29111. {
  29112. fill: 'none',
  29113. stroke: color
  29114. }
  29115. )
  29116. );
  29117. polyline.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  29118. var areaStyleModel = itemModel.getModel('areaStyle.normal');
  29119. var hoverAreaStyleModel = itemModel.getModel('areaStyle.emphasis');
  29120. var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty();
  29121. var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty();
  29122. hoverPolygonIgnore = hoverPolygonIgnore && polygonIgnore;
  29123. polygon.ignore = polygonIgnore;
  29124. polygon.useStyle(
  29125. zrUtil.defaults(
  29126. areaStyleModel.getAreaStyle(),
  29127. {
  29128. fill: color,
  29129. opacity: 0.7
  29130. }
  29131. )
  29132. );
  29133. polygon.hoverStyle = hoverAreaStyleModel.getAreaStyle();
  29134. var itemStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  29135. var itemHoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  29136. var labelModel = itemModel.getModel('label.normal');
  29137. var labelHoverModel = itemModel.getModel('label.emphasis');
  29138. symbolGroup.eachChild(function (symbolPath) {
  29139. symbolPath.setStyle(itemStyle);
  29140. symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
  29141. var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
  29142. graphic.setText(symbolPath.style, labelModel, color);
  29143. symbolPath.setStyle({
  29144. text: labelModel.get('show') ? zrUtil.retrieve(
  29145. seriesModel.getFormattedLabel(
  29146. idx, 'normal', null, symbolPath.__dimIdx
  29147. ),
  29148. defaultText
  29149. ) : ''
  29150. });
  29151. graphic.setText(symbolPath.hoverStyle, labelHoverModel, color);
  29152. symbolPath.hoverStyle.text = labelHoverModel.get('show') ? zrUtil.retrieve(
  29153. seriesModel.getFormattedLabel(
  29154. idx, 'emphasis', null, symbolPath.__dimIdx
  29155. ),
  29156. defaultText
  29157. ) : '';
  29158. });
  29159. function onEmphasis() {
  29160. polygon.attr('ignore', hoverPolygonIgnore);
  29161. }
  29162. function onNormal() {
  29163. polygon.attr('ignore', polygonIgnore);
  29164. }
  29165. itemGroup.off('mouseover').off('mouseout').off('normal').off('emphasis');
  29166. itemGroup.on('emphasis', onEmphasis)
  29167. .on('mouseover', onEmphasis)
  29168. .on('normal', onNormal)
  29169. .on('mouseout', onNormal);
  29170. graphic.setHoverStyle(itemGroup);
  29171. });
  29172. this._data = data;
  29173. },
  29174. remove: function () {
  29175. this.group.removeAll();
  29176. this._data = null;
  29177. },
  29178. dispose: function () {}
  29179. });
  29180. /***/ },
  29181. /* 167 */
  29182. /***/ function(module, exports) {
  29183. module.exports = function (ecModel) {
  29184. ecModel.eachSeriesByType('radar', function (seriesModel) {
  29185. var data = seriesModel.getData();
  29186. var points = [];
  29187. var coordSys = seriesModel.coordinateSystem;
  29188. if (!coordSys) {
  29189. return;
  29190. }
  29191. function pointsConverter(val, idx) {
  29192. points[idx] = points[idx] || [];
  29193. points[idx][i] = coordSys.dataToPoint(val, i);
  29194. }
  29195. for (var i = 0; i < coordSys.getIndicatorAxes().length; i++) {
  29196. var dim = data.dimensions[i];
  29197. data.each(dim, pointsConverter);
  29198. }
  29199. data.each(function (idx) {
  29200. // Close polygon
  29201. points[idx][0] && points[idx].push(points[idx][0].slice());
  29202. data.setItemLayout(idx, points[idx]);
  29203. });
  29204. });
  29205. };
  29206. /***/ },
  29207. /* 168 */
  29208. /***/ function(module, exports, __webpack_require__) {
  29209. // Backward compat for radar chart in 2
  29210. var zrUtil = __webpack_require__(4);
  29211. module.exports = function (option) {
  29212. var polarOptArr = option.polar;
  29213. if (polarOptArr) {
  29214. if (!zrUtil.isArray(polarOptArr)) {
  29215. polarOptArr = [polarOptArr];
  29216. }
  29217. var polarNotRadar = [];
  29218. zrUtil.each(polarOptArr, function (polarOpt, idx) {
  29219. if (polarOpt.indicator) {
  29220. if (polarOpt.type && !polarOpt.shape) {
  29221. polarOpt.shape = polarOpt.type;
  29222. }
  29223. option.radar = option.radar || [];
  29224. if (!zrUtil.isArray(option.radar)) {
  29225. option.radar = [option.radar];
  29226. }
  29227. option.radar.push(polarOpt);
  29228. }
  29229. else {
  29230. polarNotRadar.push(polarOpt);
  29231. }
  29232. });
  29233. option.polar = polarNotRadar;
  29234. }
  29235. zrUtil.each(option.series, function (seriesOpt) {
  29236. if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
  29237. seriesOpt.radarIndex = seriesOpt.polarIndex;
  29238. }
  29239. });
  29240. };
  29241. /***/ },
  29242. /* 169 */
  29243. /***/ function(module, exports, __webpack_require__) {
  29244. var echarts = __webpack_require__(1);
  29245. var PRIORITY = echarts.PRIORITY;
  29246. __webpack_require__(170);
  29247. __webpack_require__(181);
  29248. __webpack_require__(187);
  29249. __webpack_require__(171);
  29250. echarts.registerLayout(__webpack_require__(189));
  29251. echarts.registerVisual(__webpack_require__(190));
  29252. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, __webpack_require__(191));
  29253. echarts.registerPreprocessor(__webpack_require__(192));
  29254. __webpack_require__(150)('map', [{
  29255. type: 'mapToggleSelect',
  29256. event: 'mapselectchanged',
  29257. method: 'toggleSelected'
  29258. }, {
  29259. type: 'mapSelect',
  29260. event: 'mapselected',
  29261. method: 'select'
  29262. }, {
  29263. type: 'mapUnSelect',
  29264. event: 'mapunselected',
  29265. method: 'unSelect'
  29266. }]);
  29267. /***/ },
  29268. /* 170 */
  29269. /***/ function(module, exports, __webpack_require__) {
  29270. var List = __webpack_require__(98);
  29271. var SeriesModel = __webpack_require__(78);
  29272. var zrUtil = __webpack_require__(4);
  29273. var completeDimensions = __webpack_require__(110);
  29274. var formatUtil = __webpack_require__(6);
  29275. var encodeHTML = formatUtil.encodeHTML;
  29276. var addCommas = formatUtil.addCommas;
  29277. var dataSelectableMixin = __webpack_require__(148);
  29278. var geoCreator = __webpack_require__(171);
  29279. var MapSeries = SeriesModel.extend({
  29280. type: 'series.map',
  29281. dependencies: ['geo'],
  29282. layoutMode: 'box',
  29283. /**
  29284. * Only first map series of same mapType will drawMap
  29285. * @type {boolean}
  29286. */
  29287. needsDrawMap: false,
  29288. /**
  29289. * Group of all map series with same mapType
  29290. * @type {boolean}
  29291. */
  29292. seriesGroup: [],
  29293. init: function (option) {
  29294. option = this._fillOption(option, this.getMapType());
  29295. this.option = option;
  29296. MapSeries.superApply(this, 'init', arguments);
  29297. this.updateSelectedMap(option.data);
  29298. },
  29299. getInitialData: function (option) {
  29300. var dimensions = completeDimensions(['value'], option.data || []);
  29301. var list = new List(dimensions, this);
  29302. list.initData(option.data);
  29303. return list;
  29304. },
  29305. mergeOption: function (newOption) {
  29306. if (newOption.data) {
  29307. newOption = this._fillOption(newOption, this.getMapType());
  29308. }
  29309. MapSeries.superCall(this, 'mergeOption', newOption);
  29310. this.updateSelectedMap(this.option.data);
  29311. },
  29312. /**
  29313. * If no host geo model, return null, which means using a
  29314. * inner exclusive geo model.
  29315. */
  29316. getHostGeoModel: function () {
  29317. var geoIndex = this.option.geoIndex;
  29318. return geoIndex != null
  29319. ? this.dependentModels.geo[geoIndex]
  29320. : null;
  29321. },
  29322. getMapType: function () {
  29323. return (this.getHostGeoModel() || this).option.map;
  29324. },
  29325. _fillOption: function (option, mapName) {
  29326. // Shallow clone
  29327. option = zrUtil.extend({}, option);
  29328. option.data = geoCreator.getFilledRegions(option.data, mapName);
  29329. return option;
  29330. },
  29331. getRawValue: function (dataIndex) {
  29332. // Use value stored in data instead because it is calculated from multiple series
  29333. // FIXME Provide all value of multiple series ?
  29334. return this.getData().get('value', dataIndex);
  29335. },
  29336. /**
  29337. * Get model of region
  29338. * @param {string} name
  29339. * @return {module:echarts/model/Model}
  29340. */
  29341. getRegionModel: function (regionName) {
  29342. var data = this.getData();
  29343. return data.getItemModel(data.indexOfName(regionName));
  29344. },
  29345. /**
  29346. * Map tooltip formatter
  29347. *
  29348. * @param {number} dataIndex
  29349. */
  29350. formatTooltip: function (dataIndex) {
  29351. // FIXME orignalData and data is a bit confusing
  29352. var data = this.getData();
  29353. var formattedValue = addCommas(this.getRawValue(dataIndex));
  29354. var name = data.getName(dataIndex);
  29355. var seriesGroup = this.seriesGroup;
  29356. var seriesNames = [];
  29357. for (var i = 0; i < seriesGroup.length; i++) {
  29358. var otherIndex = seriesGroup[i].originalData.indexOfName(name);
  29359. if (!isNaN(seriesGroup[i].originalData.get('value', otherIndex))) {
  29360. seriesNames.push(
  29361. encodeHTML(seriesGroup[i].name)
  29362. );
  29363. }
  29364. }
  29365. return seriesNames.join(', ') + '<br />'
  29366. + encodeHTML(name + ' : ' + formattedValue);
  29367. },
  29368. /**
  29369. * @implement
  29370. */
  29371. getTooltipPosition: function (dataIndex) {
  29372. if (dataIndex != null) {
  29373. var name = this.getData().getName(dataIndex);
  29374. var geo = this.coordinateSystem;
  29375. var region = geo.getRegion(name);
  29376. return region && geo.dataToPoint(region.center);
  29377. }
  29378. },
  29379. setZoom: function (zoom) {
  29380. this.option.zoom = zoom;
  29381. },
  29382. setCenter: function (center) {
  29383. this.option.center = center;
  29384. },
  29385. defaultOption: {
  29386. // 一级层叠
  29387. zlevel: 0,
  29388. // 二级层叠
  29389. z: 2,
  29390. coordinateSystem: 'geo',
  29391. // map should be explicitly specified since ec3.
  29392. map: '',
  29393. // If `geoIndex` is not specified, a exclusive geo will be
  29394. // created. Otherwise use the specified geo component, and
  29395. // `map` and `mapType` are ignored.
  29396. // geoIndex: 0,
  29397. // 'center' | 'left' | 'right' | 'x%' | {number}
  29398. left: 'center',
  29399. // 'center' | 'top' | 'bottom' | 'x%' | {number}
  29400. top: 'center',
  29401. // right
  29402. // bottom
  29403. // width:
  29404. // height
  29405. // Aspect is width / height. Inited to be geoJson bbox aspect
  29406. // This parameter is used for scale this aspect
  29407. aspectScale: 0.75,
  29408. ///// Layout with center and size
  29409. // If you wan't to put map in a fixed size box with right aspect ratio
  29410. // This two properties may more conveninet
  29411. // layoutCenter: [50%, 50%]
  29412. // layoutSize: 100
  29413. // 数值合并方式,默认加和,可选为:
  29414. // 'sum' | 'average' | 'max' | 'min'
  29415. // mapValueCalculation: 'sum',
  29416. // 地图数值计算结果小数精度
  29417. // mapValuePrecision: 0,
  29418. // 显示图例颜色标识(系列标识的小圆点),图例开启时有效
  29419. showLegendSymbol: true,
  29420. // 选择模式,默认关闭,可选single,multiple
  29421. // selectedMode: false,
  29422. dataRangeHoverLink: true,
  29423. // 是否开启缩放及漫游模式
  29424. // roam: false,
  29425. // Define left-top, right-bottom coords to control view
  29426. // For example, [ [180, 90], [-180, -90] ],
  29427. // higher priority than center and zoom
  29428. boundingCoords: null,
  29429. // Default on center of map
  29430. center: null,
  29431. zoom: 1,
  29432. scaleLimit: null,
  29433. label: {
  29434. normal: {
  29435. show: false,
  29436. textStyle: {
  29437. color: '#000'
  29438. }
  29439. },
  29440. emphasis: {
  29441. show: true,
  29442. textStyle: {
  29443. color: 'rgb(100,0,0)'
  29444. }
  29445. }
  29446. },
  29447. // scaleLimit: null,
  29448. itemStyle: {
  29449. normal: {
  29450. // color: 各异,
  29451. borderWidth: 0.5,
  29452. borderColor: '#444',
  29453. areaColor: '#eee'
  29454. },
  29455. // 也是选中样式
  29456. emphasis: {
  29457. areaColor: 'rgba(255,215,0,0.8)'
  29458. }
  29459. }
  29460. }
  29461. });
  29462. zrUtil.mixin(MapSeries, dataSelectableMixin);
  29463. module.exports = MapSeries;
  29464. /***/ },
  29465. /* 171 */
  29466. /***/ function(module, exports, __webpack_require__) {
  29467. var Geo = __webpack_require__(172);
  29468. var layout = __webpack_require__(71);
  29469. var zrUtil = __webpack_require__(4);
  29470. var numberUtil = __webpack_require__(7);
  29471. var mapDataStores = {};
  29472. /**
  29473. * Resize method bound to the geo
  29474. * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
  29475. * @param {module:echarts/ExtensionAPI} api
  29476. */
  29477. function resizeGeo (geoModel, api) {
  29478. var boundingCoords = geoModel.get('boundingCoords');
  29479. if (boundingCoords != null) {
  29480. var leftTop = boundingCoords[0];
  29481. var rightBottom = boundingCoords[1];
  29482. if (isNaN(leftTop[0]) || isNaN(leftTop[1]) || isNaN(rightBottom[0]) || isNaN(rightBottom[1])) {
  29483. if (true) {
  29484. console.error('Invalid boundingCoords');
  29485. }
  29486. }
  29487. else {
  29488. this.setBoundingRect(leftTop[0], leftTop[1], rightBottom[0] - leftTop[0], rightBottom[1] - leftTop[1]);
  29489. }
  29490. }
  29491. var rect = this.getBoundingRect();
  29492. var boxLayoutOption;
  29493. var center = geoModel.get('layoutCenter');
  29494. var size = geoModel.get('layoutSize');
  29495. var viewWidth = api.getWidth();
  29496. var viewHeight = api.getHeight();
  29497. var aspectScale = geoModel.get('aspectScale') || 0.75;
  29498. var aspect = rect.width / rect.height * aspectScale;
  29499. var useCenterAndSize = false;
  29500. if (center && size) {
  29501. center = [
  29502. numberUtil.parsePercent(center[0], viewWidth),
  29503. numberUtil.parsePercent(center[1], viewHeight)
  29504. ];
  29505. size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
  29506. if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
  29507. useCenterAndSize = true;
  29508. }
  29509. else {
  29510. if (true) {
  29511. console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
  29512. }
  29513. }
  29514. }
  29515. var viewRect;
  29516. if (useCenterAndSize) {
  29517. var viewRect = {};
  29518. if (aspect > 1) {
  29519. // Width is same with size
  29520. viewRect.width = size;
  29521. viewRect.height = size / aspect;
  29522. }
  29523. else {
  29524. viewRect.height = size;
  29525. viewRect.width = size * aspect;
  29526. }
  29527. viewRect.y = center[1] - viewRect.height / 2;
  29528. viewRect.x = center[0] - viewRect.width / 2;
  29529. }
  29530. else {
  29531. // Use left/top/width/height
  29532. boxLayoutOption = geoModel.getBoxLayoutParams();
  29533. // 0.75 rate
  29534. boxLayoutOption.aspect = aspect;
  29535. viewRect = layout.getLayoutRect(boxLayoutOption, {
  29536. width: viewWidth,
  29537. height: viewHeight
  29538. });
  29539. }
  29540. this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
  29541. this.setCenter(geoModel.get('center'));
  29542. this.setZoom(geoModel.get('zoom'));
  29543. }
  29544. /**
  29545. * @param {module:echarts/coord/Geo} geo
  29546. * @param {module:echarts/model/Model} model
  29547. * @inner
  29548. */
  29549. function setGeoCoords(geo, model) {
  29550. zrUtil.each(model.get('geoCoord'), function (geoCoord, name) {
  29551. geo.addGeoCoord(name, geoCoord);
  29552. });
  29553. }
  29554. if (true) {
  29555. var mapNotExistsError = function (name) {
  29556. console.error('Map ' + name + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html');
  29557. };
  29558. }
  29559. var geoCreator = {
  29560. // For deciding which dimensions to use when creating list data
  29561. dimensions: Geo.prototype.dimensions,
  29562. create: function (ecModel, api) {
  29563. var geoList = [];
  29564. // FIXME Create each time may be slow
  29565. ecModel.eachComponent('geo', function (geoModel, idx) {
  29566. var name = geoModel.get('map');
  29567. var mapData = mapDataStores[name];
  29568. if (true) {
  29569. if (!mapData) {
  29570. mapNotExistsError(name);
  29571. }
  29572. }
  29573. var geo = new Geo(
  29574. name + idx, name,
  29575. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  29576. geoModel.get('nameMap')
  29577. );
  29578. geo.zoomLimit = geoModel.get('scaleLimit');
  29579. geoList.push(geo);
  29580. setGeoCoords(geo, geoModel);
  29581. geoModel.coordinateSystem = geo;
  29582. geo.model = geoModel;
  29583. // Inject resize method
  29584. geo.resize = resizeGeo;
  29585. geo.resize(geoModel, api);
  29586. });
  29587. ecModel.eachSeries(function (seriesModel) {
  29588. var coordSys = seriesModel.get('coordinateSystem');
  29589. if (coordSys === 'geo') {
  29590. var geoIndex = seriesModel.get('geoIndex') || 0;
  29591. seriesModel.coordinateSystem = geoList[geoIndex];
  29592. }
  29593. });
  29594. // If has map series
  29595. var mapModelGroupBySeries = {};
  29596. ecModel.eachSeriesByType('map', function (seriesModel) {
  29597. if (!seriesModel.getHostGeoModel()) {
  29598. var mapType = seriesModel.getMapType();
  29599. mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || [];
  29600. mapModelGroupBySeries[mapType].push(seriesModel);
  29601. }
  29602. });
  29603. zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) {
  29604. var mapData = mapDataStores[mapType];
  29605. if (true) {
  29606. if (!mapData) {
  29607. mapNotExistsError(mapSeries[0].get('map'));
  29608. }
  29609. }
  29610. var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) {
  29611. return singleMapSeries.get('nameMap');
  29612. });
  29613. var geo = new Geo(
  29614. mapType, mapType,
  29615. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  29616. zrUtil.mergeAll(nameMapList)
  29617. );
  29618. geo.zoomLimit = zrUtil.retrieve.apply(null, zrUtil.map(mapSeries, function (singleMapSeries) {
  29619. return singleMapSeries.get('scaleLimit');
  29620. }));
  29621. geoList.push(geo);
  29622. // Inject resize method
  29623. geo.resize = resizeGeo;
  29624. geo.resize(mapSeries[0], api);
  29625. zrUtil.each(mapSeries, function (singleMapSeries) {
  29626. singleMapSeries.coordinateSystem = geo;
  29627. setGeoCoords(geo, singleMapSeries);
  29628. });
  29629. });
  29630. return geoList;
  29631. },
  29632. /**
  29633. * @param {string} mapName
  29634. * @param {Object|string} geoJson
  29635. * @param {Object} [specialAreas]
  29636. *
  29637. * @example
  29638. * $.get('USA.json', function (geoJson) {
  29639. * echarts.registerMap('USA', geoJson);
  29640. * // Or
  29641. * echarts.registerMap('USA', {
  29642. * geoJson: geoJson,
  29643. * specialAreas: {}
  29644. * })
  29645. * });
  29646. */
  29647. registerMap: function (mapName, geoJson, specialAreas) {
  29648. if (geoJson.geoJson && !geoJson.features) {
  29649. specialAreas = geoJson.specialAreas;
  29650. geoJson = geoJson.geoJson;
  29651. }
  29652. if (typeof geoJson === 'string') {
  29653. geoJson = (typeof JSON !== 'undefined' && JSON.parse)
  29654. ? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))();
  29655. }
  29656. mapDataStores[mapName] = {
  29657. geoJson: geoJson,
  29658. specialAreas: specialAreas
  29659. };
  29660. },
  29661. /**
  29662. * @param {string} mapName
  29663. * @return {Object}
  29664. */
  29665. getMap: function (mapName) {
  29666. return mapDataStores[mapName];
  29667. },
  29668. /**
  29669. * Fill given regions array
  29670. * @param {Array.<Object>} originRegionArr
  29671. * @param {string} mapName
  29672. * @return {Array}
  29673. */
  29674. getFilledRegions: function (originRegionArr, mapName) {
  29675. // Not use the original
  29676. var regionsArr = (originRegionArr || []).slice();
  29677. var map = geoCreator.getMap(mapName);
  29678. var geoJson = map && map.geoJson;
  29679. if (!geoJson) {
  29680. if (true) {
  29681. mapNotExistsError(mapName);
  29682. }
  29683. return originRegionArr;
  29684. }
  29685. var dataNameMap = zrUtil.createHashMap();
  29686. var features = geoJson.features;
  29687. for (var i = 0; i < regionsArr.length; i++) {
  29688. dataNameMap.set(regionsArr[i].name, regionsArr[i]);
  29689. }
  29690. for (var i = 0; i < features.length; i++) {
  29691. var name = features[i].properties.name;
  29692. if (!dataNameMap.get(name)) {
  29693. regionsArr.push({
  29694. name: name
  29695. });
  29696. }
  29697. }
  29698. return regionsArr;
  29699. }
  29700. };
  29701. // Inject methods into echarts
  29702. var echarts = __webpack_require__(1);
  29703. echarts.registerMap = geoCreator.registerMap;
  29704. echarts.getMap = geoCreator.getMap;
  29705. echarts.parseGeoJSON = __webpack_require__(173);
  29706. // TODO
  29707. echarts.loadMap = function () {};
  29708. echarts.registerCoordinateSystem('geo', geoCreator);
  29709. module.exports = geoCreator;
  29710. /***/ },
  29711. /* 172 */
  29712. /***/ function(module, exports, __webpack_require__) {
  29713. var parseGeoJson = __webpack_require__(173);
  29714. var zrUtil = __webpack_require__(4);
  29715. var BoundingRect = __webpack_require__(9);
  29716. var View = __webpack_require__(176);
  29717. // Geo fix functions
  29718. var geoFixFuncs = [
  29719. __webpack_require__(177),
  29720. __webpack_require__(178),
  29721. __webpack_require__(179),
  29722. __webpack_require__(180)
  29723. ];
  29724. /**
  29725. * [Geo description]
  29726. * @param {string} name Geo name
  29727. * @param {string} map Map type
  29728. * @param {Object} geoJson
  29729. * @param {Object} [specialAreas]
  29730. * Specify the positioned areas by left, top, width, height
  29731. * @param {Object.<string, string>} [nameMap]
  29732. * Specify name alias
  29733. */
  29734. function Geo(name, map, geoJson, specialAreas, nameMap) {
  29735. View.call(this, name);
  29736. /**
  29737. * Map type
  29738. * @type {string}
  29739. */
  29740. this.map = map;
  29741. this._nameCoordMap = zrUtil.createHashMap();
  29742. this.loadGeoJson(geoJson, specialAreas, nameMap);
  29743. }
  29744. Geo.prototype = {
  29745. constructor: Geo,
  29746. type: 'geo',
  29747. /**
  29748. * @param {Array.<string>}
  29749. * @readOnly
  29750. */
  29751. dimensions: ['lng', 'lat'],
  29752. /**
  29753. * If contain given lng,lat coord
  29754. * @param {Array.<number>}
  29755. * @readOnly
  29756. */
  29757. containCoord: function (coord) {
  29758. var regions = this.regions;
  29759. for (var i = 0; i < regions.length; i++) {
  29760. if (regions[i].contain(coord)) {
  29761. return true;
  29762. }
  29763. }
  29764. return false;
  29765. },
  29766. /**
  29767. * @param {Object} geoJson
  29768. * @param {Object} [specialAreas]
  29769. * Specify the positioned areas by left, top, width, height
  29770. * @param {Object.<string, string>} [nameMap]
  29771. * Specify name alias
  29772. */
  29773. loadGeoJson: function (geoJson, specialAreas, nameMap) {
  29774. // https://jsperf.com/try-catch-performance-overhead
  29775. try {
  29776. this.regions = geoJson ? parseGeoJson(geoJson) : [];
  29777. }
  29778. catch (e) {
  29779. throw 'Invalid geoJson format\n' + e.message;
  29780. }
  29781. specialAreas = specialAreas || {};
  29782. nameMap = nameMap || {};
  29783. var regions = this.regions;
  29784. var regionsMap = zrUtil.createHashMap();
  29785. for (var i = 0; i < regions.length; i++) {
  29786. var regionName = regions[i].name;
  29787. // Try use the alias in nameMap
  29788. regionName = nameMap.hasOwnProperty(regionName) ? nameMap[regionName] : regionName;
  29789. regions[i].name = regionName;
  29790. regionsMap.set(regionName, regions[i]);
  29791. // Add geoJson
  29792. this.addGeoCoord(regionName, regions[i].center);
  29793. // Some area like Alaska in USA map needs to be tansformed
  29794. // to look better
  29795. var specialArea = specialAreas[regionName];
  29796. if (specialArea) {
  29797. regions[i].transformTo(
  29798. specialArea.left, specialArea.top, specialArea.width, specialArea.height
  29799. );
  29800. }
  29801. }
  29802. this._regionsMap = regionsMap;
  29803. this._rect = null;
  29804. zrUtil.each(geoFixFuncs, function (fixFunc) {
  29805. fixFunc(this);
  29806. }, this);
  29807. },
  29808. // Overwrite
  29809. transformTo: function (x, y, width, height) {
  29810. var rect = this.getBoundingRect();
  29811. rect = rect.clone();
  29812. // Longitute is inverted
  29813. rect.y = -rect.y - rect.height;
  29814. var viewTransform = this._viewTransform;
  29815. viewTransform.transform = rect.calculateTransform(
  29816. new BoundingRect(x, y, width, height)
  29817. );
  29818. viewTransform.decomposeTransform();
  29819. var scale = viewTransform.scale;
  29820. scale[1] = -scale[1];
  29821. viewTransform.updateTransform();
  29822. this._updateTransform();
  29823. },
  29824. /**
  29825. * @param {string} name
  29826. * @return {module:echarts/coord/geo/Region}
  29827. */
  29828. getRegion: function (name) {
  29829. return this._regionsMap.get(name);
  29830. },
  29831. getRegionByCoord: function (coord) {
  29832. var regions = this.regions;
  29833. for (var i = 0; i < regions.length; i++) {
  29834. if (regions[i].contain(coord)) {
  29835. return regions[i];
  29836. }
  29837. }
  29838. },
  29839. /**
  29840. * Add geoCoord for indexing by name
  29841. * @param {string} name
  29842. * @param {Array.<number>} geoCoord
  29843. */
  29844. addGeoCoord: function (name, geoCoord) {
  29845. this._nameCoordMap.set(name, geoCoord);
  29846. },
  29847. /**
  29848. * Get geoCoord by name
  29849. * @param {string} name
  29850. * @return {Array.<number>}
  29851. */
  29852. getGeoCoord: function (name) {
  29853. return this._nameCoordMap.get(name);
  29854. },
  29855. // Overwrite
  29856. getBoundingRect: function () {
  29857. if (this._rect) {
  29858. return this._rect;
  29859. }
  29860. var rect;
  29861. var regions = this.regions;
  29862. for (var i = 0; i < regions.length; i++) {
  29863. var regionRect = regions[i].getBoundingRect();
  29864. rect = rect || regionRect.clone();
  29865. rect.union(regionRect);
  29866. }
  29867. // FIXME Always return new ?
  29868. return (this._rect = rect || new BoundingRect(0, 0, 0, 0));
  29869. },
  29870. /**
  29871. * Convert series data to a list of points
  29872. * @param {module:echarts/data/List} data
  29873. * @param {boolean} stack
  29874. * @return {Array}
  29875. * Return list of points. For example:
  29876. * `[[10, 10], [20, 20], [30, 30]]`
  29877. */
  29878. dataToPoints: function (data) {
  29879. var item = [];
  29880. return data.mapArray(['lng', 'lat'], function (lon, lat) {
  29881. item[0] = lon;
  29882. item[1] = lat;
  29883. return this.dataToPoint(item);
  29884. }, this);
  29885. },
  29886. /**
  29887. * @param {string|Array.<number>} data
  29888. * @return {Array.<number>}
  29889. */
  29890. dataToPoint: function (data) {
  29891. if (typeof data === 'string') {
  29892. // Map area name to geoCoord
  29893. data = this.getGeoCoord(data);
  29894. }
  29895. if (data) {
  29896. return View.prototype.dataToPoint.call(this, data);
  29897. }
  29898. },
  29899. /**
  29900. * @inheritDoc
  29901. */
  29902. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  29903. /**
  29904. * @inheritDoc
  29905. */
  29906. convertFromPixel: zrUtil.curry(doConvert, 'pointToData')
  29907. };
  29908. zrUtil.mixin(Geo, View);
  29909. function doConvert(methodName, ecModel, finder, value) {
  29910. var geoModel = finder.geoModel;
  29911. var seriesModel = finder.seriesModel;
  29912. var coordSys = geoModel
  29913. ? geoModel.coordinateSystem
  29914. : seriesModel
  29915. ? (
  29916. seriesModel.coordinateSystem // For map.
  29917. || (seriesModel.getReferringComponents('geo')[0] || {}).coordinateSystem
  29918. )
  29919. : null;
  29920. return coordSys === this ? coordSys[methodName](value) : null;
  29921. }
  29922. module.exports = Geo;
  29923. /***/ },
  29924. /* 173 */
  29925. /***/ function(module, exports, __webpack_require__) {
  29926. /**
  29927. * Parse and decode geo json
  29928. * @module echarts/coord/geo/parseGeoJson
  29929. */
  29930. var zrUtil = __webpack_require__(4);
  29931. var Region = __webpack_require__(174);
  29932. function decode(json) {
  29933. if (!json.UTF8Encoding) {
  29934. return json;
  29935. }
  29936. var encodeScale = json.UTF8Scale;
  29937. if (encodeScale == null) {
  29938. encodeScale = 1024;
  29939. }
  29940. var features = json.features;
  29941. for (var f = 0; f < features.length; f++) {
  29942. var feature = features[f];
  29943. var geometry = feature.geometry;
  29944. var coordinates = geometry.coordinates;
  29945. var encodeOffsets = geometry.encodeOffsets;
  29946. for (var c = 0; c < coordinates.length; c++) {
  29947. var coordinate = coordinates[c];
  29948. if (geometry.type === 'Polygon') {
  29949. coordinates[c] = decodePolygon(
  29950. coordinate,
  29951. encodeOffsets[c],
  29952. encodeScale
  29953. );
  29954. }
  29955. else if (geometry.type === 'MultiPolygon') {
  29956. for (var c2 = 0; c2 < coordinate.length; c2++) {
  29957. var polygon = coordinate[c2];
  29958. coordinate[c2] = decodePolygon(
  29959. polygon,
  29960. encodeOffsets[c][c2],
  29961. encodeScale
  29962. );
  29963. }
  29964. }
  29965. }
  29966. }
  29967. // Has been decoded
  29968. json.UTF8Encoding = false;
  29969. return json;
  29970. }
  29971. function decodePolygon(coordinate, encodeOffsets, encodeScale) {
  29972. var result = [];
  29973. var prevX = encodeOffsets[0];
  29974. var prevY = encodeOffsets[1];
  29975. for (var i = 0; i < coordinate.length; i += 2) {
  29976. var x = coordinate.charCodeAt(i) - 64;
  29977. var y = coordinate.charCodeAt(i + 1) - 64;
  29978. // ZigZag decoding
  29979. x = (x >> 1) ^ (-(x & 1));
  29980. y = (y >> 1) ^ (-(y & 1));
  29981. // Delta deocding
  29982. x += prevX;
  29983. y += prevY;
  29984. prevX = x;
  29985. prevY = y;
  29986. // Dequantize
  29987. result.push([x / encodeScale, y / encodeScale]);
  29988. }
  29989. return result;
  29990. }
  29991. /**
  29992. * @alias module:echarts/coord/geo/parseGeoJson
  29993. * @param {Object} geoJson
  29994. * @return {module:zrender/container/Group}
  29995. */
  29996. module.exports = function (geoJson) {
  29997. decode(geoJson);
  29998. return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {
  29999. // Output of mapshaper may have geometry null
  30000. return featureObj.geometry
  30001. && featureObj.properties
  30002. && featureObj.geometry.coordinates.length > 0;
  30003. }), function (featureObj) {
  30004. var properties = featureObj.properties;
  30005. var geo = featureObj.geometry;
  30006. var coordinates = geo.coordinates;
  30007. var geometries = [];
  30008. if (geo.type === 'Polygon') {
  30009. geometries.push({
  30010. type: 'polygon',
  30011. // According to the GeoJSON specification.
  30012. // First must be exterior, and the rest are all interior(holes).
  30013. exterior: coordinates[0],
  30014. interiors: coordinates.slice(1)
  30015. });
  30016. }
  30017. if (geo.type === 'MultiPolygon') {
  30018. zrUtil.each(coordinates, function (item) {
  30019. if (item[0]) {
  30020. geometries.push({
  30021. type: 'polygon',
  30022. exterior: item[0],
  30023. interiors: item.slice(1)
  30024. });
  30025. }
  30026. });
  30027. }
  30028. var region = new Region(
  30029. properties.name,
  30030. geometries,
  30031. properties.cp
  30032. );
  30033. region.properties = properties;
  30034. return region;
  30035. });
  30036. };
  30037. /***/ },
  30038. /* 174 */
  30039. /***/ function(module, exports, __webpack_require__) {
  30040. /**
  30041. * @module echarts/coord/geo/Region
  30042. */
  30043. var polygonContain = __webpack_require__(175);
  30044. var BoundingRect = __webpack_require__(9);
  30045. var bbox = __webpack_require__(38);
  30046. var vec2 = __webpack_require__(10);
  30047. /**
  30048. * @param {string} name
  30049. * @param {Array} geometries
  30050. * @param {Array.<number>} cp
  30051. */
  30052. function Region(name, geometries, cp) {
  30053. /**
  30054. * @type {string}
  30055. * @readOnly
  30056. */
  30057. this.name = name;
  30058. /**
  30059. * @type {Array.<Array>}
  30060. * @readOnly
  30061. */
  30062. this.geometries = geometries;
  30063. if (!cp) {
  30064. var rect = this.getBoundingRect();
  30065. cp = [
  30066. rect.x + rect.width / 2,
  30067. rect.y + rect.height / 2
  30068. ];
  30069. }
  30070. else {
  30071. cp = [cp[0], cp[1]];
  30072. }
  30073. /**
  30074. * @type {Array.<number>}
  30075. */
  30076. this.center = cp;
  30077. }
  30078. Region.prototype = {
  30079. constructor: Region,
  30080. properties: null,
  30081. /**
  30082. * @return {module:zrender/core/BoundingRect}
  30083. */
  30084. getBoundingRect: function () {
  30085. var rect = this._rect;
  30086. if (rect) {
  30087. return rect;
  30088. }
  30089. var MAX_NUMBER = Number.MAX_VALUE;
  30090. var min = [MAX_NUMBER, MAX_NUMBER];
  30091. var max = [-MAX_NUMBER, -MAX_NUMBER];
  30092. var min2 = [];
  30093. var max2 = [];
  30094. var geometries = this.geometries;
  30095. for (var i = 0; i < geometries.length; i++) {
  30096. // Only support polygon
  30097. if (geometries[i].type !== 'polygon') {
  30098. continue;
  30099. }
  30100. // Doesn't consider hole
  30101. var exterior = geometries[i].exterior;
  30102. bbox.fromPoints(exterior, min2, max2);
  30103. vec2.min(min, min, min2);
  30104. vec2.max(max, max, max2);
  30105. }
  30106. // No data
  30107. if (i === 0) {
  30108. min[0] = min[1] = max[0] = max[1] = 0;
  30109. }
  30110. return (this._rect = new BoundingRect(
  30111. min[0], min[1], max[0] - min[0], max[1] - min[1]
  30112. ));
  30113. },
  30114. /**
  30115. * @param {<Array.<number>} coord
  30116. * @return {boolean}
  30117. */
  30118. contain: function (coord) {
  30119. var rect = this.getBoundingRect();
  30120. var geometries = this.geometries;
  30121. if (!rect.contain(coord[0], coord[1])) {
  30122. return false;
  30123. }
  30124. loopGeo: for (var i = 0, len = geometries.length; i < len; i++) {
  30125. // Only support polygon.
  30126. if (geometries[i].type !== 'polygon') {
  30127. continue;
  30128. }
  30129. var exterior = geometries[i].exterior;
  30130. var interiors = geometries[i].interiors;
  30131. if (polygonContain.contain(exterior, coord[0], coord[1])) {
  30132. // Not in the region if point is in the hole.
  30133. for (var k = 0; k < (interiors ? interiors.length : 0); k++) {
  30134. if (polygonContain.contain(interiors[k])) {
  30135. continue loopGeo;
  30136. }
  30137. }
  30138. return true;
  30139. }
  30140. }
  30141. return false;
  30142. },
  30143. transformTo: function (x, y, width, height) {
  30144. var rect = this.getBoundingRect();
  30145. var aspect = rect.width / rect.height;
  30146. if (!width) {
  30147. width = aspect * height;
  30148. }
  30149. else if (!height) {
  30150. height = width / aspect ;
  30151. }
  30152. var target = new BoundingRect(x, y, width, height);
  30153. var transform = rect.calculateTransform(target);
  30154. var geometries = this.geometries;
  30155. for (var i = 0; i < geometries.length; i++) {
  30156. // Only support polygon.
  30157. if (geometries[i].type !== 'polygon') {
  30158. continue;
  30159. }
  30160. var exterior = geometries[i].exterior;
  30161. var interiors = geometries[i].interiors;
  30162. for (var p = 0; p < exterior.length; p++) {
  30163. vec2.applyTransform(exterior[p], exterior[p], transform);
  30164. }
  30165. for (var h = 0; h < (interiors ? interiors.length : 0); h++) {
  30166. for (var p = 0; p < interiors[h].length; p++) {
  30167. vec2.applyTransform(interiors[h][p], interiors[h][p], transform);
  30168. }
  30169. }
  30170. }
  30171. rect = this._rect;
  30172. rect.copy(target);
  30173. // Update center
  30174. this.center = [
  30175. rect.x + rect.width / 2,
  30176. rect.y + rect.height / 2
  30177. ];
  30178. }
  30179. };
  30180. module.exports = Region;
  30181. /***/ },
  30182. /* 175 */
  30183. /***/ function(module, exports, __webpack_require__) {
  30184. var windingLine = __webpack_require__(45);
  30185. var EPSILON = 1e-8;
  30186. function isAroundEqual(a, b) {
  30187. return Math.abs(a - b) < EPSILON;
  30188. }
  30189. function contain(points, x, y) {
  30190. var w = 0;
  30191. var p = points[0];
  30192. if (!p) {
  30193. return false;
  30194. }
  30195. for (var i = 1; i < points.length; i++) {
  30196. var p2 = points[i];
  30197. w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
  30198. p = p2;
  30199. }
  30200. // Close polygon
  30201. var p0 = points[0];
  30202. if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) {
  30203. w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
  30204. }
  30205. return w !== 0;
  30206. }
  30207. module.exports = {
  30208. contain: contain
  30209. };
  30210. /***/ },
  30211. /* 176 */
  30212. /***/ function(module, exports, __webpack_require__) {
  30213. /**
  30214. * Simple view coordinate system
  30215. * Mapping given x, y to transformd view x, y
  30216. */
  30217. var vector = __webpack_require__(10);
  30218. var matrix = __webpack_require__(11);
  30219. var Transformable = __webpack_require__(26);
  30220. var zrUtil = __webpack_require__(4);
  30221. var BoundingRect = __webpack_require__(9);
  30222. var v2ApplyTransform = vector.applyTransform;
  30223. // Dummy transform node
  30224. function TransformDummy() {
  30225. Transformable.call(this);
  30226. }
  30227. zrUtil.mixin(TransformDummy, Transformable);
  30228. function View(name) {
  30229. /**
  30230. * @type {string}
  30231. */
  30232. this.name = name;
  30233. /**
  30234. * @type {Object}
  30235. */
  30236. this.zoomLimit;
  30237. Transformable.call(this);
  30238. this._roamTransform = new TransformDummy();
  30239. this._viewTransform = new TransformDummy();
  30240. this._center;
  30241. this._zoom;
  30242. }
  30243. View.prototype = {
  30244. constructor: View,
  30245. type: 'view',
  30246. /**
  30247. * @param {Array.<string>}
  30248. * @readOnly
  30249. */
  30250. dimensions: ['x', 'y'],
  30251. /**
  30252. * Set bounding rect
  30253. * @param {number} x
  30254. * @param {number} y
  30255. * @param {number} width
  30256. * @param {number} height
  30257. */
  30258. // PENDING to getRect
  30259. setBoundingRect: function (x, y, width, height) {
  30260. this._rect = new BoundingRect(x, y, width, height);
  30261. return this._rect;
  30262. },
  30263. /**
  30264. * @return {module:zrender/core/BoundingRect}
  30265. */
  30266. // PENDING to getRect
  30267. getBoundingRect: function () {
  30268. return this._rect;
  30269. },
  30270. /**
  30271. * @param {number} x
  30272. * @param {number} y
  30273. * @param {number} width
  30274. * @param {number} height
  30275. */
  30276. setViewRect: function (x, y, width, height) {
  30277. this.transformTo(x, y, width, height);
  30278. this._viewRect = new BoundingRect(x, y, width, height);
  30279. },
  30280. /**
  30281. * Transformed to particular position and size
  30282. * @param {number} x
  30283. * @param {number} y
  30284. * @param {number} width
  30285. * @param {number} height
  30286. */
  30287. transformTo: function (x, y, width, height) {
  30288. var rect = this.getBoundingRect();
  30289. var viewTransform = this._viewTransform;
  30290. viewTransform.transform = rect.calculateTransform(
  30291. new BoundingRect(x, y, width, height)
  30292. );
  30293. viewTransform.decomposeTransform();
  30294. this._updateTransform();
  30295. },
  30296. /**
  30297. * Set center of view
  30298. * @param {Array.<number>} [centerCoord]
  30299. */
  30300. setCenter: function (centerCoord) {
  30301. if (!centerCoord) {
  30302. return;
  30303. }
  30304. this._center = centerCoord;
  30305. this._updateCenterAndZoom();
  30306. },
  30307. /**
  30308. * @param {number} zoom
  30309. */
  30310. setZoom: function (zoom) {
  30311. zoom = zoom || 1;
  30312. var zoomLimit = this.zoomLimit;
  30313. if (zoomLimit) {
  30314. if (zoomLimit.max != null) {
  30315. zoom = Math.min(zoomLimit.max, zoom);
  30316. }
  30317. if (zoomLimit.min != null) {
  30318. zoom = Math.max(zoomLimit.min, zoom);
  30319. }
  30320. }
  30321. this._zoom = zoom;
  30322. this._updateCenterAndZoom();
  30323. },
  30324. /**
  30325. * Get default center without roam
  30326. */
  30327. getDefaultCenter: function () {
  30328. // Rect before any transform
  30329. var rawRect = this.getBoundingRect();
  30330. var cx = rawRect.x + rawRect.width / 2;
  30331. var cy = rawRect.y + rawRect.height / 2;
  30332. return [cx, cy];
  30333. },
  30334. getCenter: function () {
  30335. return this._center || this.getDefaultCenter();
  30336. },
  30337. getZoom: function () {
  30338. return this._zoom || 1;
  30339. },
  30340. /**
  30341. * @return {Array.<number}
  30342. */
  30343. getRoamTransform: function () {
  30344. return this._roamTransform;
  30345. },
  30346. _updateCenterAndZoom: function () {
  30347. // Must update after view transform updated
  30348. var viewTransformMatrix = this._viewTransform.getLocalTransform();
  30349. var roamTransform = this._roamTransform;
  30350. var defaultCenter = this.getDefaultCenter();
  30351. var center = this.getCenter();
  30352. var zoom = this.getZoom();
  30353. center = vector.applyTransform([], center, viewTransformMatrix);
  30354. defaultCenter = vector.applyTransform([], defaultCenter, viewTransformMatrix);
  30355. roamTransform.origin = center;
  30356. roamTransform.position = [
  30357. defaultCenter[0] - center[0],
  30358. defaultCenter[1] - center[1]
  30359. ];
  30360. roamTransform.scale = [zoom, zoom];
  30361. this._updateTransform();
  30362. },
  30363. /**
  30364. * Update transform from roam and mapLocation
  30365. * @private
  30366. */
  30367. _updateTransform: function () {
  30368. var roamTransform = this._roamTransform;
  30369. var viewTransform = this._viewTransform;
  30370. viewTransform.parent = roamTransform;
  30371. roamTransform.updateTransform();
  30372. viewTransform.updateTransform();
  30373. viewTransform.transform
  30374. && matrix.copy(this.transform || (this.transform = []), viewTransform.transform);
  30375. if (this.transform) {
  30376. this.invTransform = this.invTransform || [];
  30377. matrix.invert(this.invTransform, this.transform);
  30378. }
  30379. else {
  30380. this.invTransform = null;
  30381. }
  30382. this.decomposeTransform();
  30383. },
  30384. /**
  30385. * @return {module:zrender/core/BoundingRect}
  30386. */
  30387. getViewRect: function () {
  30388. return this._viewRect;
  30389. },
  30390. /**
  30391. * Get view rect after roam transform
  30392. * @return {module:zrender/core/BoundingRect}
  30393. */
  30394. getViewRectAfterRoam: function () {
  30395. var rect = this.getBoundingRect().clone();
  30396. rect.applyTransform(this.transform);
  30397. return rect;
  30398. },
  30399. /**
  30400. * Convert a single (lon, lat) data item to (x, y) point.
  30401. * @param {Array.<number>} data
  30402. * @return {Array.<number>}
  30403. */
  30404. dataToPoint: function (data) {
  30405. var transform = this.transform;
  30406. return transform
  30407. ? v2ApplyTransform([], data, transform)
  30408. : [data[0], data[1]];
  30409. },
  30410. /**
  30411. * Convert a (x, y) point to (lon, lat) data
  30412. * @param {Array.<number>} point
  30413. * @return {Array.<number>}
  30414. */
  30415. pointToData: function (point) {
  30416. var invTransform = this.invTransform;
  30417. return invTransform
  30418. ? v2ApplyTransform([], point, invTransform)
  30419. : [point[0], point[1]];
  30420. },
  30421. /**
  30422. * @implements
  30423. * see {module:echarts/CoodinateSystem}
  30424. */
  30425. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  30426. /**
  30427. * @implements
  30428. * see {module:echarts/CoodinateSystem}
  30429. */
  30430. convertFromPixel: zrUtil.curry(doConvert, 'pointToData'),
  30431. /**
  30432. * @implements
  30433. * see {module:echarts/CoodinateSystem}
  30434. */
  30435. containPoint: function (point) {
  30436. return this.getViewRectAfterRoam().contain(point[0], point[1]);
  30437. }
  30438. /**
  30439. * @return {number}
  30440. */
  30441. // getScalarScale: function () {
  30442. // // Use determinant square root of transform to mutiply scalar
  30443. // var m = this.transform;
  30444. // var det = Math.sqrt(Math.abs(m[0] * m[3] - m[2] * m[1]));
  30445. // return det;
  30446. // }
  30447. };
  30448. zrUtil.mixin(View, Transformable);
  30449. function doConvert(methodName, ecModel, finder, value) {
  30450. var seriesModel = finder.seriesModel;
  30451. var coordSys = seriesModel ? seriesModel.coordinateSystem : null; // e.g., graph.
  30452. return coordSys === this ? coordSys[methodName](value) : null;
  30453. }
  30454. module.exports = View;
  30455. /***/ },
  30456. /* 177 */
  30457. /***/ function(module, exports, __webpack_require__) {
  30458. // Fix for 南海诸岛
  30459. var Region = __webpack_require__(174);
  30460. var zrUtil = __webpack_require__(4);
  30461. var geoCoord = [126, 25];
  30462. var points = [
  30463. [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7],
  30464. [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]],
  30465. [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]],
  30466. [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]],
  30467. [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]],
  30468. [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]],
  30469. [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]],
  30470. [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]],
  30471. [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]],
  30472. [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]],
  30473. [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]],
  30474. [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]],
  30475. [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4],
  30476. [1,92.4],[1,3.5],[0,3.5]]
  30477. ];
  30478. for (var i = 0; i < points.length; i++) {
  30479. for (var k = 0; k < points[i].length; k++) {
  30480. points[i][k][0] /= 10.5;
  30481. points[i][k][1] /= -10.5 / 0.75;
  30482. points[i][k][0] += geoCoord[0];
  30483. points[i][k][1] += geoCoord[1];
  30484. }
  30485. }
  30486. module.exports = function (geo) {
  30487. if (geo.map === 'china') {
  30488. geo.regions.push(new Region(
  30489. '南海诸岛',
  30490. zrUtil.map(points, function (exterior) {
  30491. return {
  30492. type: 'polygon',
  30493. exterior: exterior
  30494. };
  30495. }), geoCoord
  30496. ));
  30497. }
  30498. };
  30499. /***/ },
  30500. /* 178 */
  30501. /***/ function(module, exports, __webpack_require__) {
  30502. var zrUtil = __webpack_require__(4);
  30503. var coordsOffsetMap = {
  30504. '南海诸岛' : [32, 80],
  30505. // 全国
  30506. '广东': [0, -10],
  30507. '香港': [10, 5],
  30508. '澳门': [-10, 10],
  30509. //'北京': [-10, 0],
  30510. '天津': [5, 5]
  30511. };
  30512. module.exports = function (geo) {
  30513. zrUtil.each(geo.regions, function (region) {
  30514. var coordFix = coordsOffsetMap[region.name];
  30515. if (coordFix) {
  30516. var cp = region.center;
  30517. cp[0] += coordFix[0] / 10.5;
  30518. cp[1] += -coordFix[1] / (10.5 / 0.75);
  30519. }
  30520. });
  30521. };
  30522. /***/ },
  30523. /* 179 */
  30524. /***/ function(module, exports, __webpack_require__) {
  30525. var zrUtil = __webpack_require__(4);
  30526. var geoCoordMap = {
  30527. 'Russia': [100, 60],
  30528. 'United States': [-99, 38],
  30529. 'United States of America': [-99, 38]
  30530. };
  30531. module.exports = function (geo) {
  30532. zrUtil.each(geo.regions, function (region) {
  30533. var geoCoord = geoCoordMap[region.name];
  30534. if (geoCoord) {
  30535. var cp = region.center;
  30536. cp[0] = geoCoord[0];
  30537. cp[1] = geoCoord[1];
  30538. }
  30539. });
  30540. };
  30541. /***/ },
  30542. /* 180 */
  30543. /***/ function(module, exports, __webpack_require__) {
  30544. // Fix for 钓鱼岛
  30545. var Region = __webpack_require__(174);
  30546. var zrUtil = __webpack_require__(4);
  30547. var geoCoord = [126, 25];
  30548. var points = [
  30549. [
  30550. [123.45165252685547, 25.73527164402261],
  30551. [123.49731445312499, 25.73527164402261],
  30552. [123.49731445312499, 25.750734064600884],
  30553. [123.45165252685547, 25.750734064600884],
  30554. [123.45165252685547, 25.73527164402261]
  30555. ]
  30556. ];
  30557. module.exports = function (geo) {
  30558. if (geo.map === 'china') {
  30559. for (var i = 0, len = geo.regions.length; i < len; ++i) {
  30560. if (geo.regions[i].name === '台湾') {
  30561. geo.regions[i].geometries.push({
  30562. type: 'polygon',
  30563. exterior: points[0]
  30564. });
  30565. }
  30566. }
  30567. }
  30568. };
  30569. /***/ },
  30570. /* 181 */
  30571. /***/ function(module, exports, __webpack_require__) {
  30572. // var zrUtil = require('zrender/lib/core/util');
  30573. var graphic = __webpack_require__(18);
  30574. var MapDraw = __webpack_require__(182);
  30575. __webpack_require__(1).extendChartView({
  30576. type: 'map',
  30577. render: function (mapModel, ecModel, api, payload) {
  30578. // Not render if it is an toggleSelect action from self
  30579. if (payload && payload.type === 'mapToggleSelect'
  30580. && payload.from === this.uid
  30581. ) {
  30582. return;
  30583. }
  30584. var group = this.group;
  30585. group.removeAll();
  30586. if (mapModel.getHostGeoModel()) {
  30587. return;
  30588. }
  30589. // Not update map if it is an roam action from self
  30590. if (!(payload && payload.type === 'geoRoam'
  30591. && payload.componentType === 'series'
  30592. && payload.seriesId === mapModel.id
  30593. )
  30594. ) {
  30595. if (mapModel.needsDrawMap) {
  30596. var mapDraw = this._mapDraw || new MapDraw(api, true);
  30597. group.add(mapDraw.group);
  30598. mapDraw.draw(mapModel, ecModel, api, this, payload);
  30599. this._mapDraw = mapDraw;
  30600. }
  30601. else {
  30602. // Remove drawed map
  30603. this._mapDraw && this._mapDraw.remove();
  30604. this._mapDraw = null;
  30605. }
  30606. }
  30607. else {
  30608. var mapDraw = this._mapDraw;
  30609. mapDraw && group.add(mapDraw.group);
  30610. }
  30611. mapModel.get('showLegendSymbol') && ecModel.getComponent('legend')
  30612. && this._renderSymbols(mapModel, ecModel, api);
  30613. },
  30614. remove: function () {
  30615. this._mapDraw && this._mapDraw.remove();
  30616. this._mapDraw = null;
  30617. this.group.removeAll();
  30618. },
  30619. dispose: function () {
  30620. this._mapDraw && this._mapDraw.remove();
  30621. this._mapDraw = null;
  30622. },
  30623. _renderSymbols: function (mapModel, ecModel, api) {
  30624. var originalData = mapModel.originalData;
  30625. var group = this.group;
  30626. originalData.each('value', function (value, idx) {
  30627. if (isNaN(value)) {
  30628. return;
  30629. }
  30630. var layout = originalData.getItemLayout(idx);
  30631. if (!layout || !layout.point) {
  30632. // Not exists in map
  30633. return;
  30634. }
  30635. var point = layout.point;
  30636. var offset = layout.offset;
  30637. var circle = new graphic.Circle({
  30638. style: {
  30639. // Because the special of map draw.
  30640. // Which needs statistic of multiple series and draw on one map.
  30641. // And each series also need a symbol with legend color
  30642. //
  30643. // Layout and visual are put one the different data
  30644. fill: mapModel.getData().getVisual('color')
  30645. },
  30646. shape: {
  30647. cx: point[0] + offset * 9,
  30648. cy: point[1],
  30649. r: 3
  30650. },
  30651. silent: true,
  30652. z2: 10
  30653. });
  30654. // First data on the same region
  30655. if (!offset) {
  30656. var fullData = mapModel.mainSeries.getData();
  30657. var name = originalData.getName(idx);
  30658. var labelText = name;
  30659. var fullIndex = fullData.indexOfName(name);
  30660. var itemModel = originalData.getItemModel(idx);
  30661. var labelModel = itemModel.getModel('label.normal');
  30662. var hoverLabelModel = itemModel.getModel('label.emphasis');
  30663. var textStyleModel = labelModel.getModel('textStyle');
  30664. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  30665. var polygonGroups = fullData.getItemGraphicEl(fullIndex);
  30666. circle.setStyle({
  30667. textPosition: 'bottom'
  30668. });
  30669. var onEmphasis = function () {
  30670. circle.setStyle({
  30671. text: hoverLabelModel.get('show') ? labelText : '',
  30672. textFill: hoverTextStyleModel.getTextColor(),
  30673. textFont: hoverTextStyleModel.getFont()
  30674. });
  30675. };
  30676. var onNormal = function () {
  30677. circle.setStyle({
  30678. text: labelModel.get('show') ? labelText : '',
  30679. textFill: textStyleModel.getTextColor(),
  30680. textFont: textStyleModel.getFont()
  30681. });
  30682. };
  30683. polygonGroups.on('mouseover', onEmphasis)
  30684. .on('mouseout', onNormal)
  30685. .on('emphasis', onEmphasis)
  30686. .on('normal', onNormal);
  30687. onNormal();
  30688. }
  30689. group.add(circle);
  30690. });
  30691. }
  30692. });
  30693. /***/ },
  30694. /* 182 */
  30695. /***/ function(module, exports, __webpack_require__) {
  30696. /**
  30697. * @module echarts/component/helper/MapDraw
  30698. */
  30699. var RoamController = __webpack_require__(183);
  30700. var roamHelper = __webpack_require__(185);
  30701. var cursorHelper = __webpack_require__(186);
  30702. var graphic = __webpack_require__(18);
  30703. var zrUtil = __webpack_require__(4);
  30704. function getFixedItemStyle(model, scale) {
  30705. var itemStyle = model.getItemStyle();
  30706. var areaColor = model.get('areaColor');
  30707. // If user want the color not to be changed when hover,
  30708. // they should both set areaColor and color to be null.
  30709. if (areaColor != null) {
  30710. itemStyle.fill = areaColor;
  30711. }
  30712. return itemStyle;
  30713. }
  30714. function updateMapSelectHandler(mapDraw, mapOrGeoModel, group, api, fromView) {
  30715. group.off('click');
  30716. group.off('mousedown');
  30717. if (mapOrGeoModel.get('selectedMode')) {
  30718. group.on('mousedown', function () {
  30719. mapDraw._mouseDownFlag = true;
  30720. });
  30721. group.on('click', function (e) {
  30722. if (!mapDraw._mouseDownFlag) {
  30723. return;
  30724. }
  30725. mapDraw._mouseDownFlag = false;
  30726. var el = e.target;
  30727. while (!el.__regions) {
  30728. el = el.parent;
  30729. }
  30730. if (!el) {
  30731. return;
  30732. }
  30733. var action = {
  30734. type: (mapOrGeoModel.mainType === 'geo' ? 'geo' : 'map') + 'ToggleSelect',
  30735. batch: zrUtil.map(el.__regions, function (region) {
  30736. return {
  30737. name: region.name,
  30738. from: fromView.uid
  30739. };
  30740. })
  30741. };
  30742. action[mapOrGeoModel.mainType + 'Id'] = mapOrGeoModel.id;
  30743. api.dispatchAction(action);
  30744. updateMapSelected(mapOrGeoModel, group);
  30745. });
  30746. }
  30747. }
  30748. function updateMapSelected(mapOrGeoModel, group) {
  30749. // FIXME
  30750. group.eachChild(function (otherRegionEl) {
  30751. zrUtil.each(otherRegionEl.__regions, function (region) {
  30752. otherRegionEl.trigger(mapOrGeoModel.isSelected(region.name) ? 'emphasis' : 'normal');
  30753. });
  30754. });
  30755. }
  30756. /**
  30757. * @alias module:echarts/component/helper/MapDraw
  30758. * @param {module:echarts/ExtensionAPI} api
  30759. * @param {boolean} updateGroup
  30760. */
  30761. function MapDraw(api, updateGroup) {
  30762. var group = new graphic.Group();
  30763. /**
  30764. * @type {module:echarts/component/helper/RoamController}
  30765. * @private
  30766. */
  30767. this._controller = new RoamController(api.getZr());
  30768. /**
  30769. * @type {Object} {target, zoom, zoomLimit}
  30770. * @private
  30771. */
  30772. this._controllerHost = {target: updateGroup ? group : null};
  30773. /**
  30774. * @type {module:zrender/container/Group}
  30775. * @readOnly
  30776. */
  30777. this.group = group;
  30778. /**
  30779. * @type {boolean}
  30780. * @private
  30781. */
  30782. this._updateGroup = updateGroup;
  30783. /**
  30784. * This flag is used to make sure that only one among
  30785. * `pan`, `zoom`, `click` can occurs, otherwise 'selected'
  30786. * action may be triggered when `pan`, which is unexpected.
  30787. * @type {booelan}
  30788. */
  30789. this._mouseDownFlag;
  30790. }
  30791. MapDraw.prototype = {
  30792. constructor: MapDraw,
  30793. draw: function (mapOrGeoModel, ecModel, api, fromView, payload) {
  30794. var isGeo = mapOrGeoModel.mainType === 'geo';
  30795. // map series has data, geo model that controlled by map series
  30796. // has no data, otherwise data exists.
  30797. var data = mapOrGeoModel.getData && mapOrGeoModel.getData();
  30798. isGeo && ecModel.eachComponent({mainType: 'series', subType: 'map'}, function (mapSeries) {
  30799. if (!data && mapSeries.getHostGeoModel() === mapOrGeoModel) {
  30800. data = mapSeries.getData();
  30801. }
  30802. });
  30803. var geo = mapOrGeoModel.coordinateSystem;
  30804. var group = this.group;
  30805. var scale = geo.scale;
  30806. var groupNewProp = {
  30807. position: geo.position,
  30808. scale: scale
  30809. };
  30810. // No animation when first draw or in action
  30811. if (!group.childAt(0) || payload) {
  30812. group.attr(groupNewProp);
  30813. }
  30814. else {
  30815. graphic.updateProps(group, groupNewProp, mapOrGeoModel);
  30816. }
  30817. group.removeAll();
  30818. var itemStyleAccessPath = ['itemStyle', 'normal'];
  30819. var hoverItemStyleAccessPath = ['itemStyle', 'emphasis'];
  30820. var labelAccessPath = ['label', 'normal'];
  30821. var hoverLabelAccessPath = ['label', 'emphasis'];
  30822. var nameMap = zrUtil.createHashMap();
  30823. zrUtil.each(geo.regions, function (region) {
  30824. // Consider in GeoJson properties.name may be duplicated, for example,
  30825. // there is multiple region named "United Kindom" or "France" (so many
  30826. // colonies). And it is not appropriate to merge them in geo, which
  30827. // will make them share the same label and bring trouble in label
  30828. // location calculation.
  30829. var regionGroup = nameMap.get(region.name)
  30830. || nameMap.set(region.name, new graphic.Group());
  30831. var compoundPath = new graphic.CompoundPath({
  30832. shape: {
  30833. paths: []
  30834. }
  30835. });
  30836. regionGroup.add(compoundPath);
  30837. var regionModel = mapOrGeoModel.getRegionModel(region.name) || mapOrGeoModel;
  30838. var itemStyleModel = regionModel.getModel(itemStyleAccessPath);
  30839. var hoverItemStyleModel = regionModel.getModel(hoverItemStyleAccessPath);
  30840. var itemStyle = getFixedItemStyle(itemStyleModel, scale);
  30841. var hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale);
  30842. var labelModel = regionModel.getModel(labelAccessPath);
  30843. var hoverLabelModel = regionModel.getModel(hoverLabelAccessPath);
  30844. var dataIdx;
  30845. // Use the itemStyle in data if has data
  30846. if (data) {
  30847. dataIdx = data.indexOfName(region.name);
  30848. // Only visual color of each item will be used. It can be encoded by dataRange
  30849. // But visual color of series is used in symbol drawing
  30850. //
  30851. // Visual color for each series is for the symbol draw
  30852. var visualColor = data.getItemVisual(dataIdx, 'color', true);
  30853. if (visualColor) {
  30854. itemStyle.fill = visualColor;
  30855. }
  30856. }
  30857. var textStyleModel = labelModel.getModel('textStyle');
  30858. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  30859. zrUtil.each(region.geometries, function (geometry) {
  30860. if (geometry.type !== 'polygon') {
  30861. return;
  30862. }
  30863. compoundPath.shape.paths.push(new graphic.Polygon({
  30864. shape: {
  30865. points: geometry.exterior
  30866. }
  30867. }));
  30868. for (var i = 0; i < (geometry.interiors ? geometry.interiors.length : 0); i++) {
  30869. compoundPath.shape.paths.push(new graphic.Polygon({
  30870. shape: {
  30871. points: geometry.interiors[i]
  30872. }
  30873. }));
  30874. }
  30875. });
  30876. compoundPath.setStyle(itemStyle);
  30877. compoundPath.style.strokeNoScale = true;
  30878. compoundPath.culling = true;
  30879. // Label
  30880. var showLabel = labelModel.get('show');
  30881. var hoverShowLabel = hoverLabelModel.get('show');
  30882. var isDataNaN = data && isNaN(data.get('value', dataIdx));
  30883. var itemLayout = data && data.getItemLayout(dataIdx);
  30884. // In the following cases label will be drawn
  30885. // 1. In map series and data value is NaN
  30886. // 2. In geo component
  30887. // 4. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout
  30888. if (
  30889. (isGeo || isDataNaN && (showLabel || hoverShowLabel))
  30890. || (itemLayout && itemLayout.showLabel)
  30891. ) {
  30892. var query = data ? dataIdx : region.name;
  30893. var formattedStr = mapOrGeoModel.getFormattedLabel(query, 'normal');
  30894. var hoverFormattedStr = mapOrGeoModel.getFormattedLabel(query, 'emphasis');
  30895. var text = new graphic.Text({
  30896. style: {
  30897. text: showLabel ? (formattedStr || region.name) : '',
  30898. fill: textStyleModel.getTextColor(),
  30899. textFont: textStyleModel.getFont(),
  30900. textAlign: 'center',
  30901. textVerticalAlign: 'middle'
  30902. },
  30903. hoverStyle: {
  30904. text: hoverShowLabel ? (hoverFormattedStr || region.name) : '',
  30905. fill: hoverTextStyleModel.getTextColor(),
  30906. textFont: hoverTextStyleModel.getFont()
  30907. },
  30908. position: region.center.slice(),
  30909. scale: [1 / scale[0], 1 / scale[1]],
  30910. z2: 10,
  30911. silent: true
  30912. });
  30913. regionGroup.add(text);
  30914. }
  30915. // setItemGraphicEl, setHoverStyle after all polygons and labels
  30916. // are added to the rigionGroup
  30917. if (data) {
  30918. data.setItemGraphicEl(dataIdx, regionGroup);
  30919. }
  30920. else {
  30921. var regionModel = mapOrGeoModel.getRegionModel(region.name);
  30922. // Package custom mouse event for geo component
  30923. compoundPath.eventData = {
  30924. componentType: 'geo',
  30925. geoIndex: mapOrGeoModel.componentIndex,
  30926. name: region.name,
  30927. region: (regionModel && regionModel.option) || {}
  30928. };
  30929. }
  30930. var groupRegions = regionGroup.__regions || (regionGroup.__regions = []);
  30931. groupRegions.push(region);
  30932. graphic.setHoverStyle(
  30933. regionGroup,
  30934. hoverItemStyle,
  30935. {hoverSilentOnTouch: !!mapOrGeoModel.get('selectedMode')}
  30936. );
  30937. group.add(regionGroup);
  30938. });
  30939. this._updateController(mapOrGeoModel, ecModel, api);
  30940. updateMapSelectHandler(this, mapOrGeoModel, group, api, fromView);
  30941. updateMapSelected(mapOrGeoModel, group);
  30942. },
  30943. remove: function () {
  30944. this.group.removeAll();
  30945. this._controller.dispose();
  30946. this._controllerHost = {};
  30947. },
  30948. _updateController: function (mapOrGeoModel, ecModel, api) {
  30949. var geo = mapOrGeoModel.coordinateSystem;
  30950. var controller = this._controller;
  30951. var controllerHost = this._controllerHost;
  30952. controllerHost.zoomLimit = mapOrGeoModel.get('scaleLimit');
  30953. controllerHost.zoom = geo.getZoom();
  30954. // roamType is will be set default true if it is null
  30955. controller.enable(mapOrGeoModel.get('roam') || false);
  30956. var mainType = mapOrGeoModel.mainType;
  30957. function makeActionBase() {
  30958. var action = {
  30959. type: 'geoRoam',
  30960. componentType: mainType
  30961. };
  30962. action[mainType + 'Id'] = mapOrGeoModel.id;
  30963. return action;
  30964. }
  30965. controller.off('pan').on('pan', function (dx, dy) {
  30966. this._mouseDownFlag = false;
  30967. roamHelper.updateViewOnPan(controllerHost, dx, dy);
  30968. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  30969. dx: dx,
  30970. dy: dy
  30971. }));
  30972. }, this);
  30973. controller.off('zoom').on('zoom', function (zoom, mouseX, mouseY) {
  30974. this._mouseDownFlag = false;
  30975. roamHelper.updateViewOnZoom(controllerHost, zoom, mouseX, mouseY);
  30976. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  30977. zoom: zoom,
  30978. originX: mouseX,
  30979. originY: mouseY
  30980. }));
  30981. if (this._updateGroup) {
  30982. var group = this.group;
  30983. var scale = group.scale;
  30984. group.traverse(function (el) {
  30985. if (el.type === 'text') {
  30986. el.attr('scale', [1 / scale[0], 1 / scale[1]]);
  30987. }
  30988. });
  30989. }
  30990. }, this);
  30991. controller.setPointerChecker(function (e, x, y) {
  30992. return geo.getViewRectAfterRoam().contain(x, y)
  30993. && !cursorHelper.onIrrelevantElement(e, api, mapOrGeoModel);
  30994. });
  30995. }
  30996. };
  30997. module.exports = MapDraw;
  30998. /***/ },
  30999. /* 183 */
  31000. /***/ function(module, exports, __webpack_require__) {
  31001. /**
  31002. * @module echarts/component/helper/RoamController
  31003. */
  31004. var Eventful = __webpack_require__(25);
  31005. var zrUtil = __webpack_require__(4);
  31006. var eventTool = __webpack_require__(88);
  31007. var interactionMutex = __webpack_require__(184);
  31008. /**
  31009. * @alias module:echarts/component/helper/RoamController
  31010. * @constructor
  31011. * @mixin {module:zrender/mixin/Eventful}
  31012. *
  31013. * @param {module:zrender/zrender~ZRender} zr
  31014. */
  31015. function RoamController(zr) {
  31016. /**
  31017. * @type {Function}
  31018. */
  31019. this.pointerChecker;
  31020. /**
  31021. * @type {module:zrender}
  31022. */
  31023. this._zr = zr;
  31024. /**
  31025. * @type {Object}
  31026. */
  31027. this._opt = {};
  31028. // Avoid two roamController bind the same handler
  31029. var bind = zrUtil.bind;
  31030. var mousedownHandler = bind(mousedown, this);
  31031. var mousemoveHandler = bind(mousemove, this);
  31032. var mouseupHandler = bind(mouseup, this);
  31033. var mousewheelHandler = bind(mousewheel, this);
  31034. var pinchHandler = bind(pinch, this);
  31035. Eventful.call(this);
  31036. /**
  31037. * @param {Function} pointerChecker
  31038. * input: x, y
  31039. * output: boolean
  31040. */
  31041. this.setPointerChecker = function (pointerChecker) {
  31042. this.pointerChecker = pointerChecker;
  31043. };
  31044. /**
  31045. * Notice: only enable needed types. For example, if 'zoom'
  31046. * is not needed, 'zoom' should not be enabled, otherwise
  31047. * default mousewheel behaviour (scroll page) will be disabled.
  31048. *
  31049. * @param {boolean|string} [controlType=true] Specify the control type,
  31050. * which can be null/undefined or true/false
  31051. * or 'pan/move' or 'zoom'/'scale'
  31052. * @param {Object} [opt]
  31053. * @param {Object} [opt.zoomOnMouseWheel=true]
  31054. * @param {Object} [opt.moveOnMouseMove=true]
  31055. * @param {Object} [opt.preventDefaultMouseMove=true] When pan.
  31056. */
  31057. this.enable = function (controlType, opt) {
  31058. // Disable previous first
  31059. this.disable();
  31060. this._opt = zrUtil.defaults(zrUtil.clone(opt) || {}, {
  31061. zoomOnMouseWheel: true,
  31062. moveOnMouseMove: true,
  31063. preventDefaultMouseMove: true
  31064. });
  31065. if (controlType == null) {
  31066. controlType = true;
  31067. }
  31068. if (controlType === true || (controlType === 'move' || controlType === 'pan')) {
  31069. zr.on('mousedown', mousedownHandler);
  31070. zr.on('mousemove', mousemoveHandler);
  31071. zr.on('mouseup', mouseupHandler);
  31072. }
  31073. if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) {
  31074. zr.on('mousewheel', mousewheelHandler);
  31075. zr.on('pinch', pinchHandler);
  31076. }
  31077. };
  31078. this.disable = function () {
  31079. zr.off('mousedown', mousedownHandler);
  31080. zr.off('mousemove', mousemoveHandler);
  31081. zr.off('mouseup', mouseupHandler);
  31082. zr.off('mousewheel', mousewheelHandler);
  31083. zr.off('pinch', pinchHandler);
  31084. };
  31085. this.dispose = this.disable;
  31086. this.isDragging = function () {
  31087. return this._dragging;
  31088. };
  31089. this.isPinching = function () {
  31090. return this._pinching;
  31091. };
  31092. }
  31093. zrUtil.mixin(RoamController, Eventful);
  31094. function mousedown(e) {
  31095. if (e.target && e.target.draggable) {
  31096. return;
  31097. }
  31098. var x = e.offsetX;
  31099. var y = e.offsetY;
  31100. // Only check on mosedown, but not mousemove.
  31101. // Mouse can be out of target when mouse moving.
  31102. if (this.pointerChecker && this.pointerChecker(e, x, y)) {
  31103. this._x = x;
  31104. this._y = y;
  31105. this._dragging = true;
  31106. }
  31107. }
  31108. function mousemove(e) {
  31109. if (!checkKeyBinding(this, 'moveOnMouseMove', e) || !this._dragging) {
  31110. return;
  31111. }
  31112. if (e.gestureEvent === 'pinch') {
  31113. return;
  31114. }
  31115. if (interactionMutex.isTaken(this._zr, 'globalPan')) {
  31116. return;
  31117. }
  31118. var x = e.offsetX;
  31119. var y = e.offsetY;
  31120. var oldX = this._x;
  31121. var oldY = this._y;
  31122. var dx = x - oldX;
  31123. var dy = y - oldY;
  31124. this._x = x;
  31125. this._y = y;
  31126. this._opt.preventDefaultMouseMove && eventTool.stop(e.event);
  31127. this.trigger('pan', dx, dy, oldX, oldY, x, y);
  31128. }
  31129. function mouseup(e) {
  31130. this._dragging = false;
  31131. }
  31132. function mousewheel(e) {
  31133. // wheelDelta maybe -0 in chrome mac.
  31134. if (!checkKeyBinding(this, 'zoomOnMouseWheel', e) || e.wheelDelta === 0) {
  31135. return;
  31136. }
  31137. // Convenience:
  31138. // Mac and VM Windows on Mac: scroll up: zoom out.
  31139. // Windows: scroll up: zoom in.
  31140. var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1;
  31141. zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY);
  31142. }
  31143. function pinch(e) {
  31144. if (interactionMutex.isTaken(this._zr, 'globalPan')) {
  31145. return;
  31146. }
  31147. var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
  31148. zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY);
  31149. }
  31150. function zoom(e, zoomDelta, zoomX, zoomY) {
  31151. if (this.pointerChecker && this.pointerChecker(e, zoomX, zoomY)) {
  31152. // When mouse is out of roamController rect,
  31153. // default befavoius should not be be disabled, otherwise
  31154. // page sliding is disabled, contrary to expectation.
  31155. eventTool.stop(e.event);
  31156. this.trigger('zoom', zoomDelta, zoomX, zoomY);
  31157. }
  31158. }
  31159. function checkKeyBinding(roamController, prop, e) {
  31160. var setting = roamController._opt[prop];
  31161. return setting
  31162. && (!zrUtil.isString(setting) || e.event[setting + 'Key']);
  31163. }
  31164. module.exports = RoamController;
  31165. /***/ },
  31166. /* 184 */
  31167. /***/ function(module, exports, __webpack_require__) {
  31168. var ATTR = '\0_ec_interaction_mutex';
  31169. var interactionMutex = {
  31170. take: function (zr, resourceKey, userKey) {
  31171. var store = getStore(zr);
  31172. store[resourceKey] = userKey;
  31173. },
  31174. release: function (zr, resourceKey, userKey) {
  31175. var store = getStore(zr);
  31176. var uKey = store[resourceKey];
  31177. if (uKey === userKey) {
  31178. store[resourceKey] = null;
  31179. }
  31180. },
  31181. isTaken: function (zr, resourceKey) {
  31182. return !!getStore(zr)[resourceKey];
  31183. }
  31184. };
  31185. function getStore(zr) {
  31186. return zr[ATTR] || (zr[ATTR] = {});
  31187. }
  31188. /**
  31189. * payload: {
  31190. * type: 'takeGlobalCursor',
  31191. * key: 'dataZoomSelect', or 'brush', or ...,
  31192. * If no userKey, release global cursor.
  31193. * }
  31194. */
  31195. __webpack_require__(1).registerAction(
  31196. {type: 'takeGlobalCursor', event: 'globalCursorTaken', update: 'update'},
  31197. function () {}
  31198. );
  31199. module.exports = interactionMutex;
  31200. /***/ },
  31201. /* 185 */
  31202. /***/ function(module, exports) {
  31203. var helper = {};
  31204. /**
  31205. * For geo and graph.
  31206. *
  31207. * @param {Object} controllerHost
  31208. * @param {module:zrender/Element} controllerHost.target
  31209. */
  31210. helper.updateViewOnPan = function (controllerHost, dx, dy) {
  31211. var target = controllerHost.target;
  31212. var pos = target.position;
  31213. pos[0] += dx;
  31214. pos[1] += dy;
  31215. target.dirty();
  31216. };
  31217. /**
  31218. * For geo and graph.
  31219. *
  31220. * @param {Object} controllerHost
  31221. * @param {module:zrender/Element} controllerHost.target
  31222. * @param {number} controllerHost.zoom
  31223. * @param {number} controllerHost.zoomLimit like: {min: 1, max: 2}
  31224. */
  31225. helper.updateViewOnZoom = function (controllerHost, zoomDelta, zoomX, zoomY) {
  31226. var target = controllerHost.target;
  31227. var zoomLimit = controllerHost.zoomLimit;
  31228. var pos = target.position;
  31229. var scale = target.scale;
  31230. var newZoom = controllerHost.zoom = controllerHost.zoom || 1;
  31231. newZoom *= zoomDelta;
  31232. if (zoomLimit) {
  31233. var zoomMin = zoomLimit.min || 0;
  31234. var zoomMax = zoomLimit.max || Infinity;
  31235. newZoom = Math.max(
  31236. Math.min(zoomMax, newZoom),
  31237. zoomMin
  31238. );
  31239. }
  31240. var zoomScale = newZoom / controllerHost.zoom;
  31241. controllerHost.zoom = newZoom;
  31242. // Keep the mouse center when scaling
  31243. pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
  31244. pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
  31245. scale[0] *= zoomScale;
  31246. scale[1] *= zoomScale;
  31247. target.dirty();
  31248. };
  31249. module.exports = helper;
  31250. /***/ },
  31251. /* 186 */
  31252. /***/ function(module, exports) {
  31253. var helper = {};
  31254. var IRRELEVANT_EXCLUDES = {'axisPointer': 1, 'tooltip': 1, 'brush': 1};
  31255. /**
  31256. * Avoid that: mouse click on a elements that is over geo or graph,
  31257. * but roam is triggered.
  31258. */
  31259. helper.onIrrelevantElement = function (e, api, targetCoordSysModel) {
  31260. var model = api.getComponentByElement(e.topTarget);
  31261. // If model is axisModel, it works only if it is injected with coordinateSystem.
  31262. var coordSys = model && model.coordinateSystem;
  31263. return model
  31264. && model !== targetCoordSysModel
  31265. && !IRRELEVANT_EXCLUDES[model.mainType]
  31266. && (coordSys && coordSys.model !== targetCoordSysModel);
  31267. };
  31268. module.exports = helper;
  31269. /***/ },
  31270. /* 187 */
  31271. /***/ function(module, exports, __webpack_require__) {
  31272. var zrUtil = __webpack_require__(4);
  31273. var roamHelper = __webpack_require__(188);
  31274. var echarts = __webpack_require__(1);
  31275. /**
  31276. * @payload
  31277. * @property {string} [componentType=series]
  31278. * @property {number} [dx]
  31279. * @property {number} [dy]
  31280. * @property {number} [zoom]
  31281. * @property {number} [originX]
  31282. * @property {number} [originY]
  31283. */
  31284. echarts.registerAction({
  31285. type: 'geoRoam',
  31286. event: 'geoRoam',
  31287. update: 'updateLayout'
  31288. }, function (payload, ecModel) {
  31289. var componentType = payload.componentType || 'series';
  31290. ecModel.eachComponent(
  31291. { mainType: componentType, query: payload },
  31292. function (componentModel) {
  31293. var geo = componentModel.coordinateSystem;
  31294. if (geo.type !== 'geo') {
  31295. return;
  31296. }
  31297. var res = roamHelper.updateCenterAndZoom(
  31298. geo, payload, componentModel.get('scaleLimit')
  31299. );
  31300. componentModel.setCenter
  31301. && componentModel.setCenter(res.center);
  31302. componentModel.setZoom
  31303. && componentModel.setZoom(res.zoom);
  31304. // All map series with same `map` use the same geo coordinate system
  31305. // So the center and zoom must be in sync. Include the series not selected by legend
  31306. if (componentType === 'series') {
  31307. zrUtil.each(componentModel.seriesGroup, function (seriesModel) {
  31308. seriesModel.setCenter(res.center);
  31309. seriesModel.setZoom(res.zoom);
  31310. });
  31311. }
  31312. }
  31313. );
  31314. });
  31315. /***/ },
  31316. /* 188 */
  31317. /***/ function(module, exports) {
  31318. var roamHelper = {};
  31319. /**
  31320. * @param {module:echarts/coord/View} view
  31321. * @param {Object} payload
  31322. * @param {Object} [zoomLimit]
  31323. */
  31324. roamHelper.updateCenterAndZoom = function (
  31325. view, payload, zoomLimit
  31326. ) {
  31327. var previousZoom = view.getZoom();
  31328. var center = view.getCenter();
  31329. var zoom = payload.zoom;
  31330. var point = view.dataToPoint(center);
  31331. if (payload.dx != null && payload.dy != null) {
  31332. point[0] -= payload.dx;
  31333. point[1] -= payload.dy;
  31334. var center = view.pointToData(point);
  31335. view.setCenter(center);
  31336. }
  31337. if (zoom != null) {
  31338. if (zoomLimit) {
  31339. var zoomMin = zoomLimit.min || 0;
  31340. var zoomMax = zoomLimit.max || Infinity;
  31341. zoom = Math.max(
  31342. Math.min(previousZoom * zoom, zoomMax),
  31343. zoomMin
  31344. ) / previousZoom;
  31345. }
  31346. // Zoom on given point(originX, originY)
  31347. view.scale[0] *= zoom;
  31348. view.scale[1] *= zoom;
  31349. var position = view.position;
  31350. var fixX = (payload.originX - position[0]) * (zoom - 1);
  31351. var fixY = (payload.originY - position[1]) * (zoom - 1);
  31352. position[0] -= fixX;
  31353. position[1] -= fixY;
  31354. view.updateTransform();
  31355. // Get the new center
  31356. var center = view.pointToData(point);
  31357. view.setCenter(center);
  31358. view.setZoom(zoom * previousZoom);
  31359. }
  31360. return {
  31361. center: view.getCenter(),
  31362. zoom: view.getZoom()
  31363. };
  31364. };
  31365. module.exports = roamHelper;
  31366. /***/ },
  31367. /* 189 */
  31368. /***/ function(module, exports, __webpack_require__) {
  31369. var zrUtil = __webpack_require__(4);
  31370. module.exports = function (ecModel) {
  31371. var processedMapType = {};
  31372. ecModel.eachSeriesByType('map', function (mapSeries) {
  31373. var mapType = mapSeries.getMapType();
  31374. if (mapSeries.getHostGeoModel() || processedMapType[mapType]) {
  31375. return;
  31376. }
  31377. var mapSymbolOffsets = {};
  31378. zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) {
  31379. var geo = subMapSeries.coordinateSystem;
  31380. var data = subMapSeries.originalData;
  31381. if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) {
  31382. data.each('value', function (value, idx) {
  31383. var name = data.getName(idx);
  31384. var region = geo.getRegion(name);
  31385. // If input series.data is [11, 22, '-'/null/undefined, 44],
  31386. // it will be filled with NaN: [11, 22, NaN, 44] and NaN will
  31387. // not be drawn. So here must validate if value is NaN.
  31388. if (!region || isNaN(value)) {
  31389. return;
  31390. }
  31391. var offset = mapSymbolOffsets[name] || 0;
  31392. var point = geo.dataToPoint(region.center);
  31393. mapSymbolOffsets[name] = offset + 1;
  31394. data.setItemLayout(idx, {
  31395. point: point,
  31396. offset: offset
  31397. });
  31398. });
  31399. }
  31400. });
  31401. // Show label of those region not has legendSymbol(which is offset 0)
  31402. var data = mapSeries.getData();
  31403. data.each(function (idx) {
  31404. var name = data.getName(idx);
  31405. var layout = data.getItemLayout(idx) || {};
  31406. layout.showLabel = !mapSymbolOffsets[name];
  31407. data.setItemLayout(idx, layout);
  31408. });
  31409. processedMapType[mapType] = true;
  31410. });
  31411. };
  31412. /***/ },
  31413. /* 190 */
  31414. /***/ function(module, exports) {
  31415. module.exports = function (ecModel) {
  31416. ecModel.eachSeriesByType('map', function (seriesModel) {
  31417. var colorList = seriesModel.get('color');
  31418. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  31419. var areaColor = itemStyleModel.get('areaColor');
  31420. var color = itemStyleModel.get('color')
  31421. || colorList[seriesModel.seriesIndex % colorList.length];
  31422. seriesModel.getData().setVisual({
  31423. 'areaColor': areaColor,
  31424. 'color': color
  31425. });
  31426. });
  31427. };
  31428. /***/ },
  31429. /* 191 */
  31430. /***/ function(module, exports, __webpack_require__) {
  31431. var zrUtil = __webpack_require__(4);
  31432. // FIXME 公用?
  31433. /**
  31434. * @param {Array.<module:echarts/data/List>} datas
  31435. * @param {string} statisticType 'average' 'sum'
  31436. * @inner
  31437. */
  31438. function dataStatistics(datas, statisticType) {
  31439. var dataNameMap = {};
  31440. var dims = ['value'];
  31441. zrUtil.each(datas, function (data) {
  31442. data.each(dims, function (value, idx) {
  31443. // Add prefix to avoid conflict with Object.prototype.
  31444. var mapKey = 'ec-' + data.getName(idx);
  31445. dataNameMap[mapKey] = dataNameMap[mapKey] || [];
  31446. if (!isNaN(value)) {
  31447. dataNameMap[mapKey].push(value);
  31448. }
  31449. });
  31450. });
  31451. return datas[0].map(dims, function (value, idx) {
  31452. var mapKey = 'ec-' + datas[0].getName(idx);
  31453. var sum = 0;
  31454. var min = Infinity;
  31455. var max = -Infinity;
  31456. var len = dataNameMap[mapKey].length;
  31457. for (var i = 0; i < len; i++) {
  31458. min = Math.min(min, dataNameMap[mapKey][i]);
  31459. max = Math.max(max, dataNameMap[mapKey][i]);
  31460. sum += dataNameMap[mapKey][i];
  31461. }
  31462. var result;
  31463. if (statisticType === 'min') {
  31464. result = min;
  31465. }
  31466. else if (statisticType === 'max') {
  31467. result = max;
  31468. }
  31469. else if (statisticType === 'average') {
  31470. result = sum / len;
  31471. }
  31472. else {
  31473. result = sum;
  31474. }
  31475. return len === 0 ? NaN : result;
  31476. });
  31477. }
  31478. module.exports = function (ecModel) {
  31479. var seriesGroups = {};
  31480. ecModel.eachSeriesByType('map', function (seriesModel) {
  31481. var hostGeoModel = seriesModel.getHostGeoModel();
  31482. var key = hostGeoModel ? 'o' + hostGeoModel.id : 'i' + seriesModel.getMapType();
  31483. (seriesGroups[key] = seriesGroups[key] || []).push(seriesModel);
  31484. });
  31485. zrUtil.each(seriesGroups, function (seriesList, key) {
  31486. var data = dataStatistics(
  31487. zrUtil.map(seriesList, function (seriesModel) {
  31488. return seriesModel.getData();
  31489. }),
  31490. seriesList[0].get('mapValueCalculation')
  31491. );
  31492. for (var i = 0; i < seriesList.length; i++) {
  31493. seriesList[i].originalData = seriesList[i].getData();
  31494. }
  31495. // FIXME Put where?
  31496. for (var i = 0; i < seriesList.length; i++) {
  31497. seriesList[i].seriesGroup = seriesList;
  31498. seriesList[i].needsDrawMap = i === 0 && !seriesList[i].getHostGeoModel();
  31499. seriesList[i].setData(data.cloneShallow());
  31500. seriesList[i].mainSeries = seriesList[0];
  31501. }
  31502. });
  31503. };
  31504. /***/ },
  31505. /* 192 */
  31506. /***/ function(module, exports, __webpack_require__) {
  31507. var zrUtil = __webpack_require__(4);
  31508. module.exports = function (option) {
  31509. // Save geoCoord
  31510. var mapSeries = [];
  31511. zrUtil.each(option.series, function (seriesOpt) {
  31512. if (seriesOpt.type === 'map') {
  31513. mapSeries.push(seriesOpt);
  31514. }
  31515. });
  31516. zrUtil.each(mapSeries, function (seriesOpt) {
  31517. seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
  31518. // Put x, y, width, height, x2, y2 in the top level
  31519. zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
  31520. });
  31521. };
  31522. /***/ },
  31523. /* 193 */
  31524. /***/ function(module, exports, __webpack_require__) {
  31525. var echarts = __webpack_require__(1);
  31526. __webpack_require__(194);
  31527. __webpack_require__(198);
  31528. __webpack_require__(201);
  31529. echarts.registerVisual(__webpack_require__(202));
  31530. echarts.registerLayout(__webpack_require__(204));
  31531. /***/ },
  31532. /* 194 */
  31533. /***/ function(module, exports, __webpack_require__) {
  31534. var SeriesModel = __webpack_require__(78);
  31535. var Tree = __webpack_require__(195);
  31536. var zrUtil = __webpack_require__(4);
  31537. var Model = __webpack_require__(12);
  31538. var formatUtil = __webpack_require__(6);
  31539. var helper = __webpack_require__(197);
  31540. var encodeHTML = formatUtil.encodeHTML;
  31541. var addCommas = formatUtil.addCommas;
  31542. module.exports = SeriesModel.extend({
  31543. type: 'series.treemap',
  31544. layoutMode: 'box',
  31545. dependencies: ['grid', 'polar'],
  31546. /**
  31547. * @type {module:echarts/data/Tree~Node}
  31548. */
  31549. _viewRoot: null,
  31550. defaultOption: {
  31551. // Disable progressive rendering
  31552. progressive: 0,
  31553. hoverLayerThreshold: Infinity,
  31554. // center: ['50%', '50%'], // not supported in ec3.
  31555. // size: ['80%', '80%'], // deprecated, compatible with ec2.
  31556. left: 'center',
  31557. top: 'middle',
  31558. right: null,
  31559. bottom: null,
  31560. width: '80%',
  31561. height: '80%',
  31562. sort: true, // Can be null or false or true
  31563. // (order by desc default, asc not supported yet (strange effect))
  31564. clipWindow: 'origin', // Size of clipped window when zooming. 'origin' or 'fullscreen'
  31565. squareRatio: 0.5 * (1 + Math.sqrt(5)), // golden ratio
  31566. leafDepth: null, // Nodes on depth from root are regarded as leaves.
  31567. // Count from zero (zero represents only view root).
  31568. drillDownIcon: '▶', // Use html character temporarily because it is complicated
  31569. // to align specialized icon. ▷▶❒❐▼✚
  31570. zoomToNodeRatio: 0.32 * 0.32, // Be effective when using zoomToNode. Specify the proportion of the
  31571. // target node area in the view area.
  31572. roam: true, // true, false, 'scale' or 'zoom', 'move'.
  31573. nodeClick: 'zoomToNode', // Leaf node click behaviour: 'zoomToNode', 'link', false.
  31574. // If leafDepth is set and clicking a node which has children but
  31575. // be on left depth, the behaviour would be changing root. Otherwise
  31576. // use behavious defined above.
  31577. animation: true,
  31578. animationDurationUpdate: 900,
  31579. animationEasing: 'quinticInOut',
  31580. breadcrumb: {
  31581. show: true,
  31582. height: 22,
  31583. left: 'center',
  31584. top: 'bottom',
  31585. // right
  31586. // bottom
  31587. emptyItemWidth: 25, // Width of empty node.
  31588. itemStyle: {
  31589. normal: {
  31590. color: 'rgba(0,0,0,0.7)', //'#5793f3',
  31591. borderColor: 'rgba(255,255,255,0.7)',
  31592. borderWidth: 1,
  31593. shadowColor: 'rgba(150,150,150,1)',
  31594. shadowBlur: 3,
  31595. shadowOffsetX: 0,
  31596. shadowOffsetY: 0,
  31597. textStyle: {
  31598. color: '#fff'
  31599. }
  31600. },
  31601. emphasis: {
  31602. textStyle: {}
  31603. }
  31604. }
  31605. },
  31606. label: {
  31607. normal: {
  31608. show: true,
  31609. position: 'inside', // Can be [5, '5%'] or position stirng like 'insideTopLeft', ...
  31610. // formatter: null,
  31611. textStyle: {
  31612. color: '#fff',
  31613. ellipsis: true
  31614. // align
  31615. // baseline
  31616. }
  31617. }
  31618. },
  31619. upperLabel: { // Label when node is parent.
  31620. normal: {
  31621. show: false,
  31622. position: [0, '50%'],
  31623. height: 20,
  31624. // formatter: null,
  31625. textStyle: {
  31626. color: '#fff',
  31627. ellipsis: true,
  31628. // align: null,
  31629. baseline: 'middle'
  31630. }
  31631. },
  31632. emphasis: {
  31633. show: true,
  31634. position: [0, '50%'],
  31635. textStyle: {
  31636. color: '#fff',
  31637. ellipsis: true,
  31638. baseline: 'middle'
  31639. }
  31640. }
  31641. },
  31642. itemStyle: {
  31643. normal: {
  31644. color: null, // Can be 'none' if not necessary.
  31645. colorAlpha: null, // Can be 'none' if not necessary.
  31646. colorSaturation: null, // Can be 'none' if not necessary.
  31647. borderWidth: 0,
  31648. gapWidth: 0,
  31649. borderColor: '#fff',
  31650. borderColorSaturation: null // If specified, borderColor will be ineffective, and the
  31651. // border color is evaluated by color of current node and
  31652. // borderColorSaturation.
  31653. },
  31654. emphasis: {
  31655. }
  31656. },
  31657. visualDimension: 0, // Can be 0, 1, 2, 3.
  31658. visualMin: null,
  31659. visualMax: null,
  31660. color: [], // + treemapSeries.color should not be modified. Please only modified
  31661. // level[n].color (if necessary).
  31662. // + Specify color list of each level. level[0].color would be global
  31663. // color list if not specified. (see method `setDefault`).
  31664. // + But set as a empty array to forbid fetch color from global palette
  31665. // when using nodeModel.get('color'), otherwise nodes on deep level
  31666. // will always has color palette set and are not able to inherit color
  31667. // from parent node.
  31668. // + TreemapSeries.color can not be set as 'none', otherwise effect
  31669. // legend color fetching (see seriesColor.js).
  31670. colorAlpha: null, // Array. Specify color alpha range of each level, like [0.2, 0.8]
  31671. colorSaturation: null, // Array. Specify color saturation of each level, like [0.2, 0.5]
  31672. colorMappingBy: 'index', // 'value' or 'index' or 'id'.
  31673. visibleMin: 10, // If area less than this threshold (unit: pixel^2), node will not
  31674. // be rendered. Only works when sort is 'asc' or 'desc'.
  31675. childrenVisibleMin: null, // If area of a node less than this threshold (unit: pixel^2),
  31676. // grandchildren will not show.
  31677. // Why grandchildren? If not grandchildren but children,
  31678. // some siblings show children and some not,
  31679. // the appearance may be mess and not consistent,
  31680. levels: [] // Each item: {
  31681. // visibleMin, itemStyle, visualDimension, label
  31682. // }
  31683. // data: {
  31684. // value: [],
  31685. // children: [],
  31686. // link: 'http://xxx.xxx.xxx',
  31687. // target: 'blank' or 'self'
  31688. // }
  31689. },
  31690. /**
  31691. * @override
  31692. */
  31693. getInitialData: function (option, ecModel) {
  31694. // Create a virtual root.
  31695. var root = {name: option.name, children: option.data};
  31696. completeTreeValue(root);
  31697. var levels = option.levels || [];
  31698. levels = option.levels = setDefault(levels, ecModel);
  31699. // Make sure always a new tree is created when setOption,
  31700. // in TreemapView, we check whether oldTree === newTree
  31701. // to choose mappings approach among old shapes and new shapes.
  31702. return Tree.createTree(root, this, levels).data;
  31703. },
  31704. optionUpdated: function () {
  31705. this.resetViewRoot();
  31706. },
  31707. /**
  31708. * @override
  31709. * @param {number} dataIndex
  31710. * @param {boolean} [mutipleSeries=false]
  31711. */
  31712. formatTooltip: function (dataIndex) {
  31713. var data = this.getData();
  31714. var value = this.getRawValue(dataIndex);
  31715. var formattedValue = zrUtil.isArray(value)
  31716. ? addCommas(value[0]) : addCommas(value);
  31717. var name = data.getName(dataIndex);
  31718. return encodeHTML(name + ': ' + formattedValue);
  31719. },
  31720. /**
  31721. * Add tree path to tooltip param
  31722. *
  31723. * @override
  31724. * @param {number} dataIndex
  31725. * @return {Object}
  31726. */
  31727. getDataParams: function (dataIndex) {
  31728. var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
  31729. var node = this.getData().tree.getNodeByDataIndex(dataIndex);
  31730. params.treePathInfo = helper.wrapTreePathInfo(node, this);
  31731. return params;
  31732. },
  31733. /**
  31734. * @public
  31735. * @param {Object} layoutInfo {
  31736. * x: containerGroup x
  31737. * y: containerGroup y
  31738. * width: containerGroup width
  31739. * height: containerGroup height
  31740. * }
  31741. */
  31742. setLayoutInfo: function (layoutInfo) {
  31743. /**
  31744. * @readOnly
  31745. * @type {Object}
  31746. */
  31747. this.layoutInfo = this.layoutInfo || {};
  31748. zrUtil.extend(this.layoutInfo, layoutInfo);
  31749. },
  31750. /**
  31751. * @param {string} id
  31752. * @return {number} index
  31753. */
  31754. mapIdToIndex: function (id) {
  31755. // A feature is implemented:
  31756. // index is monotone increasing with the sequence of
  31757. // input id at the first time.
  31758. // This feature can make sure that each data item and its
  31759. // mapped color have the same index between data list and
  31760. // color list at the beginning, which is useful for user
  31761. // to adjust data-color mapping.
  31762. /**
  31763. * @private
  31764. * @type {Object}
  31765. */
  31766. var idIndexMap = this._idIndexMap;
  31767. if (!idIndexMap) {
  31768. idIndexMap = this._idIndexMap = zrUtil.createHashMap();
  31769. /**
  31770. * @private
  31771. * @type {number}
  31772. */
  31773. this._idIndexMapCount = 0;
  31774. }
  31775. var index = idIndexMap.get(id);
  31776. if (index == null) {
  31777. idIndexMap.set(id, index = this._idIndexMapCount++);
  31778. }
  31779. return index;
  31780. },
  31781. getViewRoot: function () {
  31782. return this._viewRoot;
  31783. },
  31784. /**
  31785. * @param {module:echarts/data/Tree~Node} [viewRoot]
  31786. */
  31787. resetViewRoot: function (viewRoot) {
  31788. viewRoot
  31789. ? (this._viewRoot = viewRoot)
  31790. : (viewRoot = this._viewRoot);
  31791. var root = this.getData().tree.root;
  31792. if (!viewRoot
  31793. || (viewRoot !== root && !root.contains(viewRoot))
  31794. ) {
  31795. this._viewRoot = root;
  31796. }
  31797. }
  31798. });
  31799. /**
  31800. * @param {Object} dataNode
  31801. */
  31802. function completeTreeValue(dataNode) {
  31803. // Postorder travel tree.
  31804. // If value of none-leaf node is not set,
  31805. // calculate it by suming up the value of all children.
  31806. var sum = 0;
  31807. zrUtil.each(dataNode.children, function (child) {
  31808. completeTreeValue(child);
  31809. var childValue = child.value;
  31810. zrUtil.isArray(childValue) && (childValue = childValue[0]);
  31811. sum += childValue;
  31812. });
  31813. var thisValue = dataNode.value;
  31814. if (zrUtil.isArray(thisValue)) {
  31815. thisValue = thisValue[0];
  31816. }
  31817. if (thisValue == null || isNaN(thisValue)) {
  31818. thisValue = sum;
  31819. }
  31820. // Value should not less than 0.
  31821. if (thisValue < 0) {
  31822. thisValue = 0;
  31823. }
  31824. zrUtil.isArray(dataNode.value)
  31825. ? (dataNode.value[0] = thisValue)
  31826. : (dataNode.value = thisValue);
  31827. }
  31828. /**
  31829. * set default to level configuration
  31830. */
  31831. function setDefault(levels, ecModel) {
  31832. var globalColorList = ecModel.get('color');
  31833. if (!globalColorList) {
  31834. return;
  31835. }
  31836. levels = levels || [];
  31837. var hasColorDefine;
  31838. zrUtil.each(levels, function (levelDefine) {
  31839. var model = new Model(levelDefine);
  31840. var modelColor = model.get('color');
  31841. if (model.get('itemStyle.normal.color')
  31842. || (modelColor && modelColor !== 'none')
  31843. ) {
  31844. hasColorDefine = true;
  31845. }
  31846. });
  31847. if (!hasColorDefine) {
  31848. var level0 = levels[0] || (levels[0] = {});
  31849. level0.color = globalColorList.slice();
  31850. }
  31851. return levels;
  31852. }
  31853. /***/ },
  31854. /* 195 */
  31855. /***/ function(module, exports, __webpack_require__) {
  31856. /**
  31857. * Tree data structure
  31858. *
  31859. * @module echarts/data/Tree
  31860. */
  31861. var zrUtil = __webpack_require__(4);
  31862. var Model = __webpack_require__(12);
  31863. var List = __webpack_require__(98);
  31864. var linkList = __webpack_require__(196);
  31865. var completeDimensions = __webpack_require__(110);
  31866. /**
  31867. * @constructor module:echarts/data/Tree~TreeNode
  31868. * @param {string} name
  31869. * @param {module:echarts/data/Tree} hostTree
  31870. */
  31871. var TreeNode = function (name, hostTree) {
  31872. /**
  31873. * @type {string}
  31874. */
  31875. this.name = name || '';
  31876. /**
  31877. * Depth of node
  31878. *
  31879. * @type {number}
  31880. * @readOnly
  31881. */
  31882. this.depth = 0;
  31883. /**
  31884. * Height of the subtree rooted at this node.
  31885. * @type {number}
  31886. * @readOnly
  31887. */
  31888. this.height = 0;
  31889. /**
  31890. * @type {module:echarts/data/Tree~TreeNode}
  31891. * @readOnly
  31892. */
  31893. this.parentNode = null;
  31894. /**
  31895. * Reference to list item.
  31896. * Do not persistent dataIndex outside,
  31897. * besause it may be changed by list.
  31898. * If dataIndex -1,
  31899. * this node is logical deleted (filtered) in list.
  31900. *
  31901. * @type {Object}
  31902. * @readOnly
  31903. */
  31904. this.dataIndex = -1;
  31905. /**
  31906. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  31907. * @readOnly
  31908. */
  31909. this.children = [];
  31910. /**
  31911. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  31912. * @pubilc
  31913. */
  31914. this.viewChildren = [];
  31915. /**
  31916. * @type {moduel:echarts/data/Tree}
  31917. * @readOnly
  31918. */
  31919. this.hostTree = hostTree;
  31920. };
  31921. TreeNode.prototype = {
  31922. constructor: TreeNode,
  31923. /**
  31924. * The node is removed.
  31925. * @return {boolean} is removed.
  31926. */
  31927. isRemoved: function () {
  31928. return this.dataIndex < 0;
  31929. },
  31930. /**
  31931. * Travel this subtree (include this node).
  31932. * Usage:
  31933. * node.eachNode(function () { ... }); // preorder
  31934. * node.eachNode('preorder', function () { ... }); // preorder
  31935. * node.eachNode('postorder', function () { ... }); // postorder
  31936. * node.eachNode(
  31937. * {order: 'postorder', attr: 'viewChildren'},
  31938. * function () { ... }
  31939. * ); // postorder
  31940. *
  31941. * @param {(Object|string)} options If string, means order.
  31942. * @param {string=} options.order 'preorder' or 'postorder'
  31943. * @param {string=} options.attr 'children' or 'viewChildren'
  31944. * @param {Function} cb If in preorder and return false,
  31945. * its subtree will not be visited.
  31946. * @param {Object} [context]
  31947. */
  31948. eachNode: function (options, cb, context) {
  31949. if (typeof options === 'function') {
  31950. context = cb;
  31951. cb = options;
  31952. options = null;
  31953. }
  31954. options = options || {};
  31955. if (zrUtil.isString(options)) {
  31956. options = {order: options};
  31957. }
  31958. var order = options.order || 'preorder';
  31959. var children = this[options.attr || 'children'];
  31960. var suppressVisitSub;
  31961. order === 'preorder' && (suppressVisitSub = cb.call(context, this));
  31962. for (var i = 0; !suppressVisitSub && i < children.length; i++) {
  31963. children[i].eachNode(options, cb, context);
  31964. }
  31965. order === 'postorder' && cb.call(context, this);
  31966. },
  31967. /**
  31968. * Update depth and height of this subtree.
  31969. *
  31970. * @param {number} depth
  31971. */
  31972. updateDepthAndHeight: function (depth) {
  31973. var height = 0;
  31974. this.depth = depth;
  31975. for (var i = 0; i < this.children.length; i++) {
  31976. var child = this.children[i];
  31977. child.updateDepthAndHeight(depth + 1);
  31978. if (child.height > height) {
  31979. height = child.height;
  31980. }
  31981. }
  31982. this.height = height + 1;
  31983. },
  31984. /**
  31985. * @param {string} id
  31986. * @return {module:echarts/data/Tree~TreeNode}
  31987. */
  31988. getNodeById: function (id) {
  31989. if (this.getId() === id) {
  31990. return this;
  31991. }
  31992. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  31993. var res = children[i].getNodeById(id);
  31994. if (res) {
  31995. return res;
  31996. }
  31997. }
  31998. },
  31999. /**
  32000. * @param {module:echarts/data/Tree~TreeNode} node
  32001. * @return {boolean}
  32002. */
  32003. contains: function (node) {
  32004. if (node === this) {
  32005. return true;
  32006. }
  32007. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  32008. var res = children[i].contains(node);
  32009. if (res) {
  32010. return res;
  32011. }
  32012. }
  32013. },
  32014. /**
  32015. * @param {boolean} includeSelf Default false.
  32016. * @return {Array.<module:echarts/data/Tree~TreeNode>} order: [root, child, grandchild, ...]
  32017. */
  32018. getAncestors: function (includeSelf) {
  32019. var ancestors = [];
  32020. var node = includeSelf ? this : this.parentNode;
  32021. while (node) {
  32022. ancestors.push(node);
  32023. node = node.parentNode;
  32024. }
  32025. ancestors.reverse();
  32026. return ancestors;
  32027. },
  32028. /**
  32029. * @param {string|Array=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3
  32030. * @return {number} Value.
  32031. */
  32032. getValue: function (dimension) {
  32033. var data = this.hostTree.data;
  32034. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  32035. },
  32036. /**
  32037. * @param {Object} layout
  32038. * @param {boolean=} [merge=false]
  32039. */
  32040. setLayout: function (layout, merge) {
  32041. this.dataIndex >= 0
  32042. && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge);
  32043. },
  32044. /**
  32045. * @return {Object} layout
  32046. */
  32047. getLayout: function () {
  32048. return this.hostTree.data.getItemLayout(this.dataIndex);
  32049. },
  32050. /**
  32051. * @param {string} [path]
  32052. * @return {module:echarts/model/Model}
  32053. */
  32054. getModel: function (path) {
  32055. if (this.dataIndex < 0) {
  32056. return;
  32057. }
  32058. var hostTree = this.hostTree;
  32059. var itemModel = hostTree.data.getItemModel(this.dataIndex);
  32060. var levelModel = this.getLevelModel();
  32061. return itemModel.getModel(path, (levelModel || hostTree.hostModel).getModel(path));
  32062. },
  32063. /**
  32064. * @return {module:echarts/model/Model}
  32065. */
  32066. getLevelModel: function () {
  32067. return (this.hostTree.levelModels || [])[this.depth];
  32068. },
  32069. /**
  32070. * @example
  32071. * setItemVisual('color', color);
  32072. * setItemVisual({
  32073. * 'color': color
  32074. * });
  32075. */
  32076. setVisual: function (key, value) {
  32077. this.dataIndex >= 0
  32078. && this.hostTree.data.setItemVisual(this.dataIndex, key, value);
  32079. },
  32080. /**
  32081. * Get item visual
  32082. */
  32083. getVisual: function (key, ignoreParent) {
  32084. return this.hostTree.data.getItemVisual(this.dataIndex, key, ignoreParent);
  32085. },
  32086. /**
  32087. * @public
  32088. * @return {number}
  32089. */
  32090. getRawIndex: function () {
  32091. return this.hostTree.data.getRawIndex(this.dataIndex);
  32092. },
  32093. /**
  32094. * @public
  32095. * @return {string}
  32096. */
  32097. getId: function () {
  32098. return this.hostTree.data.getId(this.dataIndex);
  32099. }
  32100. };
  32101. /**
  32102. * @constructor
  32103. * @alias module:echarts/data/Tree
  32104. * @param {module:echarts/model/Model} hostModel
  32105. * @param {Array.<Object>} levelOptions
  32106. */
  32107. function Tree(hostModel, levelOptions) {
  32108. /**
  32109. * @type {module:echarts/data/Tree~TreeNode}
  32110. * @readOnly
  32111. */
  32112. this.root;
  32113. /**
  32114. * @type {module:echarts/data/List}
  32115. * @readOnly
  32116. */
  32117. this.data;
  32118. /**
  32119. * Index of each item is the same as the raw index of coresponding list item.
  32120. * @private
  32121. * @type {Array.<module:echarts/data/Tree~TreeNode}
  32122. */
  32123. this._nodes = [];
  32124. /**
  32125. * @private
  32126. * @readOnly
  32127. * @type {module:echarts/model/Model}
  32128. */
  32129. this.hostModel = hostModel;
  32130. /**
  32131. * @private
  32132. * @readOnly
  32133. * @type {Array.<module:echarts/model/Model}
  32134. */
  32135. this.levelModels = zrUtil.map(levelOptions || [], function (levelDefine) {
  32136. return new Model(levelDefine, hostModel, hostModel.ecModel);
  32137. });
  32138. }
  32139. Tree.prototype = {
  32140. constructor: Tree,
  32141. type: 'tree',
  32142. /**
  32143. * Travel this subtree (include this node).
  32144. * Usage:
  32145. * node.eachNode(function () { ... }); // preorder
  32146. * node.eachNode('preorder', function () { ... }); // preorder
  32147. * node.eachNode('postorder', function () { ... }); // postorder
  32148. * node.eachNode(
  32149. * {order: 'postorder', attr: 'viewChildren'},
  32150. * function () { ... }
  32151. * ); // postorder
  32152. *
  32153. * @param {(Object|string)} options If string, means order.
  32154. * @param {string=} options.order 'preorder' or 'postorder'
  32155. * @param {string=} options.attr 'children' or 'viewChildren'
  32156. * @param {Function} cb
  32157. * @param {Object} [context]
  32158. */
  32159. eachNode: function(options, cb, context) {
  32160. this.root.eachNode(options, cb, context);
  32161. },
  32162. /**
  32163. * @param {number} dataIndex
  32164. * @return {module:echarts/data/Tree~TreeNode}
  32165. */
  32166. getNodeByDataIndex: function (dataIndex) {
  32167. var rawIndex = this.data.getRawIndex(dataIndex);
  32168. return this._nodes[rawIndex];
  32169. },
  32170. /**
  32171. * @param {string} name
  32172. * @return {module:echarts/data/Tree~TreeNode}
  32173. */
  32174. getNodeByName: function (name) {
  32175. return this.root.getNodeByName(name);
  32176. },
  32177. /**
  32178. * Update item available by list,
  32179. * when list has been performed options like 'filterSelf' or 'map'.
  32180. */
  32181. update: function () {
  32182. var data = this.data;
  32183. var nodes = this._nodes;
  32184. for (var i = 0, len = nodes.length; i < len; i++) {
  32185. nodes[i].dataIndex = -1;
  32186. }
  32187. for (var i = 0, len = data.count(); i < len; i++) {
  32188. nodes[data.getRawIndex(i)].dataIndex = i;
  32189. }
  32190. },
  32191. /**
  32192. * Clear all layouts
  32193. */
  32194. clearLayouts: function () {
  32195. this.data.clearItemLayouts();
  32196. }
  32197. };
  32198. /**
  32199. * data node format:
  32200. * {
  32201. * name: ...
  32202. * value: ...
  32203. * children: [
  32204. * {
  32205. * name: ...
  32206. * value: ...
  32207. * children: ...
  32208. * },
  32209. * ...
  32210. * ]
  32211. * }
  32212. *
  32213. * @static
  32214. * @param {Objec} dataRoot Root node.
  32215. * @param {module:echarts/model/Model} hostModel
  32216. * @param {Array.<Object>} levelOptions
  32217. * @return module:echarts/data/Tree
  32218. */
  32219. Tree.createTree = function (dataRoot, hostModel, levelOptions) {
  32220. var tree = new Tree(hostModel, levelOptions);
  32221. var listData = [];
  32222. var dimMax = 1;
  32223. buildHierarchy(dataRoot);
  32224. function buildHierarchy(dataNode, parentNode) {
  32225. var value = dataNode.value;
  32226. dimMax = Math.max(dimMax, zrUtil.isArray(value) ? value.length : 1);
  32227. listData.push(dataNode);
  32228. var node = new TreeNode(dataNode.name, tree);
  32229. parentNode
  32230. ? addChild(node, parentNode)
  32231. : (tree.root = node);
  32232. tree._nodes.push(node);
  32233. var children = dataNode.children;
  32234. if (children) {
  32235. for (var i = 0; i < children.length; i++) {
  32236. buildHierarchy(children[i], node);
  32237. }
  32238. }
  32239. }
  32240. tree.root.updateDepthAndHeight(0);
  32241. var dimensions = completeDimensions([{name: 'value'}], listData, {dimCount: dimMax});
  32242. var list = new List(dimensions, hostModel);
  32243. list.initData(listData);
  32244. linkList({
  32245. mainData: list,
  32246. struct: tree,
  32247. structAttr: 'tree'
  32248. });
  32249. tree.update();
  32250. return tree;
  32251. };
  32252. /**
  32253. * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote,
  32254. * so this function is not ready and not necessary to be public.
  32255. *
  32256. * @param {(module:echarts/data/Tree~TreeNode|Object)} child
  32257. */
  32258. function addChild(child, node) {
  32259. var children = node.children;
  32260. if (child.parentNode === node) {
  32261. return;
  32262. }
  32263. children.push(child);
  32264. child.parentNode = node;
  32265. }
  32266. module.exports = Tree;
  32267. /***/ },
  32268. /* 196 */
  32269. /***/ function(module, exports, __webpack_require__) {
  32270. /**
  32271. * Link lists and struct (graph or tree)
  32272. */
  32273. var zrUtil = __webpack_require__(4);
  32274. var each = zrUtil.each;
  32275. var DATAS = '\0__link_datas';
  32276. var MAIN_DATA = '\0__link_mainData';
  32277. // Caution:
  32278. // In most case, either list or its shallow clones (see list.cloneShallow)
  32279. // is active in echarts process. So considering heap memory consumption,
  32280. // we do not clone tree or graph, but share them among list and its shallow clones.
  32281. // But in some rare case, we have to keep old list (like do animation in chart). So
  32282. // please take care that both the old list and the new list share the same tree/graph.
  32283. /**
  32284. * @param {Object} opt
  32285. * @param {module:echarts/data/List} opt.mainData
  32286. * @param {Object} [opt.struct] For example, instance of Graph or Tree.
  32287. * @param {string} [opt.structAttr] designation: list[structAttr] = struct;
  32288. * @param {Object} [opt.datas] {dataType: data},
  32289. * like: {node: nodeList, edge: edgeList}.
  32290. * Should contain mainData.
  32291. * @param {Object} [opt.datasAttr] {dataType: attr},
  32292. * designation: struct[datasAttr[dataType]] = list;
  32293. */
  32294. function linkList(opt) {
  32295. var mainData = opt.mainData;
  32296. var datas = opt.datas;
  32297. if (!datas) {
  32298. datas = {main: mainData};
  32299. opt.datasAttr = {main: 'data'};
  32300. }
  32301. opt.datas = opt.mainData = null;
  32302. linkAll(mainData, datas, opt);
  32303. // Porxy data original methods.
  32304. each(datas, function (data) {
  32305. each(mainData.TRANSFERABLE_METHODS, function (methodName) {
  32306. data.wrapMethod(methodName, zrUtil.curry(transferInjection, opt));
  32307. });
  32308. });
  32309. // Beyond transfer, additional features should be added to `cloneShallow`.
  32310. mainData.wrapMethod('cloneShallow', zrUtil.curry(cloneShallowInjection, opt));
  32311. // Only mainData trigger change, because struct.update may trigger
  32312. // another changable methods, which may bring about dead lock.
  32313. each(mainData.CHANGABLE_METHODS, function (methodName) {
  32314. mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
  32315. });
  32316. // Make sure datas contains mainData.
  32317. zrUtil.assert(datas[mainData.dataType] === mainData);
  32318. }
  32319. function transferInjection(opt, res) {
  32320. if (isMainData(this)) {
  32321. // Transfer datas to new main data.
  32322. var datas = zrUtil.extend({}, this[DATAS]);
  32323. datas[this.dataType] = res;
  32324. linkAll(res, datas, opt);
  32325. }
  32326. else {
  32327. // Modify the reference in main data to point newData.
  32328. linkSingle(res, this.dataType, this[MAIN_DATA], opt);
  32329. }
  32330. return res;
  32331. }
  32332. function changeInjection(opt, res) {
  32333. opt.struct && opt.struct.update(this);
  32334. return res;
  32335. }
  32336. function cloneShallowInjection(opt, res) {
  32337. // cloneShallow, which brings about some fragilities, may be inappropriate
  32338. // to be exposed as an API. So for implementation simplicity we can make
  32339. // the restriction that cloneShallow of not-mainData should not be invoked
  32340. // outside, but only be invoked here.
  32341. each(res[DATAS], function (data, dataType) {
  32342. data !== res && linkSingle(data.cloneShallow(), dataType, res, opt);
  32343. });
  32344. return res;
  32345. }
  32346. /**
  32347. * Supplement method to List.
  32348. *
  32349. * @public
  32350. * @param {string} [dataType] If not specified, return mainData.
  32351. * @return {module:echarts/data/List}
  32352. */
  32353. function getLinkedData(dataType) {
  32354. var mainData = this[MAIN_DATA];
  32355. return (dataType == null || mainData == null)
  32356. ? mainData
  32357. : mainData[DATAS][dataType];
  32358. }
  32359. function isMainData(data) {
  32360. return data[MAIN_DATA] === data;
  32361. }
  32362. function linkAll(mainData, datas, opt) {
  32363. mainData[DATAS] = {};
  32364. each(datas, function (data, dataType) {
  32365. linkSingle(data, dataType, mainData, opt);
  32366. });
  32367. }
  32368. function linkSingle(data, dataType, mainData, opt) {
  32369. mainData[DATAS][dataType] = data;
  32370. data[MAIN_DATA] = mainData;
  32371. data.dataType = dataType;
  32372. if (opt.struct) {
  32373. data[opt.structAttr] = opt.struct;
  32374. opt.struct[opt.datasAttr[dataType]] = data;
  32375. }
  32376. // Supplement method.
  32377. data.getLinkedData = getLinkedData;
  32378. }
  32379. module.exports = linkList;
  32380. /***/ },
  32381. /* 197 */
  32382. /***/ function(module, exports, __webpack_require__) {
  32383. var zrUtil = __webpack_require__(4);
  32384. var helper = {
  32385. retrieveTargetInfo: function (payload, seriesModel) {
  32386. if (payload
  32387. && (
  32388. payload.type === 'treemapZoomToNode'
  32389. || payload.type === 'treemapRootToNode'
  32390. )
  32391. ) {
  32392. var root = seriesModel.getData().tree.root;
  32393. var targetNode = payload.targetNode;
  32394. if (targetNode && root.contains(targetNode)) {
  32395. return {node: targetNode};
  32396. }
  32397. var targetNodeId = payload.targetNodeId;
  32398. if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
  32399. return {node: targetNode};
  32400. }
  32401. }
  32402. },
  32403. // Not includes the given node at the last item.
  32404. getPathToRoot: function (node) {
  32405. var path = [];
  32406. while (node) {
  32407. node = node.parentNode;
  32408. node && path.push(node);
  32409. }
  32410. return path.reverse();
  32411. },
  32412. aboveViewRoot: function (viewRoot, node) {
  32413. var viewPath = helper.getPathToRoot(viewRoot);
  32414. return zrUtil.indexOf(viewPath, node) >= 0;
  32415. },
  32416. // From root to the input node (the input node will be included).
  32417. wrapTreePathInfo: function (node, seriesModel) {
  32418. var treePathInfo = [];
  32419. while (node) {
  32420. var nodeDataIndex = node.dataIndex;
  32421. treePathInfo.push({
  32422. name: node.name,
  32423. dataIndex: nodeDataIndex,
  32424. value: seriesModel.getRawValue(nodeDataIndex)
  32425. });
  32426. node = node.parentNode;
  32427. }
  32428. treePathInfo.reverse();
  32429. return treePathInfo;
  32430. }
  32431. };
  32432. module.exports = helper;
  32433. /***/ },
  32434. /* 198 */
  32435. /***/ function(module, exports, __webpack_require__) {
  32436. var zrUtil = __webpack_require__(4);
  32437. var graphic = __webpack_require__(18);
  32438. var DataDiffer = __webpack_require__(99);
  32439. var helper = __webpack_require__(197);
  32440. var Breadcrumb = __webpack_require__(199);
  32441. var RoamController = __webpack_require__(183);
  32442. var BoundingRect = __webpack_require__(9);
  32443. var matrix = __webpack_require__(11);
  32444. var animationUtil = __webpack_require__(200);
  32445. var bind = zrUtil.bind;
  32446. var Group = graphic.Group;
  32447. var Rect = graphic.Rect;
  32448. var each = zrUtil.each;
  32449. var DRAG_THRESHOLD = 3;
  32450. var PATH_LABEL_NOAMAL = ['label', 'normal'];
  32451. var PATH_LABEL_EMPHASIS = ['label', 'emphasis'];
  32452. var PATH_UPPERLABEL_NORMAL = ['upperLabel', 'normal'];
  32453. var PATH_UPPERLABEL_EMPHASIS = ['upperLabel', 'emphasis'];
  32454. var Z_BASE = 10; // Should bigger than every z.
  32455. var Z_BG = 1;
  32456. var Z_CONTENT = 2;
  32457. module.exports = __webpack_require__(1).extendChartView({
  32458. type: 'treemap',
  32459. /**
  32460. * @override
  32461. */
  32462. init: function (o, api) {
  32463. /**
  32464. * @private
  32465. * @type {module:zrender/container/Group}
  32466. */
  32467. this._containerGroup;
  32468. /**
  32469. * @private
  32470. * @type {Object.<string, Array.<module:zrender/container/Group>>}
  32471. */
  32472. this._storage = createStorage();
  32473. /**
  32474. * @private
  32475. * @type {module:echarts/data/Tree}
  32476. */
  32477. this._oldTree;
  32478. /**
  32479. * @private
  32480. * @type {module:echarts/chart/treemap/Breadcrumb}
  32481. */
  32482. this._breadcrumb;
  32483. /**
  32484. * @private
  32485. * @type {module:echarts/component/helper/RoamController}
  32486. */
  32487. this._controller;
  32488. /**
  32489. * 'ready', 'animating'
  32490. * @private
  32491. */
  32492. this._state = 'ready';
  32493. /**
  32494. * @private
  32495. * @type {boolean}
  32496. */
  32497. this._mayClick;
  32498. },
  32499. /**
  32500. * @override
  32501. */
  32502. render: function (seriesModel, ecModel, api, payload) {
  32503. var models = ecModel.findComponents({
  32504. mainType: 'series', subType: 'treemap', query: payload
  32505. });
  32506. if (zrUtil.indexOf(models, seriesModel) < 0) {
  32507. return;
  32508. }
  32509. this.seriesModel = seriesModel;
  32510. this.api = api;
  32511. this.ecModel = ecModel;
  32512. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  32513. var payloadType = payload && payload.type;
  32514. var layoutInfo = seriesModel.layoutInfo;
  32515. var isInit = !this._oldTree;
  32516. var thisStorage = this._storage;
  32517. // Mark new root when action is treemapRootToNode.
  32518. var reRoot = (payloadType === 'treemapRootToNode' && targetInfo && thisStorage)
  32519. ? {
  32520. rootNodeGroup: thisStorage.nodeGroup[targetInfo.node.getRawIndex()],
  32521. direction: payload.direction
  32522. }
  32523. : null;
  32524. var containerGroup = this._giveContainerGroup(layoutInfo);
  32525. var renderResult = this._doRender(containerGroup, seriesModel, reRoot);
  32526. (
  32527. !isInit && (
  32528. !payloadType
  32529. || payloadType === 'treemapZoomToNode'
  32530. || payloadType === 'treemapRootToNode'
  32531. )
  32532. )
  32533. ? this._doAnimation(containerGroup, renderResult, seriesModel, reRoot)
  32534. : renderResult.renderFinally();
  32535. this._resetController(api);
  32536. this._renderBreadcrumb(seriesModel, api, targetInfo);
  32537. },
  32538. /**
  32539. * @private
  32540. */
  32541. _giveContainerGroup: function (layoutInfo) {
  32542. var containerGroup = this._containerGroup;
  32543. if (!containerGroup) {
  32544. // FIXME
  32545. // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。
  32546. containerGroup = this._containerGroup = new Group();
  32547. this._initEvents(containerGroup);
  32548. this.group.add(containerGroup);
  32549. }
  32550. containerGroup.attr('position', [layoutInfo.x, layoutInfo.y]);
  32551. return containerGroup;
  32552. },
  32553. /**
  32554. * @private
  32555. */
  32556. _doRender: function (containerGroup, seriesModel, reRoot) {
  32557. var thisTree = seriesModel.getData().tree;
  32558. var oldTree = this._oldTree;
  32559. // Clear last shape records.
  32560. var lastsForAnimation = createStorage();
  32561. var thisStorage = createStorage();
  32562. var oldStorage = this._storage;
  32563. var willInvisibleEls = [];
  32564. var doRenderNode = zrUtil.curry(
  32565. renderNode, seriesModel,
  32566. thisStorage, oldStorage, reRoot,
  32567. lastsForAnimation, willInvisibleEls
  32568. );
  32569. // Notice: when thisTree and oldTree are the same tree (see list.cloneShadow),
  32570. // the oldTree is actually losted, so we can not find all of the old graphic
  32571. // elements from tree. So we use this stragegy: make element storage, move
  32572. // from old storage to new storage, clear old storage.
  32573. dualTravel(
  32574. thisTree.root ? [thisTree.root] : [],
  32575. (oldTree && oldTree.root) ? [oldTree.root] : [],
  32576. containerGroup,
  32577. thisTree === oldTree || !oldTree,
  32578. 0
  32579. );
  32580. // Process all removing.
  32581. var willDeleteEls = clearStorage(oldStorage);
  32582. this._oldTree = thisTree;
  32583. this._storage = thisStorage;
  32584. return {
  32585. lastsForAnimation: lastsForAnimation,
  32586. willDeleteEls: willDeleteEls,
  32587. renderFinally: renderFinally
  32588. };
  32589. function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, depth) {
  32590. // When 'render' is triggered by action,
  32591. // 'this' and 'old' may be the same tree,
  32592. // we use rawIndex in that case.
  32593. if (sameTree) {
  32594. oldViewChildren = thisViewChildren;
  32595. each(thisViewChildren, function (child, index) {
  32596. !child.isRemoved() && processNode(index, index);
  32597. });
  32598. }
  32599. // Diff hierarchically (diff only in each subtree, but not whole).
  32600. // because, consistency of view is important.
  32601. else {
  32602. (new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey))
  32603. .add(processNode)
  32604. .update(processNode)
  32605. .remove(zrUtil.curry(processNode, null))
  32606. .execute();
  32607. }
  32608. function getKey(node) {
  32609. // Identify by name or raw index.
  32610. return node.getId();
  32611. }
  32612. function processNode(newIndex, oldIndex) {
  32613. var thisNode = newIndex != null ? thisViewChildren[newIndex] : null;
  32614. var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null;
  32615. var group = doRenderNode(thisNode, oldNode, parentGroup, depth);
  32616. group && dualTravel(
  32617. thisNode && thisNode.viewChildren || [],
  32618. oldNode && oldNode.viewChildren || [],
  32619. group,
  32620. sameTree,
  32621. depth + 1
  32622. );
  32623. }
  32624. }
  32625. function clearStorage(storage) {
  32626. var willDeleteEls = createStorage();
  32627. storage && each(storage, function (store, storageName) {
  32628. var delEls = willDeleteEls[storageName];
  32629. each(store, function (el) {
  32630. el && (delEls.push(el), el.__tmWillDelete = 1);
  32631. });
  32632. });
  32633. return willDeleteEls;
  32634. }
  32635. function renderFinally() {
  32636. each(willDeleteEls, function (els) {
  32637. each(els, function (el) {
  32638. el.parent && el.parent.remove(el);
  32639. });
  32640. });
  32641. each(willInvisibleEls, function (el) {
  32642. el.invisible = true;
  32643. // Setting invisible is for optimizing, so no need to set dirty,
  32644. // just mark as invisible.
  32645. el.dirty();
  32646. });
  32647. }
  32648. },
  32649. /**
  32650. * @private
  32651. */
  32652. _doAnimation: function (containerGroup, renderResult, seriesModel, reRoot) {
  32653. if (!seriesModel.get('animation')) {
  32654. return;
  32655. }
  32656. var duration = seriesModel.get('animationDurationUpdate');
  32657. var easing = seriesModel.get('animationEasing');
  32658. var animationWrap = animationUtil.createWrap();
  32659. // Make delete animations.
  32660. each(renderResult.willDeleteEls, function (store, storageName) {
  32661. each(store, function (el, rawIndex) {
  32662. if (el.invisible) {
  32663. return;
  32664. }
  32665. var parent = el.parent; // Always has parent, and parent is nodeGroup.
  32666. var target;
  32667. if (reRoot && reRoot.direction === 'drillDown') {
  32668. target = parent === reRoot.rootNodeGroup
  32669. // This is the content element of view root.
  32670. // Only `content` will enter this branch, because
  32671. // `background` and `nodeGroup` will not be deleted.
  32672. ? {
  32673. shape: {
  32674. x: 0,
  32675. y: 0,
  32676. width: parent.__tmNodeWidth,
  32677. height: parent.__tmNodeHeight
  32678. },
  32679. style: {
  32680. opacity: 0
  32681. }
  32682. }
  32683. // Others.
  32684. : {style: {opacity: 0}};
  32685. }
  32686. else {
  32687. var targetX = 0;
  32688. var targetY = 0;
  32689. if (!parent.__tmWillDelete) {
  32690. // Let node animate to right-bottom corner, cooperating with fadeout,
  32691. // which is appropriate for user understanding.
  32692. // Divided by 2 for reRoot rolling up effect.
  32693. targetX = parent.__tmNodeWidth / 2;
  32694. targetY = parent.__tmNodeHeight / 2;
  32695. }
  32696. target = storageName === 'nodeGroup'
  32697. ? {position: [targetX, targetY], style: {opacity: 0}}
  32698. : {
  32699. shape: {x: targetX, y: targetY, width: 0, height: 0},
  32700. style: {opacity: 0}
  32701. };
  32702. }
  32703. target && animationWrap.add(el, target, duration, easing);
  32704. });
  32705. });
  32706. // Make other animations
  32707. each(this._storage, function (store, storageName) {
  32708. each(store, function (el, rawIndex) {
  32709. var last = renderResult.lastsForAnimation[storageName][rawIndex];
  32710. var target = {};
  32711. if (!last) {
  32712. return;
  32713. }
  32714. if (storageName === 'nodeGroup') {
  32715. if (last.old) {
  32716. target.position = el.position.slice();
  32717. el.attr('position', last.old);
  32718. }
  32719. }
  32720. else {
  32721. if (last.old) {
  32722. target.shape = zrUtil.extend({}, el.shape);
  32723. el.setShape(last.old);
  32724. }
  32725. if (last.fadein) {
  32726. el.setStyle('opacity', 0);
  32727. target.style = {opacity: 1};
  32728. }
  32729. // When animation is stopped for succedent animation starting,
  32730. // el.style.opacity might not be 1
  32731. else if (el.style.opacity !== 1) {
  32732. target.style = {opacity: 1};
  32733. }
  32734. }
  32735. animationWrap.add(el, target, duration, easing);
  32736. });
  32737. }, this);
  32738. this._state = 'animating';
  32739. animationWrap
  32740. .done(bind(function () {
  32741. this._state = 'ready';
  32742. renderResult.renderFinally();
  32743. }, this))
  32744. .start();
  32745. },
  32746. /**
  32747. * @private
  32748. */
  32749. _resetController: function (api) {
  32750. var controller = this._controller;
  32751. // Init controller.
  32752. if (!controller) {
  32753. controller = this._controller = new RoamController(api.getZr());
  32754. controller.enable(this.seriesModel.get('roam'));
  32755. controller.on('pan', bind(this._onPan, this));
  32756. controller.on('zoom', bind(this._onZoom, this));
  32757. }
  32758. var rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight());
  32759. controller.setPointerChecker(function (e, x, y) {
  32760. return rect.contain(x, y);
  32761. });
  32762. },
  32763. /**
  32764. * @private
  32765. */
  32766. _clearController: function () {
  32767. var controller = this._controller;
  32768. if (controller) {
  32769. controller.dispose();
  32770. controller = null;
  32771. }
  32772. },
  32773. /**
  32774. * @private
  32775. */
  32776. _onPan: function (dx, dy) {
  32777. this._mayClick = false;
  32778. if (this._state !== 'animating'
  32779. && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)
  32780. ) {
  32781. // These param must not be cached.
  32782. var root = this.seriesModel.getData().tree.root;
  32783. if (!root) {
  32784. return;
  32785. }
  32786. var rootLayout = root.getLayout();
  32787. if (!rootLayout) {
  32788. return;
  32789. }
  32790. this.api.dispatchAction({
  32791. type: 'treemapMove',
  32792. from: this.uid,
  32793. seriesId: this.seriesModel.id,
  32794. rootRect: {
  32795. x: rootLayout.x + dx, y: rootLayout.y + dy,
  32796. width: rootLayout.width, height: rootLayout.height
  32797. }
  32798. });
  32799. }
  32800. },
  32801. /**
  32802. * @private
  32803. */
  32804. _onZoom: function (scale, mouseX, mouseY) {
  32805. this._mayClick = false;
  32806. if (this._state !== 'animating') {
  32807. // These param must not be cached.
  32808. var root = this.seriesModel.getData().tree.root;
  32809. if (!root) {
  32810. return;
  32811. }
  32812. var rootLayout = root.getLayout();
  32813. if (!rootLayout) {
  32814. return;
  32815. }
  32816. var rect = new BoundingRect(
  32817. rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height
  32818. );
  32819. var layoutInfo = this.seriesModel.layoutInfo;
  32820. // Transform mouse coord from global to containerGroup.
  32821. mouseX -= layoutInfo.x;
  32822. mouseY -= layoutInfo.y;
  32823. // Scale root bounding rect.
  32824. var m = matrix.create();
  32825. matrix.translate(m, m, [-mouseX, -mouseY]);
  32826. matrix.scale(m, m, [scale, scale]);
  32827. matrix.translate(m, m, [mouseX, mouseY]);
  32828. rect.applyTransform(m);
  32829. this.api.dispatchAction({
  32830. type: 'treemapRender',
  32831. from: this.uid,
  32832. seriesId: this.seriesModel.id,
  32833. rootRect: {
  32834. x: rect.x, y: rect.y,
  32835. width: rect.width, height: rect.height
  32836. }
  32837. });
  32838. }
  32839. },
  32840. /**
  32841. * @private
  32842. */
  32843. _initEvents: function (containerGroup) {
  32844. // FIXME
  32845. // 不用click以及silent的原因是,animate时视图设置silent true来避免click生效,
  32846. // 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标,
  32847. // 还是会触发click,期望是不触发。
  32848. // Mousedown occurs when drag start, and mouseup occurs when drag end,
  32849. // click event should not be triggered in that case.
  32850. containerGroup.on('mousedown', function (e) {
  32851. this._state === 'ready' && (this._mayClick = true);
  32852. }, this);
  32853. containerGroup.on('mouseup', function (e) {
  32854. if (this._mayClick) {
  32855. this._mayClick = false;
  32856. this._state === 'ready' && onClick.call(this, e);
  32857. }
  32858. }, this);
  32859. function onClick(e) {
  32860. var nodeClick = this.seriesModel.get('nodeClick', true);
  32861. if (!nodeClick) {
  32862. return;
  32863. }
  32864. var targetInfo = this.findTarget(e.offsetX, e.offsetY);
  32865. if (!targetInfo) {
  32866. return;
  32867. }
  32868. var node = targetInfo.node;
  32869. if (node.getLayout().isLeafRoot) {
  32870. this._rootToNode(targetInfo);
  32871. }
  32872. else {
  32873. if (nodeClick === 'zoomToNode') {
  32874. this._zoomToNode(targetInfo);
  32875. }
  32876. else if (nodeClick === 'link') {
  32877. var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
  32878. var link = itemModel.get('link', true);
  32879. var linkTarget = itemModel.get('target', true) || 'blank';
  32880. link && window.open(link, linkTarget);
  32881. }
  32882. }
  32883. }
  32884. },
  32885. /**
  32886. * @private
  32887. */
  32888. _renderBreadcrumb: function (seriesModel, api, targetInfo) {
  32889. if (!targetInfo) {
  32890. targetInfo = seriesModel.get('leafDepth', true) != null
  32891. ? {node: seriesModel.getViewRoot()}
  32892. // FIXME
  32893. // better way?
  32894. // Find breadcrumb tail on center of containerGroup.
  32895. : this.findTarget(api.getWidth() / 2, api.getHeight() / 2);
  32896. if (!targetInfo) {
  32897. targetInfo = {node: seriesModel.getData().tree.root};
  32898. }
  32899. }
  32900. (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group)))
  32901. .render(seriesModel, api, targetInfo.node, bind(onSelect, this));
  32902. function onSelect(node) {
  32903. if (this._state !== 'animating') {
  32904. helper.aboveViewRoot(seriesModel.getViewRoot(), node)
  32905. ? this._rootToNode({node: node})
  32906. : this._zoomToNode({node: node});
  32907. }
  32908. }
  32909. },
  32910. /**
  32911. * @override
  32912. */
  32913. remove: function () {
  32914. this._clearController();
  32915. this._containerGroup && this._containerGroup.removeAll();
  32916. this._storage = createStorage();
  32917. this._state = 'ready';
  32918. this._breadcrumb && this._breadcrumb.remove();
  32919. },
  32920. dispose: function () {
  32921. this._clearController();
  32922. },
  32923. /**
  32924. * @private
  32925. */
  32926. _zoomToNode: function (targetInfo) {
  32927. this.api.dispatchAction({
  32928. type: 'treemapZoomToNode',
  32929. from: this.uid,
  32930. seriesId: this.seriesModel.id,
  32931. targetNode: targetInfo.node
  32932. });
  32933. },
  32934. /**
  32935. * @private
  32936. */
  32937. _rootToNode: function (targetInfo) {
  32938. this.api.dispatchAction({
  32939. type: 'treemapRootToNode',
  32940. from: this.uid,
  32941. seriesId: this.seriesModel.id,
  32942. targetNode: targetInfo.node
  32943. });
  32944. },
  32945. /**
  32946. * @public
  32947. * @param {number} x Global coord x.
  32948. * @param {number} y Global coord y.
  32949. * @return {Object} info If not found, return undefined;
  32950. * @return {number} info.node Target node.
  32951. * @return {number} info.offsetX x refer to target node.
  32952. * @return {number} info.offsetY y refer to target node.
  32953. */
  32954. findTarget: function (x, y) {
  32955. var targetInfo;
  32956. var viewRoot = this.seriesModel.getViewRoot();
  32957. viewRoot.eachNode({attr: 'viewChildren', order: 'preorder'}, function (node) {
  32958. var bgEl = this._storage.background[node.getRawIndex()];
  32959. // If invisible, there might be no element.
  32960. if (bgEl) {
  32961. var point = bgEl.transformCoordToLocal(x, y);
  32962. var shape = bgEl.shape;
  32963. // For performance consideration, dont use 'getBoundingRect'.
  32964. if (shape.x <= point[0]
  32965. && point[0] <= shape.x + shape.width
  32966. && shape.y <= point[1]
  32967. && point[1] <= shape.y + shape.height
  32968. ) {
  32969. targetInfo = {node: node, offsetX: point[0], offsetY: point[1]};
  32970. }
  32971. else {
  32972. return false; // Suppress visit subtree.
  32973. }
  32974. }
  32975. }, this);
  32976. return targetInfo;
  32977. }
  32978. });
  32979. /**
  32980. * @inner
  32981. */
  32982. function createStorage() {
  32983. return {nodeGroup: [], background: [], content: []};
  32984. }
  32985. /**
  32986. * @inner
  32987. * @return Return undefined means do not travel further.
  32988. */
  32989. function renderNode(
  32990. seriesModel, thisStorage, oldStorage, reRoot,
  32991. lastsForAnimation, willInvisibleEls,
  32992. thisNode, oldNode, parentGroup, depth
  32993. ) {
  32994. // Whether under viewRoot.
  32995. if (!thisNode) {
  32996. // Deleting nodes will be performed finally. This method just find
  32997. // element from old storage, or create new element, set them to new
  32998. // storage, and set styles.
  32999. return;
  33000. }
  33001. // -------------------------------------------------------------------
  33002. // Start of closure variables available in "Procedures in renderNode".
  33003. var thisLayout = thisNode.getLayout();
  33004. if (!thisLayout || !thisLayout.isInView) {
  33005. return;
  33006. }
  33007. var thisWidth = thisLayout.width;
  33008. var thisHeight = thisLayout.height;
  33009. var borderWidth = thisLayout.borderWidth;
  33010. var thisInvisible = thisLayout.invisible;
  33011. var thisRawIndex = thisNode.getRawIndex();
  33012. var oldRawIndex = oldNode && oldNode.getRawIndex();
  33013. var thisViewChildren = thisNode.viewChildren;
  33014. var upperHeight = thisLayout.upperHeight;
  33015. var isParent = thisViewChildren && thisViewChildren.length;
  33016. var itemStyleEmphasisModel = thisNode.getModel('itemStyle.emphasis');
  33017. // End of closure ariables available in "Procedures in renderNode".
  33018. // -----------------------------------------------------------------
  33019. // Node group
  33020. var group = giveGraphic('nodeGroup', Group);
  33021. if (!group) {
  33022. return;
  33023. }
  33024. parentGroup.add(group);
  33025. // x,y are not set when el is above view root.
  33026. group.attr('position', [thisLayout.x || 0, thisLayout.y || 0]);
  33027. group.__tmNodeWidth = thisWidth;
  33028. group.__tmNodeHeight = thisHeight;
  33029. if (thisLayout.isAboveViewRoot) {
  33030. return group;
  33031. }
  33032. // Background
  33033. var bg = giveGraphic('background', Rect, depth, Z_BG);
  33034. bg && renderBackground(group, bg, isParent && thisLayout.upperHeight);
  33035. // No children, render content.
  33036. if (!isParent) {
  33037. var content = giveGraphic('content', Rect, depth, Z_CONTENT);
  33038. content && renderContent(group, content);
  33039. }
  33040. return group;
  33041. // ----------------------------
  33042. // | Procedures in renderNode |
  33043. // ----------------------------
  33044. function renderBackground(group, bg, useUpperLabel) {
  33045. // For tooltip.
  33046. bg.dataIndex = thisNode.dataIndex;
  33047. bg.seriesIndex = seriesModel.seriesIndex;
  33048. bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
  33049. var visualBorderColor = thisNode.getVisual('borderColor', true);
  33050. var emphasisBorderColor = itemStyleEmphasisModel.get('borderColor');
  33051. updateStyle(bg, function () {
  33052. var normalStyle = {fill: visualBorderColor};
  33053. var emphasisStyle = {fill: emphasisBorderColor};
  33054. if (useUpperLabel) {
  33055. var upperLabelWidth = thisWidth - 2 * borderWidth;
  33056. prepareText(
  33057. normalStyle, emphasisStyle, visualBorderColor, upperLabelWidth, upperHeight,
  33058. {x: borderWidth, y: 0, width: upperLabelWidth, height: upperHeight}
  33059. );
  33060. }
  33061. // For old bg.
  33062. else {
  33063. normalStyle.text = emphasisStyle.text = '';
  33064. }
  33065. bg.setStyle(normalStyle);
  33066. graphic.setHoverStyle(bg, emphasisStyle);
  33067. });
  33068. group.add(bg);
  33069. }
  33070. function renderContent(group, content) {
  33071. // For tooltip.
  33072. content.dataIndex = thisNode.dataIndex;
  33073. content.seriesIndex = seriesModel.seriesIndex;
  33074. var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0);
  33075. var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0);
  33076. content.culling = true;
  33077. content.setShape({
  33078. x: borderWidth,
  33079. y: borderWidth,
  33080. width: contentWidth,
  33081. height: contentHeight
  33082. });
  33083. var visualColor = thisNode.getVisual('color', true);
  33084. updateStyle(content, function () {
  33085. var normalStyle = {fill: visualColor};
  33086. var emphasisStyle = itemStyleEmphasisModel.getItemStyle();
  33087. prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
  33088. content.setStyle(normalStyle);
  33089. graphic.setHoverStyle(content, emphasisStyle);
  33090. });
  33091. group.add(content);
  33092. }
  33093. function updateStyle(element, cb) {
  33094. if (!thisInvisible) {
  33095. // If invisible, do not set visual, otherwise the element will
  33096. // change immediately before animation. We think it is OK to
  33097. // remain its origin color when moving out of the view window.
  33098. cb();
  33099. if (!element.__tmWillVisible) {
  33100. element.invisible = false;
  33101. }
  33102. }
  33103. else {
  33104. // Delay invisible setting utill animation finished,
  33105. // avoid element vanish suddenly before animation.
  33106. !element.invisible && willInvisibleEls.push(element);
  33107. }
  33108. }
  33109. function prepareText(normalStyle, emphasisStyle, visualColor, width, height, upperLabelRect) {
  33110. var nodeModel = thisNode.getModel();
  33111. var text = zrUtil.retrieve(
  33112. seriesModel.getFormattedLabel(
  33113. thisNode.dataIndex, 'normal', null, null, upperLabelRect ? 'upperLabel' : 'label'
  33114. ),
  33115. nodeModel.get('name')
  33116. );
  33117. if (!upperLabelRect && thisLayout.isLeafRoot) {
  33118. var iconChar = seriesModel.get('drillDownIcon', true);
  33119. text = iconChar ? iconChar + ' ' + text : text;
  33120. }
  33121. setText(
  33122. text, normalStyle, nodeModel, upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL,
  33123. visualColor, width, height, upperLabelRect
  33124. );
  33125. setText(
  33126. text, emphasisStyle, nodeModel, upperLabelRect ? PATH_UPPERLABEL_EMPHASIS : PATH_LABEL_EMPHASIS,
  33127. visualColor, width, height, upperLabelRect
  33128. );
  33129. }
  33130. function setText(text, style, nodeModel, labelPath, visualColor, width, height, upperLabelRect) {
  33131. var labelModel = nodeModel.getModel(labelPath);
  33132. var labelTextStyleModel = labelModel.getModel('textStyle');
  33133. graphic.setText(style, labelModel, visualColor);
  33134. // text.align and text.baseline is not included by graphic.setText,
  33135. // because in most cases the two attributes are not exposed to user,
  33136. // except in treemap.
  33137. style.textAlign = labelTextStyleModel.get('align');
  33138. style.textVerticalAlign = labelTextStyleModel.get('baseline');
  33139. upperLabelRect && (style.textPositionRect = zrUtil.clone(upperLabelRect));
  33140. var textRect = labelTextStyleModel.getTextRect(text);
  33141. if (!labelModel.getShallow('show') || textRect.height > height) {
  33142. style.text = '';
  33143. }
  33144. else if (textRect.width > width) {
  33145. style.text = labelTextStyleModel.get('ellipsis')
  33146. ? labelTextStyleModel.truncateText(
  33147. text, width, null, {minChar: 2}
  33148. )
  33149. : '';
  33150. }
  33151. else {
  33152. style.text = text;
  33153. }
  33154. }
  33155. function giveGraphic(storageName, Ctor, depth, z) {
  33156. var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
  33157. var lasts = lastsForAnimation[storageName];
  33158. if (element) {
  33159. // Remove from oldStorage
  33160. oldStorage[storageName][oldRawIndex] = null;
  33161. prepareAnimationWhenHasOld(lasts, element, storageName);
  33162. }
  33163. // If invisible and no old element, do not create new element (for optimizing).
  33164. else if (!thisInvisible) {
  33165. element = new Ctor({z: calculateZ(depth, z)});
  33166. element.__tmDepth = depth;
  33167. element.__tmStorageName = storageName;
  33168. prepareAnimationWhenNoOld(lasts, element, storageName);
  33169. }
  33170. // Set to thisStorage
  33171. return (thisStorage[storageName][thisRawIndex] = element);
  33172. }
  33173. function prepareAnimationWhenHasOld(lasts, element, storageName) {
  33174. var lastCfg = lasts[thisRawIndex] = {};
  33175. lastCfg.old = storageName === 'nodeGroup'
  33176. ? element.position.slice()
  33177. : zrUtil.extend({}, element.shape);
  33178. }
  33179. // If a element is new, we need to find the animation start point carefully,
  33180. // otherwise it will looks strange when 'zoomToNode'.
  33181. function prepareAnimationWhenNoOld(lasts, element, storageName) {
  33182. var lastCfg = lasts[thisRawIndex] = {};
  33183. var parentNode = thisNode.parentNode;
  33184. if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
  33185. var parentOldX = 0;
  33186. var parentOldY = 0;
  33187. // New nodes appear from right-bottom corner in 'zoomToNode' animation.
  33188. // For convenience, get old bounding rect from background.
  33189. var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
  33190. if (!reRoot && parentOldBg && parentOldBg.old) {
  33191. parentOldX = parentOldBg.old.width;
  33192. parentOldY = parentOldBg.old.height;
  33193. }
  33194. // When no parent old shape found, its parent is new too,
  33195. // so we can just use {x:0, y:0}.
  33196. lastCfg.old = storageName === 'nodeGroup'
  33197. ? [0, parentOldY]
  33198. : {x: parentOldX, y: parentOldY, width: 0, height: 0};
  33199. }
  33200. // Fade in, user can be aware that these nodes are new.
  33201. lastCfg.fadein = storageName !== 'nodeGroup';
  33202. }
  33203. }
  33204. // We can not set all backgroud with the same z, Because the behaviour of
  33205. // drill down and roll up differ background creation sequence from tree
  33206. // hierarchy sequence, which cause that lowser background element overlap
  33207. // upper ones. So we calculate z based on depth.
  33208. // Moreover, we try to shrink down z interval to [0, 1] to avoid that
  33209. // treemap with large z overlaps other components.
  33210. function calculateZ(depth, zInLevel) {
  33211. var zb = depth * Z_BASE + zInLevel;
  33212. return (zb - 1) / zb;
  33213. }
  33214. /***/ },
  33215. /* 199 */
  33216. /***/ function(module, exports, __webpack_require__) {
  33217. var graphic = __webpack_require__(18);
  33218. var layout = __webpack_require__(71);
  33219. var zrUtil = __webpack_require__(4);
  33220. var helper = __webpack_require__(197);
  33221. var TEXT_PADDING = 8;
  33222. var ITEM_GAP = 8;
  33223. var ARRAY_LENGTH = 5;
  33224. function Breadcrumb(containerGroup) {
  33225. /**
  33226. * @private
  33227. * @type {module:zrender/container/Group}
  33228. */
  33229. this.group = new graphic.Group();
  33230. containerGroup.add(this.group);
  33231. }
  33232. Breadcrumb.prototype = {
  33233. constructor: Breadcrumb,
  33234. render: function (seriesModel, api, targetNode, onSelect) {
  33235. var model = seriesModel.getModel('breadcrumb');
  33236. var thisGroup = this.group;
  33237. thisGroup.removeAll();
  33238. if (!model.get('show') || !targetNode) {
  33239. return;
  33240. }
  33241. var normalStyleModel = model.getModel('itemStyle.normal');
  33242. // var emphasisStyleModel = model.getModel('itemStyle.emphasis');
  33243. var textStyleModel = normalStyleModel.getModel('textStyle');
  33244. var layoutParam = {
  33245. pos: {
  33246. left: model.get('left'),
  33247. right: model.get('right'),
  33248. top: model.get('top'),
  33249. bottom: model.get('bottom')
  33250. },
  33251. box: {
  33252. width: api.getWidth(),
  33253. height: api.getHeight()
  33254. },
  33255. emptyItemWidth: model.get('emptyItemWidth'),
  33256. totalWidth: 0,
  33257. renderList: []
  33258. };
  33259. this._prepare(targetNode, layoutParam, textStyleModel);
  33260. this._renderContent(seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect);
  33261. layout.positionElement(thisGroup, layoutParam.pos, layoutParam.box);
  33262. },
  33263. /**
  33264. * Prepare render list and total width
  33265. * @private
  33266. */
  33267. _prepare: function (targetNode, layoutParam, textStyleModel) {
  33268. for (var node = targetNode; node; node = node.parentNode) {
  33269. var text = node.getModel().get('name');
  33270. var textRect = textStyleModel.getTextRect(text);
  33271. var itemWidth = Math.max(
  33272. textRect.width + TEXT_PADDING * 2,
  33273. layoutParam.emptyItemWidth
  33274. );
  33275. layoutParam.totalWidth += itemWidth + ITEM_GAP;
  33276. layoutParam.renderList.push({node: node, text: text, width: itemWidth});
  33277. }
  33278. },
  33279. /**
  33280. * @private
  33281. */
  33282. _renderContent: function (
  33283. seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect
  33284. ) {
  33285. // Start rendering.
  33286. var lastX = 0;
  33287. var emptyItemWidth = layoutParam.emptyItemWidth;
  33288. var height = seriesModel.get('breadcrumb.height');
  33289. var availableSize = layout.getAvailableSize(layoutParam.pos, layoutParam.box);
  33290. var totalWidth = layoutParam.totalWidth;
  33291. var renderList = layoutParam.renderList;
  33292. for (var i = renderList.length - 1; i >= 0; i--) {
  33293. var item = renderList[i];
  33294. var itemNode = item.node;
  33295. var itemWidth = item.width;
  33296. var text = item.text;
  33297. // Hdie text and shorten width if necessary.
  33298. if (totalWidth > availableSize.width) {
  33299. totalWidth -= itemWidth - emptyItemWidth;
  33300. itemWidth = emptyItemWidth;
  33301. text = '';
  33302. }
  33303. var el = new graphic.Polygon({
  33304. shape: {
  33305. points: makeItemPoints(
  33306. lastX, 0, itemWidth, height,
  33307. i === renderList.length - 1, i === 0
  33308. )
  33309. },
  33310. style: zrUtil.defaults(
  33311. normalStyleModel.getItemStyle(),
  33312. {
  33313. lineJoin: 'bevel',
  33314. text: text,
  33315. textFill: textStyleModel.getTextColor(),
  33316. textFont: textStyleModel.getFont()
  33317. }
  33318. ),
  33319. z: 10,
  33320. onclick: zrUtil.curry(onSelect, itemNode)
  33321. });
  33322. this.group.add(el);
  33323. packEventData(el, seriesModel, itemNode);
  33324. lastX += itemWidth + ITEM_GAP;
  33325. }
  33326. },
  33327. /**
  33328. * @override
  33329. */
  33330. remove: function () {
  33331. this.group.removeAll();
  33332. }
  33333. };
  33334. function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) {
  33335. var points = [
  33336. [head ? x : x - ARRAY_LENGTH, y],
  33337. [x + itemWidth, y],
  33338. [x + itemWidth, y + itemHeight],
  33339. [head ? x : x - ARRAY_LENGTH, y + itemHeight]
  33340. ];
  33341. !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]);
  33342. !head && points.push([x, y + itemHeight / 2]);
  33343. return points;
  33344. }
  33345. // Package custom mouse event.
  33346. function packEventData(el, seriesModel, itemNode) {
  33347. el.eventData = {
  33348. componentType: 'series',
  33349. componentSubType: 'treemap',
  33350. seriesIndex: seriesModel.componentIndex,
  33351. seriesName: seriesModel.name,
  33352. seriesType: 'treemap',
  33353. selfType: 'breadcrumb', // Distinguish with click event on treemap node.
  33354. nodeData: {
  33355. dataIndex: itemNode && itemNode.dataIndex,
  33356. name: itemNode && itemNode.name
  33357. },
  33358. treePathInfo: itemNode && helper.wrapTreePathInfo(itemNode, seriesModel)
  33359. };
  33360. }
  33361. module.exports = Breadcrumb;
  33362. /***/ },
  33363. /* 200 */
  33364. /***/ function(module, exports, __webpack_require__) {
  33365. var zrUtil = __webpack_require__(4);
  33366. /**
  33367. * @param {number} [time=500] Time in ms
  33368. * @param {string} [easing='linear']
  33369. * @param {number} [delay=0]
  33370. * @param {Function} [callback]
  33371. *
  33372. * @example
  33373. * // Animate position
  33374. * animation
  33375. * .createWrap()
  33376. * .add(el1, {position: [10, 10]})
  33377. * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400)
  33378. * .done(function () { // done })
  33379. * .start('cubicOut');
  33380. */
  33381. function createWrap() {
  33382. var storage = [];
  33383. var elExistsMap = {};
  33384. var doneCallback;
  33385. return {
  33386. /**
  33387. * Caution: a el can only be added once, otherwise 'done'
  33388. * might not be called. This method checks this (by el.id),
  33389. * suppresses adding and returns false when existing el found.
  33390. *
  33391. * @param {modele:zrender/Element} el
  33392. * @param {Object} target
  33393. * @param {number} [time=500]
  33394. * @param {number} [delay=0]
  33395. * @param {string} [easing='linear']
  33396. * @return {boolean} Whether adding succeeded.
  33397. *
  33398. * @example
  33399. * add(el, target, time, delay, easing);
  33400. * add(el, target, time, easing);
  33401. * add(el, target, time);
  33402. * add(el, target);
  33403. */
  33404. add: function (el, target, time, delay, easing) {
  33405. if (zrUtil.isString(delay)) {
  33406. easing = delay;
  33407. delay = 0;
  33408. }
  33409. if (elExistsMap[el.id]) {
  33410. return false;
  33411. }
  33412. elExistsMap[el.id] = 1;
  33413. storage.push(
  33414. {el: el, target: target, time: time, delay: delay, easing: easing}
  33415. );
  33416. return true;
  33417. },
  33418. /**
  33419. * Only execute when animation finished. Will not execute when any
  33420. * of 'stop' or 'stopAnimation' called.
  33421. *
  33422. * @param {Function} callback
  33423. */
  33424. done: function (callback) {
  33425. doneCallback = callback;
  33426. return this;
  33427. },
  33428. /**
  33429. * Will stop exist animation firstly.
  33430. */
  33431. start: function () {
  33432. var count = storage.length;
  33433. for (var i = 0, len = storage.length; i < len; i++) {
  33434. var item = storage[i];
  33435. item.el.animateTo(item.target, item.time, item.delay, item.easing, done);
  33436. }
  33437. return this;
  33438. function done() {
  33439. count--;
  33440. if (!count) {
  33441. storage.length = 0;
  33442. elExistsMap = {};
  33443. doneCallback && doneCallback();
  33444. }
  33445. }
  33446. }
  33447. };
  33448. }
  33449. module.exports = {createWrap: createWrap};
  33450. /***/ },
  33451. /* 201 */
  33452. /***/ function(module, exports, __webpack_require__) {
  33453. /**
  33454. * @file Treemap action
  33455. */
  33456. var echarts = __webpack_require__(1);
  33457. var helper = __webpack_require__(197);
  33458. var noop = function () {};
  33459. var actionTypes = [
  33460. 'treemapZoomToNode',
  33461. 'treemapRender',
  33462. 'treemapMove'
  33463. ];
  33464. for (var i = 0; i < actionTypes.length; i++) {
  33465. echarts.registerAction({type: actionTypes[i], update: 'updateView'}, noop);
  33466. }
  33467. echarts.registerAction(
  33468. {type: 'treemapRootToNode', update: 'updateView'},
  33469. function (payload, ecModel) {
  33470. ecModel.eachComponent(
  33471. {mainType: 'series', subType: 'treemap', query: payload},
  33472. handleRootToNode
  33473. );
  33474. function handleRootToNode(model, index) {
  33475. var targetInfo = helper.retrieveTargetInfo(payload, model);
  33476. if (targetInfo) {
  33477. var originViewRoot = model.getViewRoot();
  33478. if (originViewRoot) {
  33479. payload.direction = helper.aboveViewRoot(originViewRoot, targetInfo.node)
  33480. ? 'rollUp' : 'drillDown';
  33481. }
  33482. model.resetViewRoot(targetInfo.node);
  33483. }
  33484. }
  33485. }
  33486. );
  33487. /***/ },
  33488. /* 202 */
  33489. /***/ function(module, exports, __webpack_require__) {
  33490. var VisualMapping = __webpack_require__(203);
  33491. var zrColor = __webpack_require__(31);
  33492. var zrUtil = __webpack_require__(4);
  33493. var isArray = zrUtil.isArray;
  33494. var ITEM_STYLE_NORMAL = 'itemStyle.normal';
  33495. module.exports = function (ecModel, api, payload) {
  33496. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  33497. ecModel.eachComponent(condition, function (seriesModel) {
  33498. var tree = seriesModel.getData().tree;
  33499. var root = tree.root;
  33500. var seriesItemStyleModel = seriesModel.getModel(ITEM_STYLE_NORMAL);
  33501. if (root.isRemoved()) {
  33502. return;
  33503. }
  33504. var levelItemStyles = zrUtil.map(tree.levelModels, function (levelModel) {
  33505. return levelModel ? levelModel.get(ITEM_STYLE_NORMAL) : null;
  33506. });
  33507. travelTree(
  33508. root, // Visual should calculate from tree root but not view root.
  33509. {},
  33510. levelItemStyles,
  33511. seriesItemStyleModel,
  33512. seriesModel.getViewRoot().getAncestors(),
  33513. seriesModel
  33514. );
  33515. });
  33516. };
  33517. function travelTree(
  33518. node, designatedVisual, levelItemStyles, seriesItemStyleModel,
  33519. viewRootAncestors, seriesModel
  33520. ) {
  33521. var nodeModel = node.getModel();
  33522. var nodeLayout = node.getLayout();
  33523. // Optimize
  33524. if (!nodeLayout || nodeLayout.invisible || !nodeLayout.isInView) {
  33525. return;
  33526. }
  33527. var nodeItemStyleModel = node.getModel(ITEM_STYLE_NORMAL);
  33528. var levelItemStyle = levelItemStyles[node.depth];
  33529. var visuals = buildVisuals(
  33530. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  33531. );
  33532. // calculate border color
  33533. var borderColor = nodeItemStyleModel.get('borderColor');
  33534. var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation');
  33535. var thisNodeColor;
  33536. if (borderColorSaturation != null) {
  33537. // For performance, do not always execute 'calculateColor'.
  33538. thisNodeColor = calculateColor(visuals, node);
  33539. borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor);
  33540. }
  33541. node.setVisual('borderColor', borderColor);
  33542. var viewChildren = node.viewChildren;
  33543. if (!viewChildren || !viewChildren.length) {
  33544. thisNodeColor = calculateColor(visuals, node);
  33545. // Apply visual to this node.
  33546. node.setVisual('color', thisNodeColor);
  33547. }
  33548. else {
  33549. var mapping = buildVisualMapping(
  33550. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  33551. );
  33552. // Designate visual to children.
  33553. zrUtil.each(viewChildren, function (child, index) {
  33554. // If higher than viewRoot, only ancestors of viewRoot is needed to visit.
  33555. if (child.depth >= viewRootAncestors.length
  33556. || child === viewRootAncestors[child.depth]
  33557. ) {
  33558. var childVisual = mapVisual(
  33559. nodeModel, visuals, child, index, mapping, seriesModel
  33560. );
  33561. travelTree(
  33562. child, childVisual, levelItemStyles, seriesItemStyleModel,
  33563. viewRootAncestors, seriesModel
  33564. );
  33565. }
  33566. });
  33567. }
  33568. }
  33569. function buildVisuals(
  33570. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  33571. ) {
  33572. var visuals = zrUtil.extend({}, designatedVisual);
  33573. zrUtil.each(['color', 'colorAlpha', 'colorSaturation'], function (visualName) {
  33574. // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel
  33575. var val = nodeItemStyleModel.get(visualName, true); // Ignore parent
  33576. val == null && levelItemStyle && (val = levelItemStyle[visualName]);
  33577. val == null && (val = designatedVisual[visualName]);
  33578. val == null && (val = seriesItemStyleModel.get(visualName));
  33579. val != null && (visuals[visualName] = val);
  33580. });
  33581. return visuals;
  33582. }
  33583. function calculateColor(visuals) {
  33584. var color = getValueVisualDefine(visuals, 'color');
  33585. if (color) {
  33586. var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha');
  33587. var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation');
  33588. if (colorSaturation) {
  33589. color = zrColor.modifyHSL(color, null, null, colorSaturation);
  33590. }
  33591. if (colorAlpha) {
  33592. color = zrColor.modifyAlpha(color, colorAlpha);
  33593. }
  33594. return color;
  33595. }
  33596. }
  33597. function calculateBorderColor(borderColorSaturation, thisNodeColor) {
  33598. return thisNodeColor != null
  33599. ? zrColor.modifyHSL(thisNodeColor, null, null, borderColorSaturation)
  33600. : null;
  33601. }
  33602. function getValueVisualDefine(visuals, name) {
  33603. var value = visuals[name];
  33604. if (value != null && value !== 'none') {
  33605. return value;
  33606. }
  33607. }
  33608. function buildVisualMapping(
  33609. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  33610. ) {
  33611. if (!viewChildren || !viewChildren.length) {
  33612. return;
  33613. }
  33614. var rangeVisual = getRangeVisual(nodeModel, 'color')
  33615. || (
  33616. visuals.color != null
  33617. && visuals.color !== 'none'
  33618. && (
  33619. getRangeVisual(nodeModel, 'colorAlpha')
  33620. || getRangeVisual(nodeModel, 'colorSaturation')
  33621. )
  33622. );
  33623. if (!rangeVisual) {
  33624. return;
  33625. }
  33626. var visualMin = nodeModel.get('visualMin');
  33627. var visualMax = nodeModel.get('visualMax');
  33628. var dataExtent = nodeLayout.dataExtent.slice();
  33629. visualMin != null && visualMin < dataExtent[0] && (dataExtent[0] = visualMin);
  33630. visualMax != null && visualMax > dataExtent[1] && (dataExtent[1] = visualMax);
  33631. var colorMappingBy = nodeModel.get('colorMappingBy');
  33632. var opt = {
  33633. type: rangeVisual.name,
  33634. dataExtent: dataExtent,
  33635. visual: rangeVisual.range
  33636. };
  33637. if (opt.type === 'color'
  33638. && (colorMappingBy === 'index' || colorMappingBy === 'id')
  33639. ) {
  33640. opt.mappingMethod = 'category';
  33641. opt.loop = true;
  33642. // categories is ordinal, so do not set opt.categories.
  33643. }
  33644. else {
  33645. opt.mappingMethod = 'linear';
  33646. }
  33647. var mapping = new VisualMapping(opt);
  33648. mapping.__drColorMappingBy = colorMappingBy;
  33649. return mapping;
  33650. }
  33651. // Notice: If we dont have the attribute 'colorRange', but only use
  33652. // attribute 'color' to represent both concepts of 'colorRange' and 'color',
  33653. // (It means 'colorRange' when 'color' is Array, means 'color' when not array),
  33654. // this problem will be encountered:
  33655. // If a level-1 node dont have children, and its siblings has children,
  33656. // and colorRange is set on level-1, then the node can not be colored.
  33657. // So we separate 'colorRange' and 'color' to different attributes.
  33658. function getRangeVisual(nodeModel, name) {
  33659. // 'colorRange', 'colorARange', 'colorSRange'.
  33660. // If not exsits on this node, fetch from levels and series.
  33661. var range = nodeModel.get(name);
  33662. return (isArray(range) && range.length) ? {name: name, range: range} : null;
  33663. }
  33664. function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) {
  33665. var childVisuals = zrUtil.extend({}, visuals);
  33666. if (mapping) {
  33667. var mappingType = mapping.type;
  33668. var colorMappingBy = mappingType === 'color' && mapping.__drColorMappingBy;
  33669. var value =
  33670. colorMappingBy === 'index'
  33671. ? index
  33672. : colorMappingBy === 'id'
  33673. ? seriesModel.mapIdToIndex(child.getId())
  33674. : child.getValue(nodeModel.get('visualDimension'));
  33675. childVisuals[mappingType] = mapping.mapValueToVisual(value);
  33676. }
  33677. return childVisuals;
  33678. }
  33679. /***/ },
  33680. /* 203 */
  33681. /***/ function(module, exports, __webpack_require__) {
  33682. /**
  33683. * @file Visual mapping.
  33684. */
  33685. var zrUtil = __webpack_require__(4);
  33686. var zrColor = __webpack_require__(31);
  33687. var linearMap = __webpack_require__(7).linearMap;
  33688. var each = zrUtil.each;
  33689. var isObject = zrUtil.isObject;
  33690. var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
  33691. /**
  33692. * @param {Object} option
  33693. * @param {string} [option.type] See visualHandlers.
  33694. * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' or 'fixed'
  33695. * @param {Array.<number>=} [option.dataExtent] [minExtent, maxExtent],
  33696. * required when mappingMethod is 'linear'
  33697. * @param {Array.<Object>=} [option.pieceList] [
  33698. * {value: someValue},
  33699. * {interval: [min1, max1], visual: {...}},
  33700. * {interval: [min2, max2]}
  33701. * ],
  33702. * required when mappingMethod is 'piecewise'.
  33703. * Visual for only each piece can be specified.
  33704. * @param {Array.<string|Object>=} [option.categories] ['cate1', 'cate2']
  33705. * required when mappingMethod is 'category'.
  33706. * If no option.categories, categories is set
  33707. * as [0, 1, 2, ...].
  33708. * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'.
  33709. * @param {(Array|Object|*)} [option.visual] Visual data.
  33710. * when mappingMethod is 'category',
  33711. * visual data can be array or object
  33712. * (like: {cate1: '#222', none: '#fff'})
  33713. * or primary types (which represents
  33714. * defualt category visual), otherwise visual
  33715. * can be array or primary (which will be
  33716. * normalized to array).
  33717. *
  33718. */
  33719. var VisualMapping = function (option) {
  33720. var mappingMethod = option.mappingMethod;
  33721. var visualType = option.type;
  33722. /**
  33723. * @readOnly
  33724. * @type {Object}
  33725. */
  33726. var thisOption = this.option = zrUtil.clone(option);
  33727. /**
  33728. * @readOnly
  33729. * @type {string}
  33730. */
  33731. this.type = visualType;
  33732. /**
  33733. * @readOnly
  33734. * @type {string}
  33735. */
  33736. this.mappingMethod = mappingMethod;
  33737. /**
  33738. * @private
  33739. * @type {Function}
  33740. */
  33741. this._normalizeData = normalizers[mappingMethod];
  33742. var visualHandler = visualHandlers[visualType];
  33743. /**
  33744. * @public
  33745. * @type {Function}
  33746. */
  33747. this.applyVisual = visualHandler.applyVisual;
  33748. /**
  33749. * @public
  33750. * @type {Function}
  33751. */
  33752. this.getColorMapper = visualHandler.getColorMapper;
  33753. /**
  33754. * @private
  33755. * @type {Function}
  33756. */
  33757. this._doMap = visualHandler._doMap[mappingMethod];
  33758. if (mappingMethod === 'piecewise') {
  33759. normalizeVisualRange(thisOption);
  33760. preprocessForPiecewise(thisOption);
  33761. }
  33762. else if (mappingMethod === 'category') {
  33763. thisOption.categories
  33764. ? preprocessForSpecifiedCategory(thisOption)
  33765. // categories is ordinal when thisOption.categories not specified,
  33766. // which need no more preprocess except normalize visual.
  33767. : normalizeVisualRange(thisOption, true);
  33768. }
  33769. else { // mappingMethod === 'linear' or 'fixed'
  33770. zrUtil.assert(mappingMethod !== 'linear' || thisOption.dataExtent);
  33771. normalizeVisualRange(thisOption);
  33772. }
  33773. };
  33774. VisualMapping.prototype = {
  33775. constructor: VisualMapping,
  33776. mapValueToVisual: function (value) {
  33777. var normalized = this._normalizeData(value);
  33778. return this._doMap(normalized, value);
  33779. },
  33780. getNormalizer: function () {
  33781. return zrUtil.bind(this._normalizeData, this);
  33782. }
  33783. };
  33784. var visualHandlers = VisualMapping.visualHandlers = {
  33785. color: {
  33786. applyVisual: makeApplyVisual('color'),
  33787. /**
  33788. * Create a mapper function
  33789. * @return {Function}
  33790. */
  33791. getColorMapper: function () {
  33792. var thisOption = this.option;
  33793. return zrUtil.bind(
  33794. thisOption.mappingMethod === 'category'
  33795. ? function (value, isNormalized) {
  33796. !isNormalized && (value = this._normalizeData(value));
  33797. return doMapCategory.call(this, value);
  33798. }
  33799. : function (value, isNormalized, out) {
  33800. // If output rgb array
  33801. // which will be much faster and useful in pixel manipulation
  33802. var returnRGBArray = !!out;
  33803. !isNormalized && (value = this._normalizeData(value));
  33804. out = zrColor.fastMapToColor(value, thisOption.parsedVisual, out);
  33805. return returnRGBArray ? out : zrColor.stringify(out, 'rgba');
  33806. },
  33807. this
  33808. );
  33809. },
  33810. _doMap: {
  33811. linear: function (normalized) {
  33812. return zrColor.stringify(
  33813. zrColor.fastMapToColor(normalized, this.option.parsedVisual),
  33814. 'rgba'
  33815. );
  33816. },
  33817. category: doMapCategory,
  33818. piecewise: function (normalized, value) {
  33819. var result = getSpecifiedVisual.call(this, value);
  33820. if (result == null) {
  33821. result = zrColor.stringify(
  33822. zrColor.fastMapToColor(normalized, this.option.parsedVisual),
  33823. 'rgba'
  33824. );
  33825. }
  33826. return result;
  33827. },
  33828. fixed: doMapFixed
  33829. }
  33830. },
  33831. colorHue: makePartialColorVisualHandler(function (color, value) {
  33832. return zrColor.modifyHSL(color, value);
  33833. }),
  33834. colorSaturation: makePartialColorVisualHandler(function (color, value) {
  33835. return zrColor.modifyHSL(color, null, value);
  33836. }),
  33837. colorLightness: makePartialColorVisualHandler(function (color, value) {
  33838. return zrColor.modifyHSL(color, null, null, value);
  33839. }),
  33840. colorAlpha: makePartialColorVisualHandler(function (color, value) {
  33841. return zrColor.modifyAlpha(color, value);
  33842. }),
  33843. opacity: {
  33844. applyVisual: makeApplyVisual('opacity'),
  33845. _doMap: makeDoMap([0, 1])
  33846. },
  33847. symbol: {
  33848. applyVisual: function (value, getter, setter) {
  33849. var symbolCfg = this.mapValueToVisual(value);
  33850. if (zrUtil.isString(symbolCfg)) {
  33851. setter('symbol', symbolCfg);
  33852. }
  33853. else if (isObject(symbolCfg)) {
  33854. for (var name in symbolCfg) {
  33855. if (symbolCfg.hasOwnProperty(name)) {
  33856. setter(name, symbolCfg[name]);
  33857. }
  33858. }
  33859. }
  33860. },
  33861. _doMap: {
  33862. linear: doMapToArray,
  33863. category: doMapCategory,
  33864. piecewise: function (normalized, value) {
  33865. var result = getSpecifiedVisual.call(this, value);
  33866. if (result == null) {
  33867. result = doMapToArray.call(this, normalized);
  33868. }
  33869. return result;
  33870. },
  33871. fixed: doMapFixed
  33872. }
  33873. },
  33874. symbolSize: {
  33875. applyVisual: makeApplyVisual('symbolSize'),
  33876. _doMap: makeDoMap([0, 1])
  33877. }
  33878. };
  33879. function preprocessForPiecewise(thisOption) {
  33880. var pieceList = thisOption.pieceList;
  33881. thisOption.hasSpecialVisual = false;
  33882. zrUtil.each(pieceList, function (piece, index) {
  33883. piece.originIndex = index;
  33884. // piece.visual is "result visual value" but not
  33885. // a visual range, so it does not need to be normalized.
  33886. if (piece.visual != null) {
  33887. thisOption.hasSpecialVisual = true;
  33888. }
  33889. });
  33890. }
  33891. function preprocessForSpecifiedCategory(thisOption) {
  33892. // Hash categories.
  33893. var categories = thisOption.categories;
  33894. var visual = thisOption.visual;
  33895. var categoryMap = thisOption.categoryMap = {};
  33896. each(categories, function (cate, index) {
  33897. categoryMap[cate] = index;
  33898. });
  33899. // Process visual map input.
  33900. if (!zrUtil.isArray(visual)) {
  33901. var visualArr = [];
  33902. if (zrUtil.isObject(visual)) {
  33903. each(visual, function (v, cate) {
  33904. var index = categoryMap[cate];
  33905. visualArr[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v;
  33906. });
  33907. }
  33908. else { // Is primary type, represents default visual.
  33909. visualArr[CATEGORY_DEFAULT_VISUAL_INDEX] = visual;
  33910. }
  33911. visual = setVisualToOption(thisOption, visualArr);
  33912. }
  33913. // Remove categories that has no visual,
  33914. // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX.
  33915. for (var i = categories.length - 1; i >= 0; i--) {
  33916. if (visual[i] == null) {
  33917. delete categoryMap[categories[i]];
  33918. categories.pop();
  33919. }
  33920. }
  33921. }
  33922. function normalizeVisualRange(thisOption, isCategory) {
  33923. var visual = thisOption.visual;
  33924. var visualArr = [];
  33925. if (zrUtil.isObject(visual)) {
  33926. each(visual, function (v) {
  33927. visualArr.push(v);
  33928. });
  33929. }
  33930. else if (visual != null) {
  33931. visualArr.push(visual);
  33932. }
  33933. var doNotNeedPair = {color: 1, symbol: 1};
  33934. if (!isCategory
  33935. && visualArr.length === 1
  33936. && !doNotNeedPair.hasOwnProperty(thisOption.type)
  33937. ) {
  33938. // Do not care visualArr.length === 0, which is illegal.
  33939. visualArr[1] = visualArr[0];
  33940. }
  33941. setVisualToOption(thisOption, visualArr);
  33942. }
  33943. function makePartialColorVisualHandler(applyValue) {
  33944. return {
  33945. applyVisual: function (value, getter, setter) {
  33946. value = this.mapValueToVisual(value);
  33947. // Must not be array value
  33948. setter('color', applyValue(getter('color'), value));
  33949. },
  33950. _doMap: makeDoMap([0, 1])
  33951. };
  33952. }
  33953. function doMapToArray(normalized) {
  33954. var visual = this.option.visual;
  33955. return visual[
  33956. Math.round(linearMap(normalized, [0, 1], [0, visual.length - 1], true))
  33957. ] || {};
  33958. }
  33959. function makeApplyVisual(visualType) {
  33960. return function (value, getter, setter) {
  33961. setter(visualType, this.mapValueToVisual(value));
  33962. };
  33963. }
  33964. function doMapCategory(normalized) {
  33965. var visual = this.option.visual;
  33966. return visual[
  33967. (this.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX)
  33968. ? normalized % visual.length
  33969. : normalized
  33970. ];
  33971. }
  33972. function doMapFixed() {
  33973. return this.option.visual[0];
  33974. }
  33975. function makeDoMap(sourceExtent) {
  33976. return {
  33977. linear: function (normalized) {
  33978. return linearMap(normalized, sourceExtent, this.option.visual, true);
  33979. },
  33980. category: doMapCategory,
  33981. piecewise: function (normalized, value) {
  33982. var result = getSpecifiedVisual.call(this, value);
  33983. if (result == null) {
  33984. result = linearMap(normalized, sourceExtent, this.option.visual, true);
  33985. }
  33986. return result;
  33987. },
  33988. fixed: doMapFixed
  33989. };
  33990. }
  33991. function getSpecifiedVisual(value) {
  33992. var thisOption = this.option;
  33993. var pieceList = thisOption.pieceList;
  33994. if (thisOption.hasSpecialVisual) {
  33995. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList);
  33996. var piece = pieceList[pieceIndex];
  33997. if (piece && piece.visual) {
  33998. return piece.visual[this.type];
  33999. }
  34000. }
  34001. }
  34002. function setVisualToOption(thisOption, visualArr) {
  34003. thisOption.visual = visualArr;
  34004. if (thisOption.type === 'color') {
  34005. thisOption.parsedVisual = zrUtil.map(visualArr, function (item) {
  34006. return zrColor.parse(item);
  34007. });
  34008. }
  34009. return visualArr;
  34010. }
  34011. /**
  34012. * Normalizers by mapping methods.
  34013. */
  34014. var normalizers = {
  34015. linear: function (value) {
  34016. return linearMap(value, this.option.dataExtent, [0, 1], true);
  34017. },
  34018. piecewise: function (value) {
  34019. var pieceList = this.option.pieceList;
  34020. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList, true);
  34021. if (pieceIndex != null) {
  34022. return linearMap(pieceIndex, [0, pieceList.length - 1], [0, 1], true);
  34023. }
  34024. },
  34025. category: function (value) {
  34026. var index = this.option.categories
  34027. ? this.option.categoryMap[value]
  34028. : value; // ordinal
  34029. return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index;
  34030. },
  34031. fixed: zrUtil.noop
  34032. };
  34033. /**
  34034. * List available visual types.
  34035. *
  34036. * @public
  34037. * @return {Array.<string>}
  34038. */
  34039. VisualMapping.listVisualTypes = function () {
  34040. var visualTypes = [];
  34041. zrUtil.each(visualHandlers, function (handler, key) {
  34042. visualTypes.push(key);
  34043. });
  34044. return visualTypes;
  34045. };
  34046. /**
  34047. * @public
  34048. */
  34049. VisualMapping.addVisualHandler = function (name, handler) {
  34050. visualHandlers[name] = handler;
  34051. };
  34052. /**
  34053. * @public
  34054. */
  34055. VisualMapping.isValidType = function (visualType) {
  34056. return visualHandlers.hasOwnProperty(visualType);
  34057. };
  34058. /**
  34059. * Convinent method.
  34060. * Visual can be Object or Array or primary type.
  34061. *
  34062. * @public
  34063. */
  34064. VisualMapping.eachVisual = function (visual, callback, context) {
  34065. if (zrUtil.isObject(visual)) {
  34066. zrUtil.each(visual, callback, context);
  34067. }
  34068. else {
  34069. callback.call(context, visual);
  34070. }
  34071. };
  34072. VisualMapping.mapVisual = function (visual, callback, context) {
  34073. var isPrimary;
  34074. var newVisual = zrUtil.isArray(visual)
  34075. ? []
  34076. : zrUtil.isObject(visual)
  34077. ? {}
  34078. : (isPrimary = true, null);
  34079. VisualMapping.eachVisual(visual, function (v, key) {
  34080. var newVal = callback.call(context, v, key);
  34081. isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal);
  34082. });
  34083. return newVisual;
  34084. };
  34085. /**
  34086. * @public
  34087. * @param {Object} obj
  34088. * @return {Oject} new object containers visual values.
  34089. * If no visuals, return null.
  34090. */
  34091. VisualMapping.retrieveVisuals = function (obj) {
  34092. var ret = {};
  34093. var hasVisual;
  34094. obj && each(visualHandlers, function (h, visualType) {
  34095. if (obj.hasOwnProperty(visualType)) {
  34096. ret[visualType] = obj[visualType];
  34097. hasVisual = true;
  34098. }
  34099. });
  34100. return hasVisual ? ret : null;
  34101. };
  34102. /**
  34103. * Give order to visual types, considering colorSaturation, colorAlpha depends on color.
  34104. *
  34105. * @public
  34106. * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...}
  34107. * IF Array, like: ['color', 'symbol', 'colorSaturation']
  34108. * @return {Array.<string>} Sorted visual types.
  34109. */
  34110. VisualMapping.prepareVisualTypes = function (visualTypes) {
  34111. if (isObject(visualTypes)) {
  34112. var types = [];
  34113. each(visualTypes, function (item, type) {
  34114. types.push(type);
  34115. });
  34116. visualTypes = types;
  34117. }
  34118. else if (zrUtil.isArray(visualTypes)) {
  34119. visualTypes = visualTypes.slice();
  34120. }
  34121. else {
  34122. return [];
  34123. }
  34124. visualTypes.sort(function (type1, type2) {
  34125. // color should be front of colorSaturation, colorAlpha, ...
  34126. // symbol and symbolSize do not matter.
  34127. return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0)
  34128. ? 1 : -1;
  34129. });
  34130. return visualTypes;
  34131. };
  34132. /**
  34133. * 'color', 'colorSaturation', 'colorAlpha', ... are depends on 'color'.
  34134. * Other visuals are only depends on themself.
  34135. *
  34136. * @public
  34137. * @param {string} visualType1
  34138. * @param {string} visualType2
  34139. * @return {boolean}
  34140. */
  34141. VisualMapping.dependsOn = function (visualType1, visualType2) {
  34142. return visualType2 === 'color'
  34143. ? !!(visualType1 && visualType1.indexOf(visualType2) === 0)
  34144. : visualType1 === visualType2;
  34145. };
  34146. /**
  34147. * @param {number} value
  34148. * @param {Array.<Object>} pieceList [{value: ..., interval: [min, max]}, ...]
  34149. * Always from small to big.
  34150. * @param {boolean} [findClosestWhenOutside=false]
  34151. * @return {number} index
  34152. */
  34153. VisualMapping.findPieceIndex = function (value, pieceList, findClosestWhenOutside) {
  34154. var possibleI;
  34155. var abs = Infinity;
  34156. // value has the higher priority.
  34157. for (var i = 0, len = pieceList.length; i < len; i++) {
  34158. var pieceValue = pieceList[i].value;
  34159. if (pieceValue != null) {
  34160. if (pieceValue === value
  34161. // FIXME
  34162. // It is supposed to compare value according to value type of dimension,
  34163. // but currently value type can exactly be string or number.
  34164. // Compromise for numeric-like string (like '12'), especially
  34165. // in the case that visualMap.categories is ['22', '33'].
  34166. || (typeof pieceValue === 'string' && pieceValue === value + '')
  34167. ) {
  34168. return i;
  34169. }
  34170. findClosestWhenOutside && updatePossible(pieceValue, i);
  34171. }
  34172. }
  34173. for (var i = 0, len = pieceList.length; i < len; i++) {
  34174. var piece = pieceList[i];
  34175. var interval = piece.interval;
  34176. var close = piece.close;
  34177. if (interval) {
  34178. if (interval[0] === -Infinity) {
  34179. if (littleThan(close[1], value, interval[1])) {
  34180. return i;
  34181. }
  34182. }
  34183. else if (interval[1] === Infinity) {
  34184. if (littleThan(close[0], interval[0], value)) {
  34185. return i;
  34186. }
  34187. }
  34188. else if (
  34189. littleThan(close[0], interval[0], value)
  34190. && littleThan(close[1], value, interval[1])
  34191. ) {
  34192. return i;
  34193. }
  34194. findClosestWhenOutside && updatePossible(interval[0], i);
  34195. findClosestWhenOutside && updatePossible(interval[1], i);
  34196. }
  34197. }
  34198. if (findClosestWhenOutside) {
  34199. return value === Infinity
  34200. ? pieceList.length - 1
  34201. : value === -Infinity
  34202. ? 0
  34203. : possibleI;
  34204. }
  34205. function updatePossible(val, index) {
  34206. var newAbs = Math.abs(val - value);
  34207. if (newAbs < abs) {
  34208. abs = newAbs;
  34209. possibleI = index;
  34210. }
  34211. }
  34212. };
  34213. function littleThan(close, a, b) {
  34214. return close ? a <= b : a < b;
  34215. }
  34216. module.exports = VisualMapping;
  34217. /***/ },
  34218. /* 204 */
  34219. /***/ function(module, exports, __webpack_require__) {
  34220. var zrUtil = __webpack_require__(4);
  34221. var numberUtil = __webpack_require__(7);
  34222. var layout = __webpack_require__(71);
  34223. var helper = __webpack_require__(197);
  34224. var BoundingRect = __webpack_require__(9);
  34225. var helper = __webpack_require__(197);
  34226. var mathMax = Math.max;
  34227. var mathMin = Math.min;
  34228. var parsePercent = numberUtil.parsePercent;
  34229. var retrieveValue = zrUtil.retrieve;
  34230. var each = zrUtil.each;
  34231. var PATH_BORDER_WIDTH = ['itemStyle', 'normal', 'borderWidth'];
  34232. var PATH_GAP_WIDTH = ['itemStyle', 'normal', 'gapWidth'];
  34233. var PATH_UPPER_LABEL_SHOW = ['upperLabel', 'normal', 'show'];
  34234. var PATH_UPPER_LABEL_HEIGHT = ['upperLabel', 'normal', 'height'];
  34235. /**
  34236. * @public
  34237. */
  34238. function update(ecModel, api, payload) {
  34239. // Layout result in each node:
  34240. // {x, y, width, height, area, borderWidth}
  34241. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  34242. ecModel.eachComponent(condition, function (seriesModel) {
  34243. var ecWidth = api.getWidth();
  34244. var ecHeight = api.getHeight();
  34245. var seriesOption = seriesModel.option;
  34246. var layoutInfo = layout.getLayoutRect(
  34247. seriesModel.getBoxLayoutParams(),
  34248. {
  34249. width: api.getWidth(),
  34250. height: api.getHeight()
  34251. }
  34252. );
  34253. var size = seriesOption.size || []; // Compatible with ec2.
  34254. var containerWidth = parsePercent(
  34255. retrieveValue(layoutInfo.width, size[0]),
  34256. ecWidth
  34257. );
  34258. var containerHeight = parsePercent(
  34259. retrieveValue(layoutInfo.height, size[1]),
  34260. ecHeight
  34261. );
  34262. // Fetch payload info.
  34263. var payloadType = payload && payload.type;
  34264. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  34265. var rootRect = (payloadType === 'treemapRender' || payloadType === 'treemapMove')
  34266. ? payload.rootRect : null;
  34267. var viewRoot = seriesModel.getViewRoot();
  34268. var viewAbovePath = helper.getPathToRoot(viewRoot);
  34269. if (payloadType !== 'treemapMove') {
  34270. var rootSize = payloadType === 'treemapZoomToNode'
  34271. ? estimateRootSize(
  34272. seriesModel, targetInfo, viewRoot, containerWidth, containerHeight
  34273. )
  34274. : rootRect
  34275. ? [rootRect.width, rootRect.height]
  34276. : [containerWidth, containerHeight];
  34277. var sort = seriesOption.sort;
  34278. if (sort && sort !== 'asc' && sort !== 'desc') {
  34279. sort = 'desc';
  34280. }
  34281. var options = {
  34282. squareRatio: seriesOption.squareRatio,
  34283. sort: sort,
  34284. leafDepth: seriesOption.leafDepth
  34285. };
  34286. // layout should be cleared because using updateView but not update.
  34287. viewRoot.hostTree.clearLayouts();
  34288. // TODO
  34289. // optimize: if out of view clip, do not layout.
  34290. // But take care that if do not render node out of view clip,
  34291. // how to calculate start po
  34292. var viewRootLayout = {
  34293. x: 0, y: 0,
  34294. width: rootSize[0], height: rootSize[1],
  34295. area: rootSize[0] * rootSize[1]
  34296. };
  34297. viewRoot.setLayout(viewRootLayout);
  34298. squarify(viewRoot, options, false, 0);
  34299. // Supplement layout.
  34300. var viewRootLayout = viewRoot.getLayout();
  34301. each(viewAbovePath, function (node, index) {
  34302. var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
  34303. node.setLayout(zrUtil.extend(
  34304. {dataExtent: [childValue, childValue], borderWidth: 0, upperHeight: 0},
  34305. viewRootLayout
  34306. ));
  34307. });
  34308. }
  34309. var treeRoot = seriesModel.getData().tree.root;
  34310. treeRoot.setLayout(
  34311. calculateRootPosition(layoutInfo, rootRect, targetInfo),
  34312. true
  34313. );
  34314. seriesModel.setLayoutInfo(layoutInfo);
  34315. // FIXME
  34316. // 现在没有clip功能,暂时取ec高宽。
  34317. prunning(
  34318. treeRoot,
  34319. // Transform to base element coordinate system.
  34320. new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight),
  34321. viewAbovePath,
  34322. viewRoot,
  34323. 0
  34324. );
  34325. });
  34326. }
  34327. /**
  34328. * Layout treemap with squarify algorithm.
  34329. * @see https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf
  34330. * @see https://github.com/mbostock/d3/blob/master/src/layout/treemap.js
  34331. *
  34332. * @protected
  34333. * @param {module:echarts/data/Tree~TreeNode} node
  34334. * @param {Object} options
  34335. * @param {string} options.sort 'asc' or 'desc'
  34336. * @param {number} options.squareRatio
  34337. * @param {boolean} hideChildren
  34338. * @param {number} depth
  34339. */
  34340. function squarify(node, options, hideChildren, depth) {
  34341. var width;
  34342. var height;
  34343. if (node.isRemoved()) {
  34344. return;
  34345. }
  34346. var thisLayout = node.getLayout();
  34347. width = thisLayout.width;
  34348. height = thisLayout.height;
  34349. // Considering border and gap
  34350. var nodeModel = node.getModel();
  34351. var borderWidth = nodeModel.get(PATH_BORDER_WIDTH);
  34352. var halfGapWidth = nodeModel.get(PATH_GAP_WIDTH) / 2;
  34353. var upperLabelHeight = getUpperLabelHeight(nodeModel);
  34354. var upperHeight = Math.max(borderWidth, upperLabelHeight);
  34355. var layoutOffset = borderWidth - halfGapWidth;
  34356. var layoutOffsetUpper = upperHeight - halfGapWidth;
  34357. var nodeModel = node.getModel();
  34358. node.setLayout({
  34359. borderWidth: borderWidth,
  34360. upperHeight: upperHeight,
  34361. upperLabelHeight: upperLabelHeight
  34362. }, true);
  34363. width = mathMax(width - 2 * layoutOffset, 0);
  34364. height = mathMax(height - layoutOffset - layoutOffsetUpper, 0);
  34365. var totalArea = width * height;
  34366. var viewChildren = initChildren(
  34367. node, nodeModel, totalArea, options, hideChildren, depth
  34368. );
  34369. if (!viewChildren.length) {
  34370. return;
  34371. }
  34372. var rect = {x: layoutOffset, y: layoutOffsetUpper, width: width, height: height};
  34373. var rowFixedLength = mathMin(width, height);
  34374. var best = Infinity; // the best row score so far
  34375. var row = [];
  34376. row.area = 0;
  34377. for (var i = 0, len = viewChildren.length; i < len;) {
  34378. var child = viewChildren[i];
  34379. row.push(child);
  34380. row.area += child.getLayout().area;
  34381. var score = worst(row, rowFixedLength, options.squareRatio);
  34382. // continue with this orientation
  34383. if (score <= best) {
  34384. i++;
  34385. best = score;
  34386. }
  34387. // abort, and try a different orientation
  34388. else {
  34389. row.area -= row.pop().getLayout().area;
  34390. position(row, rowFixedLength, rect, halfGapWidth, false);
  34391. rowFixedLength = mathMin(rect.width, rect.height);
  34392. row.length = row.area = 0;
  34393. best = Infinity;
  34394. }
  34395. }
  34396. if (row.length) {
  34397. position(row, rowFixedLength, rect, halfGapWidth, true);
  34398. }
  34399. if (!hideChildren) {
  34400. var childrenVisibleMin = nodeModel.get('childrenVisibleMin');
  34401. if (childrenVisibleMin != null && totalArea < childrenVisibleMin) {
  34402. hideChildren = true;
  34403. }
  34404. }
  34405. for (var i = 0, len = viewChildren.length; i < len; i++) {
  34406. squarify(viewChildren[i], options, hideChildren, depth + 1);
  34407. }
  34408. }
  34409. /**
  34410. * Set area to each child, and calculate data extent for visual coding.
  34411. */
  34412. function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
  34413. var viewChildren = node.children || [];
  34414. var orderBy = options.sort;
  34415. orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
  34416. var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth;
  34417. // leafDepth has higher priority.
  34418. if (hideChildren && !overLeafDepth) {
  34419. return (node.viewChildren = []);
  34420. }
  34421. // Sort children, order by desc.
  34422. viewChildren = zrUtil.filter(viewChildren, function (child) {
  34423. return !child.isRemoved();
  34424. });
  34425. sort(viewChildren, orderBy);
  34426. var info = statistic(nodeModel, viewChildren, orderBy);
  34427. if (info.sum === 0) {
  34428. return (node.viewChildren = []);
  34429. }
  34430. info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
  34431. if (info.sum === 0) {
  34432. return (node.viewChildren = []);
  34433. }
  34434. // Set area to each child.
  34435. for (var i = 0, len = viewChildren.length; i < len; i++) {
  34436. var area = viewChildren[i].getValue() / info.sum * totalArea;
  34437. // Do not use setLayout({...}, true), because it is needed to clear last layout.
  34438. viewChildren[i].setLayout({area: area});
  34439. }
  34440. if (overLeafDepth) {
  34441. viewChildren.length && node.setLayout({isLeafRoot: true}, true);
  34442. viewChildren.length = 0;
  34443. }
  34444. node.viewChildren = viewChildren;
  34445. node.setLayout({dataExtent: info.dataExtent}, true);
  34446. return viewChildren;
  34447. }
  34448. /**
  34449. * Consider 'visibleMin'. Modify viewChildren and get new sum.
  34450. */
  34451. function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
  34452. // visibleMin is not supported yet when no option.sort.
  34453. if (!orderBy) {
  34454. return sum;
  34455. }
  34456. var visibleMin = nodeModel.get('visibleMin');
  34457. var len = orderedChildren.length;
  34458. var deletePoint = len;
  34459. // Always travel from little value to big value.
  34460. for (var i = len - 1; i >= 0; i--) {
  34461. var value = orderedChildren[
  34462. orderBy === 'asc' ? len - i - 1 : i
  34463. ].getValue();
  34464. if (value / sum * totalArea < visibleMin) {
  34465. deletePoint = i;
  34466. sum -= value;
  34467. }
  34468. }
  34469. orderBy === 'asc'
  34470. ? orderedChildren.splice(0, len - deletePoint)
  34471. : orderedChildren.splice(deletePoint, len - deletePoint);
  34472. return sum;
  34473. }
  34474. /**
  34475. * Sort
  34476. */
  34477. function sort(viewChildren, orderBy) {
  34478. if (orderBy) {
  34479. viewChildren.sort(function (a, b) {
  34480. var diff = orderBy === 'asc'
  34481. ? a.getValue() - b.getValue() : b.getValue() - a.getValue();
  34482. return diff === 0
  34483. ? (orderBy === 'asc'
  34484. ? a.dataIndex - b.dataIndex : b.dataIndex - a.dataIndex
  34485. )
  34486. : diff;
  34487. });
  34488. }
  34489. return viewChildren;
  34490. }
  34491. /**
  34492. * Statistic
  34493. */
  34494. function statistic(nodeModel, children, orderBy) {
  34495. // Calculate sum.
  34496. var sum = 0;
  34497. for (var i = 0, len = children.length; i < len; i++) {
  34498. sum += children[i].getValue();
  34499. }
  34500. // Statistic data extent for latter visual coding.
  34501. // Notice: data extent should be calculate based on raw children
  34502. // but not filtered view children, otherwise visual mapping will not
  34503. // be stable when zoom (where children is filtered by visibleMin).
  34504. var dimension = nodeModel.get('visualDimension');
  34505. var dataExtent;
  34506. // The same as area dimension.
  34507. if (!children || !children.length) {
  34508. dataExtent = [NaN, NaN];
  34509. }
  34510. else if (dimension === 'value' && orderBy) {
  34511. dataExtent = [
  34512. children[children.length - 1].getValue(),
  34513. children[0].getValue()
  34514. ];
  34515. orderBy === 'asc' && dataExtent.reverse();
  34516. }
  34517. // Other dimension.
  34518. else {
  34519. var dataExtent = [Infinity, -Infinity];
  34520. each(children, function (child) {
  34521. var value = child.getValue(dimension);
  34522. value < dataExtent[0] && (dataExtent[0] = value);
  34523. value > dataExtent[1] && (dataExtent[1] = value);
  34524. });
  34525. }
  34526. return {sum: sum, dataExtent: dataExtent};
  34527. }
  34528. /**
  34529. * Computes the score for the specified row,
  34530. * as the worst aspect ratio.
  34531. */
  34532. function worst(row, rowFixedLength, ratio) {
  34533. var areaMax = 0;
  34534. var areaMin = Infinity;
  34535. for (var i = 0, area, len = row.length; i < len; i++) {
  34536. area = row[i].getLayout().area;
  34537. if (area) {
  34538. area < areaMin && (areaMin = area);
  34539. area > areaMax && (areaMax = area);
  34540. }
  34541. }
  34542. var squareArea = row.area * row.area;
  34543. var f = rowFixedLength * rowFixedLength * ratio;
  34544. return squareArea
  34545. ? mathMax(
  34546. (f * areaMax) / squareArea,
  34547. squareArea / (f * areaMin)
  34548. )
  34549. : Infinity;
  34550. }
  34551. /**
  34552. * Positions the specified row of nodes. Modifies `rect`.
  34553. */
  34554. function position(row, rowFixedLength, rect, halfGapWidth, flush) {
  34555. // When rowFixedLength === rect.width,
  34556. // it is horizontal subdivision,
  34557. // rowFixedLength is the width of the subdivision,
  34558. // rowOtherLength is the height of the subdivision,
  34559. // and nodes will be positioned from left to right.
  34560. // wh[idx0WhenH] means: when horizontal,
  34561. // wh[idx0WhenH] => wh[0] => 'width'.
  34562. // xy[idx1WhenH] => xy[1] => 'y'.
  34563. var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
  34564. var idx1WhenH = 1 - idx0WhenH;
  34565. var xy = ['x', 'y'];
  34566. var wh = ['width', 'height'];
  34567. var last = rect[xy[idx0WhenH]];
  34568. var rowOtherLength = rowFixedLength
  34569. ? row.area / rowFixedLength : 0;
  34570. if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
  34571. rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
  34572. }
  34573. for (var i = 0, rowLen = row.length; i < rowLen; i++) {
  34574. var node = row[i];
  34575. var nodeLayout = {};
  34576. var step = rowOtherLength
  34577. ? node.getLayout().area / rowOtherLength : 0;
  34578. var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);
  34579. // We use Math.max/min to avoid negative width/height when considering gap width.
  34580. var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
  34581. var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
  34582. var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);
  34583. nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
  34584. nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);
  34585. last += modWH;
  34586. node.setLayout(nodeLayout, true);
  34587. }
  34588. rect[xy[idx1WhenH]] += rowOtherLength;
  34589. rect[wh[idx1WhenH]] -= rowOtherLength;
  34590. }
  34591. // Return [containerWidth, containerHeight] as defualt.
  34592. function estimateRootSize(seriesModel, targetInfo, viewRoot, containerWidth, containerHeight) {
  34593. // If targetInfo.node exists, we zoom to the node,
  34594. // so estimate whold width and heigth by target node.
  34595. var currNode = (targetInfo || {}).node;
  34596. var defaultSize = [containerWidth, containerHeight];
  34597. if (!currNode || currNode === viewRoot) {
  34598. return defaultSize;
  34599. }
  34600. var parent;
  34601. var viewArea = containerWidth * containerHeight;
  34602. var area = viewArea * seriesModel.option.zoomToNodeRatio;
  34603. while (parent = currNode.parentNode) { // jshint ignore:line
  34604. var sum = 0;
  34605. var siblings = parent.children;
  34606. for (var i = 0, len = siblings.length; i < len; i++) {
  34607. sum += siblings[i].getValue();
  34608. }
  34609. var currNodeValue = currNode.getValue();
  34610. if (currNodeValue === 0) {
  34611. return defaultSize;
  34612. }
  34613. area *= sum / currNodeValue;
  34614. // Considering border, suppose aspect ratio is 1.
  34615. var parentModel = parent.getModel();
  34616. var borderWidth = parentModel.get(PATH_BORDER_WIDTH);
  34617. var upperHeight = Math.max(borderWidth, getUpperLabelHeight(parentModel, borderWidth));
  34618. area += 4 * borderWidth * borderWidth
  34619. + (3 * borderWidth + upperHeight) * Math.pow(area, 0.5);
  34620. area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER);
  34621. currNode = parent;
  34622. }
  34623. area < viewArea && (area = viewArea);
  34624. var scale = Math.pow(area / viewArea, 0.5);
  34625. return [containerWidth * scale, containerHeight * scale];
  34626. }
  34627. // Root postion base on coord of containerGroup
  34628. function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
  34629. if (rootRect) {
  34630. return {x: rootRect.x, y: rootRect.y};
  34631. }
  34632. var defaultPosition = {x: 0, y: 0};
  34633. if (!targetInfo) {
  34634. return defaultPosition;
  34635. }
  34636. // If targetInfo is fetched by 'retrieveTargetInfo',
  34637. // old tree and new tree are the same tree,
  34638. // so the node still exists and we can visit it.
  34639. var targetNode = targetInfo.node;
  34640. var layout = targetNode.getLayout();
  34641. if (!layout) {
  34642. return defaultPosition;
  34643. }
  34644. // Transform coord from local to container.
  34645. var targetCenter = [layout.width / 2, layout.height / 2];
  34646. var node = targetNode;
  34647. while (node) {
  34648. var nodeLayout = node.getLayout();
  34649. targetCenter[0] += nodeLayout.x;
  34650. targetCenter[1] += nodeLayout.y;
  34651. node = node.parentNode;
  34652. }
  34653. return {
  34654. x: layoutInfo.width / 2 - targetCenter[0],
  34655. y: layoutInfo.height / 2 - targetCenter[1]
  34656. };
  34657. }
  34658. // Mark nodes visible for prunning when visual coding and rendering.
  34659. // Prunning depends on layout and root position, so we have to do it after layout.
  34660. function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
  34661. var nodeLayout = node.getLayout();
  34662. var nodeInViewAbovePath = viewAbovePath[depth];
  34663. var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
  34664. if (
  34665. (nodeInViewAbovePath && !isAboveViewRoot)
  34666. || (depth === viewAbovePath.length && node !== viewRoot)
  34667. ) {
  34668. return;
  34669. }
  34670. node.setLayout({
  34671. // isInView means: viewRoot sub tree + viewAbovePath
  34672. isInView: true,
  34673. // invisible only means: outside view clip so that the node can not
  34674. // see but still layout for animation preparation but not render.
  34675. invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
  34676. isAboveViewRoot: isAboveViewRoot
  34677. }, true);
  34678. // Transform to child coordinate.
  34679. var childClipRect = new BoundingRect(
  34680. clipRect.x - nodeLayout.x,
  34681. clipRect.y - nodeLayout.y,
  34682. clipRect.width,
  34683. clipRect.height
  34684. );
  34685. each(node.viewChildren || [], function (child) {
  34686. prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
  34687. });
  34688. }
  34689. function getUpperLabelHeight(model) {
  34690. return model.get(PATH_UPPER_LABEL_SHOW) ? model.get(PATH_UPPER_LABEL_HEIGHT) : 0;
  34691. }
  34692. module.exports = update;
  34693. /***/ },
  34694. /* 205 */
  34695. /***/ function(module, exports, __webpack_require__) {
  34696. var echarts = __webpack_require__(1);
  34697. var zrUtil = __webpack_require__(4);
  34698. __webpack_require__(206);
  34699. __webpack_require__(209);
  34700. __webpack_require__(214);
  34701. echarts.registerProcessor(__webpack_require__(215));
  34702. echarts.registerVisual(zrUtil.curry(
  34703. __webpack_require__(121), 'graph', 'circle', null
  34704. ));
  34705. echarts.registerVisual(__webpack_require__(216));
  34706. echarts.registerVisual(__webpack_require__(217));
  34707. echarts.registerLayout(__webpack_require__(218));
  34708. echarts.registerLayout(__webpack_require__(221));
  34709. echarts.registerLayout(__webpack_require__(223));
  34710. // Graph view coordinate system
  34711. echarts.registerCoordinateSystem('graphView', {
  34712. create: __webpack_require__(225)
  34713. });
  34714. /***/ },
  34715. /* 206 */
  34716. /***/ function(module, exports, __webpack_require__) {
  34717. 'use strict';
  34718. var List = __webpack_require__(98);
  34719. var zrUtil = __webpack_require__(4);
  34720. var modelUtil = __webpack_require__(5);
  34721. var Model = __webpack_require__(12);
  34722. var formatUtil = __webpack_require__(6);
  34723. var createGraphFromNodeEdge = __webpack_require__(207);
  34724. var GraphSeries = __webpack_require__(1).extendSeriesModel({
  34725. type: 'series.graph',
  34726. init: function (option) {
  34727. GraphSeries.superApply(this, 'init', arguments);
  34728. // Provide data for legend select
  34729. this.legendDataProvider = function () {
  34730. return this._categoriesData;
  34731. };
  34732. this.fillDataTextStyle(option.edges || option.links);
  34733. this._updateCategoriesData();
  34734. },
  34735. mergeOption: function (option) {
  34736. GraphSeries.superApply(this, 'mergeOption', arguments);
  34737. this.fillDataTextStyle(option.edges || option.links);
  34738. this._updateCategoriesData();
  34739. },
  34740. mergeDefaultAndTheme: function (option) {
  34741. GraphSeries.superApply(this, 'mergeDefaultAndTheme', arguments);
  34742. modelUtil.defaultEmphasis(option.edgeLabel, modelUtil.LABEL_OPTIONS);
  34743. },
  34744. getInitialData: function (option, ecModel) {
  34745. var edges = option.edges || option.links || [];
  34746. var nodes = option.data || option.nodes || [];
  34747. var self = this;
  34748. if (nodes && edges) {
  34749. return createGraphFromNodeEdge(nodes, edges, this, true, beforeLink).data;
  34750. }
  34751. function beforeLink(nodeData, edgeData) {
  34752. // Overwrite nodeData.getItemModel to
  34753. nodeData.wrapMethod('getItemModel', function (model) {
  34754. var categoriesModels = self._categoriesModels;
  34755. var categoryIdx = model.getShallow('category');
  34756. var categoryModel = categoriesModels[categoryIdx];
  34757. if (categoryModel) {
  34758. categoryModel.parentModel = model.parentModel;
  34759. model.parentModel = categoryModel;
  34760. }
  34761. return model;
  34762. });
  34763. var edgeLabelModel = self.getModel('edgeLabel');
  34764. // For option `edgeLabel` can be found by label.xxx.xxx on item mode.
  34765. var fakeSeriesModel = new Model(
  34766. {label: edgeLabelModel.option},
  34767. edgeLabelModel.parentModel,
  34768. ecModel
  34769. );
  34770. edgeData.wrapMethod('getItemModel', function (model) {
  34771. model.customizeGetParent(edgeGetParent);
  34772. return model;
  34773. });
  34774. function edgeGetParent(path) {
  34775. path = this.parsePath(path);
  34776. return (path && path[0] === 'label')
  34777. ? fakeSeriesModel
  34778. : this.parentModel;
  34779. }
  34780. }
  34781. },
  34782. /**
  34783. * @return {module:echarts/data/Graph}
  34784. */
  34785. getGraph: function () {
  34786. return this.getData().graph;
  34787. },
  34788. /**
  34789. * @return {module:echarts/data/List}
  34790. */
  34791. getEdgeData: function () {
  34792. return this.getGraph().edgeData;
  34793. },
  34794. /**
  34795. * @return {module:echarts/data/List}
  34796. */
  34797. getCategoriesData: function () {
  34798. return this._categoriesData;
  34799. },
  34800. /**
  34801. * @override
  34802. */
  34803. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  34804. if (dataType === 'edge') {
  34805. var nodeData = this.getData();
  34806. var params = this.getDataParams(dataIndex, dataType);
  34807. var edge = nodeData.graph.getEdgeByIndex(dataIndex);
  34808. var sourceName = nodeData.getName(edge.node1.dataIndex);
  34809. var targetName = nodeData.getName(edge.node2.dataIndex);
  34810. var html = [];
  34811. sourceName != null && html.push(sourceName);
  34812. targetName != null && html.push(targetName);
  34813. html = formatUtil.encodeHTML(html.join(' > '));
  34814. if (params.value) {
  34815. html += ' : ' + formatUtil.encodeHTML(params.value);
  34816. }
  34817. return html;
  34818. }
  34819. else { // dataType === 'node' or empty
  34820. return GraphSeries.superApply(this, 'formatTooltip', arguments);
  34821. }
  34822. },
  34823. _updateCategoriesData: function () {
  34824. var categories = zrUtil.map(this.option.categories || [], function (category) {
  34825. // Data must has value
  34826. return category.value != null ? category : zrUtil.extend({
  34827. value: 0
  34828. }, category);
  34829. });
  34830. var categoriesData = new List(['value'], this);
  34831. categoriesData.initData(categories);
  34832. this._categoriesData = categoriesData;
  34833. this._categoriesModels = categoriesData.mapArray(function (idx) {
  34834. return categoriesData.getItemModel(idx, true);
  34835. });
  34836. },
  34837. setZoom: function (zoom) {
  34838. this.option.zoom = zoom;
  34839. },
  34840. setCenter: function (center) {
  34841. this.option.center = center;
  34842. },
  34843. isAnimationEnabled: function () {
  34844. return GraphSeries.superCall(this, 'isAnimationEnabled')
  34845. // Not enable animation when do force layout
  34846. && !(this.get('layout') === 'force' && this.get('force.layoutAnimation'));
  34847. },
  34848. defaultOption: {
  34849. zlevel: 0,
  34850. z: 2,
  34851. coordinateSystem: 'view',
  34852. // Default option for all coordinate systems
  34853. // xAxisIndex: 0,
  34854. // yAxisIndex: 0,
  34855. // polarIndex: 0,
  34856. // geoIndex: 0,
  34857. legendHoverLink: true,
  34858. hoverAnimation: true,
  34859. layout: null,
  34860. focusNodeAdjacency: false,
  34861. // Configuration of circular layout
  34862. circular: {
  34863. rotateLabel: false
  34864. },
  34865. // Configuration of force directed layout
  34866. force: {
  34867. initLayout: null,
  34868. // Node repulsion. Can be an array to represent range.
  34869. repulsion: [0, 50],
  34870. gravity: 0.1,
  34871. // Edge length. Can be an array to represent range.
  34872. edgeLength: 30,
  34873. layoutAnimation: true
  34874. },
  34875. left: 'center',
  34876. top: 'center',
  34877. // right: null,
  34878. // bottom: null,
  34879. // width: '80%',
  34880. // height: '80%',
  34881. symbol: 'circle',
  34882. symbolSize: 10,
  34883. edgeSymbol: ['none', 'none'],
  34884. edgeSymbolSize: 10,
  34885. edgeLabel: {
  34886. normal: {
  34887. position: 'middle'
  34888. },
  34889. emphasis: {}
  34890. },
  34891. draggable: false,
  34892. roam: false,
  34893. // Default on center of graph
  34894. center: null,
  34895. zoom: 1,
  34896. // Symbol size scale ratio in roam
  34897. nodeScaleRatio: 0.6,
  34898. // cursor: null,
  34899. // categories: [],
  34900. // data: []
  34901. // Or
  34902. // nodes: []
  34903. //
  34904. // links: []
  34905. // Or
  34906. // edges: []
  34907. label: {
  34908. normal: {
  34909. show: false,
  34910. formatter: '{b}'
  34911. },
  34912. emphasis: {
  34913. show: true
  34914. }
  34915. },
  34916. itemStyle: {
  34917. normal: {},
  34918. emphasis: {}
  34919. },
  34920. lineStyle: {
  34921. normal: {
  34922. color: '#aaa',
  34923. width: 1,
  34924. curveness: 0,
  34925. opacity: 0.5
  34926. },
  34927. emphasis: {}
  34928. }
  34929. }
  34930. });
  34931. module.exports = GraphSeries;
  34932. /***/ },
  34933. /* 207 */
  34934. /***/ function(module, exports, __webpack_require__) {
  34935. var List = __webpack_require__(98);
  34936. var Graph = __webpack_require__(208);
  34937. var linkList = __webpack_require__(196);
  34938. var completeDimensions = __webpack_require__(110);
  34939. var CoordinateSystem = __webpack_require__(76);
  34940. var zrUtil = __webpack_require__(4);
  34941. var createListFromArray = __webpack_require__(109);
  34942. module.exports = function (nodes, edges, hostModel, directed, beforeLink) {
  34943. var graph = new Graph(directed);
  34944. for (var i = 0; i < nodes.length; i++) {
  34945. graph.addNode(zrUtil.retrieve(
  34946. // Id, name, dataIndex
  34947. nodes[i].id, nodes[i].name, i
  34948. ), i);
  34949. }
  34950. var linkNameList = [];
  34951. var validEdges = [];
  34952. var linkCount = 0;
  34953. for (var i = 0; i < edges.length; i++) {
  34954. var link = edges[i];
  34955. var source = link.source;
  34956. var target = link.target;
  34957. // addEdge may fail when source or target not exists
  34958. if (graph.addEdge(source, target, linkCount)) {
  34959. validEdges.push(link);
  34960. linkNameList.push(zrUtil.retrieve(link.id, source + ' > ' + target));
  34961. linkCount++;
  34962. }
  34963. }
  34964. var coordSys = hostModel.get('coordinateSystem');
  34965. var nodeData;
  34966. if (coordSys === 'cartesian2d' || coordSys === 'polar') {
  34967. nodeData = createListFromArray(nodes, hostModel, hostModel.ecModel);
  34968. }
  34969. else {
  34970. // FIXME
  34971. var coordSysCtor = CoordinateSystem.get(coordSys);
  34972. // FIXME
  34973. var dimensionNames = completeDimensions(
  34974. ((coordSysCtor && coordSysCtor.type !== 'view') ? (coordSysCtor.dimensions || []) : []).concat(['value']),
  34975. nodes
  34976. );
  34977. nodeData = new List(dimensionNames, hostModel);
  34978. nodeData.initData(nodes);
  34979. }
  34980. var edgeData = new List(['value'], hostModel);
  34981. edgeData.initData(validEdges, linkNameList);
  34982. beforeLink && beforeLink(nodeData, edgeData);
  34983. linkList({
  34984. mainData: nodeData,
  34985. struct: graph,
  34986. structAttr: 'graph',
  34987. datas: {node: nodeData, edge: edgeData},
  34988. datasAttr: {node: 'data', edge: 'edgeData'}
  34989. });
  34990. // Update dataIndex of nodes and edges because invalid edge may be removed
  34991. graph.update();
  34992. return graph;
  34993. };
  34994. /***/ },
  34995. /* 208 */
  34996. /***/ function(module, exports, __webpack_require__) {
  34997. 'use strict';
  34998. /**
  34999. * Graph data structure
  35000. *
  35001. * @module echarts/data/Graph
  35002. * @author Yi Shen(https://www.github.com/pissang)
  35003. */
  35004. var zrUtil = __webpack_require__(4);
  35005. // id may be function name of Object, add a prefix to avoid this problem.
  35006. function generateNodeKey (id) {
  35007. return '_EC_' + id;
  35008. }
  35009. /**
  35010. * @alias module:echarts/data/Graph
  35011. * @constructor
  35012. * @param {boolean} directed
  35013. */
  35014. var Graph = function(directed) {
  35015. /**
  35016. * 是否是有向图
  35017. * @type {boolean}
  35018. * @private
  35019. */
  35020. this._directed = directed || false;
  35021. /**
  35022. * @type {Array.<module:echarts/data/Graph.Node>}
  35023. * @readOnly
  35024. */
  35025. this.nodes = [];
  35026. /**
  35027. * @type {Array.<module:echarts/data/Graph.Edge>}
  35028. * @readOnly
  35029. */
  35030. this.edges = [];
  35031. /**
  35032. * @type {Object.<string, module:echarts/data/Graph.Node>}
  35033. * @private
  35034. */
  35035. this._nodesMap = {};
  35036. /**
  35037. * @type {Object.<string, module:echarts/data/Graph.Edge>}
  35038. * @private
  35039. */
  35040. this._edgesMap = {};
  35041. /**
  35042. * @type {module:echarts/data/List}
  35043. * @readOnly
  35044. */
  35045. this.data;
  35046. /**
  35047. * @type {module:echarts/data/List}
  35048. * @readOnly
  35049. */
  35050. this.edgeData;
  35051. };
  35052. var graphProto = Graph.prototype;
  35053. /**
  35054. * @type {string}
  35055. */
  35056. graphProto.type = 'graph';
  35057. /**
  35058. * If is directed graph
  35059. * @return {boolean}
  35060. */
  35061. graphProto.isDirected = function () {
  35062. return this._directed;
  35063. };
  35064. /**
  35065. * Add a new node
  35066. * @param {string} id
  35067. * @param {number} [dataIndex]
  35068. */
  35069. graphProto.addNode = function (id, dataIndex) {
  35070. id = id || ('' + dataIndex);
  35071. var nodesMap = this._nodesMap;
  35072. if (nodesMap[generateNodeKey(id)]) {
  35073. if (true) {
  35074. console.error('Graph nodes have duplicate name or id');
  35075. }
  35076. return;
  35077. }
  35078. var node = new Node(id, dataIndex);
  35079. node.hostGraph = this;
  35080. this.nodes.push(node);
  35081. nodesMap[generateNodeKey(id)] = node;
  35082. return node;
  35083. };
  35084. /**
  35085. * Get node by data index
  35086. * @param {number} dataIndex
  35087. * @return {module:echarts/data/Graph~Node}
  35088. */
  35089. graphProto.getNodeByIndex = function (dataIndex) {
  35090. var rawIdx = this.data.getRawIndex(dataIndex);
  35091. return this.nodes[rawIdx];
  35092. };
  35093. /**
  35094. * Get node by id
  35095. * @param {string} id
  35096. * @return {module:echarts/data/Graph.Node}
  35097. */
  35098. graphProto.getNodeById = function (id) {
  35099. return this._nodesMap[generateNodeKey(id)];
  35100. };
  35101. /**
  35102. * Add a new edge
  35103. * @param {number|string|module:echarts/data/Graph.Node} n1
  35104. * @param {number|string|module:echarts/data/Graph.Node} n2
  35105. * @param {number} [dataIndex=-1]
  35106. * @return {module:echarts/data/Graph.Edge}
  35107. */
  35108. graphProto.addEdge = function (n1, n2, dataIndex) {
  35109. var nodesMap = this._nodesMap;
  35110. var edgesMap = this._edgesMap;
  35111. // PNEDING
  35112. if (typeof n1 === 'number') {
  35113. n1 = this.nodes[n1];
  35114. }
  35115. if (typeof n2 === 'number') {
  35116. n2 = this.nodes[n2];
  35117. }
  35118. if (!(n1 instanceof Node)) {
  35119. n1 = nodesMap[generateNodeKey(n1)];
  35120. }
  35121. if (!(n2 instanceof Node)) {
  35122. n2 = nodesMap[generateNodeKey(n2)];
  35123. }
  35124. if (!n1 || !n2) {
  35125. return;
  35126. }
  35127. var key = n1.id + '-' + n2.id;
  35128. // PENDING
  35129. if (edgesMap[key]) {
  35130. return;
  35131. }
  35132. var edge = new Edge(n1, n2, dataIndex);
  35133. edge.hostGraph = this;
  35134. if (this._directed) {
  35135. n1.outEdges.push(edge);
  35136. n2.inEdges.push(edge);
  35137. }
  35138. n1.edges.push(edge);
  35139. if (n1 !== n2) {
  35140. n2.edges.push(edge);
  35141. }
  35142. this.edges.push(edge);
  35143. edgesMap[key] = edge;
  35144. return edge;
  35145. };
  35146. /**
  35147. * Get edge by data index
  35148. * @param {number} dataIndex
  35149. * @return {module:echarts/data/Graph~Node}
  35150. */
  35151. graphProto.getEdgeByIndex = function (dataIndex) {
  35152. var rawIdx = this.edgeData.getRawIndex(dataIndex);
  35153. return this.edges[rawIdx];
  35154. };
  35155. /**
  35156. * Get edge by two linked nodes
  35157. * @param {module:echarts/data/Graph.Node|string} n1
  35158. * @param {module:echarts/data/Graph.Node|string} n2
  35159. * @return {module:echarts/data/Graph.Edge}
  35160. */
  35161. graphProto.getEdge = function (n1, n2) {
  35162. if (n1 instanceof Node) {
  35163. n1 = n1.id;
  35164. }
  35165. if (n2 instanceof Node) {
  35166. n2 = n2.id;
  35167. }
  35168. var edgesMap = this._edgesMap;
  35169. if (this._directed) {
  35170. return edgesMap[n1 + '-' + n2];
  35171. } else {
  35172. return edgesMap[n1 + '-' + n2]
  35173. || edgesMap[n2 + '-' + n1];
  35174. }
  35175. };
  35176. /**
  35177. * Iterate all nodes
  35178. * @param {Function} cb
  35179. * @param {*} [context]
  35180. */
  35181. graphProto.eachNode = function (cb, context) {
  35182. var nodes = this.nodes;
  35183. var len = nodes.length;
  35184. for (var i = 0; i < len; i++) {
  35185. if (nodes[i].dataIndex >= 0) {
  35186. cb.call(context, nodes[i], i);
  35187. }
  35188. }
  35189. };
  35190. /**
  35191. * Iterate all edges
  35192. * @param {Function} cb
  35193. * @param {*} [context]
  35194. */
  35195. graphProto.eachEdge = function (cb, context) {
  35196. var edges = this.edges;
  35197. var len = edges.length;
  35198. for (var i = 0; i < len; i++) {
  35199. if (edges[i].dataIndex >= 0
  35200. && edges[i].node1.dataIndex >= 0
  35201. && edges[i].node2.dataIndex >= 0
  35202. ) {
  35203. cb.call(context, edges[i], i);
  35204. }
  35205. }
  35206. };
  35207. /**
  35208. * Breadth first traverse
  35209. * @param {Function} cb
  35210. * @param {module:echarts/data/Graph.Node} startNode
  35211. * @param {string} [direction='none'] 'none'|'in'|'out'
  35212. * @param {*} [context]
  35213. */
  35214. graphProto.breadthFirstTraverse = function (
  35215. cb, startNode, direction, context
  35216. ) {
  35217. if (!(startNode instanceof Node)) {
  35218. startNode = this._nodesMap[generateNodeKey(startNode)];
  35219. }
  35220. if (!startNode) {
  35221. return;
  35222. }
  35223. var edgeType = direction === 'out'
  35224. ? 'outEdges' : (direction === 'in' ? 'inEdges' : 'edges');
  35225. for (var i = 0; i < this.nodes.length; i++) {
  35226. this.nodes[i].__visited = false;
  35227. }
  35228. if (cb.call(context, startNode, null)) {
  35229. return;
  35230. }
  35231. var queue = [startNode];
  35232. while (queue.length) {
  35233. var currentNode = queue.shift();
  35234. var edges = currentNode[edgeType];
  35235. for (var i = 0; i < edges.length; i++) {
  35236. var e = edges[i];
  35237. var otherNode = e.node1 === currentNode
  35238. ? e.node2 : e.node1;
  35239. if (!otherNode.__visited) {
  35240. if (cb.call(context, otherNode, currentNode)) {
  35241. // Stop traversing
  35242. return;
  35243. }
  35244. queue.push(otherNode);
  35245. otherNode.__visited = true;
  35246. }
  35247. }
  35248. }
  35249. };
  35250. // TODO
  35251. // graphProto.depthFirstTraverse = function (
  35252. // cb, startNode, direction, context
  35253. // ) {
  35254. // };
  35255. // Filter update
  35256. graphProto.update = function () {
  35257. var data = this.data;
  35258. var edgeData = this.edgeData;
  35259. var nodes = this.nodes;
  35260. var edges = this.edges;
  35261. for (var i = 0, len = nodes.length; i < len; i++) {
  35262. nodes[i].dataIndex = -1;
  35263. }
  35264. for (var i = 0, len = data.count(); i < len; i++) {
  35265. nodes[data.getRawIndex(i)].dataIndex = i;
  35266. }
  35267. edgeData.filterSelf(function (idx) {
  35268. var edge = edges[edgeData.getRawIndex(idx)];
  35269. return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0;
  35270. });
  35271. // Update edge
  35272. for (var i = 0, len = edges.length; i < len; i++) {
  35273. edges[i].dataIndex = -1;
  35274. }
  35275. for (var i = 0, len = edgeData.count(); i < len; i++) {
  35276. edges[edgeData.getRawIndex(i)].dataIndex = i;
  35277. }
  35278. };
  35279. /**
  35280. * @return {module:echarts/data/Graph}
  35281. */
  35282. graphProto.clone = function () {
  35283. var graph = new Graph(this._directed);
  35284. var nodes = this.nodes;
  35285. var edges = this.edges;
  35286. for (var i = 0; i < nodes.length; i++) {
  35287. graph.addNode(nodes[i].id, nodes[i].dataIndex);
  35288. }
  35289. for (var i = 0; i < edges.length; i++) {
  35290. var e = edges[i];
  35291. graph.addEdge(e.node1.id, e.node2.id, e.dataIndex);
  35292. }
  35293. return graph;
  35294. };
  35295. /**
  35296. * @alias module:echarts/data/Graph.Node
  35297. */
  35298. function Node(id, dataIndex) {
  35299. /**
  35300. * @type {string}
  35301. */
  35302. this.id = id == null ? '' : id;
  35303. /**
  35304. * @type {Array.<module:echarts/data/Graph.Edge>}
  35305. */
  35306. this.inEdges = [];
  35307. /**
  35308. * @type {Array.<module:echarts/data/Graph.Edge>}
  35309. */
  35310. this.outEdges = [];
  35311. /**
  35312. * @type {Array.<module:echarts/data/Graph.Edge>}
  35313. */
  35314. this.edges = [];
  35315. /**
  35316. * @type {module:echarts/data/Graph}
  35317. */
  35318. this.hostGraph;
  35319. /**
  35320. * @type {number}
  35321. */
  35322. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  35323. }
  35324. Node.prototype = {
  35325. constructor: Node,
  35326. /**
  35327. * @return {number}
  35328. */
  35329. degree: function () {
  35330. return this.edges.length;
  35331. },
  35332. /**
  35333. * @return {number}
  35334. */
  35335. inDegree: function () {
  35336. return this.inEdges.length;
  35337. },
  35338. /**
  35339. * @return {number}
  35340. */
  35341. outDegree: function () {
  35342. return this.outEdges.length;
  35343. },
  35344. /**
  35345. * @param {string} [path]
  35346. * @return {module:echarts/model/Model}
  35347. */
  35348. getModel: function (path) {
  35349. if (this.dataIndex < 0) {
  35350. return;
  35351. }
  35352. var graph = this.hostGraph;
  35353. var itemModel = graph.data.getItemModel(this.dataIndex);
  35354. return itemModel.getModel(path);
  35355. }
  35356. };
  35357. /**
  35358. * 图边
  35359. * @alias module:echarts/data/Graph.Edge
  35360. * @param {module:echarts/data/Graph.Node} n1
  35361. * @param {module:echarts/data/Graph.Node} n2
  35362. * @param {number} [dataIndex=-1]
  35363. */
  35364. function Edge(n1, n2, dataIndex) {
  35365. /**
  35366. * 节点1,如果是有向图则为源节点
  35367. * @type {module:echarts/data/Graph.Node}
  35368. */
  35369. this.node1 = n1;
  35370. /**
  35371. * 节点2,如果是有向图则为目标节点
  35372. * @type {module:echarts/data/Graph.Node}
  35373. */
  35374. this.node2 = n2;
  35375. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  35376. }
  35377. /**
  35378. * @param {string} [path]
  35379. * @return {module:echarts/model/Model}
  35380. */
  35381. Edge.prototype.getModel = function (path) {
  35382. if (this.dataIndex < 0) {
  35383. return;
  35384. }
  35385. var graph = this.hostGraph;
  35386. var itemModel = graph.edgeData.getItemModel(this.dataIndex);
  35387. return itemModel.getModel(path);
  35388. };
  35389. var createGraphDataProxyMixin = function (hostName, dataName) {
  35390. return {
  35391. /**
  35392. * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
  35393. * @return {number}
  35394. */
  35395. getValue: function (dimension) {
  35396. var data = this[hostName][dataName];
  35397. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  35398. },
  35399. /**
  35400. * @param {Object|string} key
  35401. * @param {*} [value]
  35402. */
  35403. setVisual: function (key, value) {
  35404. this.dataIndex >= 0
  35405. && this[hostName][dataName].setItemVisual(this.dataIndex, key, value);
  35406. },
  35407. /**
  35408. * @param {string} key
  35409. * @return {boolean}
  35410. */
  35411. getVisual: function (key, ignoreParent) {
  35412. return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent);
  35413. },
  35414. /**
  35415. * @param {Object} layout
  35416. * @return {boolean} [merge=false]
  35417. */
  35418. setLayout: function (layout, merge) {
  35419. this.dataIndex >= 0
  35420. && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge);
  35421. },
  35422. /**
  35423. * @return {Object}
  35424. */
  35425. getLayout: function () {
  35426. return this[hostName][dataName].getItemLayout(this.dataIndex);
  35427. },
  35428. /**
  35429. * @return {module:zrender/Element}
  35430. */
  35431. getGraphicEl: function () {
  35432. return this[hostName][dataName].getItemGraphicEl(this.dataIndex);
  35433. },
  35434. /**
  35435. * @return {number}
  35436. */
  35437. getRawIndex: function () {
  35438. return this[hostName][dataName].getRawIndex(this.dataIndex);
  35439. }
  35440. };
  35441. };
  35442. zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data'));
  35443. zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
  35444. Graph.Node = Node;
  35445. Graph.Edge = Edge;
  35446. module.exports = Graph;
  35447. /***/ },
  35448. /* 209 */
  35449. /***/ function(module, exports, __webpack_require__) {
  35450. var SymbolDraw = __webpack_require__(116);
  35451. var LineDraw = __webpack_require__(210);
  35452. var RoamController = __webpack_require__(183);
  35453. var roamHelper = __webpack_require__(185);
  35454. var cursorHelper = __webpack_require__(186);
  35455. var graphic = __webpack_require__(18);
  35456. var adjustEdge = __webpack_require__(213);
  35457. var zrUtil = __webpack_require__(4);
  35458. var nodeOpacityPath = ['itemStyle', 'normal', 'opacity'];
  35459. var lineOpacityPath = ['lineStyle', 'normal', 'opacity'];
  35460. function getItemOpacity(item, opacityPath) {
  35461. return item.getVisual('opacity') || item.getModel().get(opacityPath);
  35462. }
  35463. __webpack_require__(1).extendChartView({
  35464. type: 'graph',
  35465. init: function (ecModel, api) {
  35466. var symbolDraw = new SymbolDraw();
  35467. var lineDraw = new LineDraw();
  35468. var group = this.group;
  35469. this._controller = new RoamController(api.getZr());
  35470. this._controllerHost = {target: group};
  35471. group.add(symbolDraw.group);
  35472. group.add(lineDraw.group);
  35473. this._symbolDraw = symbolDraw;
  35474. this._lineDraw = lineDraw;
  35475. this._firstRender = true;
  35476. },
  35477. render: function (seriesModel, ecModel, api) {
  35478. var coordSys = seriesModel.coordinateSystem;
  35479. this._model = seriesModel;
  35480. this._nodeScaleRatio = seriesModel.get('nodeScaleRatio');
  35481. var symbolDraw = this._symbolDraw;
  35482. var lineDraw = this._lineDraw;
  35483. var group = this.group;
  35484. if (coordSys.type === 'view') {
  35485. var groupNewProp = {
  35486. position: coordSys.position,
  35487. scale: coordSys.scale
  35488. };
  35489. if (this._firstRender) {
  35490. group.attr(groupNewProp);
  35491. }
  35492. else {
  35493. graphic.updateProps(group, groupNewProp, seriesModel);
  35494. }
  35495. }
  35496. // Fix edge contact point with node
  35497. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  35498. var data = seriesModel.getData();
  35499. symbolDraw.updateData(data);
  35500. var edgeData = seriesModel.getEdgeData();
  35501. lineDraw.updateData(edgeData);
  35502. this._updateNodeAndLinkScale();
  35503. this._updateController(seriesModel, ecModel, api);
  35504. clearTimeout(this._layoutTimeout);
  35505. var forceLayout = seriesModel.forceLayout;
  35506. var layoutAnimation = seriesModel.get('force.layoutAnimation');
  35507. if (forceLayout) {
  35508. this._startForceLayoutIteration(forceLayout, layoutAnimation);
  35509. }
  35510. data.eachItemGraphicEl(function (el, idx) {
  35511. var itemModel = data.getItemModel(idx);
  35512. // Update draggable
  35513. el.off('drag').off('dragend');
  35514. var draggable = data.getItemModel(idx).get('draggable');
  35515. if (draggable) {
  35516. el.on('drag', function () {
  35517. if (forceLayout) {
  35518. forceLayout.warmUp();
  35519. !this._layouting
  35520. && this._startForceLayoutIteration(forceLayout, layoutAnimation);
  35521. forceLayout.setFixed(idx);
  35522. // Write position back to layout
  35523. data.setItemLayout(idx, el.position);
  35524. }
  35525. }, this).on('dragend', function () {
  35526. if (forceLayout) {
  35527. forceLayout.setUnfixed(idx);
  35528. }
  35529. }, this);
  35530. }
  35531. el.setDraggable(draggable && forceLayout);
  35532. el.off('mouseover', el.__focusNodeAdjacency);
  35533. el.off('mouseout', el.__unfocusNodeAdjacency);
  35534. if (itemModel.get('focusNodeAdjacency')) {
  35535. el.on('mouseover', el.__focusNodeAdjacency = function () {
  35536. api.dispatchAction({
  35537. type: 'focusNodeAdjacency',
  35538. seriesId: seriesModel.id,
  35539. dataIndex: el.dataIndex
  35540. });
  35541. });
  35542. el.on('mouseout', el.__unfocusNodeAdjacency = function () {
  35543. api.dispatchAction({
  35544. type: 'unfocusNodeAdjacency',
  35545. seriesId: seriesModel.id
  35546. });
  35547. });
  35548. }
  35549. }, this);
  35550. var circularRotateLabel = seriesModel.get('layout') === 'circular' && seriesModel.get('circular.rotateLabel');
  35551. var cx = data.getLayout('cx');
  35552. var cy = data.getLayout('cy');
  35553. data.eachItemGraphicEl(function (el, idx) {
  35554. var symbolPath = el.getSymbolPath();
  35555. if (circularRotateLabel) {
  35556. var pos = data.getItemLayout(idx);
  35557. var rad = Math.atan2(pos[1] - cy, pos[0] - cx);
  35558. if (rad < 0) {
  35559. rad = Math.PI * 2 + rad;
  35560. }
  35561. var isLeft = pos[0] < cx;
  35562. if (isLeft) {
  35563. rad = rad - Math.PI;
  35564. }
  35565. var textPosition = isLeft ? 'left' : 'right';
  35566. symbolPath.setStyle({
  35567. textRotation: rad,
  35568. textPosition: textPosition
  35569. });
  35570. symbolPath.hoverStyle && (symbolPath.hoverStyle.textPosition = textPosition);
  35571. }
  35572. else {
  35573. symbolPath.setStyle({
  35574. textRotation: 0
  35575. });
  35576. }
  35577. });
  35578. this._firstRender = false;
  35579. },
  35580. dispose: function () {
  35581. this._controller && this._controller.dispose();
  35582. this._controllerHost = {};
  35583. },
  35584. focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
  35585. var data = this._model.getData();
  35586. var dataIndex = payload.dataIndex;
  35587. var el = data.getItemGraphicEl(dataIndex);
  35588. if (!el) {
  35589. return;
  35590. }
  35591. var graph = data.graph;
  35592. var dataType = el.dataType;
  35593. function fadeOutItem(item, opacityPath) {
  35594. var opacity = getItemOpacity(item, opacityPath);
  35595. var el = item.getGraphicEl();
  35596. if (opacity == null) {
  35597. opacity = 1;
  35598. }
  35599. el.traverse(function (child) {
  35600. child.trigger('normal');
  35601. if (child.type !== 'group') {
  35602. child.setStyle('opacity', opacity * 0.1);
  35603. }
  35604. });
  35605. }
  35606. function fadeInItem(item, opacityPath) {
  35607. var opacity = getItemOpacity(item, opacityPath);
  35608. var el = item.getGraphicEl();
  35609. el.traverse(function (child) {
  35610. child.trigger('emphasis');
  35611. if (child.type !== 'group') {
  35612. child.setStyle('opacity', opacity);
  35613. }
  35614. });
  35615. }
  35616. if (dataIndex !== null && dataType !== 'edge') {
  35617. graph.eachNode(function (node) {
  35618. fadeOutItem(node, nodeOpacityPath);
  35619. });
  35620. graph.eachEdge(function (edge) {
  35621. fadeOutItem(edge, lineOpacityPath);
  35622. });
  35623. var node = graph.getNodeByIndex(dataIndex);
  35624. fadeInItem(node, nodeOpacityPath);
  35625. zrUtil.each(node.edges, function (edge) {
  35626. if (edge.dataIndex < 0) {
  35627. return;
  35628. }
  35629. fadeInItem(edge, lineOpacityPath);
  35630. fadeInItem(edge.node1, nodeOpacityPath);
  35631. fadeInItem(edge.node2, nodeOpacityPath);
  35632. });
  35633. }
  35634. },
  35635. unfocusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
  35636. var graph = this._model.getData().graph;
  35637. graph.eachNode(function (node) {
  35638. var opacity = getItemOpacity(node, nodeOpacityPath);
  35639. node.getGraphicEl().traverse(function (child) {
  35640. child.trigger('normal');
  35641. if (child.type !== 'group') {
  35642. child.setStyle('opacity', opacity);
  35643. }
  35644. });
  35645. });
  35646. graph.eachEdge(function (edge) {
  35647. var opacity = getItemOpacity(edge, lineOpacityPath);
  35648. edge.getGraphicEl().traverse(function (child) {
  35649. child.trigger('normal');
  35650. if (child.type !== 'group') {
  35651. child.setStyle('opacity', opacity);
  35652. }
  35653. });
  35654. });
  35655. },
  35656. _startForceLayoutIteration: function (forceLayout, layoutAnimation) {
  35657. var self = this;
  35658. (function step() {
  35659. forceLayout.step(function (stopped) {
  35660. self.updateLayout(self._model);
  35661. (self._layouting = !stopped) && (
  35662. layoutAnimation
  35663. ? (self._layoutTimeout = setTimeout(step, 16))
  35664. : step()
  35665. );
  35666. });
  35667. })();
  35668. },
  35669. _updateController: function (seriesModel, ecModel, api) {
  35670. var controller = this._controller;
  35671. var controllerHost = this._controllerHost;
  35672. var group = this.group;
  35673. controller.setPointerChecker(function (e, x, y) {
  35674. var rect = group.getBoundingRect();
  35675. rect.applyTransform(group.transform);
  35676. return rect.contain(x, y)
  35677. && !cursorHelper.onIrrelevantElement(e, api, seriesModel);
  35678. });
  35679. if (seriesModel.coordinateSystem.type !== 'view') {
  35680. controller.disable();
  35681. return;
  35682. }
  35683. controller.enable(seriesModel.get('roam'));
  35684. controllerHost.zoomLimit = seriesModel.get('scaleLimit');
  35685. controllerHost.zoom = seriesModel.coordinateSystem.getZoom();
  35686. controller
  35687. .off('pan')
  35688. .off('zoom')
  35689. .on('pan', function (dx, dy) {
  35690. roamHelper.updateViewOnPan(controllerHost, dx, dy);
  35691. api.dispatchAction({
  35692. seriesId: seriesModel.id,
  35693. type: 'graphRoam',
  35694. dx: dx,
  35695. dy: dy
  35696. });
  35697. })
  35698. .on('zoom', function (zoom, mouseX, mouseY) {
  35699. roamHelper.updateViewOnZoom(controllerHost, zoom, mouseX, mouseY);
  35700. api.dispatchAction({
  35701. seriesId: seriesModel.id,
  35702. type: 'graphRoam',
  35703. zoom: zoom,
  35704. originX: mouseX,
  35705. originY: mouseY
  35706. });
  35707. this._updateNodeAndLinkScale();
  35708. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  35709. this._lineDraw.updateLayout();
  35710. }, this);
  35711. },
  35712. _updateNodeAndLinkScale: function () {
  35713. var seriesModel = this._model;
  35714. var data = seriesModel.getData();
  35715. var nodeScale = this._getNodeGlobalScale(seriesModel);
  35716. var invScale = [nodeScale, nodeScale];
  35717. data.eachItemGraphicEl(function (el, idx) {
  35718. el.attr('scale', invScale);
  35719. });
  35720. },
  35721. _getNodeGlobalScale: function (seriesModel) {
  35722. var coordSys = seriesModel.coordinateSystem;
  35723. if (coordSys.type !== 'view') {
  35724. return 1;
  35725. }
  35726. var nodeScaleRatio = this._nodeScaleRatio;
  35727. var groupScale = coordSys.scale;
  35728. var groupZoom = (groupScale && groupScale[0]) || 1;
  35729. // Scale node when zoom changes
  35730. var roamZoom = coordSys.getZoom();
  35731. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  35732. return nodeScale / groupZoom;
  35733. },
  35734. updateLayout: function (seriesModel) {
  35735. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  35736. this._symbolDraw.updateLayout();
  35737. this._lineDraw.updateLayout();
  35738. },
  35739. remove: function (ecModel, api) {
  35740. this._symbolDraw && this._symbolDraw.remove();
  35741. this._lineDraw && this._lineDraw.remove();
  35742. }
  35743. });
  35744. /***/ },
  35745. /* 210 */
  35746. /***/ function(module, exports, __webpack_require__) {
  35747. /**
  35748. * @module echarts/chart/helper/LineDraw
  35749. */
  35750. var graphic = __webpack_require__(18);
  35751. var LineGroup = __webpack_require__(211);
  35752. function isPointNaN(pt) {
  35753. return isNaN(pt[0]) || isNaN(pt[1]);
  35754. }
  35755. function lineNeedsDraw(pts) {
  35756. return !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
  35757. }
  35758. /**
  35759. * @alias module:echarts/component/marker/LineDraw
  35760. * @constructor
  35761. */
  35762. function LineDraw(ctor) {
  35763. this._ctor = ctor || LineGroup;
  35764. this.group = new graphic.Group();
  35765. }
  35766. var lineDrawProto = LineDraw.prototype;
  35767. /**
  35768. * @param {module:echarts/data/List} lineData
  35769. */
  35770. lineDrawProto.updateData = function (lineData) {
  35771. var oldLineData = this._lineData;
  35772. var group = this.group;
  35773. var LineCtor = this._ctor;
  35774. var hostModel = lineData.hostModel;
  35775. var seriesScope = {
  35776. lineStyle: hostModel.getModel('lineStyle.normal').getLineStyle(),
  35777. hoverLineStyle: hostModel.getModel('lineStyle.emphasis').getLineStyle(),
  35778. labelModel: hostModel.getModel('label.normal'),
  35779. hoverLabelModel: hostModel.getModel('label.emphasis')
  35780. };
  35781. lineData.diff(oldLineData)
  35782. .add(function (idx) {
  35783. if (!lineNeedsDraw(lineData.getItemLayout(idx))) {
  35784. return;
  35785. }
  35786. var lineGroup = new LineCtor(lineData, idx, seriesScope);
  35787. lineData.setItemGraphicEl(idx, lineGroup);
  35788. group.add(lineGroup);
  35789. })
  35790. .update(function (newIdx, oldIdx) {
  35791. var lineGroup = oldLineData.getItemGraphicEl(oldIdx);
  35792. if (!lineNeedsDraw(lineData.getItemLayout(newIdx))) {
  35793. group.remove(lineGroup);
  35794. return;
  35795. }
  35796. if (!lineGroup) {
  35797. lineGroup = new LineCtor(lineData, newIdx, seriesScope);
  35798. }
  35799. else {
  35800. lineGroup.updateData(lineData, newIdx, seriesScope);
  35801. }
  35802. lineData.setItemGraphicEl(newIdx, lineGroup);
  35803. group.add(lineGroup);
  35804. })
  35805. .remove(function (idx) {
  35806. group.remove(oldLineData.getItemGraphicEl(idx));
  35807. })
  35808. .execute();
  35809. this._lineData = lineData;
  35810. };
  35811. lineDrawProto.updateLayout = function () {
  35812. var lineData = this._lineData;
  35813. lineData.eachItemGraphicEl(function (el, idx) {
  35814. el.updateLayout(lineData, idx);
  35815. }, this);
  35816. };
  35817. lineDrawProto.remove = function () {
  35818. this.group.removeAll();
  35819. };
  35820. module.exports = LineDraw;
  35821. /***/ },
  35822. /* 211 */
  35823. /***/ function(module, exports, __webpack_require__) {
  35824. /**
  35825. * @module echarts/chart/helper/Line
  35826. */
  35827. var symbolUtil = __webpack_require__(111);
  35828. var vector = __webpack_require__(10);
  35829. // var matrix = require('zrender/lib/core/matrix');
  35830. var LinePath = __webpack_require__(212);
  35831. var graphic = __webpack_require__(18);
  35832. var zrUtil = __webpack_require__(4);
  35833. var numberUtil = __webpack_require__(7);
  35834. var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
  35835. function makeSymbolTypeKey(symbolCategory) {
  35836. return '_' + symbolCategory + 'Type';
  35837. }
  35838. /**
  35839. * @inner
  35840. */
  35841. function createSymbol(name, lineData, idx) {
  35842. var color = lineData.getItemVisual(idx, 'color');
  35843. var symbolType = lineData.getItemVisual(idx, name);
  35844. var symbolSize = lineData.getItemVisual(idx, name + 'Size');
  35845. if (!symbolType || symbolType === 'none') {
  35846. return;
  35847. }
  35848. if (!zrUtil.isArray(symbolSize)) {
  35849. symbolSize = [symbolSize, symbolSize];
  35850. }
  35851. var symbolPath = symbolUtil.createSymbol(
  35852. symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2,
  35853. symbolSize[0], symbolSize[1], color
  35854. );
  35855. symbolPath.name = name;
  35856. return symbolPath;
  35857. }
  35858. function createLine(points) {
  35859. var line = new LinePath({
  35860. name: 'line'
  35861. });
  35862. setLinePoints(line.shape, points);
  35863. return line;
  35864. }
  35865. function setLinePoints(targetShape, points) {
  35866. var p1 = points[0];
  35867. var p2 = points[1];
  35868. var cp1 = points[2];
  35869. targetShape.x1 = p1[0];
  35870. targetShape.y1 = p1[1];
  35871. targetShape.x2 = p2[0];
  35872. targetShape.y2 = p2[1];
  35873. targetShape.percent = 1;
  35874. if (cp1) {
  35875. targetShape.cpx1 = cp1[0];
  35876. targetShape.cpy1 = cp1[1];
  35877. }
  35878. else {
  35879. targetShape.cpx1 = NaN;
  35880. targetShape.cpy1 = NaN;
  35881. }
  35882. }
  35883. function updateSymbolAndLabelBeforeLineUpdate () {
  35884. var lineGroup = this;
  35885. var symbolFrom = lineGroup.childOfName('fromSymbol');
  35886. var symbolTo = lineGroup.childOfName('toSymbol');
  35887. var label = lineGroup.childOfName('label');
  35888. // Quick reject
  35889. if (!symbolFrom && !symbolTo && label.ignore) {
  35890. return;
  35891. }
  35892. var invScale = 1;
  35893. var parentNode = this.parent;
  35894. while (parentNode) {
  35895. if (parentNode.scale) {
  35896. invScale /= parentNode.scale[0];
  35897. }
  35898. parentNode = parentNode.parent;
  35899. }
  35900. var line = lineGroup.childOfName('line');
  35901. // If line not changed
  35902. // FIXME Parent scale changed
  35903. if (!this.__dirty && !line.__dirty) {
  35904. return;
  35905. }
  35906. var percent = line.shape.percent;
  35907. var fromPos = line.pointAt(0);
  35908. var toPos = line.pointAt(percent);
  35909. var d = vector.sub([], toPos, fromPos);
  35910. vector.normalize(d, d);
  35911. if (symbolFrom) {
  35912. symbolFrom.attr('position', fromPos);
  35913. var tangent = line.tangentAt(0);
  35914. symbolFrom.attr('rotation', Math.PI / 2 - Math.atan2(
  35915. tangent[1], tangent[0]
  35916. ));
  35917. symbolFrom.attr('scale', [invScale * percent, invScale * percent]);
  35918. }
  35919. if (symbolTo) {
  35920. symbolTo.attr('position', toPos);
  35921. var tangent = line.tangentAt(1);
  35922. symbolTo.attr('rotation', -Math.PI / 2 - Math.atan2(
  35923. tangent[1], tangent[0]
  35924. ));
  35925. symbolTo.attr('scale', [invScale * percent, invScale * percent]);
  35926. }
  35927. if (!label.ignore) {
  35928. label.attr('position', toPos);
  35929. var textPosition;
  35930. var textAlign;
  35931. var textVerticalAlign;
  35932. var distance = 5 * invScale;
  35933. // End
  35934. if (label.__position === 'end') {
  35935. textPosition = [d[0] * distance + toPos[0], d[1] * distance + toPos[1]];
  35936. textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
  35937. textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
  35938. }
  35939. // Middle
  35940. else if (label.__position === 'middle') {
  35941. var halfPercent = percent / 2;
  35942. var tangent = line.tangentAt(halfPercent);
  35943. var n = [tangent[1], -tangent[0]];
  35944. var cp = line.pointAt(halfPercent);
  35945. if (n[1] > 0) {
  35946. n[0] = -n[0];
  35947. n[1] = -n[1];
  35948. }
  35949. textPosition = [cp[0] + n[0] * distance, cp[1] + n[1] * distance];
  35950. textAlign = 'center';
  35951. textVerticalAlign = 'bottom';
  35952. var rotation = -Math.atan2(tangent[1], tangent[0]);
  35953. if (toPos[0] < fromPos[0]) {
  35954. rotation = Math.PI + rotation;
  35955. }
  35956. label.attr('rotation', rotation);
  35957. }
  35958. // Start
  35959. else {
  35960. textPosition = [-d[0] * distance + fromPos[0], -d[1] * distance + fromPos[1]];
  35961. textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center');
  35962. textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle');
  35963. }
  35964. label.attr({
  35965. style: {
  35966. // Use the user specified text align and baseline first
  35967. textVerticalAlign: label.__verticalAlign || textVerticalAlign,
  35968. textAlign: label.__textAlign || textAlign
  35969. },
  35970. position: textPosition,
  35971. scale: [invScale, invScale]
  35972. });
  35973. }
  35974. }
  35975. /**
  35976. * @constructor
  35977. * @extends {module:zrender/graphic/Group}
  35978. * @alias {module:echarts/chart/helper/Line}
  35979. */
  35980. function Line(lineData, idx, seriesScope) {
  35981. graphic.Group.call(this);
  35982. this._createLine(lineData, idx, seriesScope);
  35983. }
  35984. var lineProto = Line.prototype;
  35985. // Update symbol position and rotation
  35986. lineProto.beforeUpdate = updateSymbolAndLabelBeforeLineUpdate;
  35987. lineProto._createLine = function (lineData, idx, seriesScope) {
  35988. var seriesModel = lineData.hostModel;
  35989. var linePoints = lineData.getItemLayout(idx);
  35990. var line = createLine(linePoints);
  35991. line.shape.percent = 0;
  35992. graphic.initProps(line, {
  35993. shape: {
  35994. percent: 1
  35995. }
  35996. }, seriesModel, idx);
  35997. this.add(line);
  35998. var label = new graphic.Text({
  35999. name: 'label'
  36000. });
  36001. this.add(label);
  36002. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  36003. var symbol = createSymbol(symbolCategory, lineData, idx);
  36004. // symbols must added after line to make sure
  36005. // it will be updated after line#update.
  36006. // Or symbol position and rotation update in line#beforeUpdate will be one frame slow
  36007. this.add(symbol);
  36008. this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
  36009. }, this);
  36010. this._updateCommonStl(lineData, idx, seriesScope);
  36011. };
  36012. lineProto.updateData = function (lineData, idx, seriesScope) {
  36013. var seriesModel = lineData.hostModel;
  36014. var line = this.childOfName('line');
  36015. var linePoints = lineData.getItemLayout(idx);
  36016. var target = {
  36017. shape: {}
  36018. };
  36019. setLinePoints(target.shape, linePoints);
  36020. graphic.updateProps(line, target, seriesModel, idx);
  36021. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  36022. var symbolType = lineData.getItemVisual(idx, symbolCategory);
  36023. var key = makeSymbolTypeKey(symbolCategory);
  36024. // Symbol changed
  36025. if (this[key] !== symbolType) {
  36026. this.remove(this.childOfName(symbolCategory));
  36027. var symbol = createSymbol(symbolCategory, lineData, idx);
  36028. this.add(symbol);
  36029. }
  36030. this[key] = symbolType;
  36031. }, this);
  36032. this._updateCommonStl(lineData, idx, seriesScope);
  36033. };
  36034. lineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  36035. var seriesModel = lineData.hostModel;
  36036. var line = this.childOfName('line');
  36037. var lineStyle = seriesScope && seriesScope.lineStyle;
  36038. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  36039. var labelModel = seriesScope && seriesScope.labelModel;
  36040. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  36041. // Optimization for large dataset
  36042. if (!seriesScope || lineData.hasItemOption) {
  36043. var itemModel = lineData.getItemModel(idx);
  36044. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  36045. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  36046. labelModel = itemModel.getModel('label.normal');
  36047. hoverLabelModel = itemModel.getModel('label.emphasis');
  36048. }
  36049. var visualColor = lineData.getItemVisual(idx, 'color');
  36050. var visualOpacity = zrUtil.retrieve(
  36051. lineData.getItemVisual(idx, 'opacity'),
  36052. lineStyle.opacity,
  36053. 1
  36054. );
  36055. line.useStyle(zrUtil.defaults(
  36056. {
  36057. strokeNoScale: true,
  36058. fill: 'none',
  36059. stroke: visualColor,
  36060. opacity: visualOpacity
  36061. },
  36062. lineStyle
  36063. ));
  36064. line.hoverStyle = hoverLineStyle;
  36065. // Update symbol
  36066. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  36067. var symbol = this.childOfName(symbolCategory);
  36068. if (symbol) {
  36069. symbol.setColor(visualColor);
  36070. symbol.setStyle({
  36071. opacity: visualOpacity
  36072. });
  36073. }
  36074. }, this);
  36075. var showLabel = labelModel.getShallow('show');
  36076. var hoverShowLabel = hoverLabelModel.getShallow('show');
  36077. var label = this.childOfName('label');
  36078. var defaultLabelColor;
  36079. var defaultText;
  36080. if (showLabel || hoverShowLabel) {
  36081. var rawVal = seriesModel.getRawValue(idx);
  36082. defaultText = rawVal == null
  36083. ? defaultText = lineData.getName(idx)
  36084. : isFinite(rawVal)
  36085. ? numberUtil.round(rawVal)
  36086. : rawVal;
  36087. defaultLabelColor = visualColor || '#000';
  36088. }
  36089. // label.afterUpdate = lineAfterUpdate;
  36090. if (showLabel) {
  36091. var textStyleModel = labelModel.getModel('textStyle');
  36092. label.setStyle({
  36093. text: zrUtil.retrieve(
  36094. seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType),
  36095. defaultText
  36096. ),
  36097. textFont: textStyleModel.getFont(),
  36098. fill: textStyleModel.getTextColor() || defaultLabelColor
  36099. });
  36100. label.__textAlign = textStyleModel.get('align');
  36101. label.__verticalAlign = textStyleModel.get('baseline');
  36102. label.__position = labelModel.get('position');
  36103. }
  36104. else {
  36105. label.setStyle('text', '');
  36106. }
  36107. if (hoverShowLabel) {
  36108. var textStyleHoverModel = hoverLabelModel.getModel('textStyle');
  36109. label.hoverStyle = {
  36110. text: zrUtil.retrieve(
  36111. seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType),
  36112. defaultText
  36113. ),
  36114. textFont: textStyleHoverModel.getFont(),
  36115. fill: textStyleHoverModel.getTextColor() || defaultLabelColor
  36116. };
  36117. }
  36118. else {
  36119. label.hoverStyle = {
  36120. text: ''
  36121. };
  36122. }
  36123. label.ignore = !showLabel && !hoverShowLabel;
  36124. graphic.setHoverStyle(this);
  36125. };
  36126. lineProto.updateLayout = function (lineData, idx) {
  36127. this.setLinePoints(lineData.getItemLayout(idx));
  36128. };
  36129. lineProto.setLinePoints = function (points) {
  36130. var linePath = this.childOfName('line');
  36131. setLinePoints(linePath.shape, points);
  36132. linePath.dirty();
  36133. };
  36134. zrUtil.inherits(Line, graphic.Group);
  36135. module.exports = Line;
  36136. /***/ },
  36137. /* 212 */
  36138. /***/ function(module, exports, __webpack_require__) {
  36139. /**
  36140. * Line path for bezier and straight line draw
  36141. */
  36142. var graphic = __webpack_require__(18);
  36143. var vec2 = __webpack_require__(10);
  36144. var straightLineProto = graphic.Line.prototype;
  36145. var bezierCurveProto = graphic.BezierCurve.prototype;
  36146. function isLine(shape) {
  36147. return isNaN(+shape.cpx1) || isNaN(+shape.cpy1);
  36148. }
  36149. module.exports = graphic.extendShape({
  36150. type: 'ec-line',
  36151. style: {
  36152. stroke: '#000',
  36153. fill: null
  36154. },
  36155. shape: {
  36156. x1: 0,
  36157. y1: 0,
  36158. x2: 0,
  36159. y2: 0,
  36160. percent: 1,
  36161. cpx1: null,
  36162. cpy1: null
  36163. },
  36164. buildPath: function (ctx, shape) {
  36165. (isLine(shape) ? straightLineProto : bezierCurveProto).buildPath(ctx, shape);
  36166. },
  36167. pointAt: function (t) {
  36168. return isLine(this.shape)
  36169. ? straightLineProto.pointAt.call(this, t)
  36170. : bezierCurveProto.pointAt.call(this, t);
  36171. },
  36172. tangentAt: function (t) {
  36173. var shape = this.shape;
  36174. var p = isLine(shape)
  36175. ? [shape.x2 - shape.x1, shape.y2 - shape.y1]
  36176. : bezierCurveProto.tangentAt.call(this, t);
  36177. return vec2.normalize(p, p);
  36178. }
  36179. });
  36180. /***/ },
  36181. /* 213 */
  36182. /***/ function(module, exports, __webpack_require__) {
  36183. var curveTool = __webpack_require__(37);
  36184. var vec2 = __webpack_require__(10);
  36185. var v1 = [];
  36186. var v2 = [];
  36187. var v3 = [];
  36188. var quadraticAt = curveTool.quadraticAt;
  36189. var v2DistSquare = vec2.distSquare;
  36190. var mathAbs = Math.abs;
  36191. function intersectCurveCircle(curvePoints, center, radius) {
  36192. var p0 = curvePoints[0];
  36193. var p1 = curvePoints[1];
  36194. var p2 = curvePoints[2];
  36195. var d = Infinity;
  36196. var t;
  36197. var radiusSquare = radius * radius;
  36198. var interval = 0.1;
  36199. for (var _t = 0.1; _t <= 0.9; _t += 0.1) {
  36200. v1[0] = quadraticAt(p0[0], p1[0], p2[0], _t);
  36201. v1[1] = quadraticAt(p0[1], p1[1], p2[1], _t);
  36202. var diff = mathAbs(v2DistSquare(v1, center) - radiusSquare);
  36203. if (diff < d) {
  36204. d = diff;
  36205. t = _t;
  36206. }
  36207. }
  36208. // Assume the segment is monotone,Find root through Bisection method
  36209. // At most 32 iteration
  36210. for (var i = 0; i < 32; i++) {
  36211. // var prev = t - interval;
  36212. var next = t + interval;
  36213. // v1[0] = quadraticAt(p0[0], p1[0], p2[0], prev);
  36214. // v1[1] = quadraticAt(p0[1], p1[1], p2[1], prev);
  36215. v2[0] = quadraticAt(p0[0], p1[0], p2[0], t);
  36216. v2[1] = quadraticAt(p0[1], p1[1], p2[1], t);
  36217. v3[0] = quadraticAt(p0[0], p1[0], p2[0], next);
  36218. v3[1] = quadraticAt(p0[1], p1[1], p2[1], next);
  36219. var diff = v2DistSquare(v2, center) - radiusSquare;
  36220. if (mathAbs(diff) < 1e-2) {
  36221. break;
  36222. }
  36223. // var prevDiff = v2DistSquare(v1, center) - radiusSquare;
  36224. var nextDiff = v2DistSquare(v3, center) - radiusSquare;
  36225. interval /= 2;
  36226. if (diff < 0) {
  36227. if (nextDiff >= 0) {
  36228. t = t + interval;
  36229. }
  36230. else {
  36231. t = t - interval;
  36232. }
  36233. }
  36234. else {
  36235. if (nextDiff >= 0) {
  36236. t = t - interval;
  36237. }
  36238. else {
  36239. t = t + interval;
  36240. }
  36241. }
  36242. }
  36243. return t;
  36244. }
  36245. // Adjust edge to avoid
  36246. module.exports = function (graph, scale) {
  36247. var tmp0 = [];
  36248. var quadraticSubdivide = curveTool.quadraticSubdivide;
  36249. var pts = [[], [], []];
  36250. var pts2 = [[], []];
  36251. var v = [];
  36252. scale /= 2;
  36253. function getSymbolSize(node) {
  36254. var symbolSize = node.getVisual('symbolSize');
  36255. if (symbolSize instanceof Array) {
  36256. symbolSize = (symbolSize[0] + symbolSize[1]) / 2;
  36257. }
  36258. return symbolSize;
  36259. }
  36260. graph.eachEdge(function (edge, idx) {
  36261. var linePoints = edge.getLayout();
  36262. var fromSymbol = edge.getVisual('fromSymbol');
  36263. var toSymbol = edge.getVisual('toSymbol');
  36264. if (!linePoints.__original) {
  36265. linePoints.__original = [
  36266. vec2.clone(linePoints[0]),
  36267. vec2.clone(linePoints[1])
  36268. ];
  36269. if (linePoints[2]) {
  36270. linePoints.__original.push(vec2.clone(linePoints[2]));
  36271. }
  36272. }
  36273. var originalPoints = linePoints.__original;
  36274. // Quadratic curve
  36275. if (linePoints[2] != null) {
  36276. vec2.copy(pts[0], originalPoints[0]);
  36277. vec2.copy(pts[1], originalPoints[2]);
  36278. vec2.copy(pts[2], originalPoints[1]);
  36279. if (fromSymbol && fromSymbol != 'none') {
  36280. var symbolSize = getSymbolSize(edge.node1);
  36281. var t = intersectCurveCircle(pts, originalPoints[0], symbolSize * scale);
  36282. // Subdivide and get the second
  36283. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  36284. pts[0][0] = tmp0[3];
  36285. pts[1][0] = tmp0[4];
  36286. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  36287. pts[0][1] = tmp0[3];
  36288. pts[1][1] = tmp0[4];
  36289. }
  36290. if (toSymbol && toSymbol != 'none') {
  36291. var symbolSize = getSymbolSize(edge.node2);
  36292. var t = intersectCurveCircle(pts, originalPoints[1], symbolSize * scale);
  36293. // Subdivide and get the first
  36294. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  36295. pts[1][0] = tmp0[1];
  36296. pts[2][0] = tmp0[2];
  36297. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  36298. pts[1][1] = tmp0[1];
  36299. pts[2][1] = tmp0[2];
  36300. }
  36301. // Copy back to layout
  36302. vec2.copy(linePoints[0], pts[0]);
  36303. vec2.copy(linePoints[1], pts[2]);
  36304. vec2.copy(linePoints[2], pts[1]);
  36305. }
  36306. // Line
  36307. else {
  36308. vec2.copy(pts2[0], originalPoints[0]);
  36309. vec2.copy(pts2[1], originalPoints[1]);
  36310. vec2.sub(v, pts2[1], pts2[0]);
  36311. vec2.normalize(v, v);
  36312. if (fromSymbol && fromSymbol != 'none') {
  36313. var symbolSize = getSymbolSize(edge.node1);
  36314. vec2.scaleAndAdd(pts2[0], pts2[0], v, symbolSize * scale);
  36315. }
  36316. if (toSymbol && toSymbol != 'none') {
  36317. var symbolSize = getSymbolSize(edge.node2);
  36318. vec2.scaleAndAdd(pts2[1], pts2[1], v, -symbolSize * scale);
  36319. }
  36320. vec2.copy(linePoints[0], pts2[0]);
  36321. vec2.copy(linePoints[1], pts2[1]);
  36322. }
  36323. });
  36324. };
  36325. /***/ },
  36326. /* 214 */
  36327. /***/ function(module, exports, __webpack_require__) {
  36328. var echarts = __webpack_require__(1);
  36329. var roamHelper = __webpack_require__(188);
  36330. var actionInfo = {
  36331. type: 'graphRoam',
  36332. event: 'graphRoam',
  36333. update: 'none'
  36334. };
  36335. /**
  36336. * @payload
  36337. * @property {string} name Series name
  36338. * @property {number} [dx]
  36339. * @property {number} [dy]
  36340. * @property {number} [zoom]
  36341. * @property {number} [originX]
  36342. * @property {number} [originY]
  36343. */
  36344. echarts.registerAction(actionInfo, function (payload, ecModel) {
  36345. ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) {
  36346. var coordSys = seriesModel.coordinateSystem;
  36347. var res = roamHelper.updateCenterAndZoom(coordSys, payload);
  36348. seriesModel.setCenter
  36349. && seriesModel.setCenter(res.center);
  36350. seriesModel.setZoom
  36351. && seriesModel.setZoom(res.zoom);
  36352. });
  36353. });
  36354. /**
  36355. * @payload
  36356. * @property {number} [seriesIndex]
  36357. * @property {string} [seriesId]
  36358. * @property {string} [seriesName]
  36359. * @property {number} [dataIndex]
  36360. */
  36361. echarts.registerAction({
  36362. type: 'focusNodeAdjacency',
  36363. event: 'focusNodeAdjacency',
  36364. update: 'series.graph:focusNodeAdjacency'
  36365. }, function () {});
  36366. /**
  36367. * @payload
  36368. * @property {number} [seriesIndex]
  36369. * @property {string} [seriesId]
  36370. * @property {string} [seriesName]
  36371. */
  36372. echarts.registerAction({
  36373. type: 'unfocusNodeAdjacency',
  36374. event: 'unfocusNodeAdjacency',
  36375. update: 'series.graph:unfocusNodeAdjacency'
  36376. }, function () {});
  36377. /***/ },
  36378. /* 215 */
  36379. /***/ function(module, exports) {
  36380. module.exports = function (ecModel) {
  36381. var legendModels = ecModel.findComponents({
  36382. mainType: 'legend'
  36383. });
  36384. if (!legendModels || !legendModels.length) {
  36385. return;
  36386. }
  36387. ecModel.eachSeriesByType('graph', function (graphSeries) {
  36388. var categoriesData = graphSeries.getCategoriesData();
  36389. var graph = graphSeries.getGraph();
  36390. var data = graph.data;
  36391. var categoryNames = categoriesData.mapArray(categoriesData.getName);
  36392. data.filterSelf(function (idx) {
  36393. var model = data.getItemModel(idx);
  36394. var category = model.getShallow('category');
  36395. if (category != null) {
  36396. if (typeof category === 'number') {
  36397. category = categoryNames[category];
  36398. }
  36399. // If in any legend component the status is not selected.
  36400. for (var i = 0; i < legendModels.length; i++) {
  36401. if (!legendModels[i].isSelected(category)) {
  36402. return false;
  36403. }
  36404. }
  36405. }
  36406. return true;
  36407. });
  36408. }, this);
  36409. };
  36410. /***/ },
  36411. /* 216 */
  36412. /***/ function(module, exports) {
  36413. module.exports = function (ecModel) {
  36414. var paletteScope = {};
  36415. ecModel.eachSeriesByType('graph', function (seriesModel) {
  36416. var categoriesData = seriesModel.getCategoriesData();
  36417. var data = seriesModel.getData();
  36418. var categoryNameIdxMap = {};
  36419. categoriesData.each(function (idx) {
  36420. var name = categoriesData.getName(idx);
  36421. // Add prefix to avoid conflict with Object.prototype.
  36422. categoryNameIdxMap['ec-' + name] = idx;
  36423. var itemModel = categoriesData.getItemModel(idx);
  36424. var color = itemModel.get('itemStyle.normal.color')
  36425. || seriesModel.getColorFromPalette(name, paletteScope);
  36426. categoriesData.setItemVisual(idx, 'color', color);
  36427. });
  36428. // Assign category color to visual
  36429. if (categoriesData.count()) {
  36430. data.each(function (idx) {
  36431. var model = data.getItemModel(idx);
  36432. var category = model.getShallow('category');
  36433. if (category != null) {
  36434. if (typeof category === 'string') {
  36435. category = categoryNameIdxMap['ec-' + category];
  36436. }
  36437. if (!data.getItemVisual(idx, 'color', true)) {
  36438. data.setItemVisual(
  36439. idx, 'color',
  36440. categoriesData.getItemVisual(category, 'color')
  36441. );
  36442. }
  36443. }
  36444. });
  36445. }
  36446. });
  36447. };
  36448. /***/ },
  36449. /* 217 */
  36450. /***/ function(module, exports) {
  36451. function normalize(a) {
  36452. if (!(a instanceof Array)) {
  36453. a = [a, a];
  36454. }
  36455. return a;
  36456. }
  36457. module.exports = function (ecModel) {
  36458. ecModel.eachSeriesByType('graph', function (seriesModel) {
  36459. var graph = seriesModel.getGraph();
  36460. var edgeData = seriesModel.getEdgeData();
  36461. var symbolType = normalize(seriesModel.get('edgeSymbol'));
  36462. var symbolSize = normalize(seriesModel.get('edgeSymbolSize'));
  36463. var colorQuery = 'lineStyle.normal.color'.split('.');
  36464. var opacityQuery = 'lineStyle.normal.opacity'.split('.');
  36465. edgeData.setVisual('fromSymbol', symbolType && symbolType[0]);
  36466. edgeData.setVisual('toSymbol', symbolType && symbolType[1]);
  36467. edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  36468. edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  36469. edgeData.setVisual('color', seriesModel.get(colorQuery));
  36470. edgeData.setVisual('opacity', seriesModel.get(opacityQuery));
  36471. edgeData.each(function (idx) {
  36472. var itemModel = edgeData.getItemModel(idx);
  36473. var edge = graph.getEdgeByIndex(idx);
  36474. var symbolType = normalize(itemModel.getShallow('symbol', true));
  36475. var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
  36476. // Edge visual must after node visual
  36477. var color = itemModel.get(colorQuery);
  36478. var opacity = itemModel.get(opacityQuery);
  36479. switch (color) {
  36480. case 'source':
  36481. color = edge.node1.getVisual('color');
  36482. break;
  36483. case 'target':
  36484. color = edge.node2.getVisual('color');
  36485. break;
  36486. }
  36487. symbolType[0] && edge.setVisual('fromSymbol', symbolType[0]);
  36488. symbolType[1] && edge.setVisual('toSymbol', symbolType[1]);
  36489. symbolSize[0] && edge.setVisual('fromSymbolSize', symbolSize[0]);
  36490. symbolSize[1] && edge.setVisual('toSymbolSize', symbolSize[1]);
  36491. edge.setVisual('color', color);
  36492. edge.setVisual('opacity', opacity);
  36493. });
  36494. });
  36495. };
  36496. /***/ },
  36497. /* 218 */
  36498. /***/ function(module, exports, __webpack_require__) {
  36499. var simpleLayoutHelper = __webpack_require__(219);
  36500. var simpleLayoutEdge = __webpack_require__(220);
  36501. module.exports = function (ecModel, api) {
  36502. ecModel.eachSeriesByType('graph', function (seriesModel) {
  36503. var layout = seriesModel.get('layout');
  36504. var coordSys = seriesModel.coordinateSystem;
  36505. if (coordSys && coordSys.type !== 'view') {
  36506. var data = seriesModel.getData();
  36507. var dimensions = coordSys.dimensions;
  36508. data.each(dimensions, function () {
  36509. var hasValue;
  36510. var args = arguments;
  36511. var value = [];
  36512. for (var i = 0; i < dimensions.length; i++) {
  36513. if (!isNaN(args[i])) {
  36514. hasValue = true;
  36515. }
  36516. value.push(args[i]);
  36517. }
  36518. var idx = args[args.length - 1];
  36519. if (hasValue) {
  36520. data.setItemLayout(idx, coordSys.dataToPoint(value));
  36521. }
  36522. else {
  36523. // Also {Array.<number>}, not undefined to avoid if...else... statement
  36524. data.setItemLayout(idx, [NaN, NaN]);
  36525. }
  36526. });
  36527. simpleLayoutEdge(data.graph);
  36528. }
  36529. else if (!layout || layout === 'none') {
  36530. simpleLayoutHelper(seriesModel);
  36531. }
  36532. });
  36533. };
  36534. /***/ },
  36535. /* 219 */
  36536. /***/ function(module, exports, __webpack_require__) {
  36537. var simpleLayoutEdge = __webpack_require__(220);
  36538. module.exports = function (seriesModel) {
  36539. var coordSys = seriesModel.coordinateSystem;
  36540. if (coordSys && coordSys.type !== 'view') {
  36541. return;
  36542. }
  36543. var graph = seriesModel.getGraph();
  36544. graph.eachNode(function (node) {
  36545. var model = node.getModel();
  36546. node.setLayout([+model.get('x'), +model.get('y')]);
  36547. });
  36548. simpleLayoutEdge(graph);
  36549. };
  36550. /***/ },
  36551. /* 220 */
  36552. /***/ function(module, exports, __webpack_require__) {
  36553. var vec2 = __webpack_require__(10);
  36554. module.exports = function (graph) {
  36555. graph.eachEdge(function (edge) {
  36556. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  36557. var p1 = vec2.clone(edge.node1.getLayout());
  36558. var p2 = vec2.clone(edge.node2.getLayout());
  36559. var points = [p1, p2];
  36560. if (+curveness) {
  36561. points.push([
  36562. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness,
  36563. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness
  36564. ]);
  36565. }
  36566. edge.setLayout(points);
  36567. });
  36568. };
  36569. /***/ },
  36570. /* 221 */
  36571. /***/ function(module, exports, __webpack_require__) {
  36572. var circularLayoutHelper = __webpack_require__(222);
  36573. module.exports = function (ecModel) {
  36574. ecModel.eachSeriesByType('graph', function (seriesModel) {
  36575. if (seriesModel.get('layout') === 'circular') {
  36576. circularLayoutHelper(seriesModel);
  36577. }
  36578. });
  36579. };
  36580. /***/ },
  36581. /* 222 */
  36582. /***/ function(module, exports, __webpack_require__) {
  36583. var vec2 = __webpack_require__(10);
  36584. module.exports = function (seriesModel) {
  36585. var coordSys = seriesModel.coordinateSystem;
  36586. if (coordSys && coordSys.type !== 'view') {
  36587. return;
  36588. }
  36589. var rect = coordSys.getBoundingRect();
  36590. var nodeData = seriesModel.getData();
  36591. var graph = nodeData.graph;
  36592. var angle = 0;
  36593. var sum = nodeData.getSum('value');
  36594. var unitAngle = Math.PI * 2 / (sum || nodeData.count());
  36595. var cx = rect.width / 2 + rect.x;
  36596. var cy = rect.height / 2 + rect.y;
  36597. var r = Math.min(rect.width, rect.height) / 2;
  36598. graph.eachNode(function (node) {
  36599. var value = node.getValue('value');
  36600. angle += unitAngle * (sum ? value : 1) / 2;
  36601. node.setLayout([
  36602. r * Math.cos(angle) + cx,
  36603. r * Math.sin(angle) + cy
  36604. ]);
  36605. angle += unitAngle * (sum ? value : 1) / 2;
  36606. });
  36607. nodeData.setLayout({
  36608. cx: cx,
  36609. cy: cy
  36610. });
  36611. graph.eachEdge(function (edge) {
  36612. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  36613. var p1 = vec2.clone(edge.node1.getLayout());
  36614. var p2 = vec2.clone(edge.node2.getLayout());
  36615. var cp1;
  36616. var x12 = (p1[0] + p2[0]) / 2;
  36617. var y12 = (p1[1] + p2[1]) / 2;
  36618. if (+curveness) {
  36619. curveness *= 3;
  36620. cp1 = [
  36621. cx * curveness + x12 * (1 - curveness),
  36622. cy * curveness + y12 * (1 - curveness)
  36623. ];
  36624. }
  36625. edge.setLayout([p1, p2, cp1]);
  36626. });
  36627. };
  36628. /***/ },
  36629. /* 223 */
  36630. /***/ function(module, exports, __webpack_require__) {
  36631. var forceHelper = __webpack_require__(224);
  36632. var numberUtil = __webpack_require__(7);
  36633. var simpleLayoutHelper = __webpack_require__(219);
  36634. var circularLayoutHelper = __webpack_require__(222);
  36635. var vec2 = __webpack_require__(10);
  36636. var zrUtil = __webpack_require__(4);
  36637. module.exports = function (ecModel) {
  36638. ecModel.eachSeriesByType('graph', function (graphSeries) {
  36639. var coordSys = graphSeries.coordinateSystem;
  36640. if (coordSys && coordSys.type !== 'view') {
  36641. return;
  36642. }
  36643. if (graphSeries.get('layout') === 'force') {
  36644. var preservedPoints = graphSeries.preservedPoints || {};
  36645. var graph = graphSeries.getGraph();
  36646. var nodeData = graph.data;
  36647. var edgeData = graph.edgeData;
  36648. var forceModel = graphSeries.getModel('force');
  36649. var initLayout = forceModel.get('initLayout');
  36650. if (graphSeries.preservedPoints) {
  36651. nodeData.each(function (idx) {
  36652. var id = nodeData.getId(idx);
  36653. nodeData.setItemLayout(idx, preservedPoints[id] || [NaN, NaN]);
  36654. });
  36655. }
  36656. else if (!initLayout || initLayout === 'none') {
  36657. simpleLayoutHelper(graphSeries);
  36658. }
  36659. else if (initLayout === 'circular') {
  36660. circularLayoutHelper(graphSeries);
  36661. }
  36662. var nodeDataExtent = nodeData.getDataExtent('value');
  36663. var edgeDataExtent = edgeData.getDataExtent('value');
  36664. // var edgeDataExtent = edgeData.getDataExtent('value');
  36665. var repulsion = forceModel.get('repulsion');
  36666. var edgeLength = forceModel.get('edgeLength');
  36667. if (!zrUtil.isArray(repulsion)) {
  36668. repulsion = [repulsion, repulsion];
  36669. }
  36670. if (!zrUtil.isArray(edgeLength)) {
  36671. edgeLength = [edgeLength, edgeLength];
  36672. }
  36673. // Larger value has smaller length
  36674. edgeLength = [edgeLength[1], edgeLength[0]];
  36675. var nodes = nodeData.mapArray('value', function (value, idx) {
  36676. var point = nodeData.getItemLayout(idx);
  36677. // var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]);
  36678. var rep = numberUtil.linearMap(value, nodeDataExtent, repulsion);
  36679. if (isNaN(rep)) {
  36680. rep = (repulsion[0] + repulsion[1]) / 2;
  36681. }
  36682. return {
  36683. w: rep,
  36684. rep: rep,
  36685. fixed: nodeData.getItemModel(idx).get('fixed'),
  36686. p: (!point || isNaN(point[0]) || isNaN(point[1])) ? null : point
  36687. };
  36688. });
  36689. var edges = edgeData.mapArray('value', function (value, idx) {
  36690. var edge = graph.getEdgeByIndex(idx);
  36691. var d = numberUtil.linearMap(value, edgeDataExtent, edgeLength);
  36692. if (isNaN(d)) {
  36693. d = (edgeLength[0] + edgeLength[1]) / 2;
  36694. }
  36695. return {
  36696. n1: nodes[edge.node1.dataIndex],
  36697. n2: nodes[edge.node2.dataIndex],
  36698. d: d,
  36699. curveness: edge.getModel().get('lineStyle.normal.curveness') || 0
  36700. };
  36701. });
  36702. var coordSys = graphSeries.coordinateSystem;
  36703. var rect = coordSys.getBoundingRect();
  36704. var forceInstance = forceHelper(nodes, edges, {
  36705. rect: rect,
  36706. gravity: forceModel.get('gravity')
  36707. });
  36708. var oldStep = forceInstance.step;
  36709. forceInstance.step = function (cb) {
  36710. for (var i = 0, l = nodes.length; i < l; i++) {
  36711. if (nodes[i].fixed) {
  36712. // Write back to layout instance
  36713. vec2.copy(nodes[i].p, graph.getNodeByIndex(i).getLayout());
  36714. }
  36715. }
  36716. oldStep(function (nodes, edges, stopped) {
  36717. for (var i = 0, l = nodes.length; i < l; i++) {
  36718. if (!nodes[i].fixed) {
  36719. graph.getNodeByIndex(i).setLayout(nodes[i].p);
  36720. }
  36721. preservedPoints[nodeData.getId(i)] = nodes[i].p;
  36722. }
  36723. for (var i = 0, l = edges.length; i < l; i++) {
  36724. var e = edges[i];
  36725. var edge = graph.getEdgeByIndex(i);
  36726. var p1 = e.n1.p;
  36727. var p2 = e.n2.p;
  36728. var points = edge.getLayout();
  36729. points = points ? points.slice() : [];
  36730. points[0] = points[0] || [];
  36731. points[1] = points[1] || [];
  36732. vec2.copy(points[0], p1);
  36733. vec2.copy(points[1], p2);
  36734. if (+e.curveness) {
  36735. points[2] = [
  36736. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness,
  36737. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness
  36738. ];
  36739. }
  36740. edge.setLayout(points);
  36741. }
  36742. // Update layout
  36743. cb && cb(stopped);
  36744. });
  36745. };
  36746. graphSeries.forceLayout = forceInstance;
  36747. graphSeries.preservedPoints = preservedPoints;
  36748. // Step to get the layout
  36749. forceInstance.step();
  36750. }
  36751. else {
  36752. // Remove prev injected forceLayout instance
  36753. graphSeries.forceLayout = null;
  36754. }
  36755. });
  36756. };
  36757. /***/ },
  36758. /* 224 */
  36759. /***/ function(module, exports, __webpack_require__) {
  36760. var vec2 = __webpack_require__(10);
  36761. var scaleAndAdd = vec2.scaleAndAdd;
  36762. // function adjacentNode(n, e) {
  36763. // return e.n1 === n ? e.n2 : e.n1;
  36764. // }
  36765. module.exports = function (nodes, edges, opts) {
  36766. var rect = opts.rect;
  36767. var width = rect.width;
  36768. var height = rect.height;
  36769. var center = [rect.x + width / 2, rect.y + height / 2];
  36770. // var scale = opts.scale || 1;
  36771. var gravity = opts.gravity == null ? 0.1 : opts.gravity;
  36772. // for (var i = 0; i < edges.length; i++) {
  36773. // var e = edges[i];
  36774. // var n1 = e.n1;
  36775. // var n2 = e.n2;
  36776. // n1.edges = n1.edges || [];
  36777. // n2.edges = n2.edges || [];
  36778. // n1.edges.push(e);
  36779. // n2.edges.push(e);
  36780. // }
  36781. // Init position
  36782. for (var i = 0; i < nodes.length; i++) {
  36783. var n = nodes[i];
  36784. if (!n.p) {
  36785. // Use the position from first adjecent node with defined position
  36786. // Or use a random position
  36787. // From d3
  36788. // if (n.edges) {
  36789. // var j = -1;
  36790. // while (++j < n.edges.length) {
  36791. // var e = n.edges[j];
  36792. // var other = adjacentNode(n, e);
  36793. // if (other.p) {
  36794. // n.p = vec2.clone(other.p);
  36795. // break;
  36796. // }
  36797. // }
  36798. // }
  36799. // if (!n.p) {
  36800. n.p = vec2.create(
  36801. width * (Math.random() - 0.5) + center[0],
  36802. height * (Math.random() - 0.5) + center[1]
  36803. );
  36804. // }
  36805. }
  36806. n.pp = vec2.clone(n.p);
  36807. n.edges = null;
  36808. }
  36809. // Formula in 'Graph Drawing by Force-directed Placement'
  36810. // var k = scale * Math.sqrt(width * height / nodes.length);
  36811. // var k2 = k * k;
  36812. var friction = 0.6;
  36813. return {
  36814. warmUp: function () {
  36815. friction = 0.5;
  36816. },
  36817. setFixed: function (idx) {
  36818. nodes[idx].fixed = true;
  36819. },
  36820. setUnfixed: function (idx) {
  36821. nodes[idx].fixed = false;
  36822. },
  36823. step: function (cb) {
  36824. var v12 = [];
  36825. var nLen = nodes.length;
  36826. for (var i = 0; i < edges.length; i++) {
  36827. var e = edges[i];
  36828. var n1 = e.n1;
  36829. var n2 = e.n2;
  36830. vec2.sub(v12, n2.p, n1.p);
  36831. var d = vec2.len(v12) - e.d;
  36832. var w = n2.w / (n1.w + n2.w);
  36833. vec2.normalize(v12, v12);
  36834. !n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
  36835. !n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction);
  36836. }
  36837. // Gravity
  36838. for (var i = 0; i < nLen; i++) {
  36839. var n = nodes[i];
  36840. if (!n.fixed) {
  36841. vec2.sub(v12, center, n.p);
  36842. // var d = vec2.len(v12);
  36843. // vec2.scale(v12, v12, 1 / d);
  36844. // var gravityFactor = gravity;
  36845. vec2.scaleAndAdd(n.p, n.p, v12, gravity * friction);
  36846. }
  36847. }
  36848. // Repulsive
  36849. // PENDING
  36850. for (var i = 0; i < nLen; i++) {
  36851. var n1 = nodes[i];
  36852. for (var j = i + 1; j < nLen; j++) {
  36853. var n2 = nodes[j];
  36854. vec2.sub(v12, n2.p, n1.p);
  36855. var d = vec2.len(v12);
  36856. if (d === 0) {
  36857. // Random repulse
  36858. vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5);
  36859. d = 1;
  36860. }
  36861. var repFact = (n1.rep + n2.rep) / d / d;
  36862. !n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact);
  36863. !n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact);
  36864. }
  36865. }
  36866. var v = [];
  36867. for (var i = 0; i < nLen; i++) {
  36868. var n = nodes[i];
  36869. if (!n.fixed) {
  36870. vec2.sub(v, n.p, n.pp);
  36871. vec2.scaleAndAdd(n.p, n.p, v, friction);
  36872. vec2.copy(n.pp, n.p);
  36873. }
  36874. }
  36875. friction = friction * 0.992;
  36876. cb && cb(nodes, edges, friction < 0.01);
  36877. }
  36878. };
  36879. };
  36880. /***/ },
  36881. /* 225 */
  36882. /***/ function(module, exports, __webpack_require__) {
  36883. // FIXME Where to create the simple view coordinate system
  36884. var View = __webpack_require__(176);
  36885. var layout = __webpack_require__(71);
  36886. var bbox = __webpack_require__(38);
  36887. function getViewRect(seriesModel, api, aspect) {
  36888. var option = seriesModel.getBoxLayoutParams();
  36889. option.aspect = aspect;
  36890. return layout.getLayoutRect(option, {
  36891. width: api.getWidth(),
  36892. height: api.getHeight()
  36893. });
  36894. }
  36895. module.exports = function (ecModel, api) {
  36896. var viewList = [];
  36897. ecModel.eachSeriesByType('graph', function (seriesModel) {
  36898. var coordSysType = seriesModel.get('coordinateSystem');
  36899. if (!coordSysType || coordSysType === 'view') {
  36900. var data = seriesModel.getData();
  36901. var positions = data.mapArray(function (idx) {
  36902. var itemModel = data.getItemModel(idx);
  36903. return [+itemModel.get('x'), +itemModel.get('y')];
  36904. });
  36905. var min = [];
  36906. var max = [];
  36907. bbox.fromPoints(positions, min, max);
  36908. // If width or height is 0
  36909. if (max[0] - min[0] === 0) {
  36910. max[0] += 1;
  36911. min[0] -= 1;
  36912. }
  36913. if (max[1] - min[1] === 0) {
  36914. max[1] += 1;
  36915. min[1] -= 1;
  36916. }
  36917. var aspect = (max[0] - min[0]) / (max[1] - min[1]);
  36918. // FIXME If get view rect after data processed?
  36919. var viewRect = getViewRect(seriesModel, api, aspect);
  36920. // Position may be NaN, use view rect instead
  36921. if (isNaN(aspect)) {
  36922. min = [viewRect.x, viewRect.y];
  36923. max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
  36924. }
  36925. var bbWidth = max[0] - min[0];
  36926. var bbHeight = max[1] - min[1];
  36927. var viewWidth = viewRect.width;
  36928. var viewHeight = viewRect.height;
  36929. var viewCoordSys = seriesModel.coordinateSystem = new View();
  36930. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  36931. viewCoordSys.setBoundingRect(
  36932. min[0], min[1], bbWidth, bbHeight
  36933. );
  36934. viewCoordSys.setViewRect(
  36935. viewRect.x, viewRect.y, viewWidth, viewHeight
  36936. );
  36937. // Update roam info
  36938. viewCoordSys.setCenter(seriesModel.get('center'));
  36939. viewCoordSys.setZoom(seriesModel.get('zoom'));
  36940. viewList.push(viewCoordSys);
  36941. }
  36942. });
  36943. return viewList;
  36944. };
  36945. /***/ },
  36946. /* 226 */
  36947. /***/ function(module, exports, __webpack_require__) {
  36948. __webpack_require__(227);
  36949. __webpack_require__(228);
  36950. /***/ },
  36951. /* 227 */
  36952. /***/ function(module, exports, __webpack_require__) {
  36953. var List = __webpack_require__(98);
  36954. var SeriesModel = __webpack_require__(78);
  36955. var zrUtil = __webpack_require__(4);
  36956. var GaugeSeries = SeriesModel.extend({
  36957. type: 'series.gauge',
  36958. getInitialData: function (option, ecModel) {
  36959. var list = new List(['value'], this);
  36960. var dataOpt = option.data || [];
  36961. if (!zrUtil.isArray(dataOpt)) {
  36962. dataOpt = [dataOpt];
  36963. }
  36964. // Only use the first data item
  36965. list.initData(dataOpt);
  36966. return list;
  36967. },
  36968. defaultOption: {
  36969. zlevel: 0,
  36970. z: 2,
  36971. // 默认全局居中
  36972. center: ['50%', '50%'],
  36973. legendHoverLink: true,
  36974. radius: '75%',
  36975. startAngle: 225,
  36976. endAngle: -45,
  36977. clockwise: true,
  36978. // 最小值
  36979. min: 0,
  36980. // 最大值
  36981. max: 100,
  36982. // 分割段数,默认为10
  36983. splitNumber: 10,
  36984. // 坐标轴线
  36985. axisLine: {
  36986. // 默认显示,属性show控制显示与否
  36987. show: true,
  36988. lineStyle: { // 属性lineStyle控制线条样式
  36989. color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']],
  36990. width: 30
  36991. }
  36992. },
  36993. // 分隔线
  36994. splitLine: {
  36995. // 默认显示,属性show控制显示与否
  36996. show: true,
  36997. // 属性length控制线长
  36998. length: 30,
  36999. // 属性lineStyle(详见lineStyle)控制线条样式
  37000. lineStyle: {
  37001. color: '#eee',
  37002. width: 2,
  37003. type: 'solid'
  37004. }
  37005. },
  37006. // 坐标轴小标记
  37007. axisTick: {
  37008. // 属性show控制显示与否,默认不显示
  37009. show: true,
  37010. // 每份split细分多少段
  37011. splitNumber: 5,
  37012. // 属性length控制线长
  37013. length: 8,
  37014. // 属性lineStyle控制线条样式
  37015. lineStyle: {
  37016. color: '#eee',
  37017. width: 1,
  37018. type: 'solid'
  37019. }
  37020. },
  37021. axisLabel: {
  37022. show: true,
  37023. distance: 5,
  37024. // formatter: null,
  37025. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  37026. color: 'auto'
  37027. }
  37028. },
  37029. pointer: {
  37030. show: true,
  37031. length: '80%',
  37032. width: 8
  37033. },
  37034. itemStyle: {
  37035. normal: {
  37036. color: 'auto'
  37037. }
  37038. },
  37039. title: {
  37040. show: true,
  37041. // x, y,单位px
  37042. offsetCenter: [0, '-40%'],
  37043. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  37044. textStyle: {
  37045. color: '#333',
  37046. fontSize: 15
  37047. }
  37048. },
  37049. detail: {
  37050. show: true,
  37051. backgroundColor: 'rgba(0,0,0,0)',
  37052. borderWidth: 0,
  37053. borderColor: '#ccc',
  37054. width: 100,
  37055. height: 40,
  37056. // x, y,单位px
  37057. offsetCenter: [0, '40%'],
  37058. // formatter: null,
  37059. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  37060. textStyle: {
  37061. color: 'auto',
  37062. fontSize: 30
  37063. }
  37064. }
  37065. }
  37066. });
  37067. module.exports = GaugeSeries;
  37068. /***/ },
  37069. /* 228 */
  37070. /***/ function(module, exports, __webpack_require__) {
  37071. var PointerPath = __webpack_require__(229);
  37072. var graphic = __webpack_require__(18);
  37073. var numberUtil = __webpack_require__(7);
  37074. var parsePercent = numberUtil.parsePercent;
  37075. function parsePosition(seriesModel, api) {
  37076. var center = seriesModel.get('center');
  37077. var width = api.getWidth();
  37078. var height = api.getHeight();
  37079. var size = Math.min(width, height);
  37080. var cx = parsePercent(center[0], api.getWidth());
  37081. var cy = parsePercent(center[1], api.getHeight());
  37082. var r = parsePercent(seriesModel.get('radius'), size / 2);
  37083. return {
  37084. cx: cx,
  37085. cy: cy,
  37086. r: r
  37087. };
  37088. }
  37089. function formatLabel(label, labelFormatter) {
  37090. if (labelFormatter) {
  37091. if (typeof labelFormatter === 'string') {
  37092. label = labelFormatter.replace('{value}', label != null ? label : '');
  37093. }
  37094. else if (typeof labelFormatter === 'function') {
  37095. label = labelFormatter(label);
  37096. }
  37097. }
  37098. return label;
  37099. }
  37100. var PI2 = Math.PI * 2;
  37101. var GaugeView = __webpack_require__(80).extend({
  37102. type: 'gauge',
  37103. render: function (seriesModel, ecModel, api) {
  37104. this.group.removeAll();
  37105. var colorList = seriesModel.get('axisLine.lineStyle.color');
  37106. var posInfo = parsePosition(seriesModel, api);
  37107. this._renderMain(
  37108. seriesModel, ecModel, api, colorList, posInfo
  37109. );
  37110. },
  37111. dispose: function () {},
  37112. _renderMain: function (seriesModel, ecModel, api, colorList, posInfo) {
  37113. var group = this.group;
  37114. var axisLineModel = seriesModel.getModel('axisLine');
  37115. var lineStyleModel = axisLineModel.getModel('lineStyle');
  37116. var clockwise = seriesModel.get('clockwise');
  37117. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  37118. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  37119. var angleRangeSpan = (endAngle - startAngle) % PI2;
  37120. var prevEndAngle = startAngle;
  37121. var axisLineWidth = lineStyleModel.get('width');
  37122. for (var i = 0; i < colorList.length; i++) {
  37123. // Clamp
  37124. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  37125. var endAngle = startAngle + angleRangeSpan * percent;
  37126. var sector = new graphic.Sector({
  37127. shape: {
  37128. startAngle: prevEndAngle,
  37129. endAngle: endAngle,
  37130. cx: posInfo.cx,
  37131. cy: posInfo.cy,
  37132. clockwise: clockwise,
  37133. r0: posInfo.r - axisLineWidth,
  37134. r: posInfo.r
  37135. },
  37136. silent: true
  37137. });
  37138. sector.setStyle({
  37139. fill: colorList[i][1]
  37140. });
  37141. sector.setStyle(lineStyleModel.getLineStyle(
  37142. // Because we use sector to simulate arc
  37143. // so the properties for stroking are useless
  37144. ['color', 'borderWidth', 'borderColor']
  37145. ));
  37146. group.add(sector);
  37147. prevEndAngle = endAngle;
  37148. }
  37149. var getColor = function (percent) {
  37150. // Less than 0
  37151. if (percent <= 0) {
  37152. return colorList[0][1];
  37153. }
  37154. for (var i = 0; i < colorList.length; i++) {
  37155. if (colorList[i][0] >= percent
  37156. && (i === 0 ? 0 : colorList[i - 1][0]) < percent
  37157. ) {
  37158. return colorList[i][1];
  37159. }
  37160. }
  37161. // More than 1
  37162. return colorList[i - 1][1];
  37163. };
  37164. if (!clockwise) {
  37165. var tmp = startAngle;
  37166. startAngle = endAngle;
  37167. endAngle = tmp;
  37168. }
  37169. this._renderTicks(
  37170. seriesModel, ecModel, api, getColor, posInfo,
  37171. startAngle, endAngle, clockwise
  37172. );
  37173. this._renderPointer(
  37174. seriesModel, ecModel, api, getColor, posInfo,
  37175. startAngle, endAngle, clockwise
  37176. );
  37177. this._renderTitle(
  37178. seriesModel, ecModel, api, getColor, posInfo
  37179. );
  37180. this._renderDetail(
  37181. seriesModel, ecModel, api, getColor, posInfo
  37182. );
  37183. },
  37184. _renderTicks: function (
  37185. seriesModel, ecModel, api, getColor, posInfo,
  37186. startAngle, endAngle, clockwise
  37187. ) {
  37188. var group = this.group;
  37189. var cx = posInfo.cx;
  37190. var cy = posInfo.cy;
  37191. var r = posInfo.r;
  37192. var minVal = +seriesModel.get('min');
  37193. var maxVal = +seriesModel.get('max');
  37194. var splitLineModel = seriesModel.getModel('splitLine');
  37195. var tickModel = seriesModel.getModel('axisTick');
  37196. var labelModel = seriesModel.getModel('axisLabel');
  37197. var splitNumber = seriesModel.get('splitNumber');
  37198. var subSplitNumber = tickModel.get('splitNumber');
  37199. var splitLineLen = parsePercent(
  37200. splitLineModel.get('length'), r
  37201. );
  37202. var tickLen = parsePercent(
  37203. tickModel.get('length'), r
  37204. );
  37205. var angle = startAngle;
  37206. var step = (endAngle - startAngle) / splitNumber;
  37207. var subStep = step / subSplitNumber;
  37208. var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
  37209. var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
  37210. var textStyleModel = labelModel.getModel('textStyle');
  37211. for (var i = 0; i <= splitNumber; i++) {
  37212. var unitX = Math.cos(angle);
  37213. var unitY = Math.sin(angle);
  37214. // Split line
  37215. if (splitLineModel.get('show')) {
  37216. var splitLine = new graphic.Line({
  37217. shape: {
  37218. x1: unitX * r + cx,
  37219. y1: unitY * r + cy,
  37220. x2: unitX * (r - splitLineLen) + cx,
  37221. y2: unitY * (r - splitLineLen) + cy
  37222. },
  37223. style: splitLineStyle,
  37224. silent: true
  37225. });
  37226. if (splitLineStyle.stroke === 'auto') {
  37227. splitLine.setStyle({
  37228. stroke: getColor(i / splitNumber)
  37229. });
  37230. }
  37231. group.add(splitLine);
  37232. }
  37233. // Label
  37234. if (labelModel.get('show')) {
  37235. var label = formatLabel(
  37236. numberUtil.round(i / splitNumber * (maxVal - minVal) + minVal),
  37237. labelModel.get('formatter')
  37238. );
  37239. var distance = labelModel.get('distance');
  37240. var text = new graphic.Text({
  37241. style: {
  37242. text: label,
  37243. x: unitX * (r - splitLineLen - distance) + cx,
  37244. y: unitY * (r - splitLineLen - distance) + cy,
  37245. fill: textStyleModel.getTextColor(),
  37246. textFont: textStyleModel.getFont(),
  37247. textVerticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
  37248. textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
  37249. },
  37250. silent: true
  37251. });
  37252. if (text.style.fill === 'auto') {
  37253. text.setStyle({
  37254. fill: getColor(i / splitNumber)
  37255. });
  37256. }
  37257. group.add(text);
  37258. }
  37259. // Axis tick
  37260. if (tickModel.get('show') && i !== splitNumber) {
  37261. for (var j = 0; j <= subSplitNumber; j++) {
  37262. var unitX = Math.cos(angle);
  37263. var unitY = Math.sin(angle);
  37264. var tickLine = new graphic.Line({
  37265. shape: {
  37266. x1: unitX * r + cx,
  37267. y1: unitY * r + cy,
  37268. x2: unitX * (r - tickLen) + cx,
  37269. y2: unitY * (r - tickLen) + cy
  37270. },
  37271. silent: true,
  37272. style: tickLineStyle
  37273. });
  37274. if (tickLineStyle.stroke === 'auto') {
  37275. tickLine.setStyle({
  37276. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  37277. });
  37278. }
  37279. group.add(tickLine);
  37280. angle += subStep;
  37281. }
  37282. angle -= subStep;
  37283. }
  37284. else {
  37285. angle += step;
  37286. }
  37287. }
  37288. },
  37289. _renderPointer: function (
  37290. seriesModel, ecModel, api, getColor, posInfo,
  37291. startAngle, endAngle, clockwise
  37292. ) {
  37293. var group = this.group;
  37294. var oldData = this._data;
  37295. if (!seriesModel.get('pointer.show')) {
  37296. // Remove old element
  37297. oldData && oldData.eachItemGraphicEl(function (el) {
  37298. group.remove(el);
  37299. });
  37300. return;
  37301. }
  37302. var valueExtent = [+seriesModel.get('min'), +seriesModel.get('max')];
  37303. var angleExtent = [startAngle, endAngle];
  37304. var data = seriesModel.getData();
  37305. data.diff(oldData)
  37306. .add(function (idx) {
  37307. var pointer = new PointerPath({
  37308. shape: {
  37309. angle: startAngle
  37310. }
  37311. });
  37312. graphic.initProps(pointer, {
  37313. shape: {
  37314. angle: numberUtil.linearMap(data.get('value', idx), valueExtent, angleExtent, true)
  37315. }
  37316. }, seriesModel);
  37317. group.add(pointer);
  37318. data.setItemGraphicEl(idx, pointer);
  37319. })
  37320. .update(function (newIdx, oldIdx) {
  37321. var pointer = oldData.getItemGraphicEl(oldIdx);
  37322. graphic.updateProps(pointer, {
  37323. shape: {
  37324. angle: numberUtil.linearMap(data.get('value', newIdx), valueExtent, angleExtent, true)
  37325. }
  37326. }, seriesModel);
  37327. group.add(pointer);
  37328. data.setItemGraphicEl(newIdx, pointer);
  37329. })
  37330. .remove(function (idx) {
  37331. var pointer = oldData.getItemGraphicEl(idx);
  37332. group.remove(pointer);
  37333. })
  37334. .execute();
  37335. data.eachItemGraphicEl(function (pointer, idx) {
  37336. var itemModel = data.getItemModel(idx);
  37337. var pointerModel = itemModel.getModel('pointer');
  37338. pointer.setShape({
  37339. x: posInfo.cx,
  37340. y: posInfo.cy,
  37341. width: parsePercent(
  37342. pointerModel.get('width'), posInfo.r
  37343. ),
  37344. r: parsePercent(pointerModel.get('length'), posInfo.r)
  37345. });
  37346. pointer.useStyle(itemModel.getModel('itemStyle.normal').getItemStyle());
  37347. if (pointer.style.fill === 'auto') {
  37348. pointer.setStyle('fill', getColor(
  37349. numberUtil.linearMap(data.get('value', idx), valueExtent, [0, 1], true)
  37350. ));
  37351. }
  37352. graphic.setHoverStyle(
  37353. pointer, itemModel.getModel('itemStyle.emphasis').getItemStyle()
  37354. );
  37355. });
  37356. this._data = data;
  37357. },
  37358. _renderTitle: function (
  37359. seriesModel, ecModel, api, getColor, posInfo
  37360. ) {
  37361. var titleModel = seriesModel.getModel('title');
  37362. if (titleModel.get('show')) {
  37363. var textStyleModel = titleModel.getModel('textStyle');
  37364. var offsetCenter = titleModel.get('offsetCenter');
  37365. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  37366. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  37367. var text = new graphic.Text({
  37368. style: {
  37369. x: x,
  37370. y: y,
  37371. // FIXME First data name ?
  37372. text: seriesModel.getData().getName(0),
  37373. fill: textStyleModel.getTextColor(),
  37374. textFont: textStyleModel.getFont(),
  37375. textAlign: 'center',
  37376. textVerticalAlign: 'middle'
  37377. }
  37378. });
  37379. if (text.style.fill === 'auto') {
  37380. var minVal = +seriesModel.get('min');
  37381. var maxVal = +seriesModel.get('max');
  37382. var value = seriesModel.getData().get('value', 0);
  37383. text.setStyle('fill', getColor(
  37384. numberUtil.linearMap(value, [minVal, maxVal], [0, 1], true)
  37385. ));
  37386. }
  37387. this.group.add(text);
  37388. }
  37389. },
  37390. _renderDetail: function (
  37391. seriesModel, ecModel, api, getColor, posInfo
  37392. ) {
  37393. var detailModel = seriesModel.getModel('detail');
  37394. var minVal = +seriesModel.get('min');
  37395. var maxVal = +seriesModel.get('max');
  37396. if (detailModel.get('show')) {
  37397. var textStyleModel = detailModel.getModel('textStyle');
  37398. var offsetCenter = detailModel.get('offsetCenter');
  37399. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  37400. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  37401. var width = parsePercent(detailModel.get('width'), posInfo.r);
  37402. var height = parsePercent(detailModel.get('height'), posInfo.r);
  37403. var value = seriesModel.getData().get('value', 0);
  37404. var rect = new graphic.Rect({
  37405. shape: {
  37406. x: x - width / 2,
  37407. y: y - height / 2,
  37408. width: width,
  37409. height: height
  37410. },
  37411. style: {
  37412. text: formatLabel(
  37413. // FIXME First data name ?
  37414. value, detailModel.get('formatter')
  37415. ),
  37416. fill: detailModel.get('backgroundColor'),
  37417. textFill: textStyleModel.getTextColor(),
  37418. textFont: textStyleModel.getFont()
  37419. }
  37420. });
  37421. if (rect.style.textFill === 'auto') {
  37422. rect.setStyle('textFill', getColor(
  37423. numberUtil.linearMap(value, [minVal, maxVal], [0, 1], true)
  37424. ));
  37425. }
  37426. rect.setStyle(detailModel.getItemStyle(['color']));
  37427. this.group.add(rect);
  37428. }
  37429. }
  37430. });
  37431. module.exports = GaugeView;
  37432. /***/ },
  37433. /* 229 */
  37434. /***/ function(module, exports, __webpack_require__) {
  37435. module.exports = __webpack_require__(20).extend({
  37436. type: 'echartsGaugePointer',
  37437. shape: {
  37438. angle: 0,
  37439. width: 10,
  37440. r: 10,
  37441. x: 0,
  37442. y: 0
  37443. },
  37444. buildPath: function (ctx, shape) {
  37445. var mathCos = Math.cos;
  37446. var mathSin = Math.sin;
  37447. var r = shape.r;
  37448. var width = shape.width;
  37449. var angle = shape.angle;
  37450. var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2);
  37451. var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2);
  37452. angle = shape.angle - Math.PI / 2;
  37453. ctx.moveTo(x, y);
  37454. ctx.lineTo(
  37455. shape.x + mathCos(angle) * width,
  37456. shape.y + mathSin(angle) * width
  37457. );
  37458. ctx.lineTo(
  37459. shape.x + mathCos(shape.angle) * r,
  37460. shape.y + mathSin(shape.angle) * r
  37461. );
  37462. ctx.lineTo(
  37463. shape.x - mathCos(angle) * width,
  37464. shape.y - mathSin(angle) * width
  37465. );
  37466. ctx.lineTo(x, y);
  37467. return;
  37468. }
  37469. });
  37470. /***/ },
  37471. /* 230 */
  37472. /***/ function(module, exports, __webpack_require__) {
  37473. var zrUtil = __webpack_require__(4);
  37474. var echarts = __webpack_require__(1);
  37475. __webpack_require__(231);
  37476. __webpack_require__(232);
  37477. echarts.registerVisual(zrUtil.curry(__webpack_require__(151), 'funnel'));
  37478. echarts.registerLayout(__webpack_require__(233));
  37479. echarts.registerProcessor(zrUtil.curry(__webpack_require__(154), 'funnel'));
  37480. /***/ },
  37481. /* 231 */
  37482. /***/ function(module, exports, __webpack_require__) {
  37483. 'use strict';
  37484. var List = __webpack_require__(98);
  37485. var modelUtil = __webpack_require__(5);
  37486. var completeDimensions = __webpack_require__(110);
  37487. var FunnelSeries = __webpack_require__(1).extendSeriesModel({
  37488. type: 'series.funnel',
  37489. init: function (option) {
  37490. FunnelSeries.superApply(this, 'init', arguments);
  37491. // Enable legend selection for each data item
  37492. // Use a function instead of direct access because data reference may changed
  37493. this.legendDataProvider = function () {
  37494. return this.getRawData();
  37495. };
  37496. // Extend labelLine emphasis
  37497. this._defaultLabelLine(option);
  37498. },
  37499. getInitialData: function (option, ecModel) {
  37500. var dimensions = completeDimensions(['value'], option.data);
  37501. var list = new List(dimensions, this);
  37502. list.initData(option.data);
  37503. return list;
  37504. },
  37505. _defaultLabelLine: function (option) {
  37506. // Extend labelLine emphasis
  37507. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  37508. var labelLineNormalOpt = option.labelLine.normal;
  37509. var labelLineEmphasisOpt = option.labelLine.emphasis;
  37510. // Not show label line if `label.normal.show = false`
  37511. labelLineNormalOpt.show = labelLineNormalOpt.show
  37512. && option.label.normal.show;
  37513. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  37514. && option.label.emphasis.show;
  37515. },
  37516. // Overwrite
  37517. getDataParams: function (dataIndex) {
  37518. var data = this.getData();
  37519. var params = FunnelSeries.superCall(this, 'getDataParams', dataIndex);
  37520. var sum = data.getSum('value');
  37521. // Percent is 0 if sum is 0
  37522. params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2);
  37523. params.$vars.push('percent');
  37524. return params;
  37525. },
  37526. defaultOption: {
  37527. zlevel: 0, // 一级层叠
  37528. z: 2, // 二级层叠
  37529. legendHoverLink: true,
  37530. left: 80,
  37531. top: 60,
  37532. right: 80,
  37533. bottom: 60,
  37534. // width: {totalWidth} - left - right,
  37535. // height: {totalHeight} - top - bottom,
  37536. // 默认取数据最小最大值
  37537. // min: 0,
  37538. // max: 100,
  37539. minSize: '0%',
  37540. maxSize: '100%',
  37541. sort: 'descending', // 'ascending', 'descending'
  37542. gap: 0,
  37543. funnelAlign: 'center',
  37544. label: {
  37545. normal: {
  37546. show: true,
  37547. position: 'outer'
  37548. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  37549. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  37550. },
  37551. emphasis: {
  37552. show: true
  37553. }
  37554. },
  37555. labelLine: {
  37556. normal: {
  37557. show: true,
  37558. length: 20,
  37559. lineStyle: {
  37560. // color: 各异,
  37561. width: 1,
  37562. type: 'solid'
  37563. }
  37564. },
  37565. emphasis: {}
  37566. },
  37567. itemStyle: {
  37568. normal: {
  37569. // color: 各异,
  37570. borderColor: '#fff',
  37571. borderWidth: 1
  37572. },
  37573. emphasis: {
  37574. // color: 各异,
  37575. }
  37576. }
  37577. }
  37578. });
  37579. module.exports = FunnelSeries;
  37580. /***/ },
  37581. /* 232 */
  37582. /***/ function(module, exports, __webpack_require__) {
  37583. var graphic = __webpack_require__(18);
  37584. var zrUtil = __webpack_require__(4);
  37585. /**
  37586. * Piece of pie including Sector, Label, LabelLine
  37587. * @constructor
  37588. * @extends {module:zrender/graphic/Group}
  37589. */
  37590. function FunnelPiece(data, idx) {
  37591. graphic.Group.call(this);
  37592. var polygon = new graphic.Polygon();
  37593. var labelLine = new graphic.Polyline();
  37594. var text = new graphic.Text();
  37595. this.add(polygon);
  37596. this.add(labelLine);
  37597. this.add(text);
  37598. this.updateData(data, idx, true);
  37599. // Hover to change label and labelLine
  37600. function onEmphasis() {
  37601. labelLine.ignore = labelLine.hoverIgnore;
  37602. text.ignore = text.hoverIgnore;
  37603. }
  37604. function onNormal() {
  37605. labelLine.ignore = labelLine.normalIgnore;
  37606. text.ignore = text.normalIgnore;
  37607. }
  37608. this.on('emphasis', onEmphasis)
  37609. .on('normal', onNormal)
  37610. .on('mouseover', onEmphasis)
  37611. .on('mouseout', onNormal);
  37612. }
  37613. var funnelPieceProto = FunnelPiece.prototype;
  37614. function getLabelStyle(data, idx, state, labelModel) {
  37615. var textStyleModel = labelModel.getModel('textStyle');
  37616. var position = labelModel.get('position');
  37617. var isLabelInside = position === 'inside' || position === 'inner' || position === 'center';
  37618. return {
  37619. fill: textStyleModel.getTextColor()
  37620. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  37621. textFont: textStyleModel.getFont(),
  37622. text: zrUtil.retrieve(
  37623. data.hostModel.getFormattedLabel(idx, state),
  37624. data.getName(idx)
  37625. )
  37626. };
  37627. }
  37628. var opacityAccessPath = ['itemStyle', 'normal', 'opacity'];
  37629. funnelPieceProto.updateData = function (data, idx, firstCreate) {
  37630. var polygon = this.childAt(0);
  37631. var seriesModel = data.hostModel;
  37632. var itemModel = data.getItemModel(idx);
  37633. var layout = data.getItemLayout(idx);
  37634. var opacity = data.getItemModel(idx).get(opacityAccessPath);
  37635. opacity = opacity == null ? 1 : opacity;
  37636. // Reset style
  37637. polygon.useStyle({});
  37638. if (firstCreate) {
  37639. polygon.setShape({
  37640. points: layout.points
  37641. });
  37642. polygon.setStyle({ opacity : 0 });
  37643. graphic.initProps(polygon, {
  37644. style: {
  37645. opacity: opacity
  37646. }
  37647. }, seriesModel, idx);
  37648. }
  37649. else {
  37650. graphic.updateProps(polygon, {
  37651. style: {
  37652. opacity: opacity
  37653. },
  37654. shape: {
  37655. points: layout.points
  37656. }
  37657. }, seriesModel, idx);
  37658. }
  37659. // Update common style
  37660. var itemStyleModel = itemModel.getModel('itemStyle');
  37661. var visualColor = data.getItemVisual(idx, 'color');
  37662. polygon.setStyle(
  37663. zrUtil.defaults(
  37664. {
  37665. lineJoin: 'round',
  37666. fill: visualColor
  37667. },
  37668. itemStyleModel.getModel('normal').getItemStyle(['opacity'])
  37669. )
  37670. );
  37671. polygon.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  37672. this._updateLabel(data, idx);
  37673. graphic.setHoverStyle(this);
  37674. };
  37675. funnelPieceProto._updateLabel = function (data, idx) {
  37676. var labelLine = this.childAt(1);
  37677. var labelText = this.childAt(2);
  37678. var seriesModel = data.hostModel;
  37679. var itemModel = data.getItemModel(idx);
  37680. var layout = data.getItemLayout(idx);
  37681. var labelLayout = layout.label;
  37682. var visualColor = data.getItemVisual(idx, 'color');
  37683. graphic.updateProps(labelLine, {
  37684. shape: {
  37685. points: labelLayout.linePoints || labelLayout.linePoints
  37686. }
  37687. }, seriesModel, idx);
  37688. graphic.updateProps(labelText, {
  37689. style: {
  37690. x: labelLayout.x,
  37691. y: labelLayout.y
  37692. }
  37693. }, seriesModel, idx);
  37694. labelText.attr({
  37695. style: {
  37696. textAlign: labelLayout.textAlign,
  37697. textVerticalAlign: labelLayout.verticalAlign,
  37698. textFont: labelLayout.font
  37699. },
  37700. rotation: labelLayout.rotation,
  37701. origin: [labelLayout.x, labelLayout.y],
  37702. z2: 10
  37703. });
  37704. var labelModel = itemModel.getModel('label.normal');
  37705. var labelHoverModel = itemModel.getModel('label.emphasis');
  37706. var labelLineModel = itemModel.getModel('labelLine.normal');
  37707. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  37708. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel));
  37709. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  37710. labelText.hoverIgnore = !labelHoverModel.get('show');
  37711. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  37712. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  37713. // Default use item visual color
  37714. labelLine.setStyle({
  37715. stroke: visualColor
  37716. });
  37717. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  37718. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel);
  37719. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  37720. };
  37721. zrUtil.inherits(FunnelPiece, graphic.Group);
  37722. var Funnel = __webpack_require__(80).extend({
  37723. type: 'funnel',
  37724. render: function (seriesModel, ecModel, api) {
  37725. var data = seriesModel.getData();
  37726. var oldData = this._data;
  37727. var group = this.group;
  37728. data.diff(oldData)
  37729. .add(function (idx) {
  37730. var funnelPiece = new FunnelPiece(data, idx);
  37731. data.setItemGraphicEl(idx, funnelPiece);
  37732. group.add(funnelPiece);
  37733. })
  37734. .update(function (newIdx, oldIdx) {
  37735. var piePiece = oldData.getItemGraphicEl(oldIdx);
  37736. piePiece.updateData(data, newIdx);
  37737. group.add(piePiece);
  37738. data.setItemGraphicEl(newIdx, piePiece);
  37739. })
  37740. .remove(function (idx) {
  37741. var piePiece = oldData.getItemGraphicEl(idx);
  37742. group.remove(piePiece);
  37743. })
  37744. .execute();
  37745. this._data = data;
  37746. },
  37747. remove: function () {
  37748. this.group.removeAll();
  37749. this._data = null;
  37750. },
  37751. dispose: function () {}
  37752. });
  37753. module.exports = Funnel;
  37754. /***/ },
  37755. /* 233 */
  37756. /***/ function(module, exports, __webpack_require__) {
  37757. var layout = __webpack_require__(71);
  37758. var number = __webpack_require__(7);
  37759. var parsePercent = number.parsePercent;
  37760. function getViewRect(seriesModel, api) {
  37761. return layout.getLayoutRect(
  37762. seriesModel.getBoxLayoutParams(), {
  37763. width: api.getWidth(),
  37764. height: api.getHeight()
  37765. }
  37766. );
  37767. }
  37768. function getSortedIndices(data, sort) {
  37769. var valueArr = data.mapArray('value', function (val) {
  37770. return val;
  37771. });
  37772. var indices = [];
  37773. var isAscending = sort === 'ascending';
  37774. for (var i = 0, len = data.count(); i < len; i++) {
  37775. indices[i] = i;
  37776. }
  37777. // Add custom sortable function & none sortable opetion by "options.sort"
  37778. if (typeof sort === 'function') {
  37779. indices.sort(sort);
  37780. } else if (sort !== 'none') {
  37781. indices.sort(function (a, b) {
  37782. return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
  37783. });
  37784. }
  37785. return indices;
  37786. }
  37787. function labelLayout (data) {
  37788. data.each(function (idx) {
  37789. var itemModel = data.getItemModel(idx);
  37790. var labelModel = itemModel.getModel('label.normal');
  37791. var labelPosition = labelModel.get('position');
  37792. var labelLineModel = itemModel.getModel('labelLine.normal');
  37793. var layout = data.getItemLayout(idx);
  37794. var points = layout.points;
  37795. var isLabelInside = labelPosition === 'inner'
  37796. || labelPosition === 'inside' || labelPosition === 'center';
  37797. var textAlign;
  37798. var textX;
  37799. var textY;
  37800. var linePoints;
  37801. if (isLabelInside) {
  37802. textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
  37803. textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
  37804. textAlign = 'center';
  37805. linePoints = [
  37806. [textX, textY], [textX, textY]
  37807. ];
  37808. }
  37809. else {
  37810. var x1;
  37811. var y1;
  37812. var x2;
  37813. var labelLineLen = labelLineModel.get('length');
  37814. if (labelPosition === 'left') {
  37815. // Left side
  37816. x1 = (points[3][0] + points[0][0]) / 2;
  37817. y1 = (points[3][1] + points[0][1]) / 2;
  37818. x2 = x1 - labelLineLen;
  37819. textX = x2 - 5;
  37820. textAlign = 'right';
  37821. }
  37822. else {
  37823. // Right side
  37824. x1 = (points[1][0] + points[2][0]) / 2;
  37825. y1 = (points[1][1] + points[2][1]) / 2;
  37826. x2 = x1 + labelLineLen;
  37827. textX = x2 + 5;
  37828. textAlign = 'left';
  37829. }
  37830. var y2 = y1;
  37831. linePoints = [[x1, y1], [x2, y2]];
  37832. textY = y2;
  37833. }
  37834. layout.label = {
  37835. linePoints: linePoints,
  37836. x: textX,
  37837. y: textY,
  37838. verticalAlign: 'middle',
  37839. textAlign: textAlign,
  37840. inside: isLabelInside
  37841. };
  37842. });
  37843. }
  37844. module.exports = function (ecModel, api, payload) {
  37845. ecModel.eachSeriesByType('funnel', function (seriesModel) {
  37846. var data = seriesModel.getData();
  37847. var sort = seriesModel.get('sort');
  37848. var viewRect = getViewRect(seriesModel, api);
  37849. var indices = getSortedIndices(data, sort);
  37850. var sizeExtent = [
  37851. parsePercent(seriesModel.get('minSize'), viewRect.width),
  37852. parsePercent(seriesModel.get('maxSize'), viewRect.width)
  37853. ];
  37854. var dataExtent = data.getDataExtent('value');
  37855. var min = seriesModel.get('min');
  37856. var max = seriesModel.get('max');
  37857. if (min == null) {
  37858. min = Math.min(dataExtent[0], 0);
  37859. }
  37860. if (max == null) {
  37861. max = dataExtent[1];
  37862. }
  37863. var funnelAlign = seriesModel.get('funnelAlign');
  37864. var gap = seriesModel.get('gap');
  37865. var itemHeight = (viewRect.height - gap * (data.count() - 1)) / data.count();
  37866. var y = viewRect.y;
  37867. var getLinePoints = function (idx, offY) {
  37868. // End point index is data.count() and we assign it 0
  37869. var val = data.get('value', idx) || 0;
  37870. var itemWidth = number.linearMap(val, [min, max], sizeExtent, true);
  37871. var x0;
  37872. switch (funnelAlign) {
  37873. case 'left':
  37874. x0 = viewRect.x;
  37875. break;
  37876. case 'center':
  37877. x0 = viewRect.x + (viewRect.width - itemWidth) / 2;
  37878. break;
  37879. case 'right':
  37880. x0 = viewRect.x + viewRect.width - itemWidth;
  37881. break;
  37882. }
  37883. return [
  37884. [x0, offY],
  37885. [x0 + itemWidth, offY]
  37886. ];
  37887. };
  37888. if (sort === 'ascending') {
  37889. // From bottom to top
  37890. itemHeight = -itemHeight;
  37891. gap = -gap;
  37892. y += viewRect.height;
  37893. indices = indices.reverse();
  37894. }
  37895. for (var i = 0; i < indices.length; i++) {
  37896. var idx = indices[i];
  37897. var nextIdx = indices[i + 1];
  37898. var start = getLinePoints(idx, y);
  37899. var end = getLinePoints(nextIdx, y + itemHeight);
  37900. y += itemHeight + gap;
  37901. data.setItemLayout(idx, {
  37902. points: start.concat(end.slice().reverse())
  37903. });
  37904. }
  37905. labelLayout(data);
  37906. });
  37907. };
  37908. /***/ },
  37909. /* 234 */
  37910. /***/ function(module, exports, __webpack_require__) {
  37911. var echarts = __webpack_require__(1);
  37912. __webpack_require__(235);
  37913. __webpack_require__(248);
  37914. __webpack_require__(249);
  37915. echarts.registerVisual(__webpack_require__(250));
  37916. /***/ },
  37917. /* 235 */
  37918. /***/ function(module, exports, __webpack_require__) {
  37919. __webpack_require__(236);
  37920. __webpack_require__(240);
  37921. __webpack_require__(242);
  37922. var echarts = __webpack_require__(1);
  37923. var zrUtil = __webpack_require__(4);
  37924. var throttle = __webpack_require__(81);
  37925. var CLICK_THRESHOLD = 5; // > 4
  37926. // Parallel view
  37927. echarts.extendComponentView({
  37928. type: 'parallel',
  37929. render: function (parallelModel, ecModel, api) {
  37930. this._model = parallelModel;
  37931. this._api = api;
  37932. if (!this._handlers) {
  37933. this._handlers = {};
  37934. zrUtil.each(handlers, function (handler, eventName) {
  37935. api.getZr().on(eventName, this._handlers[eventName] = zrUtil.bind(handler, this));
  37936. }, this);
  37937. }
  37938. throttle.createOrUpdate(
  37939. this,
  37940. '_throttledDispatchExpand',
  37941. parallelModel.get('axisExpandRate'),
  37942. 'fixRate'
  37943. );
  37944. },
  37945. dispose: function (ecModel, api) {
  37946. zrUtil.each(this._handlers, function (handler, eventName) {
  37947. api.getZr().off(eventName, handler);
  37948. });
  37949. this._handlers = null;
  37950. },
  37951. /**
  37952. * @param {Object} [opt] If null, cancle the last action triggering for debounce.
  37953. */
  37954. _throttledDispatchExpand: function (opt) {
  37955. this._dispatchExpand(opt);
  37956. },
  37957. _dispatchExpand: function (opt) {
  37958. opt && this._api.dispatchAction(
  37959. zrUtil.extend({type: 'parallelAxisExpand'}, opt)
  37960. );
  37961. }
  37962. });
  37963. var handlers = {
  37964. mousedown: function (e) {
  37965. if (checkTrigger(this, 'click')) {
  37966. this._mouseDownPoint = [e.offsetX, e.offsetY];
  37967. }
  37968. },
  37969. mouseup: function (e) {
  37970. var mouseDownPoint = this._mouseDownPoint;
  37971. if (checkTrigger(this, 'click') && mouseDownPoint) {
  37972. var point = [e.offsetX, e.offsetY];
  37973. var dist = Math.pow(mouseDownPoint[0] - point[0], 2)
  37974. + Math.pow(mouseDownPoint[1] - point[1], 2);
  37975. if (dist > CLICK_THRESHOLD) {
  37976. return;
  37977. }
  37978. var result = this._model.coordinateSystem.getSlidedAxisExpandWindow(
  37979. [e.offsetX, e.offsetY]
  37980. );
  37981. result.behavior !== 'none' && this._dispatchExpand({
  37982. axisExpandWindow: result.axisExpandWindow
  37983. });
  37984. }
  37985. this._mouseDownPoint = null;
  37986. },
  37987. mousemove: function (e) {
  37988. // Should do nothing when brushing.
  37989. if (this._mouseDownPoint || !checkTrigger(this, 'mousemove')) {
  37990. return;
  37991. }
  37992. var model = this._model;
  37993. var result = model.coordinateSystem.getSlidedAxisExpandWindow(
  37994. [e.offsetX, e.offsetY]
  37995. );
  37996. var behavior = result.behavior;
  37997. behavior === 'jump' && this._throttledDispatchExpand.debounceNextCall(model.get('axisExpandDebounce'));
  37998. this._throttledDispatchExpand(
  37999. behavior === 'none'
  38000. ? null // Cancle the last trigger, in case that mouse slide out of the area quickly.
  38001. : {
  38002. axisExpandWindow: result.axisExpandWindow,
  38003. // Jumping uses animation, and sliding suppresses animation.
  38004. animation: behavior === 'jump' ? null : false
  38005. }
  38006. );
  38007. }
  38008. };
  38009. function checkTrigger(view, triggerOn) {
  38010. var model = view._model;
  38011. return model.get('axisExpandable') && model.get('axisExpandTriggerOn') === triggerOn;
  38012. }
  38013. echarts.registerPreprocessor(
  38014. __webpack_require__(247)
  38015. );
  38016. /***/ },
  38017. /* 236 */
  38018. /***/ function(module, exports, __webpack_require__) {
  38019. /**
  38020. * Parallel coordinate system creater.
  38021. */
  38022. var Parallel = __webpack_require__(237);
  38023. function create(ecModel, api) {
  38024. var coordSysList = [];
  38025. ecModel.eachComponent('parallel', function (parallelModel, idx) {
  38026. var coordSys = new Parallel(parallelModel, ecModel, api);
  38027. coordSys.name = 'parallel_' + idx;
  38028. coordSys.resize(parallelModel, api);
  38029. parallelModel.coordinateSystem = coordSys;
  38030. coordSys.model = parallelModel;
  38031. coordSysList.push(coordSys);
  38032. });
  38033. // Inject the coordinateSystems into seriesModel
  38034. ecModel.eachSeries(function (seriesModel) {
  38035. if (seriesModel.get('coordinateSystem') === 'parallel') {
  38036. var parallelModel = ecModel.queryComponents({
  38037. mainType: 'parallel',
  38038. index: seriesModel.get('parallelIndex'),
  38039. id: seriesModel.get('parallelId')
  38040. })[0];
  38041. seriesModel.coordinateSystem = parallelModel.coordinateSystem;
  38042. }
  38043. });
  38044. return coordSysList;
  38045. }
  38046. __webpack_require__(76).register('parallel', {create: create});
  38047. /***/ },
  38048. /* 237 */
  38049. /***/ function(module, exports, __webpack_require__) {
  38050. /**
  38051. * Parallel Coordinates
  38052. * <https://en.wikipedia.org/wiki/Parallel_coordinates>
  38053. */
  38054. var layoutUtil = __webpack_require__(71);
  38055. var axisHelper = __webpack_require__(101);
  38056. var zrUtil = __webpack_require__(4);
  38057. var ParallelAxis = __webpack_require__(238);
  38058. var graphic = __webpack_require__(18);
  38059. var matrix = __webpack_require__(11);
  38060. var numberUtil = __webpack_require__(7);
  38061. var sliderMove = __webpack_require__(239);
  38062. var each = zrUtil.each;
  38063. var mathMin = Math.min;
  38064. var mathMax = Math.max;
  38065. var mathFloor = Math.floor;
  38066. var mathCeil = Math.ceil;
  38067. var round = numberUtil.round;
  38068. var PI = Math.PI;
  38069. function Parallel(parallelModel, ecModel, api) {
  38070. /**
  38071. * key: dimension
  38072. * @type {Object.<string, module:echarts/coord/parallel/Axis>}
  38073. * @private
  38074. */
  38075. this._axesMap = zrUtil.createHashMap();
  38076. /**
  38077. * key: dimension
  38078. * value: {position: [], rotation, }
  38079. * @type {Object.<string, Object>}
  38080. * @private
  38081. */
  38082. this._axesLayout = {};
  38083. /**
  38084. * Always follow axis order.
  38085. * @type {Array.<string>}
  38086. * @readOnly
  38087. */
  38088. this.dimensions = parallelModel.dimensions;
  38089. /**
  38090. * @type {module:zrender/core/BoundingRect}
  38091. */
  38092. this._rect;
  38093. /**
  38094. * @type {module:echarts/coord/parallel/ParallelModel}
  38095. */
  38096. this._model = parallelModel;
  38097. this._init(parallelModel, ecModel, api);
  38098. }
  38099. Parallel.prototype = {
  38100. type: 'parallel',
  38101. constructor: Parallel,
  38102. /**
  38103. * Initialize cartesian coordinate systems
  38104. * @private
  38105. */
  38106. _init: function (parallelModel, ecModel, api) {
  38107. var dimensions = parallelModel.dimensions;
  38108. var parallelAxisIndex = parallelModel.parallelAxisIndex;
  38109. each(dimensions, function (dim, idx) {
  38110. var axisIndex = parallelAxisIndex[idx];
  38111. var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
  38112. var axis = this._axesMap.set(dim, new ParallelAxis(
  38113. dim,
  38114. axisHelper.createScaleByModel(axisModel),
  38115. [0, 0],
  38116. axisModel.get('type'),
  38117. axisIndex
  38118. ));
  38119. var isCategory = axis.type === 'category';
  38120. axis.onBand = isCategory && axisModel.get('boundaryGap');
  38121. axis.inverse = axisModel.get('inverse');
  38122. // Injection
  38123. axisModel.axis = axis;
  38124. axis.model = axisModel;
  38125. axis.coordinateSystem = axisModel.coordinateSystem = this;
  38126. }, this);
  38127. },
  38128. /**
  38129. * Update axis scale after data processed
  38130. * @param {module:echarts/model/Global} ecModel
  38131. * @param {module:echarts/ExtensionAPI} api
  38132. */
  38133. update: function (ecModel, api) {
  38134. this._updateAxesFromSeries(this._model, ecModel);
  38135. },
  38136. /**
  38137. * @override
  38138. */
  38139. containPoint: function (point) {
  38140. var layoutInfo = this._makeLayoutInfo();
  38141. var axisBase = layoutInfo.axisBase;
  38142. var layoutBase = layoutInfo.layoutBase;
  38143. var pixelDimIndex = layoutInfo.pixelDimIndex;
  38144. var pAxis = point[1 - pixelDimIndex];
  38145. var pLayout = point[pixelDimIndex];
  38146. return pAxis >= axisBase
  38147. && pAxis <= axisBase + layoutInfo.axisLength
  38148. && pLayout >= layoutBase
  38149. && pLayout <= layoutBase + layoutInfo.layoutLength;
  38150. },
  38151. /**
  38152. * Update properties from series
  38153. * @private
  38154. */
  38155. _updateAxesFromSeries: function (parallelModel, ecModel) {
  38156. ecModel.eachSeries(function (seriesModel) {
  38157. if (!parallelModel.contains(seriesModel, ecModel)) {
  38158. return;
  38159. }
  38160. var data = seriesModel.getData();
  38161. each(this.dimensions, function (dim) {
  38162. var axis = this._axesMap.get(dim);
  38163. axis.scale.unionExtentFromData(data, dim);
  38164. axisHelper.niceScaleExtent(axis.scale, axis.model);
  38165. }, this);
  38166. }, this);
  38167. },
  38168. /**
  38169. * Resize the parallel coordinate system.
  38170. * @param {module:echarts/coord/parallel/ParallelModel} parallelModel
  38171. * @param {module:echarts/ExtensionAPI} api
  38172. */
  38173. resize: function (parallelModel, api) {
  38174. this._rect = layoutUtil.getLayoutRect(
  38175. parallelModel.getBoxLayoutParams(),
  38176. {
  38177. width: api.getWidth(),
  38178. height: api.getHeight()
  38179. }
  38180. );
  38181. this._layoutAxes();
  38182. },
  38183. /**
  38184. * @return {module:zrender/core/BoundingRect}
  38185. */
  38186. getRect: function () {
  38187. return this._rect;
  38188. },
  38189. /**
  38190. * @private
  38191. */
  38192. _makeLayoutInfo: function () {
  38193. var parallelModel = this._model;
  38194. var rect = this._rect;
  38195. var xy = ['x', 'y'];
  38196. var wh = ['width', 'height'];
  38197. var layout = parallelModel.get('layout');
  38198. var pixelDimIndex = layout === 'horizontal' ? 0 : 1;
  38199. var layoutLength = rect[wh[pixelDimIndex]];
  38200. var layoutExtent = [0, layoutLength];
  38201. var axisCount = this.dimensions.length;
  38202. var axisExpandWidth = restrict(parallelModel.get('axisExpandWidth'), layoutExtent);
  38203. var axisExpandCount = restrict(parallelModel.get('axisExpandCount') || 0, [0, axisCount]);
  38204. var axisExpandable = parallelModel.get('axisExpandable')
  38205. && axisCount > 3
  38206. && axisCount > axisExpandCount
  38207. && axisExpandCount > 1
  38208. && axisExpandWidth > 0
  38209. && layoutLength > 0;
  38210. // `axisExpandWindow` is According to the coordinates of [0, axisExpandLength],
  38211. // for sake of consider the case that axisCollapseWidth is 0 (when screen is narrow),
  38212. // where collapsed axes should be overlapped.
  38213. var axisExpandWindow = parallelModel.get('axisExpandWindow');
  38214. var winSize;
  38215. if (!axisExpandWindow) {
  38216. winSize = restrict(axisExpandWidth * (axisExpandCount - 1), layoutExtent);
  38217. var axisExpandCenter = parallelModel.get('axisExpandCenter') || mathFloor(axisCount / 2);
  38218. axisExpandWindow = [axisExpandWidth * axisExpandCenter - winSize / 2];
  38219. axisExpandWindow[1] = axisExpandWindow[0] + winSize;
  38220. }
  38221. else {
  38222. winSize = restrict(axisExpandWindow[1] - axisExpandWindow[0], layoutExtent);
  38223. axisExpandWindow[1] = axisExpandWindow[0] + winSize;
  38224. }
  38225. var axisCollapseWidth = (layoutLength - winSize) / (axisCount - axisExpandCount);
  38226. // Avoid axisCollapseWidth is too small.
  38227. axisCollapseWidth < 3 && (axisCollapseWidth = 0);
  38228. // Find the first and last indices > ewin[0] and < ewin[1].
  38229. var winInnerIndices = [
  38230. mathFloor(round(axisExpandWindow[0] / axisExpandWidth, 1)) + 1,
  38231. mathCeil(round(axisExpandWindow[1] / axisExpandWidth, 1)) - 1
  38232. ];
  38233. // Pos in ec coordinates.
  38234. var axisExpandWindow0Pos = axisCollapseWidth / axisExpandWidth * axisExpandWindow[0];
  38235. return {
  38236. layout: layout,
  38237. pixelDimIndex: pixelDimIndex,
  38238. layoutBase: rect[xy[pixelDimIndex]],
  38239. layoutLength: layoutLength,
  38240. axisBase: rect[xy[1 - pixelDimIndex]],
  38241. axisLength: rect[wh[1 - pixelDimIndex]],
  38242. axisExpandable: axisExpandable,
  38243. axisExpandWidth: axisExpandWidth,
  38244. axisCollapseWidth: axisCollapseWidth,
  38245. axisExpandWindow: axisExpandWindow,
  38246. axisCount: axisCount,
  38247. winInnerIndices: winInnerIndices,
  38248. axisExpandWindow0Pos: axisExpandWindow0Pos
  38249. };
  38250. },
  38251. /**
  38252. * @private
  38253. */
  38254. _layoutAxes: function () {
  38255. var rect = this._rect;
  38256. var axes = this._axesMap;
  38257. var dimensions = this.dimensions;
  38258. var layoutInfo = this._makeLayoutInfo();
  38259. var layout = layoutInfo.layout;
  38260. axes.each(function (axis) {
  38261. var axisExtent = [0, layoutInfo.axisLength];
  38262. var idx = axis.inverse ? 1 : 0;
  38263. axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);
  38264. });
  38265. each(dimensions, function (dim, idx) {
  38266. var posInfo = (layoutInfo.axisExpandable
  38267. ? layoutAxisWithExpand : layoutAxisWithoutExpand
  38268. )(idx, layoutInfo);
  38269. var positionTable = {
  38270. horizontal: {
  38271. x: posInfo.position,
  38272. y: layoutInfo.axisLength
  38273. },
  38274. vertical: {
  38275. x: 0,
  38276. y: posInfo.position
  38277. }
  38278. };
  38279. var rotationTable = {
  38280. horizontal: PI / 2,
  38281. vertical: 0
  38282. };
  38283. var position = [
  38284. positionTable[layout].x + rect.x,
  38285. positionTable[layout].y + rect.y
  38286. ];
  38287. var rotation = rotationTable[layout];
  38288. var transform = matrix.create();
  38289. matrix.rotate(transform, transform, rotation);
  38290. matrix.translate(transform, transform, position);
  38291. // TODO
  38292. // tick等排布信息。
  38293. // TODO
  38294. // 根据axis order 更新 dimensions顺序。
  38295. this._axesLayout[dim] = {
  38296. position: position,
  38297. rotation: rotation,
  38298. transform: transform,
  38299. axisNameAvailableWidth: posInfo.axisNameAvailableWidth,
  38300. axisLabelShow: posInfo.axisLabelShow,
  38301. nameTruncateMaxWidth: posInfo.nameTruncateMaxWidth,
  38302. tickDirection: 1,
  38303. labelDirection: 1,
  38304. labelInterval: axes.get(dim).getLabelInterval()
  38305. };
  38306. }, this);
  38307. },
  38308. /**
  38309. * Get axis by dim.
  38310. * @param {string} dim
  38311. * @return {module:echarts/coord/parallel/ParallelAxis} [description]
  38312. */
  38313. getAxis: function (dim) {
  38314. return this._axesMap.get(dim);
  38315. },
  38316. /**
  38317. * Convert a dim value of a single item of series data to Point.
  38318. * @param {*} value
  38319. * @param {string} dim
  38320. * @return {Array}
  38321. */
  38322. dataToPoint: function (value, dim) {
  38323. return this.axisCoordToPoint(
  38324. this._axesMap.get(dim).dataToCoord(value),
  38325. dim
  38326. );
  38327. },
  38328. /**
  38329. * Travel data for one time, get activeState of each data item.
  38330. * @param {module:echarts/data/List} data
  38331. * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal'
  38332. * {number} dataIndex
  38333. * @param {Object} context
  38334. */
  38335. eachActiveState: function (data, callback, context) {
  38336. var dimensions = this.dimensions;
  38337. var axesMap = this._axesMap;
  38338. var hasActiveSet = this.hasAxisBrushed();
  38339. for (var i = 0, len = data.count(); i < len; i++) {
  38340. var values = data.getValues(dimensions, i);
  38341. var activeState;
  38342. if (!hasActiveSet) {
  38343. activeState = 'normal';
  38344. }
  38345. else {
  38346. activeState = 'active';
  38347. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  38348. var dimName = dimensions[j];
  38349. var state = axesMap.get(dimName).model.getActiveState(values[j], j);
  38350. if (state === 'inactive') {
  38351. activeState = 'inactive';
  38352. break;
  38353. }
  38354. }
  38355. }
  38356. callback.call(context, activeState, i);
  38357. }
  38358. },
  38359. /**
  38360. * Whether has any activeSet.
  38361. * @return {boolean}
  38362. */
  38363. hasAxisBrushed: function () {
  38364. var dimensions = this.dimensions;
  38365. var axesMap = this._axesMap;
  38366. var hasActiveSet = false;
  38367. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  38368. if (axesMap.get(dimensions[j]).model.getActiveState() !== 'normal') {
  38369. hasActiveSet = true;
  38370. }
  38371. }
  38372. return hasActiveSet;
  38373. },
  38374. /**
  38375. * Convert coords of each axis to Point.
  38376. * Return point. For example: [10, 20]
  38377. * @param {Array.<number>} coords
  38378. * @param {string} dim
  38379. * @return {Array.<number>}
  38380. */
  38381. axisCoordToPoint: function (coord, dim) {
  38382. var axisLayout = this._axesLayout[dim];
  38383. return graphic.applyTransform([coord, 0], axisLayout.transform);
  38384. },
  38385. /**
  38386. * Get axis layout.
  38387. */
  38388. getAxisLayout: function (dim) {
  38389. return zrUtil.clone(this._axesLayout[dim]);
  38390. },
  38391. /**
  38392. * @param {Array.<number>} point
  38393. * @return {Object} {axisExpandWindow, delta, behavior: 'jump' | 'slide' | 'none'}.
  38394. */
  38395. getSlidedAxisExpandWindow: function (point) {
  38396. var layoutInfo = this._makeLayoutInfo();
  38397. var pixelDimIndex = layoutInfo.pixelDimIndex;
  38398. var axisExpandWindow = layoutInfo.axisExpandWindow.slice();
  38399. var winSize = axisExpandWindow[1] - axisExpandWindow[0];
  38400. var extent = [0, layoutInfo.axisExpandWidth * (layoutInfo.axisCount - 1)];
  38401. // Out of the area of coordinate system.
  38402. if (!this.containPoint(point)) {
  38403. return {behavior: 'none', axisExpandWindow: axisExpandWindow};
  38404. }
  38405. // Conver the point from global to expand coordinates.
  38406. var pointCoord = point[pixelDimIndex] - layoutInfo.layoutBase - layoutInfo.axisExpandWindow0Pos;
  38407. // For dragging operation convenience, the window should not be
  38408. // slided when mouse is the center area of the window.
  38409. var delta;
  38410. var behavior = 'slide';
  38411. var axisCollapseWidth = layoutInfo.axisCollapseWidth;
  38412. var triggerArea = this._model.get('axisExpandSlideTriggerArea');
  38413. // But consider touch device, jump is necessary.
  38414. var useJump = triggerArea[0] != null;
  38415. if (axisCollapseWidth) {
  38416. if (useJump && axisCollapseWidth && pointCoord < winSize * triggerArea[0]) {
  38417. behavior = 'jump';
  38418. delta = pointCoord - winSize * triggerArea[2];
  38419. }
  38420. else if (useJump && axisCollapseWidth && pointCoord > winSize * (1 - triggerArea[0])) {
  38421. behavior = 'jump';
  38422. delta = pointCoord - winSize * (1 - triggerArea[2]);
  38423. }
  38424. else {
  38425. (delta = pointCoord - winSize * triggerArea[1]) >= 0
  38426. && (delta = pointCoord - winSize * (1 - triggerArea[1])) <= 0
  38427. && (delta = 0);
  38428. }
  38429. delta *= layoutInfo.axisExpandWidth / axisCollapseWidth;
  38430. delta
  38431. ? sliderMove(delta, axisExpandWindow, extent, 'all')
  38432. // Avoid nonsense triger on mousemove.
  38433. : (behavior = 'none');
  38434. }
  38435. // When screen is too narrow, make it visible and slidable, although it is hard to interact.
  38436. else {
  38437. var winSize = axisExpandWindow[1] - axisExpandWindow[0];
  38438. var pos = extent[1] * pointCoord / winSize;
  38439. axisExpandWindow = [mathMax(0, pos - winSize / 2)];
  38440. axisExpandWindow[1] = mathMin(extent[1], axisExpandWindow[0] + winSize);
  38441. axisExpandWindow[0] = axisExpandWindow[1] - winSize;
  38442. }
  38443. return {
  38444. axisExpandWindow: axisExpandWindow,
  38445. behavior: behavior
  38446. };
  38447. }
  38448. };
  38449. function restrict(len, extent) {
  38450. return mathMin(mathMax(len, extent[0]), extent[1]);
  38451. }
  38452. function layoutAxisWithoutExpand(axisIndex, layoutInfo) {
  38453. var step = layoutInfo.layoutLength / (layoutInfo.axisCount - 1);
  38454. return {
  38455. position: step * axisIndex,
  38456. axisNameAvailableWidth: step,
  38457. axisLabelShow: true
  38458. };
  38459. }
  38460. function layoutAxisWithExpand(axisIndex, layoutInfo) {
  38461. var layoutLength = layoutInfo.layoutLength;
  38462. var axisExpandWidth = layoutInfo.axisExpandWidth;
  38463. var axisCount = layoutInfo.axisCount;
  38464. var axisCollapseWidth = layoutInfo.axisCollapseWidth;
  38465. var winInnerIndices = layoutInfo.winInnerIndices;
  38466. var position;
  38467. var axisNameAvailableWidth = axisCollapseWidth;
  38468. var axisLabelShow = false;
  38469. var nameTruncateMaxWidth;
  38470. if (axisIndex < winInnerIndices[0]) {
  38471. position = axisIndex * axisCollapseWidth;
  38472. nameTruncateMaxWidth = axisCollapseWidth;
  38473. }
  38474. else if (axisIndex <= winInnerIndices[1]) {
  38475. position = layoutInfo.axisExpandWindow0Pos
  38476. + axisIndex * axisExpandWidth - layoutInfo.axisExpandWindow[0];
  38477. axisNameAvailableWidth = axisExpandWidth;
  38478. axisLabelShow = true;
  38479. }
  38480. else {
  38481. position = layoutLength - (axisCount - 1 - axisIndex) * axisCollapseWidth;
  38482. nameTruncateMaxWidth = axisCollapseWidth;
  38483. }
  38484. return {
  38485. position: position,
  38486. axisNameAvailableWidth: axisNameAvailableWidth,
  38487. axisLabelShow: axisLabelShow,
  38488. nameTruncateMaxWidth: nameTruncateMaxWidth
  38489. };
  38490. }
  38491. module.exports = Parallel;
  38492. /***/ },
  38493. /* 238 */
  38494. /***/ function(module, exports, __webpack_require__) {
  38495. var zrUtil = __webpack_require__(4);
  38496. var Axis = __webpack_require__(100);
  38497. /**
  38498. * @constructor module:echarts/coord/parallel/ParallelAxis
  38499. * @extends {module:echarts/coord/Axis}
  38500. * @param {string} dim
  38501. * @param {*} scale
  38502. * @param {Array.<number>} coordExtent
  38503. * @param {string} axisType
  38504. */
  38505. var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) {
  38506. Axis.call(this, dim, scale, coordExtent);
  38507. /**
  38508. * Axis type
  38509. * - 'category'
  38510. * - 'value'
  38511. * - 'time'
  38512. * - 'log'
  38513. * @type {string}
  38514. */
  38515. this.type = axisType || 'value';
  38516. /**
  38517. * @type {number}
  38518. * @readOnly
  38519. */
  38520. this.axisIndex = axisIndex;
  38521. };
  38522. ParallelAxis.prototype = {
  38523. constructor: ParallelAxis,
  38524. /**
  38525. * Axis model
  38526. * @param {module:echarts/coord/parallel/AxisModel}
  38527. */
  38528. model: null
  38529. };
  38530. zrUtil.inherits(ParallelAxis, Axis);
  38531. module.exports = ParallelAxis;
  38532. /***/ },
  38533. /* 239 */
  38534. /***/ function(module, exports) {
  38535. /**
  38536. * Calculate slider move result.
  38537. * Usage:
  38538. * (1) If both handle0 and handle1 are needed to be moved, set minSpan the same as
  38539. * maxSpan and the same as `Math.abs(handleEnd[1] - handleEnds[0])`.
  38540. * (2) If handle0 is forbidden to cross handle1, set minSpan as `0`.
  38541. *
  38542. * @param {number} delta Move length.
  38543. * @param {Array.<number>} handleEnds handleEnds[0] can be bigger then handleEnds[1].
  38544. * handleEnds will be modified in this method.
  38545. * @param {Array.<number>} extent handleEnds is restricted by extent.
  38546. * extent[0] should less or equals than extent[1].
  38547. * @param {number|string} handleIndex Can be 'all', means that both move the two handleEnds,
  38548. * where the input minSpan and maxSpan will not work.
  38549. * @param {number} [minSpan] The range of dataZoom can not be smaller than that.
  38550. * If not set, handle0 and cross handle1. If set as a non-negative
  38551. * number (including `0`), handles will push each other when reaching
  38552. * the minSpan.
  38553. * @param {number} [maxSpan] The range of dataZoom can not be larger than that.
  38554. * @return {Array.<number>} The input handleEnds.
  38555. */
  38556. module.exports = function (delta, handleEnds, extent, handleIndex, minSpan, maxSpan) {
  38557. // Normalize firstly.
  38558. handleEnds[0] = restrict(handleEnds[0], extent);
  38559. handleEnds[1] = restrict(handleEnds[1], extent);
  38560. delta = delta || 0;
  38561. var extentSpan = extent[1] - extent[0];
  38562. // Notice maxSpan and minSpan can be null/undefined.
  38563. if (minSpan != null) {
  38564. minSpan = restrict(minSpan, [0, extentSpan]);
  38565. }
  38566. if (maxSpan != null) {
  38567. maxSpan = Math.max(maxSpan, minSpan != null ? minSpan : 0);
  38568. }
  38569. if (handleIndex === 'all') {
  38570. minSpan = maxSpan = Math.abs(handleEnds[1] - handleEnds[0]);
  38571. handleIndex = 0;
  38572. }
  38573. var originalDistSign = getSpanSign(handleEnds, handleIndex);
  38574. handleEnds[handleIndex] += delta;
  38575. // Restrict in extent.
  38576. var extentMinSpan = minSpan || 0;
  38577. var realExtent = extent.slice();
  38578. originalDistSign.sign < 0 ? (realExtent[0] += extentMinSpan) : (realExtent[1] -= extentMinSpan);
  38579. handleEnds[handleIndex] = restrict(handleEnds[handleIndex], realExtent);
  38580. // Expand span.
  38581. var currDistSign = getSpanSign(handleEnds, handleIndex);
  38582. if (minSpan != null && (
  38583. currDistSign.sign !== originalDistSign.sign || currDistSign.span < minSpan
  38584. )) {
  38585. // If minSpan exists, 'cross' is forbinden.
  38586. handleEnds[1 - handleIndex] = handleEnds[handleIndex] + originalDistSign.sign * minSpan;
  38587. }
  38588. // Shrink span.
  38589. var currDistSign = getSpanSign(handleEnds, handleIndex);
  38590. if (maxSpan != null && currDistSign.span > maxSpan) {
  38591. handleEnds[1 - handleIndex] = handleEnds[handleIndex] + currDistSign.sign * maxSpan;
  38592. }
  38593. return handleEnds;
  38594. };
  38595. function getSpanSign(handleEnds, handleIndex) {
  38596. var dist = handleEnds[handleIndex] - handleEnds[1 - handleIndex];
  38597. // If `handleEnds[0] === handleEnds[1]`, always believe that handleEnd[0]
  38598. // is at left of handleEnds[1] for non-cross case.
  38599. return {span: Math.abs(dist), sign: dist > 0 ? -1 : dist < 0 ? 1 : handleIndex ? -1 : 1};
  38600. }
  38601. function restrict(value, extend) {
  38602. return Math.min(extend[1], Math.max(extend[0], value));
  38603. }
  38604. /***/ },
  38605. /* 240 */
  38606. /***/ function(module, exports, __webpack_require__) {
  38607. var zrUtil = __webpack_require__(4);
  38608. var Component = __webpack_require__(69);
  38609. __webpack_require__(241);
  38610. Component.extend({
  38611. type: 'parallel',
  38612. dependencies: ['parallelAxis'],
  38613. /**
  38614. * @type {module:echarts/coord/parallel/Parallel}
  38615. */
  38616. coordinateSystem: null,
  38617. /**
  38618. * Each item like: 'dim0', 'dim1', 'dim2', ...
  38619. * @type {Array.<string>}
  38620. * @readOnly
  38621. */
  38622. dimensions: null,
  38623. /**
  38624. * Coresponding to dimensions.
  38625. * @type {Array.<number>}
  38626. * @readOnly
  38627. */
  38628. parallelAxisIndex: null,
  38629. layoutMode: 'box',
  38630. defaultOption: {
  38631. zlevel: 0,
  38632. z: 0,
  38633. left: 80,
  38634. top: 60,
  38635. right: 80,
  38636. bottom: 60,
  38637. // width: {totalWidth} - left - right,
  38638. // height: {totalHeight} - top - bottom,
  38639. layout: 'horizontal', // 'horizontal' or 'vertical'
  38640. // FIXME
  38641. // naming?
  38642. axisExpandable: false,
  38643. axisExpandCenter: null,
  38644. axisExpandCount: 0,
  38645. axisExpandWidth: 50, // FIXME '10%' ?
  38646. axisExpandRate: 17,
  38647. axisExpandDebounce: 50,
  38648. // [out, in, jumpTarget]. In percentage. If use [null, 0.05], null means full.
  38649. // Do not doc to user until necessary.
  38650. axisExpandSlideTriggerArea: [-0.15, 0.05, 0.4],
  38651. axisExpandTriggerOn: 'click', // 'mousemove' or 'click'
  38652. parallelAxisDefault: null
  38653. },
  38654. /**
  38655. * @override
  38656. */
  38657. init: function () {
  38658. Component.prototype.init.apply(this, arguments);
  38659. this.mergeOption({});
  38660. },
  38661. /**
  38662. * @override
  38663. */
  38664. mergeOption: function (newOption) {
  38665. var thisOption = this.option;
  38666. newOption && zrUtil.merge(thisOption, newOption, true);
  38667. this._initDimensions();
  38668. },
  38669. /**
  38670. * Whether series or axis is in this coordinate system.
  38671. * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model
  38672. * @param {module:echarts/model/Global} ecModel
  38673. */
  38674. contains: function (model, ecModel) {
  38675. var parallelIndex = model.get('parallelIndex');
  38676. return parallelIndex != null
  38677. && ecModel.getComponent('parallel', parallelIndex) === this;
  38678. },
  38679. setAxisExpand: function (opt) {
  38680. zrUtil.each(
  38681. ['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth', 'axisExpandWindow'],
  38682. function (name) {
  38683. if (opt.hasOwnProperty(name)) {
  38684. this.option[name] = opt[name];
  38685. }
  38686. },
  38687. this
  38688. );
  38689. },
  38690. /**
  38691. * @private
  38692. */
  38693. _initDimensions: function () {
  38694. var dimensions = this.dimensions = [];
  38695. var parallelAxisIndex = this.parallelAxisIndex = [];
  38696. var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) {
  38697. // Can not use this.contains here, because
  38698. // initialization has not been completed yet.
  38699. return axisModel.get('parallelIndex') === this.componentIndex;
  38700. });
  38701. zrUtil.each(axisModels, function (axisModel) {
  38702. dimensions.push('dim' + axisModel.get('dim'));
  38703. parallelAxisIndex.push(axisModel.componentIndex);
  38704. });
  38705. }
  38706. });
  38707. /***/ },
  38708. /* 241 */
  38709. /***/ function(module, exports, __webpack_require__) {
  38710. var ComponentModel = __webpack_require__(69);
  38711. var zrUtil = __webpack_require__(4);
  38712. var makeStyleMapper = __webpack_require__(15);
  38713. var axisModelCreator = __webpack_require__(131);
  38714. var numberUtil = __webpack_require__(7);
  38715. var AxisModel = ComponentModel.extend({
  38716. type: 'baseParallelAxis',
  38717. /**
  38718. * @type {module:echarts/coord/parallel/Axis}
  38719. */
  38720. axis: null,
  38721. /**
  38722. * @type {Array.<Array.<number>}
  38723. * @readOnly
  38724. */
  38725. activeIntervals: [],
  38726. /**
  38727. * @return {Object}
  38728. */
  38729. getAreaSelectStyle: function () {
  38730. return makeStyleMapper(
  38731. [
  38732. ['fill', 'color'],
  38733. ['lineWidth', 'borderWidth'],
  38734. ['stroke', 'borderColor'],
  38735. ['width', 'width'],
  38736. ['opacity', 'opacity']
  38737. ]
  38738. ).call(this.getModel('areaSelectStyle'));
  38739. },
  38740. /**
  38741. * The code of this feature is put on AxisModel but not ParallelAxis,
  38742. * because axisModel can be alive after echarts updating but instance of
  38743. * ParallelAxis having been disposed. this._activeInterval should be kept
  38744. * when action dispatched (i.e. legend click).
  38745. *
  38746. * @param {Array.<Array<number>>} intervals interval.length === 0
  38747. * means set all active.
  38748. * @public
  38749. */
  38750. setActiveIntervals: function (intervals) {
  38751. var activeIntervals = this.activeIntervals = zrUtil.clone(intervals);
  38752. // Normalize
  38753. if (activeIntervals) {
  38754. for (var i = activeIntervals.length - 1; i >= 0; i--) {
  38755. numberUtil.asc(activeIntervals[i]);
  38756. }
  38757. }
  38758. },
  38759. /**
  38760. * @param {number|string} [value] When attempting to detect 'no activeIntervals set',
  38761. * value can not be input.
  38762. * @return {string} 'normal': no activeIntervals set,
  38763. * 'active',
  38764. * 'inactive'.
  38765. * @public
  38766. */
  38767. getActiveState: function (value) {
  38768. var activeIntervals = this.activeIntervals;
  38769. if (!activeIntervals.length) {
  38770. return 'normal';
  38771. }
  38772. if (value == null) {
  38773. return 'inactive';
  38774. }
  38775. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  38776. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  38777. return 'active';
  38778. }
  38779. }
  38780. return 'inactive';
  38781. }
  38782. });
  38783. var defaultOption = {
  38784. type: 'value',
  38785. /**
  38786. * @type {Array.<number>}
  38787. */
  38788. dim: null, // 0, 1, 2, ...
  38789. // parallelIndex: null,
  38790. areaSelectStyle: {
  38791. width: 20,
  38792. borderWidth: 1,
  38793. borderColor: 'rgba(160,197,232)',
  38794. color: 'rgba(160,197,232)',
  38795. opacity: 0.3
  38796. },
  38797. realtime: true, // Whether realtime update view when select.
  38798. z: 10
  38799. };
  38800. zrUtil.merge(AxisModel.prototype, __webpack_require__(112));
  38801. function getAxisType(axisName, option) {
  38802. return option.type || (option.data ? 'category' : 'value');
  38803. }
  38804. axisModelCreator('parallel', AxisModel, getAxisType, defaultOption);
  38805. module.exports = AxisModel;
  38806. /***/ },
  38807. /* 242 */
  38808. /***/ function(module, exports, __webpack_require__) {
  38809. __webpack_require__(236);
  38810. __webpack_require__(243);
  38811. __webpack_require__(244);
  38812. /***/ },
  38813. /* 243 */
  38814. /***/ function(module, exports, __webpack_require__) {
  38815. var echarts = __webpack_require__(1);
  38816. /**
  38817. * @payload
  38818. * @property {string} parallelAxisId
  38819. * @property {Array.<Array.<number>>} intervals
  38820. */
  38821. var actionInfo = {
  38822. type: 'axisAreaSelect',
  38823. event: 'axisAreaSelected',
  38824. update: 'updateVisual'
  38825. };
  38826. echarts.registerAction(actionInfo, function (payload, ecModel) {
  38827. ecModel.eachComponent(
  38828. {mainType: 'parallelAxis', query: payload},
  38829. function (parallelAxisModel) {
  38830. parallelAxisModel.axis.model.setActiveIntervals(payload.intervals);
  38831. }
  38832. );
  38833. });
  38834. /**
  38835. * @payload
  38836. */
  38837. echarts.registerAction('parallelAxisExpand', function (payload, ecModel) {
  38838. ecModel.eachComponent(
  38839. {mainType: 'parallel', query: payload},
  38840. function (parallelModel) {
  38841. parallelModel.setAxisExpand(payload);
  38842. }
  38843. );
  38844. });
  38845. /***/ },
  38846. /* 244 */
  38847. /***/ function(module, exports, __webpack_require__) {
  38848. var zrUtil = __webpack_require__(4);
  38849. var AxisBuilder = __webpack_require__(135);
  38850. var BrushController = __webpack_require__(245);
  38851. var brushHelper = __webpack_require__(246);
  38852. var graphic = __webpack_require__(18);
  38853. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'axisName'];
  38854. var AxisView = __webpack_require__(1).extendComponentView({
  38855. type: 'parallelAxis',
  38856. /**
  38857. * @override
  38858. */
  38859. init: function (ecModel, api) {
  38860. AxisView.superApply(this, 'init', arguments);
  38861. /**
  38862. * @type {module:echarts/component/helper/BrushController}
  38863. */
  38864. (this._brushController = new BrushController(api.getZr()))
  38865. .on('brush', zrUtil.bind(this._onBrush, this));
  38866. },
  38867. /**
  38868. * @override
  38869. */
  38870. render: function (axisModel, ecModel, api, payload) {
  38871. if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
  38872. return;
  38873. }
  38874. this.axisModel = axisModel;
  38875. this.api = api;
  38876. this.group.removeAll();
  38877. var oldAxisGroup = this._axisGroup;
  38878. this._axisGroup = new graphic.Group();
  38879. this.group.add(this._axisGroup);
  38880. if (!axisModel.get('show')) {
  38881. return;
  38882. }
  38883. var coordSysModel = getCoordSysModel(axisModel, ecModel);
  38884. var coordSys = coordSysModel.coordinateSystem;
  38885. var areaSelectStyle = axisModel.getAreaSelectStyle();
  38886. var areaWidth = areaSelectStyle.width;
  38887. var dim = axisModel.axis.dim;
  38888. var axisLayout = coordSys.getAxisLayout(dim);
  38889. var builderOpt = zrUtil.extend(
  38890. {strokeContainThreshold: areaWidth},
  38891. axisLayout
  38892. );
  38893. var axisBuilder = new AxisBuilder(axisModel, builderOpt);
  38894. zrUtil.each(elementList, axisBuilder.add, axisBuilder);
  38895. this._axisGroup.add(axisBuilder.getGroup());
  38896. this._refreshBrushController(
  38897. builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api
  38898. );
  38899. var animationModel = (payload && payload.animation === false) ? null : axisModel;
  38900. graphic.groupTransition(oldAxisGroup, this._axisGroup, animationModel);
  38901. },
  38902. /**
  38903. * @override
  38904. */
  38905. updateVisual: function (axisModel, ecModel, api, payload) {
  38906. this._brushController && this._brushController
  38907. .updateCovers(getCoverInfoList(axisModel));
  38908. },
  38909. _refreshBrushController: function (
  38910. builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api
  38911. ) {
  38912. // After filtering, axis may change, select area needs to be update.
  38913. var extent = axisModel.axis.getExtent();
  38914. var extentLen = extent[1] - extent[0];
  38915. var extra = Math.min(30, Math.abs(extentLen) * 0.1); // Arbitrary value.
  38916. // width/height might be negative, which will be
  38917. // normalized in BoundingRect.
  38918. var rect = graphic.BoundingRect.create({
  38919. x: extent[0],
  38920. y: -areaWidth / 2,
  38921. width: extentLen,
  38922. height: areaWidth
  38923. });
  38924. rect.x -= extra;
  38925. rect.width += 2 * extra;
  38926. this._brushController
  38927. .mount({
  38928. enableGlobalPan: true,
  38929. rotation: builderOpt.rotation,
  38930. position: builderOpt.position
  38931. })
  38932. .setPanels([{
  38933. panelId: 'pl',
  38934. clipPath: brushHelper.makeRectPanelClipPath(rect),
  38935. isTargetByCursor: brushHelper.makeRectIsTargetByCursor(rect, api, coordSysModel),
  38936. getLinearBrushOtherExtent: brushHelper.makeLinearBrushOtherExtent(rect, 0)
  38937. }])
  38938. .enableBrush({
  38939. brushType: 'lineX',
  38940. brushStyle: areaSelectStyle,
  38941. removeOnClick: true
  38942. })
  38943. .updateCovers(getCoverInfoList(axisModel));
  38944. },
  38945. _onBrush: function (coverInfoList, opt) {
  38946. // Do not cache these object, because the mey be changed.
  38947. var axisModel = this.axisModel;
  38948. var axis = axisModel.axis;
  38949. var intervals = zrUtil.map(coverInfoList, function (coverInfo) {
  38950. return [
  38951. axis.coordToData(coverInfo.range[0], true),
  38952. axis.coordToData(coverInfo.range[1], true)
  38953. ];
  38954. });
  38955. // If realtime is true, action is not dispatched on drag end, because
  38956. // the drag end emits the same params with the last drag move event,
  38957. // and may have some delay when using touch pad.
  38958. if (!axisModel.option.realtime === opt.isEnd || opt.removeOnClick) { // jshint ignore:line
  38959. this.api.dispatchAction({
  38960. type: 'axisAreaSelect',
  38961. parallelAxisId: axisModel.id,
  38962. intervals: intervals
  38963. });
  38964. }
  38965. },
  38966. /**
  38967. * @override
  38968. */
  38969. dispose: function () {
  38970. this._brushController.dispose();
  38971. }
  38972. });
  38973. function fromAxisAreaSelect(axisModel, ecModel, payload) {
  38974. return payload
  38975. && payload.type === 'axisAreaSelect'
  38976. && ecModel.findComponents(
  38977. {mainType: 'parallelAxis', query: payload}
  38978. )[0] === axisModel;
  38979. }
  38980. function getCoverInfoList(axisModel) {
  38981. var axis = axisModel.axis;
  38982. return zrUtil.map(axisModel.activeIntervals, function (interval) {
  38983. return {
  38984. brushType: 'lineX',
  38985. panelId: 'pl',
  38986. range: [
  38987. axis.dataToCoord(interval[0], true),
  38988. axis.dataToCoord(interval[1], true)
  38989. ]
  38990. };
  38991. });
  38992. }
  38993. function getCoordSysModel(axisModel, ecModel) {
  38994. return ecModel.getComponent(
  38995. 'parallel', axisModel.get('parallelIndex')
  38996. );
  38997. }
  38998. module.exports = AxisView;
  38999. /***/ },
  39000. /* 245 */
  39001. /***/ function(module, exports, __webpack_require__) {
  39002. /**
  39003. * Box selection tool.
  39004. *
  39005. * @module echarts/component/helper/BrushController
  39006. */
  39007. var Eventful = __webpack_require__(25);
  39008. var zrUtil = __webpack_require__(4);
  39009. var graphic = __webpack_require__(18);
  39010. var interactionMutex = __webpack_require__(184);
  39011. var DataDiffer = __webpack_require__(99);
  39012. var curry = zrUtil.curry;
  39013. var each = zrUtil.each;
  39014. var map = zrUtil.map;
  39015. var mathMin = Math.min;
  39016. var mathMax = Math.max;
  39017. var mathPow = Math.pow;
  39018. var COVER_Z = 10000;
  39019. var UNSELECT_THRESHOLD = 6;
  39020. var MIN_RESIZE_LINE_WIDTH = 6;
  39021. var MUTEX_RESOURCE_KEY = 'globalPan';
  39022. var DIRECTION_MAP = {
  39023. w: [0, 0],
  39024. e: [0, 1],
  39025. n: [1, 0],
  39026. s: [1, 1]
  39027. };
  39028. var CURSOR_MAP = {
  39029. w: 'ew',
  39030. e: 'ew',
  39031. n: 'ns',
  39032. s: 'ns',
  39033. ne: 'nesw',
  39034. sw: 'nesw',
  39035. nw: 'nwse',
  39036. se: 'nwse'
  39037. };
  39038. var DEFAULT_BRUSH_OPT = {
  39039. brushStyle: {
  39040. lineWidth: 2,
  39041. stroke: 'rgba(0,0,0,0.3)',
  39042. fill: 'rgba(0,0,0,0.1)'
  39043. },
  39044. transformable: true,
  39045. brushMode: 'single',
  39046. removeOnClick: false
  39047. };
  39048. var baseUID = 0;
  39049. /**
  39050. * @alias module:echarts/component/helper/BrushController
  39051. * @constructor
  39052. * @mixin {module:zrender/mixin/Eventful}
  39053. * @event module:echarts/component/helper/BrushController#brush
  39054. * params:
  39055. * areas: Array.<Array>, coord relates to container group,
  39056. * If no container specified, to global.
  39057. * opt {
  39058. * isEnd: boolean,
  39059. * removeOnClick: boolean
  39060. * }
  39061. *
  39062. * @param {module:zrender/zrender~ZRender} zr
  39063. */
  39064. function BrushController(zr) {
  39065. if (true) {
  39066. zrUtil.assert(zr);
  39067. }
  39068. Eventful.call(this);
  39069. /**
  39070. * @type {module:zrender/zrender~ZRender}
  39071. * @private
  39072. */
  39073. this._zr = zr;
  39074. /**
  39075. * @type {module:zrender/container/Group}
  39076. * @readOnly
  39077. */
  39078. this.group = new graphic.Group();
  39079. /**
  39080. * Only for drawing (after enabledBrush).
  39081. * 'line', 'rect', 'polygon' or false
  39082. * If passing false/null/undefined, disable brush.
  39083. * If passing 'auto', determined by panel.defaultBrushType
  39084. * @private
  39085. * @type {string}
  39086. */
  39087. this._brushType;
  39088. /**
  39089. * Only for drawing (after enabledBrush).
  39090. *
  39091. * @private
  39092. * @type {Object}
  39093. */
  39094. this._brushOption;
  39095. /**
  39096. * @private
  39097. * @type {Object}
  39098. */
  39099. this._panels;
  39100. /**
  39101. * @private
  39102. * @type {Array.<nubmer>}
  39103. */
  39104. this._track = [];
  39105. /**
  39106. * @private
  39107. * @type {boolean}
  39108. */
  39109. this._dragging;
  39110. /**
  39111. * @private
  39112. * @type {Array}
  39113. */
  39114. this._covers = [];
  39115. /**
  39116. * @private
  39117. * @type {moudule:zrender/container/Group}
  39118. */
  39119. this._creatingCover;
  39120. /**
  39121. * `true` means global panel
  39122. * @private
  39123. * @type {module:zrender/container/Group|boolean}
  39124. */
  39125. this._creatingPanel;
  39126. /**
  39127. * @private
  39128. * @type {boolean}
  39129. */
  39130. this._enableGlobalPan;
  39131. /**
  39132. * @private
  39133. * @type {boolean}
  39134. */
  39135. if (true) {
  39136. this._mounted;
  39137. }
  39138. /**
  39139. * @private
  39140. * @type {string}
  39141. */
  39142. this._uid = 'brushController_' + baseUID++;
  39143. /**
  39144. * @private
  39145. * @type {Object}
  39146. */
  39147. this._handlers = {};
  39148. each(mouseHandlers, function (handler, eventName) {
  39149. this._handlers[eventName] = zrUtil.bind(handler, this);
  39150. }, this);
  39151. }
  39152. BrushController.prototype = {
  39153. constructor: BrushController,
  39154. /**
  39155. * If set to null/undefined/false, select disabled.
  39156. * @param {Object} brushOption
  39157. * @param {string|boolean} brushOption.brushType 'line', 'rect', 'polygon' or false
  39158. * If passing false/null/undefined, disable brush.
  39159. * If passing 'auto', determined by panel.defaultBrushType.
  39160. * ('auto' can not be used in global panel)
  39161. * @param {number} [brushOption.brushMode='single'] 'single' or 'multiple'
  39162. * @param {boolean} [brushOption.transformable=true]
  39163. * @param {boolean} [brushOption.removeOnClick=false]
  39164. * @param {Object} [brushOption.brushStyle]
  39165. * @param {number} [brushOption.brushStyle.width]
  39166. * @param {number} [brushOption.brushStyle.lineWidth]
  39167. * @param {string} [brushOption.brushStyle.stroke]
  39168. * @param {string} [brushOption.brushStyle.fill]
  39169. * @param {number} [brushOption.z]
  39170. */
  39171. enableBrush: function (brushOption) {
  39172. if (true) {
  39173. zrUtil.assert(this._mounted);
  39174. }
  39175. this._brushType && doDisableBrush(this);
  39176. brushOption.brushType && doEnableBrush(this, brushOption);
  39177. return this;
  39178. },
  39179. /**
  39180. * @param {Array.<Object>} panelOpts If not pass, it is global brush.
  39181. * Each items: {
  39182. * panelId, // mandatory.
  39183. * clipPath, // mandatory. function.
  39184. * isTargetByCursor, // mandatory. function.
  39185. * defaultBrushType, // optional, only used when brushType is 'auto'.
  39186. * getLinearBrushOtherExtent, // optional. function.
  39187. * }
  39188. */
  39189. setPanels: function (panelOpts) {
  39190. if (panelOpts && panelOpts.length) {
  39191. var panels = this._panels = {};
  39192. zrUtil.each(panelOpts, function (panelOpts) {
  39193. panels[panelOpts.panelId] = zrUtil.clone(panelOpts);
  39194. });
  39195. }
  39196. else {
  39197. this._panels = null;
  39198. }
  39199. return this;
  39200. },
  39201. /**
  39202. * @param {Object} [opt]
  39203. * @return {boolean} [opt.enableGlobalPan=false]
  39204. */
  39205. mount: function (opt) {
  39206. opt = opt || {};
  39207. if (true) {
  39208. this._mounted = true; // should be at first.
  39209. }
  39210. this._enableGlobalPan = opt.enableGlobalPan;
  39211. var thisGroup = this.group;
  39212. this._zr.add(thisGroup);
  39213. thisGroup.attr({
  39214. position: opt.position || [0, 0],
  39215. rotation: opt.rotation || 0,
  39216. scale: opt.scale || [1, 1]
  39217. });
  39218. this._transform = thisGroup.getLocalTransform();
  39219. return this;
  39220. },
  39221. eachCover: function (cb, context) {
  39222. each(this._covers, cb, context);
  39223. },
  39224. /**
  39225. * Update covers.
  39226. * @param {Array.<Object>} brushOptionList Like:
  39227. * [
  39228. * {id: 'xx', brushType: 'line', range: [23, 44], brushStyle, transformable},
  39229. * {id: 'yy', brushType: 'rect', range: [[23, 44], [23, 54]]},
  39230. * ...
  39231. * ]
  39232. * `brushType` is required in each cover info. (can not be 'auto')
  39233. * `id` is not mandatory.
  39234. * `brushStyle`, `transformable` is not mandatory, use DEFAULT_BRUSH_OPT by default.
  39235. * If brushOptionList is null/undefined, all covers removed.
  39236. */
  39237. updateCovers: function (brushOptionList) {
  39238. if (true) {
  39239. zrUtil.assert(this._mounted);
  39240. }
  39241. brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
  39242. return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  39243. });
  39244. var tmpIdPrefix = '\0-brush-index-';
  39245. var oldCovers = this._covers;
  39246. var newCovers = this._covers = [];
  39247. var controller = this;
  39248. var creatingCover = this._creatingCover;
  39249. (new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
  39250. .add(addOrUpdate)
  39251. .update(addOrUpdate)
  39252. .remove(remove)
  39253. .execute();
  39254. return this;
  39255. function getKey(brushOption, index) {
  39256. return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
  39257. + '-' + brushOption.brushType;
  39258. }
  39259. function oldGetKey(cover, index) {
  39260. return getKey(cover.__brushOption, index);
  39261. }
  39262. function addOrUpdate(newIndex, oldIndex) {
  39263. var newBrushOption = brushOptionList[newIndex];
  39264. // Consider setOption in event listener of brushSelect,
  39265. // where updating cover when creating should be forbiden.
  39266. if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
  39267. newCovers[newIndex] = oldCovers[oldIndex];
  39268. }
  39269. else {
  39270. var cover = newCovers[newIndex] = oldIndex != null
  39271. ? (
  39272. oldCovers[oldIndex].__brushOption = newBrushOption,
  39273. oldCovers[oldIndex]
  39274. )
  39275. : endCreating(controller, createCover(controller, newBrushOption));
  39276. updateCoverAfterCreation(controller, cover);
  39277. }
  39278. }
  39279. function remove(oldIndex) {
  39280. if (oldCovers[oldIndex] !== creatingCover) {
  39281. controller.group.remove(oldCovers[oldIndex]);
  39282. }
  39283. }
  39284. },
  39285. unmount: function () {
  39286. if (true) {
  39287. if (!this._mounted) {
  39288. return;
  39289. }
  39290. }
  39291. this.enableBrush(false);
  39292. // container may 'removeAll' outside.
  39293. clearCovers(this);
  39294. this._zr.remove(this.group);
  39295. if (true) {
  39296. this._mounted = false; // should be at last.
  39297. }
  39298. return this;
  39299. },
  39300. dispose: function () {
  39301. this.unmount();
  39302. this.off();
  39303. }
  39304. };
  39305. zrUtil.mixin(BrushController, Eventful);
  39306. function doEnableBrush(controller, brushOption) {
  39307. var zr = controller._zr;
  39308. // Consider roam, which takes globalPan too.
  39309. if (!controller._enableGlobalPan) {
  39310. interactionMutex.take(zr, MUTEX_RESOURCE_KEY, controller._uid);
  39311. }
  39312. each(controller._handlers, function (handler, eventName) {
  39313. zr.on(eventName, handler);
  39314. });
  39315. controller._brushType = brushOption.brushType;
  39316. controller._brushOption = zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  39317. }
  39318. function doDisableBrush(controller) {
  39319. var zr = controller._zr;
  39320. interactionMutex.release(zr, MUTEX_RESOURCE_KEY, controller._uid);
  39321. each(controller._handlers, function (handler, eventName) {
  39322. zr.off(eventName, handler);
  39323. });
  39324. controller._brushType = controller._brushOption = null;
  39325. }
  39326. function createCover(controller, brushOption) {
  39327. var cover = coverRenderers[brushOption.brushType].createCover(controller, brushOption);
  39328. cover.__brushOption = brushOption;
  39329. updateZ(cover, brushOption);
  39330. controller.group.add(cover);
  39331. return cover;
  39332. }
  39333. function endCreating(controller, creatingCover) {
  39334. var coverRenderer = getCoverRenderer(creatingCover);
  39335. if (coverRenderer.endCreating) {
  39336. coverRenderer.endCreating(controller, creatingCover);
  39337. updateZ(creatingCover, creatingCover.__brushOption);
  39338. }
  39339. return creatingCover;
  39340. }
  39341. function updateCoverShape(controller, cover) {
  39342. var brushOption = cover.__brushOption;
  39343. getCoverRenderer(cover).updateCoverShape(
  39344. controller, cover, brushOption.range, brushOption
  39345. );
  39346. }
  39347. function updateZ(cover, brushOption) {
  39348. var z = brushOption.z;
  39349. z == null && (z = COVER_Z);
  39350. cover.traverse(function (el) {
  39351. el.z = z;
  39352. el.z2 = z; // Consider in given container.
  39353. });
  39354. }
  39355. function updateCoverAfterCreation(controller, cover) {
  39356. getCoverRenderer(cover).updateCommon(controller, cover);
  39357. updateCoverShape(controller, cover);
  39358. }
  39359. function getCoverRenderer(cover) {
  39360. return coverRenderers[cover.__brushOption.brushType];
  39361. }
  39362. // return target panel or `true` (means global panel)
  39363. function getPanelByPoint(controller, e, localCursorPoint) {
  39364. var panels = controller._panels;
  39365. if (!panels) {
  39366. return true; // Global panel
  39367. }
  39368. var panel;
  39369. var transform = controller._transform;
  39370. each(panels, function (pn) {
  39371. pn.isTargetByCursor(e, localCursorPoint, transform) && (panel = pn);
  39372. });
  39373. return panel;
  39374. }
  39375. // Return a panel or true
  39376. function getPanelByCover(controller, cover) {
  39377. var panels = controller._panels;
  39378. if (!panels) {
  39379. return true; // Global panel
  39380. }
  39381. var panelId = cover.__brushOption.panelId;
  39382. // User may give cover without coord sys info,
  39383. // which is then treated as global panel.
  39384. return panelId != null ? panels[panelId] : true;
  39385. }
  39386. function clearCovers(controller) {
  39387. var covers = controller._covers;
  39388. var originalLength = covers.length;
  39389. each(covers, function (cover) {
  39390. controller.group.remove(cover);
  39391. }, controller);
  39392. covers.length = 0;
  39393. return !!originalLength;
  39394. }
  39395. function trigger(controller, opt) {
  39396. var areas = map(controller._covers, function (cover) {
  39397. var brushOption = cover.__brushOption;
  39398. var range = zrUtil.clone(brushOption.range);
  39399. return {
  39400. brushType: brushOption.brushType,
  39401. panelId: brushOption.panelId,
  39402. range: range
  39403. };
  39404. });
  39405. controller.trigger('brush', areas, {
  39406. isEnd: !!opt.isEnd,
  39407. removeOnClick: !!opt.removeOnClick
  39408. });
  39409. }
  39410. function shouldShowCover(controller) {
  39411. var track = controller._track;
  39412. if (!track.length) {
  39413. return false;
  39414. }
  39415. var p2 = track[track.length - 1];
  39416. var p1 = track[0];
  39417. var dx = p2[0] - p1[0];
  39418. var dy = p2[1] - p1[1];
  39419. var dist = mathPow(dx * dx + dy * dy, 0.5);
  39420. return dist > UNSELECT_THRESHOLD;
  39421. }
  39422. function getTrackEnds(track) {
  39423. var tail = track.length - 1;
  39424. tail < 0 && (tail = 0);
  39425. return [track[0], track[tail]];
  39426. }
  39427. function createBaseRectCover(doDrift, controller, brushOption, edgeNames) {
  39428. var cover = new graphic.Group();
  39429. cover.add(new graphic.Rect({
  39430. name: 'main',
  39431. style: makeStyle(brushOption),
  39432. silent: true,
  39433. draggable: true,
  39434. cursor: 'move',
  39435. drift: curry(doDrift, controller, cover, 'nswe'),
  39436. ondragend: curry(trigger, controller, {isEnd: true})
  39437. }));
  39438. each(
  39439. edgeNames,
  39440. function (name) {
  39441. cover.add(new graphic.Rect({
  39442. name: name,
  39443. style: {opacity: 0},
  39444. draggable: true,
  39445. silent: true,
  39446. invisible: true,
  39447. drift: curry(doDrift, controller, cover, name),
  39448. ondragend: curry(trigger, controller, {isEnd: true})
  39449. }));
  39450. }
  39451. );
  39452. return cover;
  39453. }
  39454. function updateBaseRect(controller, cover, localRange, brushOption) {
  39455. var lineWidth = brushOption.brushStyle.lineWidth || 0;
  39456. var handleSize = mathMax(lineWidth, MIN_RESIZE_LINE_WIDTH);
  39457. var x = localRange[0][0];
  39458. var y = localRange[1][0];
  39459. var xa = x - lineWidth / 2;
  39460. var ya = y - lineWidth / 2;
  39461. var x2 = localRange[0][1];
  39462. var y2 = localRange[1][1];
  39463. var x2a = x2 - handleSize + lineWidth / 2;
  39464. var y2a = y2 - handleSize + lineWidth / 2;
  39465. var width = x2 - x;
  39466. var height = y2 - y;
  39467. var widtha = width + lineWidth;
  39468. var heighta = height + lineWidth;
  39469. updateRectShape(controller, cover, 'main', x, y, width, height);
  39470. if (brushOption.transformable) {
  39471. updateRectShape(controller, cover, 'w', xa, ya, handleSize, heighta);
  39472. updateRectShape(controller, cover, 'e', x2a, ya, handleSize, heighta);
  39473. updateRectShape(controller, cover, 'n', xa, ya, widtha, handleSize);
  39474. updateRectShape(controller, cover, 's', xa, y2a, widtha, handleSize);
  39475. updateRectShape(controller, cover, 'nw', xa, ya, handleSize, handleSize);
  39476. updateRectShape(controller, cover, 'ne', x2a, ya, handleSize, handleSize);
  39477. updateRectShape(controller, cover, 'sw', xa, y2a, handleSize, handleSize);
  39478. updateRectShape(controller, cover, 'se', x2a, y2a, handleSize, handleSize);
  39479. }
  39480. }
  39481. function updateCommon(controller, cover) {
  39482. var brushOption = cover.__brushOption;
  39483. var transformable = brushOption.transformable;
  39484. var mainEl = cover.childAt(0);
  39485. mainEl.useStyle(makeStyle(brushOption));
  39486. mainEl.attr({
  39487. silent: !transformable,
  39488. cursor: transformable ? 'move' : 'default'
  39489. });
  39490. each(
  39491. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw'],
  39492. function (name) {
  39493. var el = cover.childOfName(name);
  39494. var globalDir = getGlobalDirection(controller, name);
  39495. el && el.attr({
  39496. silent: !transformable,
  39497. invisible: !transformable,
  39498. cursor: transformable ? CURSOR_MAP[globalDir] + '-resize' : null
  39499. });
  39500. }
  39501. );
  39502. }
  39503. function updateRectShape(controller, cover, name, x, y, w, h) {
  39504. var el = cover.childOfName(name);
  39505. el && el.setShape(pointsToRect(
  39506. clipByPanel(controller, cover, [[x, y], [x + w, y + h]])
  39507. ));
  39508. }
  39509. function makeStyle(brushOption) {
  39510. return zrUtil.defaults({strokeNoScale: true}, brushOption.brushStyle);
  39511. }
  39512. function formatRectRange(x, y, x2, y2) {
  39513. var min = [mathMin(x, x2), mathMin(y, y2)];
  39514. var max = [mathMax(x, x2), mathMax(y, y2)];
  39515. return [
  39516. [min[0], max[0]], // x range
  39517. [min[1], max[1]] // y range
  39518. ];
  39519. }
  39520. function getTransform(controller) {
  39521. return graphic.getTransform(controller.group);
  39522. }
  39523. function getGlobalDirection(controller, localDirection) {
  39524. if (localDirection.length > 1) {
  39525. localDirection = localDirection.split('');
  39526. var globalDir = [
  39527. getGlobalDirection(controller, localDirection[0]),
  39528. getGlobalDirection(controller, localDirection[1])
  39529. ];
  39530. (globalDir[0] === 'e' || globalDir[0] === 'w') && globalDir.reverse();
  39531. return globalDir.join('');
  39532. }
  39533. else {
  39534. var map = {w: 'left', e: 'right', n: 'top', s: 'bottom'};
  39535. var inverseMap = {left: 'w', right: 'e', top: 'n', bottom: 's'};
  39536. var globalDir = graphic.transformDirection(
  39537. map[localDirection], getTransform(controller)
  39538. );
  39539. return inverseMap[globalDir];
  39540. }
  39541. }
  39542. function driftRect(toRectRange, fromRectRange, controller, cover, name, dx, dy, e) {
  39543. var brushOption = cover.__brushOption;
  39544. var rectRange = toRectRange(brushOption.range);
  39545. var localDelta = toLocalDelta(controller, dx, dy);
  39546. each(name.split(''), function (namePart) {
  39547. var ind = DIRECTION_MAP[namePart];
  39548. rectRange[ind[0]][ind[1]] += localDelta[ind[0]];
  39549. });
  39550. brushOption.range = fromRectRange(formatRectRange(
  39551. rectRange[0][0], rectRange[1][0], rectRange[0][1], rectRange[1][1]
  39552. ));
  39553. updateCoverAfterCreation(controller, cover);
  39554. trigger(controller, {isEnd: false});
  39555. }
  39556. function driftPolygon(controller, cover, dx, dy, e) {
  39557. var range = cover.__brushOption.range;
  39558. var localDelta = toLocalDelta(controller, dx, dy);
  39559. each(range, function (point) {
  39560. point[0] += localDelta[0];
  39561. point[1] += localDelta[1];
  39562. });
  39563. updateCoverAfterCreation(controller, cover);
  39564. trigger(controller, {isEnd: false});
  39565. }
  39566. function toLocalDelta(controller, dx, dy) {
  39567. var thisGroup = controller.group;
  39568. var localD = thisGroup.transformCoordToLocal(dx, dy);
  39569. var localZero = thisGroup.transformCoordToLocal(0, 0);
  39570. return [localD[0] - localZero[0], localD[1] - localZero[1]];
  39571. }
  39572. function clipByPanel(controller, cover, data) {
  39573. var panel = getPanelByCover(controller, cover);
  39574. return (panel && panel !== true)
  39575. ? panel.clipPath(data, controller._transform)
  39576. : zrUtil.clone(data);
  39577. }
  39578. function pointsToRect(points) {
  39579. var xmin = mathMin(points[0][0], points[1][0]);
  39580. var ymin = mathMin(points[0][1], points[1][1]);
  39581. var xmax = mathMax(points[0][0], points[1][0]);
  39582. var ymax = mathMax(points[0][1], points[1][1]);
  39583. return {
  39584. x: xmin,
  39585. y: ymin,
  39586. width: xmax - xmin,
  39587. height: ymax - ymin
  39588. };
  39589. }
  39590. function resetCursor(controller, e, localCursorPoint) {
  39591. // Check active
  39592. if (!controller._brushType) {
  39593. return;
  39594. }
  39595. var zr = controller._zr;
  39596. var covers = controller._covers;
  39597. var currPanel = getPanelByPoint(controller, e, localCursorPoint);
  39598. // Check whether in covers.
  39599. if (!controller._dragging) {
  39600. for (var i = 0; i < covers.length; i++) {
  39601. var brushOption = covers[i].__brushOption;
  39602. if (currPanel
  39603. && (currPanel === true || brushOption.panelId === currPanel.panelId)
  39604. && coverRenderers[brushOption.brushType].contain(
  39605. covers[i], localCursorPoint[0], localCursorPoint[1]
  39606. )
  39607. ) {
  39608. // Use cursor style set on cover.
  39609. return;
  39610. }
  39611. }
  39612. }
  39613. currPanel && zr.setCursorStyle('crosshair');
  39614. }
  39615. function preventDefault(e) {
  39616. var rawE = e.event;
  39617. rawE.preventDefault && rawE.preventDefault();
  39618. }
  39619. function mainShapeContain(cover, x, y) {
  39620. return cover.childOfName('main').contain(x, y);
  39621. }
  39622. function updateCoverByMouse(controller, e, localCursorPoint, isEnd) {
  39623. var creatingCover = controller._creatingCover;
  39624. var panel = controller._creatingPanel;
  39625. var thisBrushOption = controller._brushOption;
  39626. var eventParams;
  39627. controller._track.push(localCursorPoint.slice());
  39628. if (shouldShowCover(controller) || creatingCover) {
  39629. if (panel && !creatingCover) {
  39630. thisBrushOption.brushMode === 'single' && clearCovers(controller);
  39631. var brushOption = zrUtil.clone(thisBrushOption);
  39632. brushOption.brushType = determineBrushType(brushOption.brushType, panel);
  39633. brushOption.panelId = panel === true ? null : panel.panelId;
  39634. creatingCover = controller._creatingCover = createCover(controller, brushOption);
  39635. controller._covers.push(creatingCover);
  39636. }
  39637. if (creatingCover) {
  39638. var coverRenderer = coverRenderers[determineBrushType(controller._brushType, panel)];
  39639. var coverBrushOption = creatingCover.__brushOption;
  39640. coverBrushOption.range = coverRenderer.getCreatingRange(
  39641. clipByPanel(controller, creatingCover, controller._track)
  39642. );
  39643. if (isEnd) {
  39644. endCreating(controller, creatingCover);
  39645. coverRenderer.updateCommon(controller, creatingCover);
  39646. }
  39647. updateCoverShape(controller, creatingCover);
  39648. eventParams = {isEnd: isEnd};
  39649. }
  39650. }
  39651. else if (
  39652. isEnd
  39653. && thisBrushOption.brushMode === 'single'
  39654. && thisBrushOption.removeOnClick
  39655. ) {
  39656. // Help user to remove covers easily, only by a tiny drag, in 'single' mode.
  39657. // But a single click do not clear covers, because user may have casual
  39658. // clicks (for example, click on other component and do not expect covers
  39659. // disappear).
  39660. // Only some cover removed, trigger action, but not every click trigger action.
  39661. if (getPanelByPoint(controller, e, localCursorPoint) && clearCovers(controller)) {
  39662. eventParams = {isEnd: isEnd, removeOnClick: true};
  39663. }
  39664. }
  39665. return eventParams;
  39666. }
  39667. function determineBrushType(brushType, panel) {
  39668. if (brushType === 'auto') {
  39669. if (true) {
  39670. zrUtil.assert(
  39671. panel && panel.defaultBrushType,
  39672. 'MUST have defaultBrushType when brushType is "atuo"'
  39673. );
  39674. }
  39675. return panel.defaultBrushType;
  39676. }
  39677. return brushType;
  39678. }
  39679. var mouseHandlers = {
  39680. mousedown: function (e) {
  39681. if (this._dragging) {
  39682. // In case some browser do not support globalOut,
  39683. // and release mose out side the browser.
  39684. handleDragEnd.call(this, e);
  39685. }
  39686. else if (!e.target || !e.target.draggable) {
  39687. preventDefault(e);
  39688. var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
  39689. this._creatingCover = null;
  39690. var panel = this._creatingPanel = getPanelByPoint(this, e, localCursorPoint);
  39691. if (panel) {
  39692. this._dragging = true;
  39693. this._track = [localCursorPoint.slice()];
  39694. }
  39695. }
  39696. },
  39697. mousemove: function (e) {
  39698. var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
  39699. resetCursor(this, e, localCursorPoint);
  39700. if (this._dragging) {
  39701. preventDefault(e);
  39702. var eventParams = updateCoverByMouse(this, e, localCursorPoint, false);
  39703. eventParams && trigger(this, eventParams);
  39704. }
  39705. },
  39706. mouseup: handleDragEnd //,
  39707. // FIXME
  39708. // in tooltip, globalout should not be triggered.
  39709. // globalout: handleDragEnd
  39710. };
  39711. function handleDragEnd(e) {
  39712. if (this._dragging) {
  39713. preventDefault(e);
  39714. var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
  39715. var eventParams = updateCoverByMouse(this, e, localCursorPoint, true);
  39716. this._dragging = false;
  39717. this._track = [];
  39718. this._creatingCover = null;
  39719. // trigger event shoule be at final, after procedure will be nested.
  39720. eventParams && trigger(this, eventParams);
  39721. }
  39722. }
  39723. /**
  39724. * key: brushType
  39725. * @type {Object}
  39726. */
  39727. var coverRenderers = {
  39728. lineX: getLineRenderer(0),
  39729. lineY: getLineRenderer(1),
  39730. rect: {
  39731. createCover: function (controller, brushOption) {
  39732. return createBaseRectCover(
  39733. curry(
  39734. driftRect,
  39735. function (range) {
  39736. return range;
  39737. },
  39738. function (range) {
  39739. return range;
  39740. }
  39741. ),
  39742. controller,
  39743. brushOption,
  39744. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw']
  39745. );
  39746. },
  39747. getCreatingRange: function (localTrack) {
  39748. var ends = getTrackEnds(localTrack);
  39749. return formatRectRange(ends[1][0], ends[1][1], ends[0][0], ends[0][1]);
  39750. },
  39751. updateCoverShape: function (controller, cover, localRange, brushOption) {
  39752. updateBaseRect(controller, cover, localRange, brushOption);
  39753. },
  39754. updateCommon: updateCommon,
  39755. contain: mainShapeContain
  39756. },
  39757. polygon: {
  39758. createCover: function (controller, brushOption) {
  39759. var cover = new graphic.Group();
  39760. // Do not use graphic.Polygon because graphic.Polyline do not close the
  39761. // border of the shape when drawing, which is a better experience for user.
  39762. cover.add(new graphic.Polyline({
  39763. name: 'main',
  39764. style: makeStyle(brushOption),
  39765. silent: true
  39766. }));
  39767. return cover;
  39768. },
  39769. getCreatingRange: function (localTrack) {
  39770. return localTrack;
  39771. },
  39772. endCreating: function (controller, cover) {
  39773. cover.remove(cover.childAt(0));
  39774. // Use graphic.Polygon close the shape.
  39775. cover.add(new graphic.Polygon({
  39776. name: 'main',
  39777. draggable: true,
  39778. drift: curry(driftPolygon, controller, cover),
  39779. ondragend: curry(trigger, controller, {isEnd: true})
  39780. }));
  39781. },
  39782. updateCoverShape: function (controller, cover, localRange, brushOption) {
  39783. cover.childAt(0).setShape({
  39784. points: clipByPanel(controller, cover, localRange)
  39785. });
  39786. },
  39787. updateCommon: updateCommon,
  39788. contain: mainShapeContain
  39789. }
  39790. };
  39791. function getLineRenderer(xyIndex) {
  39792. return {
  39793. createCover: function (controller, brushOption) {
  39794. return createBaseRectCover(
  39795. curry(
  39796. driftRect,
  39797. function (range) {
  39798. var rectRange = [range, [0, 100]];
  39799. xyIndex && rectRange.reverse();
  39800. return rectRange;
  39801. },
  39802. function (rectRange) {
  39803. return rectRange[xyIndex];
  39804. }
  39805. ),
  39806. controller,
  39807. brushOption,
  39808. [['w', 'e'], ['n', 's']][xyIndex]
  39809. );
  39810. },
  39811. getCreatingRange: function (localTrack) {
  39812. var ends = getTrackEnds(localTrack);
  39813. var min = mathMin(ends[0][xyIndex], ends[1][xyIndex]);
  39814. var max = mathMax(ends[0][xyIndex], ends[1][xyIndex]);
  39815. return [min, max];
  39816. },
  39817. updateCoverShape: function (controller, cover, localRange, brushOption) {
  39818. var otherExtent;
  39819. // If brushWidth not specified, fit the panel.
  39820. var panel = getPanelByCover(controller, cover);
  39821. if (panel !== true && panel.getLinearBrushOtherExtent) {
  39822. otherExtent = panel.getLinearBrushOtherExtent(
  39823. xyIndex, controller._transform
  39824. );
  39825. }
  39826. else {
  39827. var zr = controller._zr;
  39828. otherExtent = [0, [zr.getWidth(), zr.getHeight()][1 - xyIndex]];
  39829. }
  39830. var rectRange = [localRange, otherExtent];
  39831. xyIndex && rectRange.reverse();
  39832. updateBaseRect(controller, cover, rectRange, brushOption);
  39833. },
  39834. updateCommon: updateCommon,
  39835. contain: mainShapeContain
  39836. };
  39837. }
  39838. module.exports = BrushController;
  39839. /***/ },
  39840. /* 246 */
  39841. /***/ function(module, exports, __webpack_require__) {
  39842. var cursorHelper = __webpack_require__(186);
  39843. var BoundingRect = __webpack_require__(9);
  39844. var graphicUtil = __webpack_require__(18);
  39845. var helper = {};
  39846. helper.makeRectPanelClipPath = function (rect) {
  39847. rect = normalizeRect(rect);
  39848. return function (localPoints, transform) {
  39849. return graphicUtil.clipPointsByRect(localPoints, rect);
  39850. };
  39851. };
  39852. helper.makeLinearBrushOtherExtent = function (rect, specifiedXYIndex) {
  39853. rect = normalizeRect(rect);
  39854. return function (xyIndex) {
  39855. var idx = specifiedXYIndex != null ? specifiedXYIndex : xyIndex;
  39856. var brushWidth = idx ? rect.width : rect.height;
  39857. var base = idx ? rect.x : rect.y;
  39858. return [base, base + (brushWidth || 0)];
  39859. };
  39860. };
  39861. helper.makeRectIsTargetByCursor = function (rect, api, targetModel) {
  39862. rect = normalizeRect(rect);
  39863. return function (e, localCursorPoint, transform) {
  39864. return rect.contain(localCursorPoint[0], localCursorPoint[1])
  39865. && !cursorHelper.onIrrelevantElement(e, api, targetModel);
  39866. };
  39867. };
  39868. // Consider width/height is negative.
  39869. function normalizeRect(rect) {
  39870. return BoundingRect.create(rect);
  39871. }
  39872. module.exports = helper;
  39873. /***/ },
  39874. /* 247 */
  39875. /***/ function(module, exports, __webpack_require__) {
  39876. var zrUtil = __webpack_require__(4);
  39877. var modelUtil = __webpack_require__(5);
  39878. module.exports = function (option) {
  39879. createParallelIfNeeded(option);
  39880. mergeAxisOptionFromParallel(option);
  39881. };
  39882. /**
  39883. * Create a parallel coordinate if not exists.
  39884. * @inner
  39885. */
  39886. function createParallelIfNeeded(option) {
  39887. if (option.parallel) {
  39888. return;
  39889. }
  39890. var hasParallelSeries = false;
  39891. zrUtil.each(option.series, function (seriesOpt) {
  39892. if (seriesOpt && seriesOpt.type === 'parallel') {
  39893. hasParallelSeries = true;
  39894. }
  39895. });
  39896. if (hasParallelSeries) {
  39897. option.parallel = [{}];
  39898. }
  39899. }
  39900. /**
  39901. * Merge aixs definition from parallel option (if exists) to axis option.
  39902. * @inner
  39903. */
  39904. function mergeAxisOptionFromParallel(option) {
  39905. var axes = modelUtil.normalizeToArray(option.parallelAxis);
  39906. zrUtil.each(axes, function (axisOption) {
  39907. if (!zrUtil.isObject(axisOption)) {
  39908. return;
  39909. }
  39910. var parallelIndex = axisOption.parallelIndex || 0;
  39911. var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex];
  39912. if (parallelOption && parallelOption.parallelAxisDefault) {
  39913. zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false);
  39914. }
  39915. });
  39916. }
  39917. /***/ },
  39918. /* 248 */
  39919. /***/ function(module, exports, __webpack_require__) {
  39920. var List = __webpack_require__(98);
  39921. var zrUtil = __webpack_require__(4);
  39922. var SeriesModel = __webpack_require__(78);
  39923. var completeDimensions = __webpack_require__(110);
  39924. module.exports = SeriesModel.extend({
  39925. type: 'series.parallel',
  39926. dependencies: ['parallel'],
  39927. visualColorAccessPath: 'lineStyle.normal.color',
  39928. getInitialData: function (option, ecModel) {
  39929. var parallelModel = ecModel.getComponent(
  39930. 'parallel', this.get('parallelIndex')
  39931. );
  39932. var parallelAxisIndices = parallelModel.parallelAxisIndex;
  39933. var rawData = option.data;
  39934. var modelDims = parallelModel.dimensions;
  39935. var dataDims = generateDataDims(modelDims, rawData);
  39936. var dataDimsInfo = zrUtil.map(dataDims, function (dim, dimIndex) {
  39937. var modelDimsIndex = zrUtil.indexOf(modelDims, dim);
  39938. var axisModel = modelDimsIndex >= 0 && ecModel.getComponent(
  39939. 'parallelAxis', parallelAxisIndices[modelDimsIndex]
  39940. );
  39941. if (axisModel && axisModel.get('type') === 'category') {
  39942. translateCategoryValue(axisModel, dim, rawData);
  39943. return {name: dim, type: 'ordinal'};
  39944. }
  39945. else if (modelDimsIndex < 0) {
  39946. return completeDimensions.guessOrdinal(rawData, dimIndex)
  39947. ? {name: dim, type: 'ordinal'}
  39948. : dim;
  39949. }
  39950. else {
  39951. return dim;
  39952. }
  39953. });
  39954. var list = new List(dataDimsInfo, this);
  39955. list.initData(rawData);
  39956. // Anication is forbiden in progressive data mode.
  39957. if (this.option.progressive) {
  39958. this.option.animation = false;
  39959. }
  39960. return list;
  39961. },
  39962. /**
  39963. * User can get data raw indices on 'axisAreaSelected' event received.
  39964. *
  39965. * @public
  39966. * @param {string} activeState 'active' or 'inactive' or 'normal'
  39967. * @return {Array.<number>} Raw indices
  39968. */
  39969. getRawIndicesByActiveState: function (activeState) {
  39970. var coordSys = this.coordinateSystem;
  39971. var data = this.getData();
  39972. var indices = [];
  39973. coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
  39974. if (activeState === theActiveState) {
  39975. indices.push(data.getRawIndex(dataIndex));
  39976. }
  39977. });
  39978. return indices;
  39979. },
  39980. defaultOption: {
  39981. zlevel: 0, // 一级层叠
  39982. z: 2, // 二级层叠
  39983. coordinateSystem: 'parallel',
  39984. parallelIndex: 0,
  39985. label: {
  39986. normal: {
  39987. show: false
  39988. },
  39989. emphasis: {
  39990. show: false
  39991. }
  39992. },
  39993. inactiveOpacity: 0.05,
  39994. activeOpacity: 1,
  39995. lineStyle: {
  39996. normal: {
  39997. width: 1,
  39998. opacity: 0.45,
  39999. type: 'solid'
  40000. }
  40001. },
  40002. progressive: false, // 100
  40003. smooth: false,
  40004. animationEasing: 'linear'
  40005. }
  40006. });
  40007. function translateCategoryValue(axisModel, dim, rawData) {
  40008. var axisData = axisModel.get('data');
  40009. var numberDim = convertDimNameToNumber(dim);
  40010. if (axisData && axisData.length) {
  40011. zrUtil.each(rawData, function (dataItem) {
  40012. if (!dataItem) {
  40013. return;
  40014. }
  40015. // FIXME
  40016. // time consuming, should use hash?
  40017. var index = zrUtil.indexOf(axisData, dataItem[numberDim]);
  40018. dataItem[numberDim] = index >= 0 ? index : NaN;
  40019. });
  40020. }
  40021. // FIXME
  40022. // 如果没有设置axis data, 应自动算出,或者提示。
  40023. }
  40024. function convertDimNameToNumber(dimName) {
  40025. return +dimName.replace('dim', '');
  40026. }
  40027. function generateDataDims(modelDims, rawData) {
  40028. // parallelModel.dimension should not be regarded as data
  40029. // dimensions. Consider dimensions = ['dim4', 'dim2', 'dim6'];
  40030. // We detect max dim by parallelModel.dimensions and fist
  40031. // item in rawData arbitrarily.
  40032. var maxDimNum = 0;
  40033. zrUtil.each(modelDims, function (dimName) {
  40034. var numberDim = convertDimNameToNumber(dimName);
  40035. numberDim > maxDimNum && (maxDimNum = numberDim);
  40036. });
  40037. var firstItem = rawData[0];
  40038. if (firstItem && firstItem.length - 1 > maxDimNum) {
  40039. maxDimNum = firstItem.length - 1;
  40040. }
  40041. var dataDims = [];
  40042. for (var i = 0; i <= maxDimNum; i++) {
  40043. dataDims.push('dim' + i);
  40044. }
  40045. return dataDims;
  40046. }
  40047. /***/ },
  40048. /* 249 */
  40049. /***/ function(module, exports, __webpack_require__) {
  40050. var graphic = __webpack_require__(18);
  40051. var zrUtil = __webpack_require__(4);
  40052. var SMOOTH = 0.3;
  40053. var ParallelView = __webpack_require__(80).extend({
  40054. type: 'parallel',
  40055. init: function () {
  40056. /**
  40057. * @type {module:zrender/container/Group}
  40058. * @private
  40059. */
  40060. this._dataGroup = new graphic.Group();
  40061. this.group.add(this._dataGroup);
  40062. /**
  40063. * @type {module:echarts/data/List}
  40064. */
  40065. this._data;
  40066. },
  40067. /**
  40068. * @override
  40069. */
  40070. render: function (seriesModel, ecModel, api, payload) {
  40071. this._renderForNormal(seriesModel, payload);
  40072. // this[
  40073. // seriesModel.option.progressive
  40074. // ? '_renderForProgressive'
  40075. // : '_renderForNormal'
  40076. // ](seriesModel);
  40077. },
  40078. dispose: function () {},
  40079. /**
  40080. * @private
  40081. */
  40082. _renderForNormal: function (seriesModel, payload) {
  40083. var dataGroup = this._dataGroup;
  40084. var data = seriesModel.getData();
  40085. var oldData = this._data;
  40086. var coordSys = seriesModel.coordinateSystem;
  40087. var dimensions = coordSys.dimensions;
  40088. var option = seriesModel.option;
  40089. var smooth = option.smooth ? SMOOTH : null;
  40090. // Consider switch between progressive and not.
  40091. // oldData && oldData.__plProgressive && dataGroup.removeAll();
  40092. data.diff(oldData)
  40093. .add(add)
  40094. .update(update)
  40095. .remove(remove)
  40096. .execute();
  40097. // Update style
  40098. updateElCommon(data, smooth);
  40099. // First create
  40100. if (!this._data) {
  40101. var clipPath = createGridClipShape(
  40102. coordSys, seriesModel, function () {
  40103. // Callback will be invoked immediately if there is no animation
  40104. setTimeout(function () {
  40105. dataGroup.removeClipPath();
  40106. });
  40107. }
  40108. );
  40109. dataGroup.setClipPath(clipPath);
  40110. }
  40111. this._data = data;
  40112. function add(newDataIndex) {
  40113. addEl(data, dataGroup, newDataIndex, dimensions, coordSys, null, smooth);
  40114. }
  40115. function update(newDataIndex, oldDataIndex) {
  40116. var line = oldData.getItemGraphicEl(oldDataIndex);
  40117. var points = createLinePoints(data, newDataIndex, dimensions, coordSys);
  40118. data.setItemGraphicEl(newDataIndex, line);
  40119. var animationModel = (payload && payload.animation === false) ? null : seriesModel;
  40120. graphic.updateProps(line, {shape: {points: points}}, animationModel, newDataIndex);
  40121. }
  40122. function remove(oldDataIndex) {
  40123. var line = oldData.getItemGraphicEl(oldDataIndex);
  40124. dataGroup.remove(line);
  40125. }
  40126. },
  40127. /**
  40128. * @private
  40129. */
  40130. // _renderForProgressive: function (seriesModel) {
  40131. // var dataGroup = this._dataGroup;
  40132. // var data = seriesModel.getData();
  40133. // var oldData = this._data;
  40134. // var coordSys = seriesModel.coordinateSystem;
  40135. // var dimensions = coordSys.dimensions;
  40136. // var option = seriesModel.option;
  40137. // var progressive = option.progressive;
  40138. // var smooth = option.smooth ? SMOOTH : null;
  40139. // // In progressive animation is disabled, so use simple data diff,
  40140. // // which effects performance less.
  40141. // // (Typically performance for data with length 7000+ like:
  40142. // // simpleDiff: 60ms, addEl: 184ms,
  40143. // // in RMBP 2.4GHz intel i7, OSX 10.9 chrome 50.0.2661.102 (64-bit))
  40144. // if (simpleDiff(oldData, data, dimensions)) {
  40145. // dataGroup.removeAll();
  40146. // data.each(function (dataIndex) {
  40147. // addEl(data, dataGroup, dataIndex, dimensions, coordSys);
  40148. // });
  40149. // }
  40150. // updateElCommon(data, progressive, smooth);
  40151. // // Consider switch between progressive and not.
  40152. // data.__plProgressive = true;
  40153. // this._data = data;
  40154. // },
  40155. /**
  40156. * @override
  40157. */
  40158. remove: function () {
  40159. this._dataGroup && this._dataGroup.removeAll();
  40160. this._data = null;
  40161. }
  40162. });
  40163. function createGridClipShape(coordSys, seriesModel, cb) {
  40164. var parallelModel = coordSys.model;
  40165. var rect = coordSys.getRect();
  40166. var rectEl = new graphic.Rect({
  40167. shape: {
  40168. x: rect.x,
  40169. y: rect.y,
  40170. width: rect.width,
  40171. height: rect.height
  40172. }
  40173. });
  40174. var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height';
  40175. rectEl.setShape(dim, 0);
  40176. graphic.initProps(rectEl, {
  40177. shape: {
  40178. width: rect.width,
  40179. height: rect.height
  40180. }
  40181. }, seriesModel, cb);
  40182. return rectEl;
  40183. }
  40184. function createLinePoints(data, dataIndex, dimensions, coordSys) {
  40185. var points = [];
  40186. for (var i = 0; i < dimensions.length; i++) {
  40187. var dimName = dimensions[i];
  40188. var value = data.get(dimName, dataIndex);
  40189. if (!isEmptyValue(value, coordSys.getAxis(dimName).type)) {
  40190. points.push(coordSys.dataToPoint(value, dimName));
  40191. }
  40192. }
  40193. return points;
  40194. }
  40195. function addEl(data, dataGroup, dataIndex, dimensions, coordSys) {
  40196. var points = createLinePoints(data, dataIndex, dimensions, coordSys);
  40197. var line = new graphic.Polyline({
  40198. shape: {points: points},
  40199. silent: true,
  40200. z2: 10
  40201. });
  40202. dataGroup.add(line);
  40203. data.setItemGraphicEl(dataIndex, line);
  40204. }
  40205. function updateElCommon(data, smooth) {
  40206. var seriesStyleModel = data.hostModel.getModel('lineStyle.normal');
  40207. var lineStyle = seriesStyleModel.getLineStyle();
  40208. data.eachItemGraphicEl(function (line, dataIndex) {
  40209. if (data.hasItemOption) {
  40210. var itemModel = data.getItemModel(dataIndex);
  40211. var lineStyleModel = itemModel.getModel('lineStyle.normal', seriesStyleModel);
  40212. lineStyle = lineStyleModel.getLineStyle(['color', 'stroke']);
  40213. }
  40214. line.useStyle(zrUtil.extend(lineStyle, {
  40215. fill: null,
  40216. // lineStyle.color have been set to itemVisual in module:echarts/visual/seriesColor.
  40217. stroke: data.getItemVisual(dataIndex, 'color'),
  40218. // lineStyle.opacity have been set to itemVisual in parallelVisual.
  40219. opacity: data.getItemVisual(dataIndex, 'opacity')
  40220. }));
  40221. line.shape.smooth = smooth;
  40222. });
  40223. }
  40224. // function simpleDiff(oldData, newData, dimensions) {
  40225. // var oldLen;
  40226. // if (!oldData
  40227. // || !oldData.__plProgressive
  40228. // || (oldLen = oldData.count()) !== newData.count()
  40229. // ) {
  40230. // return true;
  40231. // }
  40232. // var dimLen = dimensions.length;
  40233. // for (var i = 0; i < oldLen; i++) {
  40234. // for (var j = 0; j < dimLen; j++) {
  40235. // if (oldData.get(dimensions[j], i) !== newData.get(dimensions[j], i)) {
  40236. // return true;
  40237. // }
  40238. // }
  40239. // }
  40240. // return false;
  40241. // }
  40242. // FIXME
  40243. // 公用方法?
  40244. function isEmptyValue(val, axisType) {
  40245. return axisType === 'category'
  40246. ? val == null
  40247. : (val == null || isNaN(val)); // axisType === 'value'
  40248. }
  40249. module.exports = ParallelView;
  40250. /***/ },
  40251. /* 250 */
  40252. /***/ function(module, exports) {
  40253. var opacityAccessPath = ['lineStyle', 'normal', 'opacity'];
  40254. module.exports = function (ecModel) {
  40255. ecModel.eachSeriesByType('parallel', function (seriesModel) {
  40256. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  40257. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  40258. var globalColors = ecModel.get('color');
  40259. var color = lineStyleModel.get('color')
  40260. || itemStyleModel.get('color')
  40261. || globalColors[seriesModel.seriesIndex % globalColors.length];
  40262. var inactiveOpacity = seriesModel.get('inactiveOpacity');
  40263. var activeOpacity = seriesModel.get('activeOpacity');
  40264. var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle();
  40265. var coordSys = seriesModel.coordinateSystem;
  40266. var data = seriesModel.getData();
  40267. var opacityMap = {
  40268. normal: lineStyle.opacity,
  40269. active: activeOpacity,
  40270. inactive: inactiveOpacity
  40271. };
  40272. coordSys.eachActiveState(data, function (activeState, dataIndex) {
  40273. var itemModel = data.getItemModel(dataIndex);
  40274. var opacity = opacityMap[activeState];
  40275. if (activeState === 'normal') {
  40276. var itemOpacity = itemModel.get(opacityAccessPath, true);
  40277. itemOpacity != null && (opacity = itemOpacity);
  40278. }
  40279. data.setItemVisual(dataIndex, 'opacity', opacity);
  40280. });
  40281. data.setVisual('color', color);
  40282. });
  40283. };
  40284. /***/ },
  40285. /* 251 */
  40286. /***/ function(module, exports, __webpack_require__) {
  40287. var echarts = __webpack_require__(1);
  40288. __webpack_require__(252);
  40289. __webpack_require__(253);
  40290. echarts.registerLayout(__webpack_require__(254));
  40291. echarts.registerVisual(__webpack_require__(256));
  40292. /***/ },
  40293. /* 252 */
  40294. /***/ function(module, exports, __webpack_require__) {
  40295. /**
  40296. * @file Get initial data and define sankey view's series model
  40297. * @author Deqing Li(annong035@gmail.com)
  40298. */
  40299. var SeriesModel = __webpack_require__(78);
  40300. var createGraphFromNodeEdge = __webpack_require__(207);
  40301. var encodeHTML = __webpack_require__(6).encodeHTML;
  40302. var SankeySeries = SeriesModel.extend({
  40303. type: 'series.sankey',
  40304. layoutInfo: null,
  40305. /**
  40306. * Init a graph data structure from data in option series
  40307. *
  40308. * @param {Object} option the object used to config echarts view
  40309. * @return {module:echarts/data/List} storage initial data
  40310. */
  40311. getInitialData: function (option) {
  40312. var links = option.edges || option.links;
  40313. var nodes = option.data || option.nodes;
  40314. if (nodes && links) {
  40315. var graph = createGraphFromNodeEdge(nodes, links, this, true);
  40316. return graph.data;
  40317. }
  40318. },
  40319. /**
  40320. * Return the graphic data structure
  40321. *
  40322. * @return {module:echarts/data/Graph} graphic data structure
  40323. */
  40324. getGraph: function () {
  40325. return this.getData().graph;
  40326. },
  40327. /**
  40328. * Get edge data of graphic data structure
  40329. *
  40330. * @return {module:echarts/data/List} data structure of list
  40331. */
  40332. getEdgeData: function () {
  40333. return this.getGraph().edgeData;
  40334. },
  40335. /**
  40336. * @override
  40337. */
  40338. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  40339. // dataType === 'node' or empty do not show tooltip by default
  40340. if (dataType === 'edge') {
  40341. var params = this.getDataParams(dataIndex, dataType);
  40342. var rawDataOpt = params.data;
  40343. var html = rawDataOpt.source + ' -- ' + rawDataOpt.target;
  40344. if (params.value) {
  40345. html += ' : ' + params.value;
  40346. }
  40347. return encodeHTML(html);
  40348. }
  40349. return SankeySeries.superCall(this, 'formatTooltip', dataIndex, multipleSeries);
  40350. },
  40351. defaultOption: {
  40352. zlevel: 0,
  40353. z: 2,
  40354. coordinateSystem: 'view',
  40355. layout: null,
  40356. // the position of the whole view
  40357. left: '5%',
  40358. top: '5%',
  40359. right: '20%',
  40360. bottom: '5%',
  40361. // the dx of the node
  40362. nodeWidth: 20,
  40363. // the vertical distance between two nodes
  40364. nodeGap: 8,
  40365. // the number of iterations to change the position of the node
  40366. layoutIterations: 32,
  40367. label: {
  40368. normal: {
  40369. show: true,
  40370. position: 'right',
  40371. textStyle: {
  40372. color: '#000',
  40373. fontSize: 12
  40374. }
  40375. },
  40376. emphasis: {
  40377. show: true
  40378. }
  40379. },
  40380. itemStyle: {
  40381. normal: {
  40382. borderWidth: 1,
  40383. borderColor: '#333'
  40384. }
  40385. },
  40386. lineStyle: {
  40387. normal: {
  40388. color: '#314656',
  40389. opacity: 0.2,
  40390. curveness: 0.5
  40391. },
  40392. emphasis: {
  40393. opacity: 0.6
  40394. }
  40395. },
  40396. animationEasing: 'linear',
  40397. animationDuration: 1000
  40398. }
  40399. });
  40400. module.exports = SankeySeries;
  40401. /***/ },
  40402. /* 253 */
  40403. /***/ function(module, exports, __webpack_require__) {
  40404. /**
  40405. * @file The file used to draw sankey view
  40406. * @author Deqing Li(annong035@gmail.com)
  40407. */
  40408. var graphic = __webpack_require__(18);
  40409. var zrUtil = __webpack_require__(4);
  40410. var SankeyShape = graphic.extendShape({
  40411. shape: {
  40412. x1: 0, y1: 0,
  40413. x2: 0, y2: 0,
  40414. cpx1: 0, cpy1: 0,
  40415. cpx2: 0, cpy2: 0,
  40416. extent: 0
  40417. },
  40418. buildPath: function (ctx, shape) {
  40419. var halfExtent = shape.extent / 2;
  40420. ctx.moveTo(shape.x1, shape.y1 - halfExtent);
  40421. ctx.bezierCurveTo(
  40422. shape.cpx1, shape.cpy1 - halfExtent,
  40423. shape.cpx2, shape.cpy2 - halfExtent,
  40424. shape.x2, shape.y2 - halfExtent
  40425. );
  40426. ctx.lineTo(shape.x2, shape.y2 + halfExtent);
  40427. ctx.bezierCurveTo(
  40428. shape.cpx2, shape.cpy2 + halfExtent,
  40429. shape.cpx1, shape.cpy1 + halfExtent,
  40430. shape.x1, shape.y1 + halfExtent
  40431. );
  40432. ctx.closePath();
  40433. }
  40434. });
  40435. module.exports = __webpack_require__(1).extendChartView({
  40436. type: 'sankey',
  40437. /**
  40438. * @private
  40439. * @type {module:echarts/chart/sankey/SankeySeries}
  40440. */
  40441. _model: null,
  40442. render: function (seriesModel, ecModel, api) {
  40443. var graph = seriesModel.getGraph();
  40444. var group = this.group;
  40445. var layoutInfo = seriesModel.layoutInfo;
  40446. var nodeData = seriesModel.getData();
  40447. var edgeData = seriesModel.getData('edge');
  40448. this._model = seriesModel;
  40449. group.removeAll();
  40450. group.position = [layoutInfo.x, layoutInfo.y];
  40451. // generate a bezire Curve for each edge
  40452. graph.eachEdge(function (edge) {
  40453. var curve = new SankeyShape();
  40454. curve.dataIndex = edge.dataIndex;
  40455. curve.seriesIndex = seriesModel.seriesIndex;
  40456. curve.dataType = 'edge';
  40457. var lineStyleModel = edge.getModel('lineStyle.normal');
  40458. var curvature = lineStyleModel.get('curveness');
  40459. var n1Layout = edge.node1.getLayout();
  40460. var n2Layout = edge.node2.getLayout();
  40461. var edgeLayout = edge.getLayout();
  40462. curve.shape.extent = Math.max(1, edgeLayout.dy);
  40463. var x1 = n1Layout.x + n1Layout.dx;
  40464. var y1 = n1Layout.y + edgeLayout.sy + edgeLayout.dy / 2;
  40465. var x2 = n2Layout.x;
  40466. var y2 = n2Layout.y + edgeLayout.ty + edgeLayout.dy / 2;
  40467. var cpx1 = x1 * (1 - curvature) + x2 * curvature;
  40468. var cpy1 = y1;
  40469. var cpx2 = x1 * curvature + x2 * (1 - curvature);
  40470. var cpy2 = y2;
  40471. curve.setShape({
  40472. x1: x1,
  40473. y1: y1,
  40474. x2: x2,
  40475. y2: y2,
  40476. cpx1: cpx1,
  40477. cpy1: cpy1,
  40478. cpx2: cpx2,
  40479. cpy2: cpy2
  40480. });
  40481. curve.setStyle(lineStyleModel.getItemStyle());
  40482. // Special color, use source node color or target node color
  40483. switch (curve.style.fill) {
  40484. case 'source':
  40485. curve.style.fill = edge.node1.getVisual('color');
  40486. break;
  40487. case 'target':
  40488. curve.style.fill = edge.node2.getVisual('color');
  40489. break;
  40490. }
  40491. graphic.setHoverStyle(curve, edge.getModel('lineStyle.emphasis').getItemStyle());
  40492. group.add(curve);
  40493. edgeData.setItemGraphicEl(edge.dataIndex, curve);
  40494. });
  40495. // generate a rect for each node
  40496. graph.eachNode(function (node) {
  40497. var layout = node.getLayout();
  40498. var itemModel = node.getModel();
  40499. var labelModel = itemModel.getModel('label.normal');
  40500. var textStyleModel = labelModel.getModel('textStyle');
  40501. var labelHoverModel = itemModel.getModel('label.emphasis');
  40502. var textStyleHoverModel = labelHoverModel.getModel('textStyle');
  40503. var rect = new graphic.Rect({
  40504. shape: {
  40505. x: layout.x,
  40506. y: layout.y,
  40507. width: node.getLayout().dx,
  40508. height: node.getLayout().dy
  40509. },
  40510. style: {
  40511. // Get formatted label in label.normal option
  40512. // Use node id if it is not specified
  40513. text: labelModel.get('show')
  40514. ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id
  40515. // Use empty string to hide the label
  40516. : '',
  40517. textFont: textStyleModel.getFont(),
  40518. textFill: textStyleModel.getTextColor(),
  40519. textPosition: labelModel.get('position')
  40520. }
  40521. });
  40522. rect.setStyle(zrUtil.defaults(
  40523. {
  40524. fill: node.getVisual('color')
  40525. },
  40526. itemModel.getModel('itemStyle.normal').getItemStyle()
  40527. ));
  40528. graphic.setHoverStyle(rect, zrUtil.extend(
  40529. node.getModel('itemStyle.emphasis'),
  40530. {
  40531. text: labelHoverModel.get('show')
  40532. ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id
  40533. : '',
  40534. textFont: textStyleHoverModel.getFont(),
  40535. textFill: textStyleHoverModel.getTextColor(),
  40536. textPosition: labelHoverModel.get('position')
  40537. }
  40538. ));
  40539. group.add(rect);
  40540. nodeData.setItemGraphicEl(node.dataIndex, rect);
  40541. rect.dataType = 'node';
  40542. });
  40543. if (!this._data && seriesModel.get('animation')) {
  40544. group.setClipPath(createGridClipShape(group.getBoundingRect(), seriesModel, function () {
  40545. group.removeClipPath();
  40546. }));
  40547. }
  40548. this._data = seriesModel.getData();
  40549. },
  40550. dispose: function () {}
  40551. });
  40552. // add animation to the view
  40553. function createGridClipShape(rect, seriesModel, cb) {
  40554. var rectEl = new graphic.Rect({
  40555. shape: {
  40556. x: rect.x - 10,
  40557. y: rect.y - 10,
  40558. width: 0,
  40559. height: rect.height + 20
  40560. }
  40561. });
  40562. graphic.initProps(rectEl, {
  40563. shape: {
  40564. width: rect.width + 20,
  40565. height: rect.height + 20
  40566. }
  40567. }, seriesModel, cb);
  40568. return rectEl;
  40569. }
  40570. /***/ },
  40571. /* 254 */
  40572. /***/ function(module, exports, __webpack_require__) {
  40573. /**
  40574. * @file The layout algorithm of sankey view
  40575. * @author Deqing Li(annong035@gmail.com)
  40576. */
  40577. var layout = __webpack_require__(71);
  40578. var nest = __webpack_require__(255);
  40579. var zrUtil = __webpack_require__(4);
  40580. module.exports = function (ecModel, api, payload) {
  40581. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  40582. var nodeWidth = seriesModel.get('nodeWidth');
  40583. var nodeGap = seriesModel.get('nodeGap');
  40584. var layoutInfo = getViewRect(seriesModel, api);
  40585. seriesModel.layoutInfo = layoutInfo;
  40586. var width = layoutInfo.width;
  40587. var height = layoutInfo.height;
  40588. var graph = seriesModel.getGraph();
  40589. var nodes = graph.nodes;
  40590. var edges = graph.edges;
  40591. computeNodeValues(nodes);
  40592. var filteredNodes = zrUtil.filter(nodes, function (node) {
  40593. return node.getLayout().value === 0;
  40594. });
  40595. var iterations = filteredNodes.length !== 0
  40596. ? 0 : seriesModel.get('layoutIterations');
  40597. layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations);
  40598. });
  40599. };
  40600. /**
  40601. * Get the layout position of the whole view
  40602. *
  40603. * @param {module:echarts/model/Series} seriesModel the model object of sankey series
  40604. * @param {module:echarts/ExtensionAPI} api provide the API list that the developer can call
  40605. * @return {module:zrender/core/BoundingRect} size of rect to draw the sankey view
  40606. */
  40607. function getViewRect(seriesModel, api) {
  40608. return layout.getLayoutRect(
  40609. seriesModel.getBoxLayoutParams(), {
  40610. width: api.getWidth(),
  40611. height: api.getHeight()
  40612. }
  40613. );
  40614. }
  40615. function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations) {
  40616. computeNodeBreadths(nodes, nodeWidth, width);
  40617. computeNodeDepths(nodes, edges, height, nodeGap, iterations);
  40618. computeEdgeDepths(nodes);
  40619. }
  40620. /**
  40621. * Compute the value of each node by summing the associated edge's value
  40622. *
  40623. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  40624. */
  40625. function computeNodeValues(nodes) {
  40626. zrUtil.each(nodes, function (node) {
  40627. var value1 = sum(node.outEdges, getEdgeValue);
  40628. var value2 = sum(node.inEdges, getEdgeValue);
  40629. var value = Math.max(value1, value2);
  40630. node.setLayout({value: value}, true);
  40631. });
  40632. }
  40633. /**
  40634. * Compute the x-position for each node
  40635. *
  40636. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  40637. * @param {number} nodeWidth the dx of the node
  40638. * @param {number} width the whole width of the area to draw the view
  40639. */
  40640. function computeNodeBreadths(nodes, nodeWidth, width) {
  40641. var remainNodes = nodes;
  40642. var nextNode = null;
  40643. var x = 0;
  40644. var kx = 0;
  40645. while (remainNodes.length) {
  40646. nextNode = [];
  40647. for (var i = 0, len = remainNodes.length; i < len; i++) {
  40648. var node = remainNodes[i];
  40649. node.setLayout({x: x}, true);
  40650. node.setLayout({dx: nodeWidth}, true);
  40651. for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) {
  40652. nextNode.push(node.outEdges[j].node2);
  40653. }
  40654. }
  40655. remainNodes = nextNode;
  40656. ++x;
  40657. }
  40658. moveSinksRight(nodes, x);
  40659. kx = (width - nodeWidth) / (x - 1);
  40660. scaleNodeBreadths(nodes, kx);
  40661. }
  40662. /**
  40663. * All the node without outEgdes are assigned maximum x-position and
  40664. * be aligned in the last column.
  40665. *
  40666. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  40667. * @param {number} x value (x-1) use to assign to node without outEdges
  40668. * as x-position
  40669. */
  40670. function moveSinksRight(nodes, x) {
  40671. zrUtil.each(nodes, function (node) {
  40672. if (!node.outEdges.length) {
  40673. node.setLayout({x: x - 1}, true);
  40674. }
  40675. });
  40676. }
  40677. /**
  40678. * Scale node x-position to the width
  40679. *
  40680. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  40681. * @param {number} kx multiple used to scale nodes
  40682. */
  40683. function scaleNodeBreadths(nodes, kx) {
  40684. zrUtil.each(nodes, function (node) {
  40685. var nodeX = node.getLayout().x * kx;
  40686. node.setLayout({x: nodeX}, true);
  40687. });
  40688. }
  40689. /**
  40690. * Using Gauss-Seidel iterations method to compute the node depth(y-position)
  40691. *
  40692. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  40693. * @param {module:echarts/data/Graph~Edge} edges edge of sankey view
  40694. * @param {number} height the whole height of the area to draw the view
  40695. * @param {numbber} nodeGap the vertical distance between two nodes
  40696. * in the same column.
  40697. * @param {number} iterations the number of iterations for the algorithm
  40698. */
  40699. function computeNodeDepths(nodes, edges, height, nodeGap, iterations) {
  40700. var nodesByBreadth = nest()
  40701. .key(function (d) {
  40702. return d.getLayout().x;
  40703. })
  40704. .sortKeys(ascending)
  40705. .entries(nodes)
  40706. .map(function (d) {
  40707. return d.values;
  40708. });
  40709. initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap);
  40710. resolveCollisions(nodesByBreadth, nodeGap, height);
  40711. for (var alpha = 1; iterations > 0; iterations--) {
  40712. // 0.99 is a experience parameter, ensure that each iterations of
  40713. // changes as small as possible.
  40714. alpha *= 0.99;
  40715. relaxRightToLeft(nodesByBreadth, alpha);
  40716. resolveCollisions(nodesByBreadth, nodeGap, height);
  40717. relaxLeftToRight(nodesByBreadth, alpha);
  40718. resolveCollisions(nodesByBreadth, nodeGap, height);
  40719. }
  40720. }
  40721. /**
  40722. * Compute the original y-position for each node
  40723. *
  40724. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  40725. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  40726. * group by the array of all sankey nodes based on the nodes x-position.
  40727. * @param {module:echarts/data/Graph~Edge} edges edge of sankey view
  40728. * @param {number} height the whole height of the area to draw the view
  40729. * @param {number} nodeGap the vertical distance between two nodes
  40730. */
  40731. function initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap) {
  40732. var kyArray = [];
  40733. zrUtil.each(nodesByBreadth, function (nodes) {
  40734. var n = nodes.length;
  40735. var sum = 0;
  40736. zrUtil.each(nodes, function (node) {
  40737. sum += node.getLayout().value;
  40738. });
  40739. var ky = (height - (n - 1) * nodeGap) / sum;
  40740. kyArray.push(ky);
  40741. });
  40742. kyArray.sort(function (a, b) {
  40743. return a - b;
  40744. });
  40745. var ky0 = kyArray[0];
  40746. zrUtil.each(nodesByBreadth, function (nodes) {
  40747. zrUtil.each(nodes, function (node, i) {
  40748. node.setLayout({y: i}, true);
  40749. var nodeDy = node.getLayout().value * ky0;
  40750. node.setLayout({dy: nodeDy}, true);
  40751. });
  40752. });
  40753. zrUtil.each(edges, function (edge) {
  40754. var edgeDy = +edge.getValue() * ky0;
  40755. edge.setLayout({dy: edgeDy}, true);
  40756. });
  40757. }
  40758. /**
  40759. * Resolve the collision of initialized depth (y-position)
  40760. *
  40761. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  40762. * group by the array of all sankey nodes based on the nodes x-position.
  40763. * @param {number} nodeGap the vertical distance between two nodes
  40764. * @param {number} height the whole height of the area to draw the view
  40765. */
  40766. function resolveCollisions(nodesByBreadth, nodeGap, height) {
  40767. zrUtil.each(nodesByBreadth, function (nodes) {
  40768. var node;
  40769. var dy;
  40770. var y0 = 0;
  40771. var n = nodes.length;
  40772. var i;
  40773. nodes.sort(ascendingDepth);
  40774. for (i = 0; i < n; i++) {
  40775. node = nodes[i];
  40776. dy = y0 - node.getLayout().y;
  40777. if (dy > 0) {
  40778. var nodeY = node.getLayout().y + dy;
  40779. node.setLayout({y: nodeY}, true);
  40780. }
  40781. y0 = node.getLayout().y + node.getLayout().dy + nodeGap;
  40782. }
  40783. // if the bottommost node goes outside the bounds, push it back up
  40784. dy = y0 - nodeGap - height;
  40785. if (dy > 0) {
  40786. var nodeY = node.getLayout().y - dy;
  40787. node.setLayout({y: nodeY}, true);
  40788. y0 = node.getLayout().y;
  40789. for (i = n - 2; i >= 0; --i) {
  40790. node = nodes[i];
  40791. dy = node.getLayout().y + node.getLayout().dy + nodeGap - y0;
  40792. if (dy > 0) {
  40793. nodeY = node.getLayout().y - dy;
  40794. node.setLayout({y: nodeY}, true);
  40795. }
  40796. y0 = node.getLayout().y;
  40797. }
  40798. }
  40799. });
  40800. }
  40801. /**
  40802. * Change the y-position of the nodes, except most the right side nodes
  40803. *
  40804. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  40805. * group by the array of all sankey nodes based on the node x-position.
  40806. * @param {number} alpha parameter used to adjust the nodes y-position
  40807. */
  40808. function relaxRightToLeft(nodesByBreadth, alpha) {
  40809. zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) {
  40810. zrUtil.each(nodes, function (node) {
  40811. if (node.outEdges.length) {
  40812. var y = sum(node.outEdges, weightedTarget) / sum(node.outEdges, getEdgeValue);
  40813. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  40814. node.setLayout({y: nodeY}, true);
  40815. }
  40816. });
  40817. });
  40818. }
  40819. function weightedTarget(edge) {
  40820. return center(edge.node2) * edge.getValue();
  40821. }
  40822. /**
  40823. * Change the y-position of the nodes, except most the left side nodes
  40824. *
  40825. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  40826. * group by the array of all sankey nodes based on the node x-position.
  40827. * @param {number} alpha parameter used to adjust the nodes y-position
  40828. */
  40829. function relaxLeftToRight(nodesByBreadth, alpha) {
  40830. zrUtil.each(nodesByBreadth, function (nodes) {
  40831. zrUtil.each(nodes, function (node) {
  40832. if (node.inEdges.length) {
  40833. var y = sum(node.inEdges, weightedSource) / sum(node.inEdges, getEdgeValue);
  40834. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  40835. node.setLayout({y: nodeY}, true);
  40836. }
  40837. });
  40838. });
  40839. }
  40840. function weightedSource(edge) {
  40841. return center(edge.node1) * edge.getValue();
  40842. }
  40843. /**
  40844. * Compute the depth(y-position) of each edge
  40845. *
  40846. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  40847. */
  40848. function computeEdgeDepths(nodes) {
  40849. zrUtil.each(nodes, function (node) {
  40850. node.outEdges.sort(ascendingTargetDepth);
  40851. node.inEdges.sort(ascendingSourceDepth);
  40852. });
  40853. zrUtil.each(nodes, function (node) {
  40854. var sy = 0;
  40855. var ty = 0;
  40856. zrUtil.each(node.outEdges, function (edge) {
  40857. edge.setLayout({sy: sy}, true);
  40858. sy += edge.getLayout().dy;
  40859. });
  40860. zrUtil.each(node.inEdges, function (edge) {
  40861. edge.setLayout({ty: ty}, true);
  40862. ty += edge.getLayout().dy;
  40863. });
  40864. });
  40865. }
  40866. function ascendingTargetDepth(a, b) {
  40867. return a.node2.getLayout().y - b.node2.getLayout().y;
  40868. }
  40869. function ascendingSourceDepth(a, b) {
  40870. return a.node1.getLayout().y - b.node1.getLayout().y;
  40871. }
  40872. function sum(array, f) {
  40873. var sum = 0;
  40874. var len = array.length;
  40875. var i = -1;
  40876. while (++i < len) {
  40877. var value = +f.call(array, array[i], i);
  40878. if (!isNaN(value)) {
  40879. sum += value;
  40880. }
  40881. }
  40882. return sum;
  40883. }
  40884. function center(node) {
  40885. return node.getLayout().y + node.getLayout().dy / 2;
  40886. }
  40887. function ascendingDepth(a, b) {
  40888. return a.getLayout().y - b.getLayout().y;
  40889. }
  40890. function ascending(a, b) {
  40891. return a < b ? -1 : a > b ? 1 : a === b ? 0 : NaN;
  40892. }
  40893. function getEdgeValue(edge) {
  40894. return edge.getValue();
  40895. }
  40896. /***/ },
  40897. /* 255 */
  40898. /***/ function(module, exports, __webpack_require__) {
  40899. var zrUtil = __webpack_require__(4);
  40900. /**
  40901. * nest helper used to group by the array.
  40902. * can specified the keys and sort the keys.
  40903. */
  40904. function nest() {
  40905. var keysFunction = [];
  40906. var sortKeysFunction = [];
  40907. /**
  40908. * map an Array into the mapObject.
  40909. * @param {Array} array
  40910. * @param {number} depth
  40911. */
  40912. function map(array, depth) {
  40913. if (depth >= keysFunction.length) {
  40914. return array;
  40915. }
  40916. var i = -1;
  40917. var n = array.length;
  40918. var keyFunction = keysFunction[depth++];
  40919. var mapObject = {};
  40920. var valuesByKey = {};
  40921. while (++i < n) {
  40922. var keyValue = keyFunction(array[i]);
  40923. var values = valuesByKey[keyValue];
  40924. if (values) {
  40925. values.push(array[i]);
  40926. }
  40927. else {
  40928. valuesByKey[keyValue] = [array[i]];
  40929. }
  40930. }
  40931. zrUtil.each(valuesByKey, function (value, key) {
  40932. mapObject[key] = map(value, depth);
  40933. });
  40934. return mapObject;
  40935. }
  40936. /**
  40937. * transform the Map Object to multidimensional Array
  40938. * @param {Object} map
  40939. * @param {number} depth
  40940. */
  40941. function entriesMap(mapObject, depth) {
  40942. if (depth >= keysFunction.length) {
  40943. return mapObject;
  40944. }
  40945. var array = [];
  40946. var sortKeyFunction = sortKeysFunction[depth++];
  40947. zrUtil.each(mapObject, function (value, key) {
  40948. array.push({
  40949. key: key, values: entriesMap(value, depth)
  40950. });
  40951. });
  40952. if (sortKeyFunction) {
  40953. return array.sort(function (a, b) {
  40954. return sortKeyFunction(a.key, b.key);
  40955. });
  40956. }
  40957. else {
  40958. return array;
  40959. }
  40960. }
  40961. return {
  40962. /**
  40963. * specified the key to groupby the arrays.
  40964. * users can specified one more keys.
  40965. * @param {Function} d
  40966. */
  40967. key: function (d) {
  40968. keysFunction.push(d);
  40969. return this;
  40970. },
  40971. /**
  40972. * specified the comparator to sort the keys
  40973. * @param {Function} order
  40974. */
  40975. sortKeys: function (order) {
  40976. sortKeysFunction[keysFunction.length - 1] = order;
  40977. return this;
  40978. },
  40979. /**
  40980. * the array to be grouped by.
  40981. * @param {Array} array
  40982. */
  40983. entries: function (array) {
  40984. return entriesMap(map(array, 0), 0);
  40985. }
  40986. };
  40987. }
  40988. module.exports = nest;
  40989. /***/ },
  40990. /* 256 */
  40991. /***/ function(module, exports, __webpack_require__) {
  40992. /**
  40993. * @file Visual encoding for sankey view
  40994. * @author Deqing Li(annong035@gmail.com)
  40995. */
  40996. var VisualMapping = __webpack_require__(203);
  40997. var zrUtil = __webpack_require__(4);
  40998. module.exports = function (ecModel, payload) {
  40999. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  41000. var graph = seriesModel.getGraph();
  41001. var nodes = graph.nodes;
  41002. nodes.sort(function (a, b) {
  41003. return a.getLayout().value - b.getLayout().value;
  41004. });
  41005. var minValue = nodes[0].getLayout().value;
  41006. var maxValue = nodes[nodes.length - 1].getLayout().value;
  41007. zrUtil.each(nodes, function (node) {
  41008. var mapping = new VisualMapping({
  41009. type: 'color',
  41010. mappingMethod: 'linear',
  41011. dataExtent: [minValue, maxValue],
  41012. visual: seriesModel.get('color')
  41013. });
  41014. var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value);
  41015. node.setVisual('color', mapValueToColor);
  41016. // If set itemStyle.normal.color
  41017. var itemModel = node.getModel();
  41018. var customColor = itemModel.get('itemStyle.normal.color');
  41019. if (customColor != null) {
  41020. node.setVisual('color', customColor);
  41021. }
  41022. });
  41023. });
  41024. };
  41025. /***/ },
  41026. /* 257 */
  41027. /***/ function(module, exports, __webpack_require__) {
  41028. var echarts = __webpack_require__(1);
  41029. __webpack_require__(258);
  41030. __webpack_require__(261);
  41031. echarts.registerVisual(__webpack_require__(262));
  41032. echarts.registerLayout(__webpack_require__(263));
  41033. /***/ },
  41034. /* 258 */
  41035. /***/ function(module, exports, __webpack_require__) {
  41036. 'use strict';
  41037. var zrUtil = __webpack_require__(4);
  41038. var SeriesModel = __webpack_require__(78);
  41039. var whiskerBoxCommon = __webpack_require__(259);
  41040. var BoxplotSeries = SeriesModel.extend({
  41041. type: 'series.boxplot',
  41042. dependencies: ['xAxis', 'yAxis', 'grid'],
  41043. // TODO
  41044. // box width represents group size, so dimension should have 'size'.
  41045. /**
  41046. * @see <https://en.wikipedia.org/wiki/Box_plot>
  41047. * The meanings of 'min' and 'max' depend on user,
  41048. * and echarts do not need to know it.
  41049. * @readOnly
  41050. */
  41051. defaultValueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'],
  41052. /**
  41053. * @type {Array.<string>}
  41054. * @readOnly
  41055. */
  41056. dimensions: null,
  41057. /**
  41058. * @override
  41059. */
  41060. defaultOption: {
  41061. zlevel: 0, // 一级层叠
  41062. z: 2, // 二级层叠
  41063. coordinateSystem: 'cartesian2d',
  41064. legendHoverLink: true,
  41065. hoverAnimation: true,
  41066. // xAxisIndex: 0,
  41067. // yAxisIndex: 0,
  41068. layout: null, // 'horizontal' or 'vertical'
  41069. boxWidth: [7, 50], // [min, max] can be percent of band width.
  41070. itemStyle: {
  41071. normal: {
  41072. color: '#fff',
  41073. borderWidth: 1
  41074. },
  41075. emphasis: {
  41076. borderWidth: 2,
  41077. shadowBlur: 5,
  41078. shadowOffsetX: 2,
  41079. shadowOffsetY: 2,
  41080. shadowColor: 'rgba(0,0,0,0.4)'
  41081. }
  41082. },
  41083. animationEasing: 'elasticOut',
  41084. animationDuration: 800
  41085. }
  41086. });
  41087. zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true);
  41088. module.exports = BoxplotSeries;
  41089. /***/ },
  41090. /* 259 */
  41091. /***/ function(module, exports, __webpack_require__) {
  41092. 'use strict';
  41093. var List = __webpack_require__(98);
  41094. var completeDimensions = __webpack_require__(110);
  41095. var WhiskerBoxDraw = __webpack_require__(260);
  41096. var zrUtil = __webpack_require__(4);
  41097. var seriesModelMixin = {
  41098. /**
  41099. * @private
  41100. * @type {string}
  41101. */
  41102. _baseAxisDim: null,
  41103. /**
  41104. * @override
  41105. */
  41106. getInitialData: function (option, ecModel) {
  41107. // When both types of xAxis and yAxis are 'value', layout is
  41108. // needed to be specified by user. Otherwise, layout can be
  41109. // judged by which axis is category.
  41110. var categories;
  41111. var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
  41112. var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
  41113. var xAxisType = xAxisModel.get('type');
  41114. var yAxisType = yAxisModel.get('type');
  41115. var addOrdinal;
  41116. // FIXME
  41117. // 考虑时间轴
  41118. if (xAxisType === 'category') {
  41119. option.layout = 'horizontal';
  41120. categories = xAxisModel.getCategories();
  41121. addOrdinal = true;
  41122. }
  41123. else if (yAxisType === 'category') {
  41124. option.layout = 'vertical';
  41125. categories = yAxisModel.getCategories();
  41126. addOrdinal = true;
  41127. }
  41128. else {
  41129. option.layout = option.layout || 'horizontal';
  41130. }
  41131. var coordDims = ['x', 'y'];
  41132. var baseAxisDimIndex = option.layout === 'horizontal' ? 0 : 1;
  41133. var baseAxisDim = this._baseAxisDim = coordDims[baseAxisDimIndex];
  41134. var otherAxisDim = coordDims[1 - baseAxisDimIndex];
  41135. var data = option.data;
  41136. addOrdinal && zrUtil.each(data, function (item, index) {
  41137. zrUtil.isArray(item) && item.unshift(index);
  41138. });
  41139. var dimensions = [{
  41140. name: baseAxisDim,
  41141. otherDims: {
  41142. tooltip: false
  41143. },
  41144. dimsDef: ['base']
  41145. }, {
  41146. name: otherAxisDim,
  41147. dimsDef: this.defaultValueDimensions.slice()
  41148. }];
  41149. dimensions = completeDimensions(dimensions, data, {
  41150. encodeDef: this.get('encode'),
  41151. dimsDef: this.get('dimensions')
  41152. });
  41153. var list = new List(dimensions, this);
  41154. list.initData(data, categories ? categories.slice() : null);
  41155. return list;
  41156. },
  41157. /**
  41158. * If horizontal, base axis is x, otherwise y.
  41159. * @override
  41160. */
  41161. getBaseAxis: function () {
  41162. var dim = this._baseAxisDim;
  41163. return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
  41164. }
  41165. };
  41166. var viewMixin = {
  41167. init: function () {
  41168. /**
  41169. * Old data.
  41170. * @private
  41171. * @type {module:echarts/chart/helper/WhiskerBoxDraw}
  41172. */
  41173. var whiskerBoxDraw = this._whiskerBoxDraw = new WhiskerBoxDraw(
  41174. this.getStyleUpdater()
  41175. );
  41176. this.group.add(whiskerBoxDraw.group);
  41177. },
  41178. render: function (seriesModel, ecModel, api) {
  41179. this._whiskerBoxDraw.updateData(seriesModel.getData());
  41180. },
  41181. remove: function (ecModel) {
  41182. this._whiskerBoxDraw.remove();
  41183. }
  41184. };
  41185. module.exports = {
  41186. seriesModelMixin: seriesModelMixin,
  41187. viewMixin: viewMixin
  41188. };
  41189. /***/ },
  41190. /* 260 */
  41191. /***/ function(module, exports, __webpack_require__) {
  41192. /**
  41193. * @module echarts/chart/helper/Symbol
  41194. */
  41195. var zrUtil = __webpack_require__(4);
  41196. var graphic = __webpack_require__(18);
  41197. var Path = __webpack_require__(20);
  41198. var WhiskerPath = Path.extend({
  41199. type: 'whiskerInBox',
  41200. shape: {},
  41201. buildPath: function (ctx, shape) {
  41202. for (var i in shape) {
  41203. if (shape.hasOwnProperty(i) && i.indexOf('ends') === 0) {
  41204. var pts = shape[i];
  41205. ctx.moveTo(pts[0][0], pts[0][1]);
  41206. ctx.lineTo(pts[1][0], pts[1][1]);
  41207. }
  41208. }
  41209. }
  41210. });
  41211. /**
  41212. * @constructor
  41213. * @alias {module:echarts/chart/helper/WhiskerBox}
  41214. * @param {module:echarts/data/List} data
  41215. * @param {number} idx
  41216. * @param {Function} styleUpdater
  41217. * @param {boolean} isInit
  41218. * @extends {module:zrender/graphic/Group}
  41219. */
  41220. function WhiskerBox(data, idx, styleUpdater, isInit) {
  41221. graphic.Group.call(this);
  41222. /**
  41223. * @type {number}
  41224. * @readOnly
  41225. */
  41226. this.bodyIndex;
  41227. /**
  41228. * @type {number}
  41229. * @readOnly
  41230. */
  41231. this.whiskerIndex;
  41232. /**
  41233. * @type {Function}
  41234. */
  41235. this.styleUpdater = styleUpdater;
  41236. this._createContent(data, idx, isInit);
  41237. this.updateData(data, idx, isInit);
  41238. /**
  41239. * Last series model.
  41240. * @type {module:echarts/model/Series}
  41241. */
  41242. this._seriesModel;
  41243. }
  41244. var whiskerBoxProto = WhiskerBox.prototype;
  41245. whiskerBoxProto._createContent = function (data, idx, isInit) {
  41246. var itemLayout = data.getItemLayout(idx);
  41247. var constDim = itemLayout.chartLayout === 'horizontal' ? 1 : 0;
  41248. var count = 0;
  41249. // Whisker element.
  41250. this.add(new graphic.Polygon({
  41251. shape: {
  41252. points: isInit
  41253. ? transInit(itemLayout.bodyEnds, constDim, itemLayout)
  41254. : itemLayout.bodyEnds
  41255. },
  41256. style: {strokeNoScale: true},
  41257. z2: 100
  41258. }));
  41259. this.bodyIndex = count++;
  41260. // Box element.
  41261. var whiskerEnds = zrUtil.map(itemLayout.whiskerEnds, function (ends) {
  41262. return isInit ? transInit(ends, constDim, itemLayout) : ends;
  41263. });
  41264. this.add(new WhiskerPath({
  41265. shape: makeWhiskerEndsShape(whiskerEnds),
  41266. style: {strokeNoScale: true},
  41267. z2: 100
  41268. }));
  41269. this.whiskerIndex = count++;
  41270. };
  41271. function transInit(points, dim, itemLayout) {
  41272. return zrUtil.map(points, function (point) {
  41273. point = point.slice();
  41274. point[dim] = itemLayout.initBaseline;
  41275. return point;
  41276. });
  41277. }
  41278. function makeWhiskerEndsShape(whiskerEnds) {
  41279. // zr animation only support 2-dim array.
  41280. var shape = {};
  41281. zrUtil.each(whiskerEnds, function (ends, i) {
  41282. shape['ends' + i] = ends;
  41283. });
  41284. return shape;
  41285. }
  41286. /**
  41287. * Update symbol properties
  41288. * @param {module:echarts/data/List} data
  41289. * @param {number} idx
  41290. */
  41291. whiskerBoxProto.updateData = function (data, idx, isInit) {
  41292. var seriesModel = this._seriesModel = data.hostModel;
  41293. var itemLayout = data.getItemLayout(idx);
  41294. var updateMethod = graphic[isInit ? 'initProps' : 'updateProps'];
  41295. // this.childAt(this.bodyIndex).stopAnimation(true);
  41296. // this.childAt(this.whiskerIndex).stopAnimation(true);
  41297. updateMethod(
  41298. this.childAt(this.bodyIndex),
  41299. {shape: {points: itemLayout.bodyEnds}},
  41300. seriesModel, idx
  41301. );
  41302. updateMethod(
  41303. this.childAt(this.whiskerIndex),
  41304. {shape: makeWhiskerEndsShape(itemLayout.whiskerEnds)},
  41305. seriesModel, idx
  41306. );
  41307. this.styleUpdater.call(null, this, data, idx);
  41308. };
  41309. zrUtil.inherits(WhiskerBox, graphic.Group);
  41310. /**
  41311. * @constructor
  41312. * @alias module:echarts/chart/helper/WhiskerBoxDraw
  41313. */
  41314. function WhiskerBoxDraw(styleUpdater) {
  41315. this.group = new graphic.Group();
  41316. this.styleUpdater = styleUpdater;
  41317. }
  41318. var whiskerBoxDrawProto = WhiskerBoxDraw.prototype;
  41319. /**
  41320. * Update symbols draw by new data
  41321. * @param {module:echarts/data/List} data
  41322. */
  41323. whiskerBoxDrawProto.updateData = function (data) {
  41324. var group = this.group;
  41325. var oldData = this._data;
  41326. var styleUpdater = this.styleUpdater;
  41327. data.diff(oldData)
  41328. .add(function (newIdx) {
  41329. if (data.hasValue(newIdx)) {
  41330. var symbolEl = new WhiskerBox(data, newIdx, styleUpdater, true);
  41331. data.setItemGraphicEl(newIdx, symbolEl);
  41332. group.add(symbolEl);
  41333. }
  41334. })
  41335. .update(function (newIdx, oldIdx) {
  41336. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  41337. // Empty data
  41338. if (!data.hasValue(newIdx)) {
  41339. group.remove(symbolEl);
  41340. return;
  41341. }
  41342. if (!symbolEl) {
  41343. symbolEl = new WhiskerBox(data, newIdx, styleUpdater);
  41344. }
  41345. else {
  41346. symbolEl.updateData(data, newIdx);
  41347. }
  41348. // Add back
  41349. group.add(symbolEl);
  41350. data.setItemGraphicEl(newIdx, symbolEl);
  41351. })
  41352. .remove(function (oldIdx) {
  41353. var el = oldData.getItemGraphicEl(oldIdx);
  41354. el && group.remove(el);
  41355. })
  41356. .execute();
  41357. this._data = data;
  41358. };
  41359. /**
  41360. * Remove symbols.
  41361. * @param {module:echarts/data/List} data
  41362. */
  41363. whiskerBoxDrawProto.remove = function () {
  41364. var group = this.group;
  41365. var data = this._data;
  41366. this._data = null;
  41367. data && data.eachItemGraphicEl(function (el) {
  41368. el && group.remove(el);
  41369. });
  41370. };
  41371. module.exports = WhiskerBoxDraw;
  41372. /***/ },
  41373. /* 261 */
  41374. /***/ function(module, exports, __webpack_require__) {
  41375. 'use strict';
  41376. var zrUtil = __webpack_require__(4);
  41377. var ChartView = __webpack_require__(80);
  41378. var graphic = __webpack_require__(18);
  41379. var whiskerBoxCommon = __webpack_require__(259);
  41380. var BoxplotView = ChartView.extend({
  41381. type: 'boxplot',
  41382. getStyleUpdater: function () {
  41383. return updateStyle;
  41384. },
  41385. dispose: zrUtil.noop
  41386. });
  41387. zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true);
  41388. // Update common properties
  41389. var normalStyleAccessPath = ['itemStyle', 'normal'];
  41390. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  41391. function updateStyle(itemGroup, data, idx) {
  41392. var itemModel = data.getItemModel(idx);
  41393. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  41394. var borderColor = data.getItemVisual(idx, 'color');
  41395. // Exclude borderColor.
  41396. var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']);
  41397. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  41398. whiskerEl.style.set(itemStyle);
  41399. whiskerEl.style.stroke = borderColor;
  41400. whiskerEl.dirty();
  41401. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  41402. bodyEl.style.set(itemStyle);
  41403. bodyEl.style.stroke = borderColor;
  41404. bodyEl.dirty();
  41405. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  41406. graphic.setHoverStyle(itemGroup, hoverStyle);
  41407. }
  41408. module.exports = BoxplotView;
  41409. /***/ },
  41410. /* 262 */
  41411. /***/ function(module, exports) {
  41412. var borderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  41413. module.exports = function (ecModel, api) {
  41414. var globalColors = ecModel.get('color');
  41415. ecModel.eachRawSeriesByType('boxplot', function (seriesModel) {
  41416. var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length];
  41417. var data = seriesModel.getData();
  41418. data.setVisual({
  41419. legendSymbol: 'roundRect',
  41420. // Use name 'color' but not 'borderColor' for legend usage and
  41421. // visual coding from other component like dataRange.
  41422. color: seriesModel.get(borderColorQuery) || defaulColor
  41423. });
  41424. // Only visible series has each data be visual encoded
  41425. if (!ecModel.isSeriesFiltered(seriesModel)) {
  41426. data.each(function (idx) {
  41427. var itemModel = data.getItemModel(idx);
  41428. data.setItemVisual(
  41429. idx,
  41430. {color: itemModel.get(borderColorQuery, true)}
  41431. );
  41432. });
  41433. }
  41434. });
  41435. };
  41436. /***/ },
  41437. /* 263 */
  41438. /***/ function(module, exports, __webpack_require__) {
  41439. var zrUtil = __webpack_require__(4);
  41440. var numberUtil = __webpack_require__(7);
  41441. var parsePercent = numberUtil.parsePercent;
  41442. var each = zrUtil.each;
  41443. module.exports = function (ecModel) {
  41444. var groupResult = groupSeriesByAxis(ecModel);
  41445. each(groupResult, function (groupItem) {
  41446. var seriesModels = groupItem.seriesModels;
  41447. if (!seriesModels.length) {
  41448. return;
  41449. }
  41450. calculateBase(groupItem);
  41451. each(seriesModels, function (seriesModel, idx) {
  41452. layoutSingleSeries(
  41453. seriesModel,
  41454. groupItem.boxOffsetList[idx],
  41455. groupItem.boxWidthList[idx]
  41456. );
  41457. });
  41458. });
  41459. };
  41460. /**
  41461. * Group series by axis.
  41462. */
  41463. function groupSeriesByAxis(ecModel) {
  41464. var result = [];
  41465. var axisList = [];
  41466. ecModel.eachSeriesByType('boxplot', function (seriesModel) {
  41467. var baseAxis = seriesModel.getBaseAxis();
  41468. var idx = zrUtil.indexOf(axisList, baseAxis);
  41469. if (idx < 0) {
  41470. idx = axisList.length;
  41471. axisList[idx] = baseAxis;
  41472. result[idx] = {axis: baseAxis, seriesModels: []};
  41473. }
  41474. result[idx].seriesModels.push(seriesModel);
  41475. });
  41476. return result;
  41477. }
  41478. /**
  41479. * Calculate offset and box width for each series.
  41480. */
  41481. function calculateBase(groupItem) {
  41482. var extent;
  41483. var baseAxis = groupItem.axis;
  41484. var seriesModels = groupItem.seriesModels;
  41485. var seriesCount = seriesModels.length;
  41486. var boxWidthList = groupItem.boxWidthList = [];
  41487. var boxOffsetList = groupItem.boxOffsetList = [];
  41488. var boundList = [];
  41489. var bandWidth;
  41490. if (baseAxis.type === 'category') {
  41491. bandWidth = baseAxis.getBandWidth();
  41492. }
  41493. else {
  41494. var maxDataCount = 0;
  41495. each(seriesModels, function (seriesModel) {
  41496. maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
  41497. });
  41498. extent = baseAxis.getExtent(),
  41499. Math.abs(extent[1] - extent[0]) / maxDataCount;
  41500. }
  41501. each(seriesModels, function (seriesModel) {
  41502. var boxWidthBound = seriesModel.get('boxWidth');
  41503. if (!zrUtil.isArray(boxWidthBound)) {
  41504. boxWidthBound = [boxWidthBound, boxWidthBound];
  41505. }
  41506. boundList.push([
  41507. parsePercent(boxWidthBound[0], bandWidth) || 0,
  41508. parsePercent(boxWidthBound[1], bandWidth) || 0
  41509. ]);
  41510. });
  41511. var availableWidth = bandWidth * 0.8 - 2;
  41512. var boxGap = availableWidth / seriesCount * 0.3;
  41513. var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
  41514. var base = boxWidth / 2 - availableWidth / 2;
  41515. each(seriesModels, function (seriesModel, idx) {
  41516. boxOffsetList.push(base);
  41517. base += boxGap + boxWidth;
  41518. boxWidthList.push(
  41519. Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
  41520. );
  41521. });
  41522. }
  41523. /**
  41524. * Calculate points location for each series.
  41525. */
  41526. function layoutSingleSeries(seriesModel, offset, boxWidth) {
  41527. var coordSys = seriesModel.coordinateSystem;
  41528. var data = seriesModel.getData();
  41529. var halfWidth = boxWidth / 2;
  41530. var chartLayout = seriesModel.get('layout');
  41531. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  41532. var constDim = 1 - variableDim;
  41533. var coordDims = ['x', 'y'];
  41534. var vDims = [];
  41535. var cDim;
  41536. zrUtil.each(data.dimensions, function (dimName) {
  41537. var dimInfo = data.getDimensionInfo(dimName);
  41538. var coordDim = dimInfo.coordDim;
  41539. if (coordDim === coordDims[constDim]) {
  41540. vDims.push(dimName);
  41541. }
  41542. else if (coordDim === coordDims[variableDim]) {
  41543. cDim = dimName;
  41544. }
  41545. });
  41546. if (cDim == null || vDims.length < 5) {
  41547. return;
  41548. }
  41549. data.each([cDim].concat(vDims), function () {
  41550. var args = arguments;
  41551. var axisDimVal = args[0];
  41552. var idx = args[vDims.length + 1];
  41553. var median = getPoint(args[3]);
  41554. var end1 = getPoint(args[1]);
  41555. var end5 = getPoint(args[5]);
  41556. var whiskerEnds = [
  41557. [end1, getPoint(args[2])],
  41558. [end5, getPoint(args[4])]
  41559. ];
  41560. layEndLine(end1);
  41561. layEndLine(end5);
  41562. layEndLine(median);
  41563. var bodyEnds = [];
  41564. addBodyEnd(whiskerEnds[0][1], 0);
  41565. addBodyEnd(whiskerEnds[1][1], 1);
  41566. data.setItemLayout(idx, {
  41567. chartLayout: chartLayout,
  41568. initBaseline: median[constDim],
  41569. median: median,
  41570. bodyEnds: bodyEnds,
  41571. whiskerEnds: whiskerEnds
  41572. });
  41573. function getPoint(val) {
  41574. var p = [];
  41575. p[variableDim] = axisDimVal;
  41576. p[constDim] = val;
  41577. var point;
  41578. if (isNaN(axisDimVal) || isNaN(val)) {
  41579. point = [NaN, NaN];
  41580. }
  41581. else {
  41582. point = coordSys.dataToPoint(p);
  41583. point[variableDim] += offset;
  41584. }
  41585. return point;
  41586. }
  41587. function addBodyEnd(point, start) {
  41588. var point1 = point.slice();
  41589. var point2 = point.slice();
  41590. point1[variableDim] += halfWidth;
  41591. point2[variableDim] -= halfWidth;
  41592. start
  41593. ? bodyEnds.push(point1, point2)
  41594. : bodyEnds.push(point2, point1);
  41595. }
  41596. function layEndLine(endCenter) {
  41597. var line = [endCenter.slice(), endCenter.slice()];
  41598. line[0][variableDim] -= halfWidth;
  41599. line[1][variableDim] += halfWidth;
  41600. whiskerEnds.push(line);
  41601. }
  41602. });
  41603. }
  41604. /***/ },
  41605. /* 264 */
  41606. /***/ function(module, exports, __webpack_require__) {
  41607. var echarts = __webpack_require__(1);
  41608. __webpack_require__(265);
  41609. __webpack_require__(266);
  41610. echarts.registerPreprocessor(
  41611. __webpack_require__(267)
  41612. );
  41613. echarts.registerVisual(__webpack_require__(268));
  41614. echarts.registerLayout(__webpack_require__(269));
  41615. /***/ },
  41616. /* 265 */
  41617. /***/ function(module, exports, __webpack_require__) {
  41618. 'use strict';
  41619. var zrUtil = __webpack_require__(4);
  41620. var SeriesModel = __webpack_require__(78);
  41621. var whiskerBoxCommon = __webpack_require__(259);
  41622. var CandlestickSeries = SeriesModel.extend({
  41623. type: 'series.candlestick',
  41624. dependencies: ['xAxis', 'yAxis', 'grid'],
  41625. /**
  41626. * @readOnly
  41627. */
  41628. defaultValueDimensions: ['open', 'close', 'lowest', 'highest'],
  41629. /**
  41630. * @type {Array.<string>}
  41631. * @readOnly
  41632. */
  41633. dimensions: null,
  41634. /**
  41635. * @override
  41636. */
  41637. defaultOption: {
  41638. zlevel: 0, // 一级层叠
  41639. z: 2, // 二级层叠
  41640. coordinateSystem: 'cartesian2d',
  41641. legendHoverLink: true,
  41642. hoverAnimation: true,
  41643. // xAxisIndex: 0,
  41644. // yAxisIndex: 0,
  41645. layout: null, // 'horizontal' or 'vertical'
  41646. itemStyle: {
  41647. normal: {
  41648. color: '#c23531', // 阳线 positive
  41649. color0: '#314656', // 阴线 negative '#c23531', '#314656'
  41650. borderWidth: 1,
  41651. // FIXME
  41652. // ec2中使用的是lineStyle.color 和 lineStyle.color0
  41653. borderColor: '#c23531',
  41654. borderColor0: '#314656'
  41655. },
  41656. emphasis: {
  41657. borderWidth: 2
  41658. }
  41659. },
  41660. barMaxWidth: null,
  41661. barMinWidth: null,
  41662. barWidth: null,
  41663. animationUpdate: false,
  41664. animationEasing: 'linear',
  41665. animationDuration: 300
  41666. },
  41667. /**
  41668. * Get dimension for shadow in dataZoom
  41669. * @return {string} dimension name
  41670. */
  41671. getShadowDim: function () {
  41672. return 'open';
  41673. },
  41674. brushSelector: function (dataIndex, data, selectors) {
  41675. var itemLayout = data.getItemLayout(dataIndex);
  41676. return selectors.rect(itemLayout.brushRect);
  41677. }
  41678. });
  41679. zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true);
  41680. module.exports = CandlestickSeries;
  41681. /***/ },
  41682. /* 266 */
  41683. /***/ function(module, exports, __webpack_require__) {
  41684. 'use strict';
  41685. var zrUtil = __webpack_require__(4);
  41686. var ChartView = __webpack_require__(80);
  41687. var graphic = __webpack_require__(18);
  41688. var whiskerBoxCommon = __webpack_require__(259);
  41689. var CandlestickView = ChartView.extend({
  41690. type: 'candlestick',
  41691. getStyleUpdater: function () {
  41692. return updateStyle;
  41693. },
  41694. dispose: zrUtil.noop
  41695. });
  41696. zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true);
  41697. // Update common properties
  41698. var normalStyleAccessPath = ['itemStyle', 'normal'];
  41699. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  41700. function updateStyle(itemGroup, data, idx) {
  41701. var itemModel = data.getItemModel(idx);
  41702. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  41703. var color = data.getItemVisual(idx, 'color');
  41704. var borderColor = data.getItemVisual(idx, 'borderColor') || color;
  41705. // Color must be excluded.
  41706. // Because symbol provide setColor individually to set fill and stroke
  41707. var itemStyle = normalItemStyleModel.getItemStyle(
  41708. ['color', 'color0', 'borderColor', 'borderColor0']
  41709. );
  41710. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  41711. whiskerEl.useStyle(itemStyle);
  41712. whiskerEl.style.stroke = borderColor;
  41713. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  41714. bodyEl.useStyle(itemStyle);
  41715. bodyEl.style.fill = color;
  41716. bodyEl.style.stroke = borderColor;
  41717. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  41718. graphic.setHoverStyle(itemGroup, hoverStyle);
  41719. }
  41720. module.exports = CandlestickView;
  41721. /***/ },
  41722. /* 267 */
  41723. /***/ function(module, exports, __webpack_require__) {
  41724. var zrUtil = __webpack_require__(4);
  41725. module.exports = function (option) {
  41726. if (!option || !zrUtil.isArray(option.series)) {
  41727. return;
  41728. }
  41729. // Translate 'k' to 'candlestick'.
  41730. zrUtil.each(option.series, function (seriesItem) {
  41731. if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') {
  41732. seriesItem.type = 'candlestick';
  41733. }
  41734. });
  41735. };
  41736. /***/ },
  41737. /* 268 */
  41738. /***/ function(module, exports) {
  41739. var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  41740. var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0'];
  41741. var positiveColorQuery = ['itemStyle', 'normal', 'color'];
  41742. var negativeColorQuery = ['itemStyle', 'normal', 'color0'];
  41743. module.exports = function (ecModel, api) {
  41744. ecModel.eachRawSeriesByType('candlestick', function (seriesModel) {
  41745. var data = seriesModel.getData();
  41746. data.setVisual({
  41747. legendSymbol: 'roundRect'
  41748. });
  41749. // Only visible series has each data be visual encoded
  41750. if (!ecModel.isSeriesFiltered(seriesModel)) {
  41751. data.each(function (idx) {
  41752. var itemModel = data.getItemModel(idx);
  41753. var sign = data.getItemLayout(idx).sign;
  41754. data.setItemVisual(
  41755. idx,
  41756. {
  41757. color: itemModel.get(
  41758. sign > 0 ? positiveColorQuery : negativeColorQuery
  41759. ),
  41760. borderColor: itemModel.get(
  41761. sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery
  41762. )
  41763. }
  41764. );
  41765. });
  41766. }
  41767. });
  41768. };
  41769. /***/ },
  41770. /* 269 */
  41771. /***/ function(module, exports, __webpack_require__) {
  41772. var zrUtil = __webpack_require__(4);
  41773. var retrieve = __webpack_require__(4).retrieve;
  41774. var parsePercent = __webpack_require__(7).parsePercent;
  41775. module.exports = function (ecModel) {
  41776. ecModel.eachSeriesByType('candlestick', function (seriesModel) {
  41777. var coordSys = seriesModel.coordinateSystem;
  41778. var data = seriesModel.getData();
  41779. var candleWidth = calculateCandleWidth(seriesModel, data);
  41780. var chartLayout = seriesModel.get('layout');
  41781. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  41782. var constDim = 1 - variableDim;
  41783. var coordDims = ['x', 'y'];
  41784. var vDims = [];
  41785. var cDim;
  41786. zrUtil.each(data.dimensions, function (dimName) {
  41787. var dimInfo = data.getDimensionInfo(dimName);
  41788. var coordDim = dimInfo.coordDim;
  41789. if (coordDim === coordDims[constDim]) {
  41790. vDims.push(dimName);
  41791. }
  41792. else if (coordDim === coordDims[variableDim]) {
  41793. cDim = dimName;
  41794. }
  41795. });
  41796. if (cDim == null || vDims.length < 4) {
  41797. return;
  41798. }
  41799. data.each([cDim].concat(vDims), function () {
  41800. var args = arguments;
  41801. var axisDimVal = args[0];
  41802. var idx = args[vDims.length + 1];
  41803. var openVal = args[1];
  41804. var closeVal = args[2];
  41805. var lowestVal = args[3];
  41806. var highestVal = args[4];
  41807. var ocLow = Math.min(openVal, closeVal);
  41808. var ocHigh = Math.max(openVal, closeVal);
  41809. var ocLowPoint = getPoint(ocLow);
  41810. var ocHighPoint = getPoint(ocHigh);
  41811. var lowestPoint = getPoint(lowestVal);
  41812. var highestPoint = getPoint(highestVal);
  41813. var whiskerEnds = [
  41814. [highestPoint, ocHighPoint],
  41815. [lowestPoint, ocLowPoint]
  41816. ];
  41817. var bodyEnds = [];
  41818. addBodyEnd(ocHighPoint, 0);
  41819. addBodyEnd(ocLowPoint, 1);
  41820. data.setItemLayout(idx, {
  41821. chartLayout: chartLayout,
  41822. sign: openVal > closeVal ? -1 : openVal < closeVal ? 1 : 0,
  41823. initBaseline: openVal > closeVal
  41824. ? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
  41825. bodyEnds: bodyEnds,
  41826. whiskerEnds: whiskerEnds,
  41827. brushRect: makeBrushRect()
  41828. });
  41829. function getPoint(val) {
  41830. var p = [];
  41831. p[variableDim] = axisDimVal;
  41832. p[constDim] = val;
  41833. return (isNaN(axisDimVal) || isNaN(val))
  41834. ? [NaN, NaN]
  41835. : coordSys.dataToPoint(p);
  41836. }
  41837. function addBodyEnd(point, start) {
  41838. var point1 = point.slice();
  41839. var point2 = point.slice();
  41840. point1[variableDim] += candleWidth / 2;
  41841. point2[variableDim] -= candleWidth / 2;
  41842. start
  41843. ? bodyEnds.push(point1, point2)
  41844. : bodyEnds.push(point2, point1);
  41845. }
  41846. function makeBrushRect() {
  41847. var pmin = getPoint(Math.min(openVal, closeVal, lowestVal, highestVal));
  41848. var pmax = getPoint(Math.max(openVal, closeVal, lowestVal, highestVal));
  41849. pmin[variableDim] -= candleWidth / 2;
  41850. pmax[variableDim] -= candleWidth / 2;
  41851. return {
  41852. x: pmin[0],
  41853. y: pmin[1],
  41854. width: constDim ? candleWidth : pmax[0] - pmin[0],
  41855. height: constDim ? pmax[1] - pmin[1] : candleWidth
  41856. };
  41857. }
  41858. }, true);
  41859. });
  41860. };
  41861. function calculateCandleWidth(seriesModel, data) {
  41862. var baseAxis = seriesModel.getBaseAxis();
  41863. var extent;
  41864. var bandWidth = baseAxis.type === 'category'
  41865. ? baseAxis.getBandWidth()
  41866. : (
  41867. extent = baseAxis.getExtent(),
  41868. Math.abs(extent[1] - extent[0]) / data.count()
  41869. );
  41870. var barMaxWidth = parsePercent(
  41871. retrieve(seriesModel.get('barMaxWidth'), bandWidth),
  41872. bandWidth
  41873. );
  41874. var barMinWidth = parsePercent(
  41875. retrieve(seriesModel.get('barMinWidth'), 1),
  41876. bandWidth
  41877. );
  41878. var barWidth = seriesModel.get('barWidth');
  41879. return barWidth != null
  41880. ? parsePercent(barWidth, bandWidth)
  41881. // Put max outer to ensure bar visible in spite of overlap.
  41882. : Math.max(Math.min(bandWidth / 2, barMaxWidth), barMinWidth);
  41883. }
  41884. /***/ },
  41885. /* 270 */
  41886. /***/ function(module, exports, __webpack_require__) {
  41887. var zrUtil = __webpack_require__(4);
  41888. var echarts = __webpack_require__(1);
  41889. __webpack_require__(271);
  41890. __webpack_require__(272);
  41891. echarts.registerVisual(zrUtil.curry(
  41892. __webpack_require__(121), 'effectScatter', 'circle', null
  41893. ));
  41894. echarts.registerLayout(zrUtil.curry(
  41895. __webpack_require__(122), 'effectScatter'
  41896. ));
  41897. /***/ },
  41898. /* 271 */
  41899. /***/ function(module, exports, __webpack_require__) {
  41900. 'use strict';
  41901. var createListFromArray = __webpack_require__(109);
  41902. var SeriesModel = __webpack_require__(78);
  41903. module.exports = SeriesModel.extend({
  41904. type: 'series.effectScatter',
  41905. dependencies: ['grid', 'polar'],
  41906. getInitialData: function (option, ecModel) {
  41907. var list = createListFromArray(option.data, this, ecModel);
  41908. return list;
  41909. },
  41910. brushSelector: 'point',
  41911. defaultOption: {
  41912. coordinateSystem: 'cartesian2d',
  41913. zlevel: 0,
  41914. z: 2,
  41915. legendHoverLink: true,
  41916. effectType: 'ripple',
  41917. progressive: 0,
  41918. // When to show the effect, option: 'render'|'emphasis'
  41919. showEffectOn: 'render',
  41920. // Ripple effect config
  41921. rippleEffect: {
  41922. period: 4,
  41923. // Scale of ripple
  41924. scale: 2.5,
  41925. // Brush type can be fill or stroke
  41926. brushType: 'fill'
  41927. },
  41928. // Cartesian coordinate system
  41929. // xAxisIndex: 0,
  41930. // yAxisIndex: 0,
  41931. // Polar coordinate system
  41932. // polarIndex: 0,
  41933. // Geo coordinate system
  41934. // geoIndex: 0,
  41935. // symbol: null, // 图形类型
  41936. symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  41937. // symbolRotate: null, // 图形旋转控制
  41938. // large: false,
  41939. // Available when large is true
  41940. // largeThreshold: 2000,
  41941. // itemStyle: {
  41942. // normal: {
  41943. // opacity: 1
  41944. // }
  41945. // }
  41946. }
  41947. });
  41948. /***/ },
  41949. /* 272 */
  41950. /***/ function(module, exports, __webpack_require__) {
  41951. var SymbolDraw = __webpack_require__(116);
  41952. var EffectSymbol = __webpack_require__(273);
  41953. __webpack_require__(1).extendChartView({
  41954. type: 'effectScatter',
  41955. init: function () {
  41956. this._symbolDraw = new SymbolDraw(EffectSymbol);
  41957. },
  41958. render: function (seriesModel, ecModel, api) {
  41959. var data = seriesModel.getData();
  41960. var effectSymbolDraw = this._symbolDraw;
  41961. effectSymbolDraw.updateData(data);
  41962. this.group.add(effectSymbolDraw.group);
  41963. },
  41964. updateLayout: function () {
  41965. this._symbolDraw.updateLayout();
  41966. },
  41967. remove: function (ecModel, api) {
  41968. this._symbolDraw && this._symbolDraw.remove(api);
  41969. },
  41970. dispose: function () {}
  41971. });
  41972. /***/ },
  41973. /* 273 */
  41974. /***/ function(module, exports, __webpack_require__) {
  41975. /**
  41976. * Symbol with ripple effect
  41977. * @module echarts/chart/helper/EffectSymbol
  41978. */
  41979. var zrUtil = __webpack_require__(4);
  41980. var symbolUtil = __webpack_require__(111);
  41981. var graphic = __webpack_require__(18);
  41982. var numberUtil = __webpack_require__(7);
  41983. var Symbol = __webpack_require__(117);
  41984. var Group = graphic.Group;
  41985. var EFFECT_RIPPLE_NUMBER = 3;
  41986. function normalizeSymbolSize(symbolSize) {
  41987. if (!zrUtil.isArray(symbolSize)) {
  41988. symbolSize = [+symbolSize, +symbolSize];
  41989. }
  41990. return symbolSize;
  41991. }
  41992. function updateRipplePath(rippleGroup, effectCfg) {
  41993. rippleGroup.eachChild(function (ripplePath) {
  41994. ripplePath.attr({
  41995. z: effectCfg.z,
  41996. zlevel: effectCfg.zlevel,
  41997. style: {
  41998. stroke: effectCfg.brushType === 'stroke' ? effectCfg.color : null,
  41999. fill: effectCfg.brushType === 'fill' ? effectCfg.color : null
  42000. }
  42001. });
  42002. });
  42003. }
  42004. /**
  42005. * @constructor
  42006. * @param {module:echarts/data/List} data
  42007. * @param {number} idx
  42008. * @extends {module:zrender/graphic/Group}
  42009. */
  42010. function EffectSymbol(data, idx) {
  42011. Group.call(this);
  42012. var symbol = new Symbol(data, idx);
  42013. var rippleGroup = new Group();
  42014. this.add(symbol);
  42015. this.add(rippleGroup);
  42016. rippleGroup.beforeUpdate = function () {
  42017. this.attr(symbol.getScale());
  42018. };
  42019. this.updateData(data, idx);
  42020. }
  42021. var effectSymbolProto = EffectSymbol.prototype;
  42022. effectSymbolProto.stopEffectAnimation = function () {
  42023. this.childAt(1).removeAll();
  42024. };
  42025. effectSymbolProto.startEffectAnimation = function (effectCfg) {
  42026. var symbolType = effectCfg.symbolType;
  42027. var color = effectCfg.color;
  42028. var rippleGroup = this.childAt(1);
  42029. for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
  42030. // var ripplePath = symbolUtil.createSymbol(
  42031. // symbolType, -0.5, -0.5, 1, 1, color
  42032. // );
  42033. // If width/height are set too small (e.g., set to 1) on ios10
  42034. // and macOS Sierra, a circle stroke become a rect, no matter what
  42035. // the scale is set. So we set width/height as 2. See #4136.
  42036. var ripplePath = symbolUtil.createSymbol(
  42037. symbolType, -1, -1, 2, 2, color
  42038. );
  42039. ripplePath.attr({
  42040. style: {
  42041. strokeNoScale: true
  42042. },
  42043. z2: 99,
  42044. silent: true,
  42045. scale: [0.5, 0.5]
  42046. });
  42047. var delay = -i / EFFECT_RIPPLE_NUMBER * effectCfg.period + effectCfg.effectOffset;
  42048. // TODO Configurable effectCfg.period
  42049. ripplePath.animate('', true)
  42050. .when(effectCfg.period, {
  42051. scale: [effectCfg.rippleScale / 2, effectCfg.rippleScale / 2]
  42052. })
  42053. .delay(delay)
  42054. .start();
  42055. ripplePath.animateStyle(true)
  42056. .when(effectCfg.period, {
  42057. opacity: 0
  42058. })
  42059. .delay(delay)
  42060. .start();
  42061. rippleGroup.add(ripplePath);
  42062. }
  42063. updateRipplePath(rippleGroup, effectCfg);
  42064. };
  42065. /**
  42066. * Update effect symbol
  42067. */
  42068. effectSymbolProto.updateEffectAnimation = function (effectCfg) {
  42069. var oldEffectCfg = this._effectCfg;
  42070. var rippleGroup = this.childAt(1);
  42071. // Must reinitialize effect if following configuration changed
  42072. var DIFFICULT_PROPS = ['symbolType', 'period', 'rippleScale'];
  42073. for (var i = 0; i < DIFFICULT_PROPS; i++) {
  42074. var propName = DIFFICULT_PROPS[i];
  42075. if (oldEffectCfg[propName] !== effectCfg[propName]) {
  42076. this.stopEffectAnimation();
  42077. this.startEffectAnimation(effectCfg);
  42078. return;
  42079. }
  42080. }
  42081. updateRipplePath(rippleGroup, effectCfg);
  42082. };
  42083. /**
  42084. * Highlight symbol
  42085. */
  42086. effectSymbolProto.highlight = function () {
  42087. this.trigger('emphasis');
  42088. };
  42089. /**
  42090. * Downplay symbol
  42091. */
  42092. effectSymbolProto.downplay = function () {
  42093. this.trigger('normal');
  42094. };
  42095. /**
  42096. * Update symbol properties
  42097. * @param {module:echarts/data/List} data
  42098. * @param {number} idx
  42099. */
  42100. effectSymbolProto.updateData = function (data, idx) {
  42101. var seriesModel = data.hostModel;
  42102. this.childAt(0).updateData(data, idx);
  42103. var rippleGroup = this.childAt(1);
  42104. var itemModel = data.getItemModel(idx);
  42105. var symbolType = data.getItemVisual(idx, 'symbol');
  42106. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  42107. var color = data.getItemVisual(idx, 'color');
  42108. rippleGroup.attr('scale', symbolSize);
  42109. rippleGroup.traverse(function (ripplePath) {
  42110. ripplePath.attr({
  42111. fill: color
  42112. });
  42113. });
  42114. var symbolOffset = itemModel.getShallow('symbolOffset');
  42115. if (symbolOffset) {
  42116. var pos = rippleGroup.position;
  42117. pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  42118. pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  42119. }
  42120. rippleGroup.rotation = (itemModel.getShallow('symbolRotate') || 0) * Math.PI / 180 || 0;
  42121. var effectCfg = {};
  42122. effectCfg.showEffectOn = seriesModel.get('showEffectOn');
  42123. effectCfg.rippleScale = itemModel.get('rippleEffect.scale');
  42124. effectCfg.brushType = itemModel.get('rippleEffect.brushType');
  42125. effectCfg.period = itemModel.get('rippleEffect.period') * 1000;
  42126. effectCfg.effectOffset = idx / data.count();
  42127. effectCfg.z = itemModel.getShallow('z') || 0;
  42128. effectCfg.zlevel = itemModel.getShallow('zlevel') || 0;
  42129. effectCfg.symbolType = symbolType;
  42130. effectCfg.color = color;
  42131. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  42132. if (effectCfg.showEffectOn === 'render') {
  42133. this._effectCfg
  42134. ? this.updateEffectAnimation(effectCfg)
  42135. : this.startEffectAnimation(effectCfg);
  42136. this._effectCfg = effectCfg;
  42137. }
  42138. else {
  42139. // Not keep old effect config
  42140. this._effectCfg = null;
  42141. this.stopEffectAnimation();
  42142. var symbol = this.childAt(0);
  42143. var onEmphasis = function () {
  42144. symbol.trigger('emphasis');
  42145. if (effectCfg.showEffectOn !== 'render') {
  42146. this.startEffectAnimation(effectCfg);
  42147. }
  42148. };
  42149. var onNormal = function () {
  42150. symbol.trigger('normal');
  42151. if (effectCfg.showEffectOn !== 'render') {
  42152. this.stopEffectAnimation();
  42153. }
  42154. };
  42155. this.on('mouseover', onEmphasis, this)
  42156. .on('mouseout', onNormal, this)
  42157. .on('emphasis', onEmphasis, this)
  42158. .on('normal', onNormal, this);
  42159. }
  42160. this._effectCfg = effectCfg;
  42161. };
  42162. effectSymbolProto.fadeOut = function (cb) {
  42163. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  42164. cb && cb();
  42165. };
  42166. zrUtil.inherits(EffectSymbol, Group);
  42167. module.exports = EffectSymbol;
  42168. /***/ },
  42169. /* 274 */
  42170. /***/ function(module, exports, __webpack_require__) {
  42171. __webpack_require__(275);
  42172. __webpack_require__(276);
  42173. var echarts = __webpack_require__(1);
  42174. echarts.registerLayout(
  42175. __webpack_require__(281)
  42176. );
  42177. echarts.registerVisual(
  42178. __webpack_require__(282)
  42179. );
  42180. /***/ },
  42181. /* 275 */
  42182. /***/ function(module, exports, __webpack_require__) {
  42183. 'use strict';
  42184. var SeriesModel = __webpack_require__(78);
  42185. var List = __webpack_require__(98);
  42186. var zrUtil = __webpack_require__(4);
  42187. var formatUtil = __webpack_require__(6);
  42188. var CoordinateSystem = __webpack_require__(76);
  42189. // Convert [ [{coord: []}, {coord: []}] ]
  42190. // to [ { coords: [[]] } ]
  42191. function preprocessOption (seriesOpt) {
  42192. var data = seriesOpt.data;
  42193. if (data && data[0] && data[0][0] && data[0][0].coord) {
  42194. if (true) {
  42195. console.warn('Lines data configuration has been changed to'
  42196. + ' { coords:[[1,2],[2,3]] }');
  42197. }
  42198. seriesOpt.data = zrUtil.map(data, function (itemOpt) {
  42199. var coords = [
  42200. itemOpt[0].coord, itemOpt[1].coord
  42201. ];
  42202. var target = {
  42203. coords: coords
  42204. };
  42205. if (itemOpt[0].name) {
  42206. target.fromName = itemOpt[0].name;
  42207. }
  42208. if (itemOpt[1].name) {
  42209. target.toName = itemOpt[1].name;
  42210. }
  42211. return zrUtil.mergeAll([target, itemOpt[0], itemOpt[1]]);
  42212. });
  42213. }
  42214. }
  42215. var LinesSeries = SeriesModel.extend({
  42216. type: 'series.lines',
  42217. dependencies: ['grid', 'polar'],
  42218. visualColorAccessPath: 'lineStyle.normal.color',
  42219. init: function (option) {
  42220. // Not using preprocessor because mergeOption may not have series.type
  42221. preprocessOption(option);
  42222. LinesSeries.superApply(this, 'init', arguments);
  42223. },
  42224. mergeOption: function (option) {
  42225. preprocessOption(option);
  42226. LinesSeries.superApply(this, 'mergeOption', arguments);
  42227. },
  42228. getInitialData: function (option, ecModel) {
  42229. if (true) {
  42230. var CoordSys = CoordinateSystem.get(option.coordinateSystem);
  42231. if (!CoordSys) {
  42232. throw new Error('Unkown coordinate system ' + option.coordinateSystem);
  42233. }
  42234. }
  42235. var lineData = new List(['value'], this);
  42236. lineData.hasItemOption = false;
  42237. lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
  42238. // dataItem is simply coords
  42239. if (dataItem instanceof Array) {
  42240. return NaN;
  42241. }
  42242. else {
  42243. lineData.hasItemOption = true;
  42244. var value = dataItem.value;
  42245. if (value != null) {
  42246. return value instanceof Array ? value[dimIndex] : value;
  42247. }
  42248. }
  42249. });
  42250. return lineData;
  42251. },
  42252. formatTooltip: function (dataIndex) {
  42253. var data = this.getData();
  42254. var itemModel = data.getItemModel(dataIndex);
  42255. var name = itemModel.get('name');
  42256. if (name) {
  42257. return name;
  42258. }
  42259. var fromName = itemModel.get('fromName');
  42260. var toName = itemModel.get('toName');
  42261. var html = [];
  42262. fromName != null && html.push(fromName);
  42263. toName != null && html.push(toName);
  42264. return formatUtil.encodeHTML(html.join(' > '));
  42265. },
  42266. defaultOption: {
  42267. coordinateSystem: 'geo',
  42268. zlevel: 0,
  42269. z: 2,
  42270. legendHoverLink: true,
  42271. hoverAnimation: true,
  42272. // Cartesian coordinate system
  42273. xAxisIndex: 0,
  42274. yAxisIndex: 0,
  42275. symbol: ['none', 'none'],
  42276. symbolSize: [10, 10],
  42277. // Geo coordinate system
  42278. geoIndex: 0,
  42279. effect: {
  42280. show: false,
  42281. period: 4,
  42282. // Animation delay. support callback
  42283. // delay: 0,
  42284. // If move with constant speed px/sec
  42285. // period will be ignored if this property is > 0,
  42286. constantSpeed: 0,
  42287. symbol: 'circle',
  42288. symbolSize: 3,
  42289. loop: true,
  42290. // Length of trail, 0 - 1
  42291. trailLength: 0.2
  42292. // Same with lineStyle.normal.color
  42293. // color
  42294. },
  42295. large: false,
  42296. // Available when large is true
  42297. largeThreshold: 2000,
  42298. // If lines are polyline
  42299. // polyline not support curveness, label, animation
  42300. polyline: false,
  42301. label: {
  42302. normal: {
  42303. show: false,
  42304. position: 'end'
  42305. // distance: 5,
  42306. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  42307. }
  42308. },
  42309. lineStyle: {
  42310. normal: {
  42311. opacity: 0.5
  42312. }
  42313. }
  42314. }
  42315. });
  42316. /***/ },
  42317. /* 276 */
  42318. /***/ function(module, exports, __webpack_require__) {
  42319. var LineDraw = __webpack_require__(210);
  42320. var EffectLine = __webpack_require__(277);
  42321. var Line = __webpack_require__(211);
  42322. var Polyline = __webpack_require__(278);
  42323. var EffectPolyline = __webpack_require__(279);
  42324. var LargeLineDraw = __webpack_require__(280);
  42325. __webpack_require__(1).extendChartView({
  42326. type: 'lines',
  42327. init: function () {},
  42328. render: function (seriesModel, ecModel, api) {
  42329. var data = seriesModel.getData();
  42330. var lineDraw = this._lineDraw;
  42331. var hasEffect = seriesModel.get('effect.show');
  42332. var isPolyline = seriesModel.get('polyline');
  42333. var isLarge = seriesModel.get('large') && data.count() >= seriesModel.get('largeThreshold');
  42334. if (true) {
  42335. if (hasEffect && isLarge) {
  42336. console.warn('Large lines not support effect');
  42337. }
  42338. }
  42339. if (hasEffect !== this._hasEffet || isPolyline !== this._isPolyline || isLarge !== this._isLarge) {
  42340. if (lineDraw) {
  42341. lineDraw.remove();
  42342. }
  42343. lineDraw = this._lineDraw = isLarge
  42344. ? new LargeLineDraw()
  42345. : new LineDraw(
  42346. isPolyline
  42347. ? (hasEffect ? EffectPolyline : Polyline)
  42348. : (hasEffect ? EffectLine : Line)
  42349. );
  42350. this._hasEffet = hasEffect;
  42351. this._isPolyline = isPolyline;
  42352. this._isLarge = isLarge;
  42353. }
  42354. var zlevel = seriesModel.get('zlevel');
  42355. var trailLength = seriesModel.get('effect.trailLength');
  42356. var zr = api.getZr();
  42357. // Avoid the drag cause ghost shadow
  42358. // FIXME Better way ?
  42359. zr.painter.getLayer(zlevel).clear(true);
  42360. // Config layer with motion blur
  42361. if (this._lastZlevel != null) {
  42362. zr.configLayer(this._lastZlevel, {
  42363. motionBlur: false
  42364. });
  42365. }
  42366. if (hasEffect && trailLength) {
  42367. if (true) {
  42368. var notInIndividual = false;
  42369. ecModel.eachSeries(function (otherSeriesModel) {
  42370. if (otherSeriesModel !== seriesModel && otherSeriesModel.get('zlevel') === zlevel) {
  42371. notInIndividual = true;
  42372. }
  42373. });
  42374. notInIndividual && console.warn('Lines with trail effect should have an individual zlevel');
  42375. }
  42376. zr.configLayer(zlevel, {
  42377. motionBlur: true,
  42378. lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
  42379. });
  42380. }
  42381. this.group.add(lineDraw.group);
  42382. lineDraw.updateData(data);
  42383. this._lastZlevel = zlevel;
  42384. },
  42385. updateLayout: function (seriesModel, ecModel, api) {
  42386. this._lineDraw.updateLayout(seriesModel);
  42387. // Not use motion when dragging or zooming
  42388. var zr = api.getZr();
  42389. zr.painter.getLayer(this._lastZlevel).clear(true);
  42390. },
  42391. remove: function (ecModel, api) {
  42392. this._lineDraw && this._lineDraw.remove(api, true);
  42393. },
  42394. dispose: function () {}
  42395. });
  42396. /***/ },
  42397. /* 277 */
  42398. /***/ function(module, exports, __webpack_require__) {
  42399. /**
  42400. * Provide effect for line
  42401. * @module echarts/chart/helper/EffectLine
  42402. */
  42403. var graphic = __webpack_require__(18);
  42404. var Line = __webpack_require__(211);
  42405. var zrUtil = __webpack_require__(4);
  42406. var symbolUtil = __webpack_require__(111);
  42407. var vec2 = __webpack_require__(10);
  42408. var curveUtil = __webpack_require__(37);
  42409. /**
  42410. * @constructor
  42411. * @extends {module:zrender/graphic/Group}
  42412. * @alias {module:echarts/chart/helper/Line}
  42413. */
  42414. function EffectLine(lineData, idx, seriesScope) {
  42415. graphic.Group.call(this);
  42416. this.add(this.createLine(lineData, idx, seriesScope));
  42417. this._updateEffectSymbol(lineData, idx);
  42418. }
  42419. var effectLineProto = EffectLine.prototype;
  42420. effectLineProto.createLine = function (lineData, idx, seriesScope) {
  42421. return new Line(lineData, idx, seriesScope);
  42422. };
  42423. effectLineProto._updateEffectSymbol = function (lineData, idx) {
  42424. var itemModel = lineData.getItemModel(idx);
  42425. var effectModel = itemModel.getModel('effect');
  42426. var size = effectModel.get('symbolSize');
  42427. var symbolType = effectModel.get('symbol');
  42428. if (!zrUtil.isArray(size)) {
  42429. size = [size, size];
  42430. }
  42431. var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color');
  42432. var symbol = this.childAt(1);
  42433. if (this._symbolType !== symbolType) {
  42434. // Remove previous
  42435. this.remove(symbol);
  42436. symbol = symbolUtil.createSymbol(
  42437. symbolType, -0.5, -0.5, 1, 1, color
  42438. );
  42439. symbol.z2 = 100;
  42440. symbol.culling = true;
  42441. this.add(symbol);
  42442. }
  42443. // Symbol may be removed if loop is false
  42444. if (!symbol) {
  42445. return;
  42446. }
  42447. // Shadow color is same with color in default
  42448. symbol.setStyle('shadowColor', color);
  42449. symbol.setStyle(effectModel.getItemStyle(['color']));
  42450. symbol.attr('scale', size);
  42451. symbol.setColor(color);
  42452. symbol.attr('scale', size);
  42453. this._symbolType = symbolType;
  42454. this._updateEffectAnimation(lineData, effectModel, idx);
  42455. };
  42456. effectLineProto._updateEffectAnimation = function (lineData, effectModel, idx) {
  42457. var symbol = this.childAt(1);
  42458. if (!symbol) {
  42459. return;
  42460. }
  42461. var self = this;
  42462. var points = lineData.getItemLayout(idx);
  42463. var period = effectModel.get('period') * 1000;
  42464. var loop = effectModel.get('loop');
  42465. var constantSpeed = effectModel.get('constantSpeed');
  42466. var delayExpr = zrUtil.retrieve(effectModel.get('delay'), function (idx) {
  42467. return idx / lineData.count() * period / 3;
  42468. });
  42469. var isDelayFunc = typeof delayExpr === 'function';
  42470. // Ignore when updating
  42471. symbol.ignore = true;
  42472. this.updateAnimationPoints(symbol, points);
  42473. if (constantSpeed > 0) {
  42474. period = this.getLineLength(symbol) / constantSpeed * 1000;
  42475. }
  42476. if (period !== this._period || loop !== this._loop) {
  42477. symbol.stopAnimation();
  42478. var delay = delayExpr;
  42479. if (isDelayFunc) {
  42480. delay = delayExpr(idx);
  42481. }
  42482. if (symbol.__t > 0) {
  42483. delay = -period * symbol.__t;
  42484. }
  42485. symbol.__t = 0;
  42486. var animator = symbol.animate('', loop)
  42487. .when(period, {
  42488. __t: 1
  42489. })
  42490. .delay(delay)
  42491. .during(function () {
  42492. self.updateSymbolPosition(symbol);
  42493. });
  42494. if (!loop) {
  42495. animator.done(function () {
  42496. self.remove(symbol);
  42497. });
  42498. }
  42499. animator.start();
  42500. }
  42501. this._period = period;
  42502. this._loop = loop;
  42503. };
  42504. effectLineProto.getLineLength = function (symbol) {
  42505. // Not so accurate
  42506. return (vec2.dist(symbol.__p1, symbol.__cp1)
  42507. + vec2.dist(symbol.__cp1, symbol.__p2));
  42508. };
  42509. effectLineProto.updateAnimationPoints = function (symbol, points) {
  42510. symbol.__p1 = points[0];
  42511. symbol.__p2 = points[1];
  42512. symbol.__cp1 = points[2] || [
  42513. (points[0][0] + points[1][0]) / 2,
  42514. (points[0][1] + points[1][1]) / 2
  42515. ];
  42516. };
  42517. effectLineProto.updateData = function (lineData, idx, seriesScope) {
  42518. this.childAt(0).updateData(lineData, idx, seriesScope);
  42519. this._updateEffectSymbol(lineData, idx);
  42520. };
  42521. effectLineProto.updateSymbolPosition = function (symbol) {
  42522. var p1 = symbol.__p1;
  42523. var p2 = symbol.__p2;
  42524. var cp1 = symbol.__cp1;
  42525. var t = symbol.__t;
  42526. var pos = symbol.position;
  42527. var quadraticAt = curveUtil.quadraticAt;
  42528. var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
  42529. pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
  42530. pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t);
  42531. // Tangent
  42532. var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t);
  42533. var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t);
  42534. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  42535. symbol.ignore = false;
  42536. };
  42537. effectLineProto.updateLayout = function (lineData, idx) {
  42538. this.childAt(0).updateLayout(lineData, idx);
  42539. var effectModel = lineData.getItemModel(idx).getModel('effect');
  42540. this._updateEffectAnimation(lineData, effectModel, idx);
  42541. };
  42542. zrUtil.inherits(EffectLine, graphic.Group);
  42543. module.exports = EffectLine;
  42544. /***/ },
  42545. /* 278 */
  42546. /***/ function(module, exports, __webpack_require__) {
  42547. /**
  42548. * @module echarts/chart/helper/Line
  42549. */
  42550. var graphic = __webpack_require__(18);
  42551. var zrUtil = __webpack_require__(4);
  42552. /**
  42553. * @constructor
  42554. * @extends {module:zrender/graphic/Group}
  42555. * @alias {module:echarts/chart/helper/Polyline}
  42556. */
  42557. function Polyline(lineData, idx, seriesScope) {
  42558. graphic.Group.call(this);
  42559. this._createPolyline(lineData, idx, seriesScope);
  42560. }
  42561. var polylineProto = Polyline.prototype;
  42562. polylineProto._createPolyline = function (lineData, idx, seriesScope) {
  42563. // var seriesModel = lineData.hostModel;
  42564. var points = lineData.getItemLayout(idx);
  42565. var line = new graphic.Polyline({
  42566. shape: {
  42567. points: points
  42568. }
  42569. });
  42570. this.add(line);
  42571. this._updateCommonStl(lineData, idx, seriesScope);
  42572. };
  42573. polylineProto.updateData = function (lineData, idx, seriesScope) {
  42574. var seriesModel = lineData.hostModel;
  42575. var line = this.childAt(0);
  42576. var target = {
  42577. shape: {
  42578. points: lineData.getItemLayout(idx)
  42579. }
  42580. };
  42581. graphic.updateProps(line, target, seriesModel, idx);
  42582. this._updateCommonStl(lineData, idx, seriesScope);
  42583. };
  42584. polylineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  42585. var line = this.childAt(0);
  42586. var itemModel = lineData.getItemModel(idx);
  42587. var visualColor = lineData.getItemVisual(idx, 'color');
  42588. var lineStyle = seriesScope && seriesScope.lineStyle;
  42589. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  42590. if (!seriesScope || lineData.hasItemOption) {
  42591. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  42592. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  42593. }
  42594. line.useStyle(zrUtil.defaults(
  42595. {
  42596. strokeNoScale: true,
  42597. fill: 'none',
  42598. stroke: visualColor
  42599. },
  42600. lineStyle
  42601. ));
  42602. line.hoverStyle = hoverLineStyle;
  42603. graphic.setHoverStyle(this);
  42604. };
  42605. polylineProto.updateLayout = function (lineData, idx) {
  42606. var polyline = this.childAt(0);
  42607. polyline.setShape('points', lineData.getItemLayout(idx));
  42608. };
  42609. zrUtil.inherits(Polyline, graphic.Group);
  42610. module.exports = Polyline;
  42611. /***/ },
  42612. /* 279 */
  42613. /***/ function(module, exports, __webpack_require__) {
  42614. /**
  42615. * Provide effect for line
  42616. * @module echarts/chart/helper/EffectLine
  42617. */
  42618. var Polyline = __webpack_require__(278);
  42619. var zrUtil = __webpack_require__(4);
  42620. var EffectLine = __webpack_require__(277);
  42621. var vec2 = __webpack_require__(10);
  42622. /**
  42623. * @constructor
  42624. * @extends {module:echarts/chart/helper/EffectLine}
  42625. * @alias {module:echarts/chart/helper/Polyline}
  42626. */
  42627. function EffectPolyline(lineData, idx, seriesScope) {
  42628. EffectLine.call(this, lineData, idx, seriesScope);
  42629. this._lastFrame = 0;
  42630. this._lastFramePercent = 0;
  42631. }
  42632. var effectPolylineProto = EffectPolyline.prototype;
  42633. // Overwrite
  42634. effectPolylineProto.createLine = function (lineData, idx, seriesScope) {
  42635. return new Polyline(lineData, idx, seriesScope);
  42636. };
  42637. // Overwrite
  42638. effectPolylineProto.updateAnimationPoints = function (symbol, points) {
  42639. this._points = points;
  42640. var accLenArr = [0];
  42641. var len = 0;
  42642. for (var i = 1; i < points.length; i++) {
  42643. var p1 = points[i - 1];
  42644. var p2 = points[i];
  42645. len += vec2.dist(p1, p2);
  42646. accLenArr.push(len);
  42647. }
  42648. if (len === 0) {
  42649. return;
  42650. }
  42651. for (var i = 0; i < accLenArr.length; i++) {
  42652. accLenArr[i] /= len;
  42653. }
  42654. this._offsets = accLenArr;
  42655. this._length = len;
  42656. };
  42657. // Overwrite
  42658. effectPolylineProto.getLineLength = function (symbol) {
  42659. return this._length;
  42660. };
  42661. // Overwrite
  42662. effectPolylineProto.updateSymbolPosition = function (symbol) {
  42663. var t = symbol.__t;
  42664. var points = this._points;
  42665. var offsets = this._offsets;
  42666. var len = points.length;
  42667. if (!offsets) {
  42668. // Has length 0
  42669. return;
  42670. }
  42671. var lastFrame = this._lastFrame;
  42672. var frame;
  42673. if (t < this._lastFramePercent) {
  42674. // Start from the next frame
  42675. // PENDING start from lastFrame ?
  42676. var start = Math.min(lastFrame + 1, len - 1);
  42677. for (frame = start; frame >= 0; frame--) {
  42678. if (offsets[frame] <= t) {
  42679. break;
  42680. }
  42681. }
  42682. // PENDING really need to do this ?
  42683. frame = Math.min(frame, len - 2);
  42684. }
  42685. else {
  42686. for (var frame = lastFrame; frame < len; frame++) {
  42687. if (offsets[frame] > t) {
  42688. break;
  42689. }
  42690. }
  42691. frame = Math.min(frame - 1, len - 2);
  42692. }
  42693. vec2.lerp(
  42694. symbol.position, points[frame], points[frame + 1],
  42695. (t - offsets[frame]) / (offsets[frame + 1] - offsets[frame])
  42696. );
  42697. var tx = points[frame + 1][0] - points[frame][0];
  42698. var ty = points[frame + 1][1] - points[frame][1];
  42699. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  42700. this._lastFrame = frame;
  42701. this._lastFramePercent = t;
  42702. symbol.ignore = false;
  42703. };
  42704. zrUtil.inherits(EffectPolyline, EffectLine);
  42705. module.exports = EffectPolyline;
  42706. /***/ },
  42707. /* 280 */
  42708. /***/ function(module, exports, __webpack_require__) {
  42709. // TODO Batch by color
  42710. var graphic = __webpack_require__(18);
  42711. var quadraticContain = __webpack_require__(42);
  42712. var lineContain = __webpack_require__(40);
  42713. var LargeLineShape = graphic.extendShape({
  42714. shape: {
  42715. polyline: false,
  42716. segs: []
  42717. },
  42718. buildPath: function (path, shape) {
  42719. var segs = shape.segs;
  42720. var isPolyline = shape.polyline;
  42721. for (var i = 0; i < segs.length; i++) {
  42722. var seg = segs[i];
  42723. if (isPolyline) {
  42724. path.moveTo(seg[0][0], seg[0][1]);
  42725. for (var j = 1; j < seg.length; j++) {
  42726. path.lineTo(seg[j][0], seg[j][1]);
  42727. }
  42728. }
  42729. else {
  42730. path.moveTo(seg[0][0], seg[0][1]);
  42731. if (seg.length > 2) {
  42732. path.quadraticCurveTo(seg[2][0], seg[2][1], seg[1][0], seg[1][1]);
  42733. }
  42734. else {
  42735. path.lineTo(seg[1][0], seg[1][1]);
  42736. }
  42737. }
  42738. }
  42739. },
  42740. findDataIndex: function (x, y) {
  42741. var shape = this.shape;
  42742. var segs = shape.segs;
  42743. var isPolyline = shape.polyline;
  42744. var lineWidth = Math.max(this.style.lineWidth, 1);
  42745. // Not consider transform
  42746. for (var i = 0; i < segs.length; i++) {
  42747. var seg = segs[i];
  42748. if (isPolyline) {
  42749. for (var j = 1; j < seg.length; j++) {
  42750. if (lineContain.containStroke(
  42751. seg[j - 1][0], seg[j - 1][1], seg[j][0], seg[j][1], lineWidth, x, y
  42752. )) {
  42753. return i;
  42754. }
  42755. }
  42756. }
  42757. else {
  42758. if (seg.length > 2) {
  42759. if (quadraticContain.containStroke(
  42760. seg[0][0], seg[0][1], seg[2][0], seg[2][1], seg[1][0], seg[1][1], lineWidth, x, y
  42761. )) {
  42762. return i;
  42763. }
  42764. }
  42765. else {
  42766. if (lineContain.containStroke(
  42767. seg[0][0], seg[0][1], seg[1][0], seg[1][1], lineWidth, x, y
  42768. )) {
  42769. return i;
  42770. }
  42771. }
  42772. }
  42773. }
  42774. return -1;
  42775. }
  42776. });
  42777. function LargeLineDraw() {
  42778. this.group = new graphic.Group();
  42779. this._lineEl = new LargeLineShape();
  42780. }
  42781. var largeLineProto = LargeLineDraw.prototype;
  42782. /**
  42783. * Update symbols draw by new data
  42784. * @param {module:echarts/data/List} data
  42785. */
  42786. largeLineProto.updateData = function (data) {
  42787. this.group.removeAll();
  42788. var lineEl = this._lineEl;
  42789. var seriesModel = data.hostModel;
  42790. lineEl.setShape({
  42791. segs: data.mapArray(data.getItemLayout),
  42792. polyline: seriesModel.get('polyline')
  42793. });
  42794. lineEl.useStyle(
  42795. seriesModel.getModel('lineStyle.normal').getLineStyle()
  42796. );
  42797. var visualColor = data.getVisual('color');
  42798. if (visualColor) {
  42799. lineEl.setStyle('stroke', visualColor);
  42800. }
  42801. lineEl.setStyle('fill');
  42802. // Enable tooltip
  42803. // PENDING May have performance issue when path is extremely large
  42804. lineEl.seriesIndex = seriesModel.seriesIndex;
  42805. lineEl.on('mousemove', function (e) {
  42806. lineEl.dataIndex = null;
  42807. var dataIndex = lineEl.findDataIndex(e.offsetX, e.offsetY);
  42808. if (dataIndex > 0) {
  42809. // Provide dataIndex for tooltip
  42810. lineEl.dataIndex = dataIndex;
  42811. }
  42812. });
  42813. // Add back
  42814. this.group.add(lineEl);
  42815. };
  42816. largeLineProto.updateLayout = function (seriesModel) {
  42817. var data = seriesModel.getData();
  42818. this._lineEl.setShape({
  42819. segs: data.mapArray(data.getItemLayout)
  42820. });
  42821. };
  42822. largeLineProto.remove = function () {
  42823. this.group.removeAll();
  42824. };
  42825. module.exports = LargeLineDraw;
  42826. /***/ },
  42827. /* 281 */
  42828. /***/ function(module, exports, __webpack_require__) {
  42829. module.exports = function (ecModel) {
  42830. ecModel.eachSeriesByType('lines', function (seriesModel) {
  42831. var coordSys = seriesModel.coordinateSystem;
  42832. var lineData = seriesModel.getData();
  42833. // FIXME Use data dimensions ?
  42834. lineData.each(function (idx) {
  42835. var itemModel = lineData.getItemModel(idx);
  42836. var coords = (itemModel.option instanceof Array) ?
  42837. itemModel.option : itemModel.get('coords');
  42838. if (true) {
  42839. if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
  42840. throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
  42841. }
  42842. }
  42843. var pts = [];
  42844. if (seriesModel.get('polyline')) {
  42845. for (var i = 0; i < coords.length; i++) {
  42846. pts.push(coordSys.dataToPoint(coords[i]));
  42847. }
  42848. }
  42849. else {
  42850. pts[0] = coordSys.dataToPoint(coords[0]);
  42851. pts[1] = coordSys.dataToPoint(coords[1]);
  42852. var curveness = itemModel.get('lineStyle.normal.curveness');
  42853. if (+curveness) {
  42854. pts[2] = [
  42855. (pts[0][0] + pts[1][0]) / 2 - (pts[0][1] - pts[1][1]) * curveness,
  42856. (pts[0][1] + pts[1][1]) / 2 - (pts[1][0] - pts[0][0]) * curveness
  42857. ];
  42858. }
  42859. }
  42860. lineData.setItemLayout(idx, pts);
  42861. });
  42862. });
  42863. };
  42864. /***/ },
  42865. /* 282 */
  42866. /***/ function(module, exports) {
  42867. function normalize(a) {
  42868. if (!(a instanceof Array)) {
  42869. a = [a, a];
  42870. }
  42871. return a;
  42872. }
  42873. module.exports = function (ecModel) {
  42874. ecModel.eachSeriesByType('lines', function (seriesModel) {
  42875. var data = seriesModel.getData();
  42876. var symbolType = normalize(seriesModel.get('symbol'));
  42877. var symbolSize = normalize(seriesModel.get('symbolSize'));
  42878. var opacityQuery = 'lineStyle.normal.opacity'.split('.');
  42879. data.setVisual('fromSymbol', symbolType && symbolType[0]);
  42880. data.setVisual('toSymbol', symbolType && symbolType[1]);
  42881. data.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  42882. data.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  42883. data.setVisual('opacity', seriesModel.get(opacityQuery));
  42884. data.each(function (idx) {
  42885. var itemModel = data.getItemModel(idx);
  42886. var symbolType = normalize(itemModel.getShallow('symbol', true));
  42887. var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
  42888. var opacity = itemModel.get(opacityQuery);
  42889. symbolType[0] && data.setItemVisual(idx, 'fromSymbol', symbolType[0]);
  42890. symbolType[1] && data.setItemVisual(idx, 'toSymbol', symbolType[1]);
  42891. symbolSize[0] && data.setItemVisual(idx, 'fromSymbolSize', symbolSize[0]);
  42892. symbolSize[1] && data.setItemVisual(idx, 'toSymbolSize', symbolSize[1]);
  42893. data.setItemVisual(idx, 'opacity', opacity);
  42894. });
  42895. });
  42896. };
  42897. /***/ },
  42898. /* 283 */
  42899. /***/ function(module, exports, __webpack_require__) {
  42900. __webpack_require__(284);
  42901. __webpack_require__(285);
  42902. /***/ },
  42903. /* 284 */
  42904. /***/ function(module, exports, __webpack_require__) {
  42905. var SeriesModel = __webpack_require__(78);
  42906. var createListFromArray = __webpack_require__(109);
  42907. module.exports = SeriesModel.extend({
  42908. type: 'series.heatmap',
  42909. getInitialData: function (option, ecModel) {
  42910. return createListFromArray(option.data, this, ecModel);
  42911. },
  42912. defaultOption: {
  42913. // Cartesian2D or geo
  42914. coordinateSystem: 'cartesian2d',
  42915. zlevel: 0,
  42916. z: 2,
  42917. // Cartesian coordinate system
  42918. // xAxisIndex: 0,
  42919. // yAxisIndex: 0,
  42920. // Geo coordinate system
  42921. geoIndex: 0,
  42922. blurSize: 30,
  42923. pointSize: 20,
  42924. maxOpacity: 1,
  42925. minOpacity: 0
  42926. }
  42927. });
  42928. /***/ },
  42929. /* 285 */
  42930. /***/ function(module, exports, __webpack_require__) {
  42931. var graphic = __webpack_require__(18);
  42932. var HeatmapLayer = __webpack_require__(286);
  42933. var zrUtil = __webpack_require__(4);
  42934. function getIsInPiecewiseRange(dataExtent, pieceList, selected) {
  42935. var dataSpan = dataExtent[1] - dataExtent[0];
  42936. pieceList = zrUtil.map(pieceList, function (piece) {
  42937. return {
  42938. interval: [
  42939. (piece.interval[0] - dataExtent[0]) / dataSpan,
  42940. (piece.interval[1] - dataExtent[0]) / dataSpan
  42941. ]
  42942. };
  42943. });
  42944. var len = pieceList.length;
  42945. var lastIndex = 0;
  42946. return function (val) {
  42947. // Try to find in the location of the last found
  42948. for (var i = lastIndex; i < len; i++) {
  42949. var interval = pieceList[i].interval;
  42950. if (interval[0] <= val && val <= interval[1]) {
  42951. lastIndex = i;
  42952. break;
  42953. }
  42954. }
  42955. if (i === len) { // Not found, back interation
  42956. for (var i = lastIndex - 1; i >= 0; i--) {
  42957. var interval = pieceList[i].interval;
  42958. if (interval[0] <= val && val <= interval[1]) {
  42959. lastIndex = i;
  42960. break;
  42961. }
  42962. }
  42963. }
  42964. return i >= 0 && i < len && selected[i];
  42965. };
  42966. }
  42967. function getIsInContinuousRange(dataExtent, range) {
  42968. var dataSpan = dataExtent[1] - dataExtent[0];
  42969. range = [
  42970. (range[0] - dataExtent[0]) / dataSpan,
  42971. (range[1] - dataExtent[0]) / dataSpan
  42972. ];
  42973. return function (val) {
  42974. return val >= range[0] && val <= range[1];
  42975. };
  42976. }
  42977. function isGeoCoordSys(coordSys) {
  42978. var dimensions = coordSys.dimensions;
  42979. // Not use coorSys.type === 'geo' because coordSys maybe extended
  42980. return dimensions[0] === 'lng' && dimensions[1] === 'lat';
  42981. }
  42982. module.exports = __webpack_require__(1).extendChartView({
  42983. type: 'heatmap',
  42984. render: function (seriesModel, ecModel, api) {
  42985. var visualMapOfThisSeries;
  42986. ecModel.eachComponent('visualMap', function (visualMap) {
  42987. visualMap.eachTargetSeries(function (targetSeries) {
  42988. if (targetSeries === seriesModel) {
  42989. visualMapOfThisSeries = visualMap;
  42990. }
  42991. });
  42992. });
  42993. if (true) {
  42994. if (!visualMapOfThisSeries) {
  42995. throw new Error('Heatmap must use with visualMap');
  42996. }
  42997. }
  42998. this.group.removeAll();
  42999. var coordSys = seriesModel.coordinateSystem;
  43000. if (coordSys.type === 'cartesian2d' || coordSys.type === 'calendar') {
  43001. this._renderOnCartesianAndCalendar(coordSys, seriesModel, api);
  43002. }
  43003. else if (isGeoCoordSys(coordSys)) {
  43004. this._renderOnGeo(
  43005. coordSys, seriesModel, visualMapOfThisSeries, api
  43006. );
  43007. }
  43008. },
  43009. dispose: function () {},
  43010. _renderOnCartesianAndCalendar: function (coordSys, seriesModel, api) {
  43011. if (coordSys.type === 'cartesian2d') {
  43012. var xAxis = coordSys.getAxis('x');
  43013. var yAxis = coordSys.getAxis('y');
  43014. if (true) {
  43015. if (!(xAxis.type === 'category' && yAxis.type === 'category')) {
  43016. throw new Error('Heatmap on cartesian must have two category axes');
  43017. }
  43018. if (!(xAxis.onBand && yAxis.onBand)) {
  43019. throw new Error('Heatmap on cartesian must have two axes with boundaryGap true');
  43020. }
  43021. }
  43022. var width = xAxis.getBandWidth();
  43023. var height = yAxis.getBandWidth();
  43024. }
  43025. var group = this.group;
  43026. var data = seriesModel.getData();
  43027. var itemStyleQuery = 'itemStyle.normal';
  43028. var hoverItemStyleQuery = 'itemStyle.emphasis';
  43029. var labelQuery = 'label.normal';
  43030. var hoverLabelQuery = 'label.emphasis';
  43031. var style = seriesModel.getModel(itemStyleQuery).getItemStyle(['color']);
  43032. var hoverStl = seriesModel.getModel(hoverItemStyleQuery).getItemStyle();
  43033. var labelModel = seriesModel.getModel('label.normal');
  43034. var hoverLabelModel = seriesModel.getModel('label.emphasis');
  43035. var coordSysType = coordSys.type;
  43036. var dataDims = coordSysType === 'cartesian2d'
  43037. ? [
  43038. seriesModel.coordDimToDataDim('x')[0],
  43039. seriesModel.coordDimToDataDim('y')[0],
  43040. seriesModel.coordDimToDataDim('value')[0]
  43041. ]
  43042. : [
  43043. seriesModel.coordDimToDataDim('time')[0],
  43044. seriesModel.coordDimToDataDim('value')[0]
  43045. ];
  43046. data.each(function (idx) {
  43047. var rect;
  43048. if (coordSysType === 'cartesian2d') {
  43049. // Ignore empty data
  43050. if (isNaN(data.get(dataDims[2], idx))) {
  43051. return;
  43052. }
  43053. var point = coordSys.dataToPoint([
  43054. data.get(dataDims[0], idx),
  43055. data.get(dataDims[1], idx)
  43056. ]);
  43057. rect = new graphic.Rect({
  43058. shape: {
  43059. x: point[0] - width / 2,
  43060. y: point[1] - height / 2,
  43061. width: width,
  43062. height: height
  43063. },
  43064. style: {
  43065. fill: data.getItemVisual(idx, 'color'),
  43066. opacity: data.getItemVisual(idx, 'opacity')
  43067. }
  43068. });
  43069. }
  43070. else {
  43071. // Ignore empty data
  43072. if (isNaN(data.get(dataDims[1], idx))) {
  43073. return;
  43074. }
  43075. rect = new graphic.Rect({
  43076. z2: 1,
  43077. shape: coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape,
  43078. style: {
  43079. fill: data.getItemVisual(idx, 'color'),
  43080. opacity: data.getItemVisual(idx, 'opacity')
  43081. }
  43082. });
  43083. }
  43084. var itemModel = data.getItemModel(idx);
  43085. // Optimization for large datset
  43086. if (data.hasItemOption) {
  43087. style = itemModel.getModel(itemStyleQuery).getItemStyle(['color']);
  43088. hoverStl = itemModel.getModel(hoverItemStyleQuery).getItemStyle();
  43089. labelModel = itemModel.getModel(labelQuery);
  43090. hoverLabelModel = itemModel.getModel(hoverLabelQuery);
  43091. }
  43092. var rawValue = seriesModel.getRawValue(idx);
  43093. var defaultText = '-';
  43094. if (rawValue && rawValue[2] != null) {
  43095. defaultText = rawValue[2];
  43096. }
  43097. if (labelModel.getShallow('show')) {
  43098. graphic.setText(style, labelModel);
  43099. style.text = seriesModel.getFormattedLabel(idx, 'normal') || defaultText;
  43100. }
  43101. if (hoverLabelModel.getShallow('show')) {
  43102. graphic.setText(hoverStl, hoverLabelModel);
  43103. hoverStl.text = seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText;
  43104. }
  43105. rect.setStyle(style);
  43106. graphic.setHoverStyle(rect, data.hasItemOption ? hoverStl : zrUtil.extend({}, hoverStl));
  43107. group.add(rect);
  43108. data.setItemGraphicEl(idx, rect);
  43109. });
  43110. },
  43111. _renderOnGeo: function (geo, seriesModel, visualMapModel, api) {
  43112. var inRangeVisuals = visualMapModel.targetVisuals.inRange;
  43113. var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange;
  43114. // if (!visualMapping) {
  43115. // throw new Error('Data range must have color visuals');
  43116. // }
  43117. var data = seriesModel.getData();
  43118. var hmLayer = this._hmLayer || (this._hmLayer || new HeatmapLayer());
  43119. hmLayer.blurSize = seriesModel.get('blurSize');
  43120. hmLayer.pointSize = seriesModel.get('pointSize');
  43121. hmLayer.minOpacity = seriesModel.get('minOpacity');
  43122. hmLayer.maxOpacity = seriesModel.get('maxOpacity');
  43123. var rect = geo.getViewRect().clone();
  43124. var roamTransform = geo.getRoamTransform().transform;
  43125. rect.applyTransform(roamTransform);
  43126. // Clamp on viewport
  43127. var x = Math.max(rect.x, 0);
  43128. var y = Math.max(rect.y, 0);
  43129. var x2 = Math.min(rect.width + rect.x, api.getWidth());
  43130. var y2 = Math.min(rect.height + rect.y, api.getHeight());
  43131. var width = x2 - x;
  43132. var height = y2 - y;
  43133. var points = data.mapArray(['lng', 'lat', 'value'], function (lng, lat, value) {
  43134. var pt = geo.dataToPoint([lng, lat]);
  43135. pt[0] -= x;
  43136. pt[1] -= y;
  43137. pt.push(value);
  43138. return pt;
  43139. });
  43140. var dataExtent = visualMapModel.getExtent();
  43141. var isInRange = visualMapModel.type === 'visualMap.continuous'
  43142. ? getIsInContinuousRange(dataExtent, visualMapModel.option.range)
  43143. : getIsInPiecewiseRange(
  43144. dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected
  43145. );
  43146. hmLayer.update(
  43147. points, width, height,
  43148. inRangeVisuals.color.getNormalizer(),
  43149. {
  43150. inRange: inRangeVisuals.color.getColorMapper(),
  43151. outOfRange: outOfRangeVisuals.color.getColorMapper()
  43152. },
  43153. isInRange
  43154. );
  43155. var img = new graphic.Image({
  43156. style: {
  43157. width: width,
  43158. height: height,
  43159. x: x,
  43160. y: y,
  43161. image: hmLayer.canvas
  43162. },
  43163. silent: true
  43164. });
  43165. this.group.add(img);
  43166. }
  43167. });
  43168. /***/ },
  43169. /* 286 */
  43170. /***/ function(module, exports, __webpack_require__) {
  43171. /**
  43172. * @file defines echarts Heatmap Chart
  43173. * @author Ovilia (me@zhangwenli.com)
  43174. * Inspired by https://github.com/mourner/simpleheat
  43175. *
  43176. * @module
  43177. */
  43178. var GRADIENT_LEVELS = 256;
  43179. var zrUtil = __webpack_require__(4);
  43180. /**
  43181. * Heatmap Chart
  43182. *
  43183. * @class
  43184. */
  43185. function Heatmap() {
  43186. var canvas = zrUtil.createCanvas();
  43187. this.canvas = canvas;
  43188. this.blurSize = 30;
  43189. this.pointSize = 20;
  43190. this.maxOpacity = 1;
  43191. this.minOpacity = 0;
  43192. this._gradientPixels = {};
  43193. }
  43194. Heatmap.prototype = {
  43195. /**
  43196. * Renders Heatmap and returns the rendered canvas
  43197. * @param {Array} data array of data, each has x, y, value
  43198. * @param {number} width canvas width
  43199. * @param {number} height canvas height
  43200. */
  43201. update: function(data, width, height, normalize, colorFunc, isInRange) {
  43202. var brush = this._getBrush();
  43203. var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
  43204. var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
  43205. var r = this.pointSize + this.blurSize;
  43206. var canvas = this.canvas;
  43207. var ctx = canvas.getContext('2d');
  43208. var len = data.length;
  43209. canvas.width = width;
  43210. canvas.height = height;
  43211. for (var i = 0; i < len; ++i) {
  43212. var p = data[i];
  43213. var x = p[0];
  43214. var y = p[1];
  43215. var value = p[2];
  43216. // calculate alpha using value
  43217. var alpha = normalize(value);
  43218. // draw with the circle brush with alpha
  43219. ctx.globalAlpha = alpha;
  43220. ctx.drawImage(brush, x - r, y - r);
  43221. }
  43222. // colorize the canvas using alpha value and set with gradient
  43223. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  43224. var pixels = imageData.data;
  43225. var offset = 0;
  43226. var pixelLen = pixels.length;
  43227. var minOpacity = this.minOpacity;
  43228. var maxOpacity = this.maxOpacity;
  43229. var diffOpacity = maxOpacity - minOpacity;
  43230. while(offset < pixelLen) {
  43231. var alpha = pixels[offset + 3] / 256;
  43232. var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
  43233. // Simple optimize to ignore the empty data
  43234. if (alpha > 0) {
  43235. var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
  43236. // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
  43237. alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
  43238. pixels[offset++] = gradient[gradientOffset];
  43239. pixels[offset++] = gradient[gradientOffset + 1];
  43240. pixels[offset++] = gradient[gradientOffset + 2];
  43241. pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
  43242. }
  43243. else {
  43244. offset += 4;
  43245. }
  43246. }
  43247. ctx.putImageData(imageData, 0, 0);
  43248. return canvas;
  43249. },
  43250. /**
  43251. * get canvas of a black circle brush used for canvas to draw later
  43252. * @private
  43253. * @returns {Object} circle brush canvas
  43254. */
  43255. _getBrush: function() {
  43256. var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas());
  43257. // set brush size
  43258. var r = this.pointSize + this.blurSize;
  43259. var d = r * 2;
  43260. brushCanvas.width = d;
  43261. brushCanvas.height = d;
  43262. var ctx = brushCanvas.getContext('2d');
  43263. ctx.clearRect(0, 0, d, d);
  43264. // in order to render shadow without the distinct circle,
  43265. // draw the distinct circle in an invisible place,
  43266. // and use shadowOffset to draw shadow in the center of the canvas
  43267. ctx.shadowOffsetX = d;
  43268. ctx.shadowBlur = this.blurSize;
  43269. // draw the shadow in black, and use alpha and shadow blur to generate
  43270. // color in color map
  43271. ctx.shadowColor = '#000';
  43272. // draw circle in the left to the canvas
  43273. ctx.beginPath();
  43274. ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
  43275. ctx.closePath();
  43276. ctx.fill();
  43277. return brushCanvas;
  43278. },
  43279. /**
  43280. * get gradient color map
  43281. * @private
  43282. */
  43283. _getGradient: function (data, colorFunc, state) {
  43284. var gradientPixels = this._gradientPixels;
  43285. var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
  43286. var color = [0, 0, 0, 0];
  43287. var off = 0;
  43288. for (var i = 0; i < 256; i++) {
  43289. colorFunc[state](i / 255, true, color);
  43290. pixelsSingleState[off++] = color[0];
  43291. pixelsSingleState[off++] = color[1];
  43292. pixelsSingleState[off++] = color[2];
  43293. pixelsSingleState[off++] = color[3];
  43294. }
  43295. return pixelsSingleState;
  43296. }
  43297. };
  43298. module.exports = Heatmap;
  43299. /***/ },
  43300. /* 287 */
  43301. /***/ function(module, exports, __webpack_require__) {
  43302. var zrUtil = __webpack_require__(4);
  43303. __webpack_require__(125);
  43304. __webpack_require__(288);
  43305. __webpack_require__(289);
  43306. var barLayoutGrid = __webpack_require__(145);
  43307. var echarts = __webpack_require__(1);
  43308. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'pictorialBar'));
  43309. echarts.registerVisual(zrUtil.curry(
  43310. __webpack_require__(121), 'pictorialBar', 'roundRect', null
  43311. ));
  43312. // In case developer forget to include grid component
  43313. __webpack_require__(124);
  43314. /***/ },
  43315. /* 288 */
  43316. /***/ function(module, exports, __webpack_require__) {
  43317. var PictorialBarSeries = __webpack_require__(141).extend({
  43318. type: 'series.pictorialBar',
  43319. dependencies: ['grid'],
  43320. defaultOption: {
  43321. symbol: 'circle', // Customized bar shape
  43322. symbolSize: null, // Can be ['100%', '100%'], null means auto.
  43323. symbolRotate: null,
  43324. symbolPosition: null, // 'start' or 'end' or 'center', null means auto.
  43325. symbolOffset: null,
  43326. symbolMargin: null, // start margin and end margin. Can be a number or a percent string.
  43327. // Auto margin by defualt.
  43328. symbolRepeat: false, // false/null/undefined, means no repeat.
  43329. // Can be true, means auto calculate repeat times and cut by data.
  43330. // Can be a number, specifies repeat times, and do not cut by data.
  43331. // Can be 'fixed', means auto calculate repeat times but do not cut by data.
  43332. symbolRepeatDirection: 'end', // 'end' means from 'start' to 'end'.
  43333. symbolClip: false,
  43334. symbolBoundingData: null, // Can be 60 or -40 or [-40, 60]
  43335. symbolPatternSize: 400, // 400 * 400 px
  43336. barGap: '-100%', // In most case, overlap is needed.
  43337. // z can be set in data item, which is z2 actually.
  43338. // Disable progressive
  43339. progressive: 0,
  43340. hoverAnimation: false // Open only when needed.
  43341. },
  43342. getInitialData: function (option) {
  43343. // Disable stack.
  43344. option.stack = null;
  43345. return PictorialBarSeries.superApply(this, 'getInitialData', arguments);
  43346. }
  43347. });
  43348. module.exports = PictorialBarSeries;
  43349. /***/ },
  43350. /* 289 */
  43351. /***/ function(module, exports, __webpack_require__) {
  43352. var zrUtil = __webpack_require__(4);
  43353. var graphic = __webpack_require__(18);
  43354. var symbolUtil = __webpack_require__(111);
  43355. var numberUtil = __webpack_require__(7);
  43356. var helper = __webpack_require__(143);
  43357. var parsePercent = numberUtil.parsePercent;
  43358. var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'normal', 'borderWidth'];
  43359. // index: +isHorizontal
  43360. var LAYOUT_ATTRS = [
  43361. {xy: 'x', wh: 'width', index: 0, posDesc: ['left', 'right']},
  43362. {xy: 'y', wh: 'height', index: 1, posDesc: ['top', 'bottom']}
  43363. ];
  43364. var pathForLineWidth = new graphic.Circle();
  43365. var BarView = __webpack_require__(1).extendChartView({
  43366. type: 'pictorialBar',
  43367. render: function (seriesModel, ecModel, api) {
  43368. var group = this.group;
  43369. var data = seriesModel.getData();
  43370. var oldData = this._data;
  43371. var cartesian = seriesModel.coordinateSystem;
  43372. var baseAxis = cartesian.getBaseAxis();
  43373. var isHorizontal = !!baseAxis.isHorizontal();
  43374. var coordSysRect = cartesian.grid.getRect();
  43375. var opt = {
  43376. ecSize: {width: api.getWidth(), height: api.getHeight()},
  43377. seriesModel: seriesModel,
  43378. coordSys: cartesian,
  43379. coordSysExtent: [
  43380. [coordSysRect.x, coordSysRect.x + coordSysRect.width],
  43381. [coordSysRect.y, coordSysRect.y + coordSysRect.height]
  43382. ],
  43383. isHorizontal: isHorizontal,
  43384. valueDim: LAYOUT_ATTRS[+isHorizontal],
  43385. categoryDim: LAYOUT_ATTRS[1 - isHorizontal]
  43386. };
  43387. data.diff(oldData)
  43388. .add(function (dataIndex) {
  43389. if (!data.hasValue(dataIndex)) {
  43390. return;
  43391. }
  43392. var itemModel = getItemModel(data, dataIndex);
  43393. var symbolMeta = getSymbolMeta(data, dataIndex, itemModel, opt);
  43394. var bar = createBar(data, opt, symbolMeta);
  43395. data.setItemGraphicEl(dataIndex, bar);
  43396. group.add(bar);
  43397. updateCommon(bar, opt, symbolMeta);
  43398. })
  43399. .update(function (newIndex, oldIndex) {
  43400. var bar = oldData.getItemGraphicEl(oldIndex);
  43401. if (!data.hasValue(newIndex)) {
  43402. group.remove(bar);
  43403. return;
  43404. }
  43405. var itemModel = getItemModel(data, newIndex);
  43406. var symbolMeta = getSymbolMeta(data, newIndex, itemModel, opt);
  43407. var pictorialShapeStr = getShapeStr(data, symbolMeta);
  43408. if (bar && pictorialShapeStr !== bar.__pictorialShapeStr) {
  43409. group.remove(bar);
  43410. data.setItemGraphicEl(newIndex, null);
  43411. bar = null;
  43412. }
  43413. if (bar) {
  43414. updateBar(bar, opt, symbolMeta);
  43415. }
  43416. else {
  43417. bar = createBar(data, opt, symbolMeta, true);
  43418. }
  43419. data.setItemGraphicEl(newIndex, bar);
  43420. bar.__pictorialSymbolMeta = symbolMeta;
  43421. // Add back
  43422. group.add(bar);
  43423. updateCommon(bar, opt, symbolMeta);
  43424. })
  43425. .remove(function (dataIndex) {
  43426. var bar = oldData.getItemGraphicEl(dataIndex);
  43427. bar && removeBar(oldData, dataIndex, bar.__pictorialSymbolMeta.animationModel, bar);
  43428. })
  43429. .execute();
  43430. this._data = data;
  43431. return this.group;
  43432. },
  43433. dispose: zrUtil.noop,
  43434. remove: function (ecModel, api) {
  43435. var group = this.group;
  43436. var data = this._data;
  43437. if (ecModel.get('animation')) {
  43438. if (data) {
  43439. data.eachItemGraphicEl(function (bar) {
  43440. removeBar(data, bar.dataIndex, ecModel, bar);
  43441. });
  43442. }
  43443. }
  43444. else {
  43445. group.removeAll();
  43446. }
  43447. }
  43448. });
  43449. // Set or calculate default value about symbol, and calculate layout info.
  43450. function getSymbolMeta(data, dataIndex, itemModel, opt) {
  43451. var layout = data.getItemLayout(dataIndex);
  43452. var symbolRepeat = itemModel.get('symbolRepeat');
  43453. var symbolClip = itemModel.get('symbolClip');
  43454. var symbolPosition = itemModel.get('symbolPosition') || 'start';
  43455. var symbolRotate = itemModel.get('symbolRotate');
  43456. var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  43457. var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
  43458. var isAnimationEnabled = itemModel.isAnimationEnabled();
  43459. var symbolMeta = {
  43460. dataIndex: dataIndex,
  43461. layout: layout,
  43462. itemModel: itemModel,
  43463. symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
  43464. color: data.getItemVisual(dataIndex, 'color'),
  43465. symbolClip: symbolClip,
  43466. symbolRepeat: symbolRepeat,
  43467. symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
  43468. symbolPatternSize: symbolPatternSize,
  43469. rotation: rotation,
  43470. animationModel: isAnimationEnabled ? itemModel : null,
  43471. hoverAnimation: isAnimationEnabled && itemModel.get('hoverAnimation'),
  43472. z2: itemModel.getShallow('z', true) || 0
  43473. };
  43474. prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
  43475. prepareSymbolSize(
  43476. data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength,
  43477. symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta
  43478. );
  43479. prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
  43480. var symbolSize = symbolMeta.symbolSize;
  43481. var symbolOffset = itemModel.get('symbolOffset');
  43482. if (zrUtil.isArray(symbolOffset)) {
  43483. symbolOffset = [
  43484. parsePercent(symbolOffset[0], symbolSize[0]),
  43485. parsePercent(symbolOffset[1], symbolSize[1])
  43486. ];
  43487. }
  43488. prepareLayoutInfo(
  43489. itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
  43490. symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength,
  43491. opt, symbolMeta
  43492. );
  43493. return symbolMeta;
  43494. }
  43495. // bar length can be negative.
  43496. function prepareBarLength(itemModel, symbolRepeat, layout, opt, output) {
  43497. var valueDim = opt.valueDim;
  43498. var symbolBoundingData = itemModel.get('symbolBoundingData');
  43499. var valueAxis = opt.coordSys.getOtherAxis(opt.coordSys.getBaseAxis());
  43500. var zeroPx = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
  43501. var pxSignIdx = 1 - +(layout[valueDim.wh] <= 0);
  43502. var boundingLength;
  43503. if (zrUtil.isArray(symbolBoundingData)) {
  43504. var symbolBoundingExtent = [
  43505. convertToCoordOnAxis(valueAxis, symbolBoundingData[0]) - zeroPx,
  43506. convertToCoordOnAxis(valueAxis, symbolBoundingData[1]) - zeroPx
  43507. ];
  43508. symbolBoundingExtent[1] < symbolBoundingExtent[0] && (symbolBoundingExtent.reverse());
  43509. boundingLength = symbolBoundingExtent[pxSignIdx];
  43510. }
  43511. else if (symbolBoundingData != null) {
  43512. boundingLength = convertToCoordOnAxis(valueAxis, symbolBoundingData) - zeroPx;
  43513. }
  43514. else if (symbolRepeat) {
  43515. boundingLength = opt.coordSysExtent[valueDim.index][pxSignIdx] - zeroPx;
  43516. }
  43517. else {
  43518. boundingLength = layout[valueDim.wh];
  43519. }
  43520. output.boundingLength = boundingLength;
  43521. if (symbolRepeat) {
  43522. output.repeatCutLength = layout[valueDim.wh];
  43523. }
  43524. output.pxSign = boundingLength > 0 ? 1 : boundingLength < 0 ? -1 : 0;
  43525. }
  43526. function convertToCoordOnAxis(axis, value) {
  43527. return axis.toGlobalCoord(axis.dataToCoord(axis.scale.parse(value)));
  43528. }
  43529. // Support ['100%', '100%']
  43530. function prepareSymbolSize(
  43531. data, dataIndex, layout, symbolRepeat, symbolClip, boundingLength,
  43532. pxSign, symbolPatternSize, opt, output
  43533. ) {
  43534. var valueDim = opt.valueDim;
  43535. var categoryDim = opt.categoryDim;
  43536. var categorySize = Math.abs(layout[categoryDim.wh]);
  43537. var symbolSize = data.getItemVisual(dataIndex, 'symbolSize');
  43538. if (zrUtil.isArray(symbolSize)) {
  43539. symbolSize = symbolSize.slice();
  43540. }
  43541. else {
  43542. if (symbolSize == null) {
  43543. symbolSize = '100%';
  43544. }
  43545. symbolSize = [symbolSize, symbolSize];
  43546. }
  43547. // Note: percentage symbolSize (like '100%') do not consider lineWidth, because it is
  43548. // to complicated to calculate real percent value if considering scaled lineWidth.
  43549. // So the actual size will bigger than layout size if lineWidth is bigger than zero,
  43550. // which can be tolerated in pictorial chart.
  43551. symbolSize[categoryDim.index] = parsePercent(
  43552. symbolSize[categoryDim.index],
  43553. categorySize
  43554. );
  43555. symbolSize[valueDim.index] = parsePercent(
  43556. symbolSize[valueDim.index],
  43557. symbolRepeat ? categorySize : Math.abs(boundingLength)
  43558. );
  43559. output.symbolSize = symbolSize;
  43560. // If x or y is less than zero, show reversed shape.
  43561. var symbolScale = output.symbolScale = [
  43562. symbolSize[0] / symbolPatternSize,
  43563. symbolSize[1] / symbolPatternSize
  43564. ];
  43565. // Follow convention, 'right' and 'top' is the normal scale.
  43566. symbolScale[valueDim.index] *= (opt.isHorizontal ? -1 : 1) * pxSign;
  43567. }
  43568. function prepareLineWidth(itemModel, symbolScale, rotation, opt, output) {
  43569. // In symbols are drawn with scale, so do not need to care about the case that width
  43570. // or height are too small. But symbol use strokeNoScale, where acture lineWidth should
  43571. // be calculated.
  43572. var valueLineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
  43573. if (valueLineWidth) {
  43574. pathForLineWidth.attr({
  43575. scale: symbolScale.slice(),
  43576. rotation: rotation
  43577. });
  43578. pathForLineWidth.updateTransform();
  43579. valueLineWidth /= pathForLineWidth.getLineScale();
  43580. valueLineWidth *= symbolScale[opt.valueDim.index];
  43581. }
  43582. output.valueLineWidth = valueLineWidth;
  43583. }
  43584. function prepareLayoutInfo(
  43585. itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
  43586. symbolPosition, valueLineWidth, boundingLength, repeatCutLength, opt, output
  43587. ) {
  43588. var categoryDim = opt.categoryDim;
  43589. var valueDim = opt.valueDim;
  43590. var pxSign = output.pxSign;
  43591. var unitLength = Math.max(symbolSize[valueDim.index] + valueLineWidth, 0);
  43592. var pathLen = unitLength;
  43593. // Note: rotation will not effect the layout of symbols, because user may
  43594. // want symbols to rotate on its center, which should not be translated
  43595. // when rotating.
  43596. if (symbolRepeat) {
  43597. var absBoundingLength = Math.abs(boundingLength);
  43598. var symbolMargin = zrUtil.retrieve(itemModel.get('symbolMargin'), '15%') + '';
  43599. var hasEndGap = false;
  43600. if (symbolMargin.lastIndexOf('!') === symbolMargin.length - 1) {
  43601. hasEndGap = true;
  43602. symbolMargin = symbolMargin.slice(0, symbolMargin.length - 1);
  43603. }
  43604. symbolMargin = parsePercent(symbolMargin, symbolSize[valueDim.index]);
  43605. var uLenWithMargin = Math.max(unitLength + symbolMargin * 2, 0);
  43606. // When symbol margin is less than 0, margin at both ends will be subtracted
  43607. // to ensure that all of the symbols will not be overflow the given area.
  43608. var endFix = hasEndGap ? 0 : symbolMargin * 2;
  43609. // Both final repeatTimes and final symbolMargin area calculated based on
  43610. // boundingLength.
  43611. var repeatSpecified = numberUtil.isNumeric(symbolRepeat);
  43612. var repeatTimes = repeatSpecified
  43613. ? symbolRepeat
  43614. : toIntTimes((absBoundingLength + endFix) / uLenWithMargin);
  43615. // Adjust calculate margin, to ensure each symbol is displayed
  43616. // entirely in the given layout area.
  43617. var mDiff = absBoundingLength - repeatTimes * unitLength;
  43618. symbolMargin = mDiff / 2 / (hasEndGap ? repeatTimes : repeatTimes - 1);
  43619. uLenWithMargin = unitLength + symbolMargin * 2;
  43620. endFix = hasEndGap ? 0 : symbolMargin * 2;
  43621. // Update repeatTimes when not all symbol will be shown.
  43622. if (!repeatSpecified && symbolRepeat !== 'fixed') {
  43623. repeatTimes = repeatCutLength
  43624. ? toIntTimes((Math.abs(repeatCutLength) + endFix) / uLenWithMargin)
  43625. : 0;
  43626. }
  43627. pathLen = repeatTimes * uLenWithMargin - endFix;
  43628. output.repeatTimes = repeatTimes;
  43629. output.symbolMargin = symbolMargin;
  43630. }
  43631. var sizeFix = pxSign * (pathLen / 2);
  43632. var pathPosition = output.pathPosition = [];
  43633. pathPosition[categoryDim.index] = layout[categoryDim.wh] / 2;
  43634. pathPosition[valueDim.index] = symbolPosition === 'start'
  43635. ? sizeFix
  43636. : symbolPosition === 'end'
  43637. ? boundingLength - sizeFix
  43638. : boundingLength / 2; // 'center'
  43639. if (symbolOffset) {
  43640. pathPosition[0] += symbolOffset[0];
  43641. pathPosition[1] += symbolOffset[1];
  43642. }
  43643. var bundlePosition = output.bundlePosition = [];
  43644. bundlePosition[categoryDim.index] = layout[categoryDim.xy];
  43645. bundlePosition[valueDim.index] = layout[valueDim.xy];
  43646. var barRectShape = output.barRectShape = zrUtil.extend({}, layout);
  43647. barRectShape[valueDim.wh] = pxSign * Math.max(
  43648. Math.abs(layout[valueDim.wh]), Math.abs(pathPosition[valueDim.index] + sizeFix)
  43649. );
  43650. barRectShape[categoryDim.wh] = layout[categoryDim.wh];
  43651. var clipShape = output.clipShape = {};
  43652. // Consider that symbol may be overflow layout rect.
  43653. clipShape[categoryDim.xy] = -layout[categoryDim.xy];
  43654. clipShape[categoryDim.wh] = opt.ecSize[categoryDim.wh];
  43655. clipShape[valueDim.xy] = 0;
  43656. clipShape[valueDim.wh] = layout[valueDim.wh];
  43657. }
  43658. function createPath(symbolMeta) {
  43659. var symbolPatternSize = symbolMeta.symbolPatternSize;
  43660. var path = symbolUtil.createSymbol(
  43661. // Consider texture img, make a big size.
  43662. symbolMeta.symbolType,
  43663. -symbolPatternSize / 2,
  43664. -symbolPatternSize / 2,
  43665. symbolPatternSize,
  43666. symbolPatternSize,
  43667. symbolMeta.color
  43668. );
  43669. path.attr({
  43670. culling: true
  43671. });
  43672. path.type !== 'image' && path.setStyle({
  43673. strokeNoScale: true
  43674. });
  43675. return path;
  43676. }
  43677. function createOrUpdateRepeatSymbols(bar, opt, symbolMeta, isUpdate) {
  43678. var bundle = bar.__pictorialBundle;
  43679. var symbolSize = symbolMeta.symbolSize;
  43680. var valueLineWidth = symbolMeta.valueLineWidth;
  43681. var pathPosition = symbolMeta.pathPosition;
  43682. var valueDim = opt.valueDim;
  43683. var repeatTimes = symbolMeta.repeatTimes || 0;
  43684. var index = 0;
  43685. var unit = symbolSize[opt.valueDim.index] + valueLineWidth + symbolMeta.symbolMargin * 2;
  43686. eachPath(bar, function (path) {
  43687. path.__pictorialAnimationIndex = index;
  43688. path.__pictorialRepeatTimes = repeatTimes;
  43689. if (index < repeatTimes) {
  43690. updateAttr(path, null, makeTarget(index), symbolMeta, isUpdate);
  43691. }
  43692. else {
  43693. updateAttr(path, null, {scale: [0, 0]}, symbolMeta, isUpdate, function () {
  43694. bundle.remove(path);
  43695. });
  43696. }
  43697. updateHoverAnimation(path, symbolMeta);
  43698. index++;
  43699. });
  43700. for (; index < repeatTimes; index++) {
  43701. var path = createPath(symbolMeta);
  43702. path.__pictorialAnimationIndex = index;
  43703. path.__pictorialRepeatTimes = repeatTimes;
  43704. bundle.add(path);
  43705. var target = makeTarget(index, true);
  43706. updateAttr(
  43707. path,
  43708. {
  43709. position: target.position,
  43710. scale: [0, 0]
  43711. },
  43712. {
  43713. scale: target.scale,
  43714. rotation: target.rotation
  43715. },
  43716. symbolMeta,
  43717. isUpdate
  43718. );
  43719. // FIXME
  43720. // If all emphasis/normal through action.
  43721. path
  43722. .on('mouseover', onMouseOver)
  43723. .on('mouseout', onMouseOut);
  43724. updateHoverAnimation(path, symbolMeta);
  43725. }
  43726. function makeTarget(index) {
  43727. var position = pathPosition.slice();
  43728. // (start && pxSign > 0) || (end && pxSign < 0): i = repeatTimes - index
  43729. // Otherwise: i = index;
  43730. var pxSign = symbolMeta.pxSign;
  43731. var i = index;
  43732. if (symbolMeta.symbolRepeatDirection === 'start' ? pxSign > 0 : pxSign < 0) {
  43733. i = repeatTimes - 1 - index;
  43734. }
  43735. position[valueDim.index] = unit * (i - repeatTimes / 2 + 0.5) + pathPosition[valueDim.index];
  43736. return {
  43737. position: position,
  43738. scale: symbolMeta.symbolScale.slice(),
  43739. rotation: symbolMeta.rotation
  43740. };
  43741. }
  43742. function onMouseOver() {
  43743. eachPath(bar, function (path) {
  43744. path.trigger('emphasis');
  43745. });
  43746. }
  43747. function onMouseOut() {
  43748. eachPath(bar, function (path) {
  43749. path.trigger('normal');
  43750. });
  43751. }
  43752. }
  43753. function createOrUpdateSingleSymbol(bar, opt, symbolMeta, isUpdate) {
  43754. var bundle = bar.__pictorialBundle;
  43755. var mainPath = bar.__pictorialMainPath;
  43756. if (!mainPath) {
  43757. mainPath = bar.__pictorialMainPath = createPath(symbolMeta);
  43758. bundle.add(mainPath);
  43759. updateAttr(
  43760. mainPath,
  43761. {
  43762. position: symbolMeta.pathPosition.slice(),
  43763. scale: [0, 0],
  43764. rotation: symbolMeta.rotation
  43765. },
  43766. {
  43767. scale: symbolMeta.symbolScale.slice()
  43768. },
  43769. symbolMeta,
  43770. isUpdate
  43771. );
  43772. mainPath
  43773. .on('mouseover', onMouseOver)
  43774. .on('mouseout', onMouseOut);
  43775. }
  43776. else {
  43777. updateAttr(
  43778. mainPath,
  43779. null,
  43780. {
  43781. position: symbolMeta.pathPosition.slice(),
  43782. scale: symbolMeta.symbolScale.slice(),
  43783. rotation: symbolMeta.rotation
  43784. },
  43785. symbolMeta,
  43786. isUpdate
  43787. );
  43788. }
  43789. updateHoverAnimation(mainPath, symbolMeta);
  43790. function onMouseOver() {
  43791. this.trigger('emphasis');
  43792. }
  43793. function onMouseOut() {
  43794. this.trigger('normal');
  43795. }
  43796. }
  43797. // bar rect is used for label.
  43798. function createOrUpdateBarRect(bar, symbolMeta, isUpdate) {
  43799. var rectShape = zrUtil.extend({}, symbolMeta.barRectShape);
  43800. var barRect = bar.__pictorialBarRect;
  43801. if (!barRect) {
  43802. barRect = bar.__pictorialBarRect = new graphic.Rect({
  43803. z2: 2,
  43804. shape: rectShape,
  43805. silent: true,
  43806. style: {
  43807. stroke: 'transparent',
  43808. fill: 'transparent',
  43809. lineWidth: 0
  43810. }
  43811. });
  43812. bar.add(barRect);
  43813. }
  43814. else {
  43815. updateAttr(barRect, null, {shape: rectShape}, symbolMeta, isUpdate);
  43816. }
  43817. }
  43818. function createOrUpdateClip(bar, opt, symbolMeta, isUpdate) {
  43819. // If not clip, symbol will be remove and rebuilt.
  43820. if (symbolMeta.symbolClip) {
  43821. var clipPath = bar.__pictorialClipPath;
  43822. var clipShape = zrUtil.extend({}, symbolMeta.clipShape);
  43823. var valueDim = opt.valueDim;
  43824. var animationModel = symbolMeta.animationModel;
  43825. var dataIndex = symbolMeta.dataIndex;
  43826. if (clipPath) {
  43827. graphic.updateProps(
  43828. clipPath, {shape: clipShape}, animationModel, dataIndex
  43829. );
  43830. }
  43831. else {
  43832. clipShape[valueDim.wh] = 0;
  43833. clipPath = new graphic.Rect({shape: clipShape});
  43834. bar.__pictorialBundle.setClipPath(clipPath);
  43835. bar.__pictorialClipPath = clipPath;
  43836. var target = {};
  43837. target[valueDim.wh] = symbolMeta.clipShape[valueDim.wh];
  43838. graphic[isUpdate ? 'updateProps' : 'initProps'](
  43839. clipPath, {shape: target}, animationModel, dataIndex
  43840. );
  43841. }
  43842. }
  43843. }
  43844. function getItemModel(data, dataIndex) {
  43845. var itemModel = data.getItemModel(dataIndex);
  43846. itemModel.getAnimationDelayParams = getAnimationDelayParams;
  43847. itemModel.isAnimationEnabled = isAnimationEnabled;
  43848. return itemModel;
  43849. }
  43850. function getAnimationDelayParams(path) {
  43851. // The order is the same as the z-order, see `symbolRepeatDiretion`.
  43852. return {
  43853. index: path.__pictorialAnimationIndex,
  43854. count: path.__pictorialRepeatTimes
  43855. };
  43856. }
  43857. function isAnimationEnabled() {
  43858. // `animation` prop can be set on itemModel in pictorial bar chart.
  43859. return this.parentModel.isAnimationEnabled() && !!this.getShallow('animation');
  43860. }
  43861. function updateHoverAnimation(path, symbolMeta) {
  43862. path.off('emphasis').off('normal');
  43863. var scale = symbolMeta.symbolScale.slice();
  43864. symbolMeta.hoverAnimation && path
  43865. .on('emphasis', function() {
  43866. this.animateTo({
  43867. scale: [scale[0] * 1.1, scale[1] * 1.1]
  43868. }, 400, 'elasticOut');
  43869. })
  43870. .on('normal', function() {
  43871. this.animateTo({
  43872. scale: scale.slice()
  43873. }, 400, 'elasticOut');
  43874. });
  43875. }
  43876. function createBar(data, opt, symbolMeta, isUpdate) {
  43877. // bar is the main element for each data.
  43878. var bar = new graphic.Group();
  43879. // bundle is used for location and clip.
  43880. var bundle = new graphic.Group();
  43881. bar.add(bundle);
  43882. bar.__pictorialBundle = bundle;
  43883. bundle.attr('position', symbolMeta.bundlePosition.slice());
  43884. if (symbolMeta.symbolRepeat) {
  43885. createOrUpdateRepeatSymbols(bar, opt, symbolMeta);
  43886. }
  43887. else {
  43888. createOrUpdateSingleSymbol(bar, opt, symbolMeta);
  43889. }
  43890. createOrUpdateBarRect(bar, symbolMeta, isUpdate);
  43891. createOrUpdateClip(bar, opt, symbolMeta, isUpdate);
  43892. bar.__pictorialShapeStr = getShapeStr(data, symbolMeta);
  43893. bar.__pictorialSymbolMeta = symbolMeta;
  43894. return bar;
  43895. }
  43896. function updateBar(bar, opt, symbolMeta) {
  43897. var animationModel = symbolMeta.animationModel;
  43898. var dataIndex = symbolMeta.dataIndex;
  43899. var bundle = bar.__pictorialBundle;
  43900. graphic.updateProps(
  43901. bundle, {position: symbolMeta.bundlePosition.slice()}, animationModel, dataIndex
  43902. );
  43903. if (symbolMeta.symbolRepeat) {
  43904. createOrUpdateRepeatSymbols(bar, opt, symbolMeta, true);
  43905. }
  43906. else {
  43907. createOrUpdateSingleSymbol(bar, opt, symbolMeta, true);
  43908. }
  43909. createOrUpdateBarRect(bar, symbolMeta, true);
  43910. createOrUpdateClip(bar, opt, symbolMeta, true);
  43911. }
  43912. function removeBar(data, dataIndex, animationModel, bar) {
  43913. // Not show text when animating
  43914. var labelRect = bar.__pictorialBarRect;
  43915. labelRect && (labelRect.style.text = '');
  43916. var pathes = [];
  43917. eachPath(bar, function (path) {
  43918. pathes.push(path);
  43919. });
  43920. bar.__pictorialMainPath && pathes.push(bar.__pictorialMainPath);
  43921. // I do not find proper remove animation for clip yet.
  43922. bar.__pictorialClipPath && (animationModel = null);
  43923. zrUtil.each(pathes, function (path) {
  43924. graphic.updateProps(
  43925. path, {scale: [0, 0]}, animationModel, dataIndex,
  43926. function () {
  43927. bar.parent && bar.parent.remove(bar);
  43928. }
  43929. );
  43930. });
  43931. data.setItemGraphicEl(dataIndex, null);
  43932. }
  43933. function getShapeStr(data, symbolMeta) {
  43934. return [
  43935. data.getItemVisual(symbolMeta.dataIndex, 'symbol') || 'none',
  43936. !!symbolMeta.symbolRepeat,
  43937. !!symbolMeta.symbolClip
  43938. ].join(':');
  43939. }
  43940. function eachPath(bar, cb, context) {
  43941. // Do not use Group#eachChild, because it do not support remove.
  43942. zrUtil.each(bar.__pictorialBundle.children(), function (el) {
  43943. el !== bar.__pictorialBarRect && cb.call(context, el);
  43944. });
  43945. }
  43946. function updateAttr(el, immediateAttrs, animationAttrs, symbolMeta, isUpdate, cb) {
  43947. immediateAttrs && el.attr(immediateAttrs);
  43948. // when symbolCip used, only clip path has init animation, otherwise it would be weird effect.
  43949. if (symbolMeta.symbolClip && !isUpdate) {
  43950. animationAttrs && el.attr(animationAttrs);
  43951. }
  43952. else {
  43953. animationAttrs && graphic[isUpdate ? 'updateProps' : 'initProps'](
  43954. el, animationAttrs, symbolMeta.animationModel, symbolMeta.dataIndex, cb
  43955. );
  43956. }
  43957. }
  43958. function updateCommon(bar, opt, symbolMeta) {
  43959. var color = symbolMeta.color;
  43960. var dataIndex = symbolMeta.dataIndex;
  43961. var itemModel = symbolMeta.itemModel;
  43962. // Color must be excluded.
  43963. // Because symbol provide setColor individually to set fill and stroke
  43964. var normalStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  43965. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  43966. var cursorStyle = itemModel.getShallow('cursor');
  43967. eachPath(bar, function (path) {
  43968. // PENDING setColor should be before setStyle!!!
  43969. path.setColor(color);
  43970. path.setStyle(zrUtil.defaults(
  43971. {
  43972. fill: color,
  43973. opacity: symbolMeta.opacity
  43974. },
  43975. normalStyle
  43976. ));
  43977. graphic.setHoverStyle(path, hoverStyle);
  43978. cursorStyle && (path.cursor = cursorStyle);
  43979. path.z2 = symbolMeta.z2;
  43980. });
  43981. var barRectHoverStyle = {};
  43982. var barPositionOutside = opt.valueDim.posDesc[+(symbolMeta.boundingLength > 0)];
  43983. var barRect = bar.__pictorialBarRect;
  43984. helper.setLabel(
  43985. barRect.style, barRectHoverStyle, itemModel,
  43986. color, opt.seriesModel, dataIndex, barPositionOutside
  43987. );
  43988. graphic.setHoverStyle(barRect, barRectHoverStyle);
  43989. }
  43990. function toIntTimes(times) {
  43991. var roundedTimes = Math.round(times);
  43992. // Escapse accurate error
  43993. return Math.abs(times - roundedTimes) < 1e-4
  43994. ? roundedTimes
  43995. : Math.ceil(times);
  43996. }
  43997. module.exports = BarView;
  43998. /***/ },
  43999. /* 290 */
  44000. /***/ function(module, exports, __webpack_require__) {
  44001. var echarts = __webpack_require__(1);
  44002. var zrUtil = __webpack_require__(4);
  44003. __webpack_require__(291);
  44004. __webpack_require__(308);
  44005. __webpack_require__(309);
  44006. echarts.registerLayout(__webpack_require__(311));
  44007. echarts.registerVisual(__webpack_require__(312));
  44008. echarts.registerProcessor(
  44009. zrUtil.curry(__webpack_require__(154), 'themeRiver')
  44010. );
  44011. /***/ },
  44012. /* 291 */
  44013. /***/ function(module, exports, __webpack_require__) {
  44014. __webpack_require__(292);
  44015. __webpack_require__(295);
  44016. __webpack_require__(297);
  44017. __webpack_require__(298);
  44018. __webpack_require__(307);
  44019. var echarts = __webpack_require__(1);
  44020. echarts.extendComponentView({
  44021. type: 'single'
  44022. });
  44023. /***/ },
  44024. /* 292 */
  44025. /***/ function(module, exports, __webpack_require__) {
  44026. /**
  44027. * Single coordinate system creator.
  44028. */
  44029. var Single = __webpack_require__(293);
  44030. /**
  44031. * Create single coordinate system and inject it into seriesModel.
  44032. *
  44033. * @param {module:echarts/model/Global} ecModel
  44034. * @param {module:echarts/ExtensionAPI} api
  44035. * @return {Array.<module:echarts/coord/single/Single>}
  44036. */
  44037. function create(ecModel, api) {
  44038. var singles = [];
  44039. ecModel.eachComponent('singleAxis', function(axisModel, idx) {
  44040. var single = new Single(axisModel, ecModel, api);
  44041. single.name = 'single_' + idx;
  44042. single.resize(axisModel, api);
  44043. axisModel.coordinateSystem = single;
  44044. singles.push(single);
  44045. });
  44046. ecModel.eachSeries(function (seriesModel) {
  44047. if (seriesModel.get('coordinateSystem') === 'singleAxis') {
  44048. var singleAxisModel = ecModel.queryComponents({
  44049. mainType: 'singleAxis',
  44050. index: seriesModel.get('singleAxisIndex'),
  44051. id: seriesModel.get('singleAxisId')
  44052. })[0];
  44053. seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
  44054. }
  44055. });
  44056. return singles;
  44057. }
  44058. __webpack_require__(76).register('single', {
  44059. create: create,
  44060. dimensions: Single.prototype.dimensions
  44061. });
  44062. /***/ },
  44063. /* 293 */
  44064. /***/ function(module, exports, __webpack_require__) {
  44065. /**
  44066. * Single coordinates system.
  44067. */
  44068. var SingleAxis = __webpack_require__(294);
  44069. var axisHelper = __webpack_require__(101);
  44070. var layout = __webpack_require__(71);
  44071. /**
  44072. * Create a single coordinates system.
  44073. *
  44074. * @param {module:echarts/coord/single/AxisModel} axisModel
  44075. * @param {module:echarts/model/Global} ecModel
  44076. * @param {module:echarts/ExtensionAPI} api
  44077. */
  44078. function Single(axisModel, ecModel, api) {
  44079. /**
  44080. * @type {string}
  44081. * @readOnly
  44082. */
  44083. this.dimension = 'single';
  44084. /**
  44085. * Add it just for draw tooltip.
  44086. *
  44087. * @type {Array.<string>}
  44088. * @readOnly
  44089. */
  44090. this.dimensions = ['single'];
  44091. /**
  44092. * @private
  44093. * @type {module:echarts/coord/single/SingleAxis}.
  44094. */
  44095. this._axis = null;
  44096. /**
  44097. * @private
  44098. * @type {module:zrender/core/BoundingRect}
  44099. */
  44100. this._rect;
  44101. this._init(axisModel, ecModel, api);
  44102. /**
  44103. * @type {module:echarts/coord/single/AxisModel}
  44104. */
  44105. this.model = axisModel;
  44106. }
  44107. Single.prototype = {
  44108. type: 'singleAxis',
  44109. axisPointerEnabled: true,
  44110. constructor: Single,
  44111. /**
  44112. * Initialize single coordinate system.
  44113. *
  44114. * @param {module:echarts/coord/single/AxisModel} axisModel
  44115. * @param {module:echarts/model/Global} ecModel
  44116. * @param {module:echarts/ExtensionAPI} api
  44117. * @private
  44118. */
  44119. _init: function (axisModel, ecModel, api) {
  44120. var dim = this.dimension;
  44121. var axis = new SingleAxis(
  44122. dim,
  44123. axisHelper.createScaleByModel(axisModel),
  44124. [0, 0],
  44125. axisModel.get('type'),
  44126. axisModel.get('position')
  44127. );
  44128. var isCategory = axis.type === 'category';
  44129. axis.onBand = isCategory && axisModel.get('boundaryGap');
  44130. axis.inverse = axisModel.get('inverse');
  44131. axis.orient = axisModel.get('orient');
  44132. axisModel.axis = axis;
  44133. axis.model = axisModel;
  44134. axis.coordinateSystem = this;
  44135. this._axis = axis;
  44136. },
  44137. /**
  44138. * Update axis scale after data processed
  44139. * @param {module:echarts/model/Global} ecModel
  44140. * @param {module:echarts/ExtensionAPI} api
  44141. */
  44142. update: function (ecModel, api) {
  44143. ecModel.eachSeries(function (seriesModel) {
  44144. if (seriesModel.coordinateSystem === this) {
  44145. var data = seriesModel.getData();
  44146. var dim = this.dimension;
  44147. this._axis.scale.unionExtentFromData(
  44148. data, seriesModel.coordDimToDataDim(dim)
  44149. );
  44150. axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
  44151. }
  44152. }, this);
  44153. },
  44154. /**
  44155. * Resize the single coordinate system.
  44156. *
  44157. * @param {module:echarts/coord/single/AxisModel} axisModel
  44158. * @param {module:echarts/ExtensionAPI} api
  44159. */
  44160. resize: function (axisModel, api) {
  44161. this._rect = layout.getLayoutRect(
  44162. {
  44163. left: axisModel.get('left'),
  44164. top: axisModel.get('top'),
  44165. right: axisModel.get('right'),
  44166. bottom: axisModel.get('bottom'),
  44167. width: axisModel.get('width'),
  44168. height: axisModel.get('height')
  44169. },
  44170. {
  44171. width: api.getWidth(),
  44172. height: api.getHeight()
  44173. }
  44174. );
  44175. this._adjustAxis();
  44176. },
  44177. /**
  44178. * @return {module:zrender/core/BoundingRect}
  44179. */
  44180. getRect: function () {
  44181. return this._rect;
  44182. },
  44183. /**
  44184. * @private
  44185. */
  44186. _adjustAxis: function () {
  44187. var rect = this._rect;
  44188. var axis = this._axis;
  44189. var isHorizontal = axis.isHorizontal();
  44190. var extent = isHorizontal ? [0, rect.width] : [0, rect.height];
  44191. var idx = axis.reverse ? 1 : 0;
  44192. axis.setExtent(extent[idx], extent[1 - idx]);
  44193. this._updateAxisTransform(axis, isHorizontal ? rect.x : rect.y);
  44194. },
  44195. /**
  44196. * @param {module:echarts/coord/single/SingleAxis} axis
  44197. * @param {number} coordBase
  44198. */
  44199. _updateAxisTransform: function (axis, coordBase) {
  44200. var axisExtent = axis.getExtent();
  44201. var extentSum = axisExtent[0] + axisExtent[1];
  44202. var isHorizontal = axis.isHorizontal();
  44203. axis.toGlobalCoord = isHorizontal
  44204. ? function (coord) {
  44205. return coord + coordBase;
  44206. }
  44207. : function (coord) {
  44208. return extentSum - coord + coordBase;
  44209. };
  44210. axis.toLocalCoord = isHorizontal
  44211. ? function (coord) {
  44212. return coord - coordBase;
  44213. }
  44214. : function (coord) {
  44215. return extentSum - coord + coordBase;
  44216. };
  44217. },
  44218. /**
  44219. * Get axis.
  44220. *
  44221. * @return {module:echarts/coord/single/SingleAxis}
  44222. */
  44223. getAxis: function () {
  44224. return this._axis;
  44225. },
  44226. /**
  44227. * Get axis, add it just for draw tooltip.
  44228. *
  44229. * @return {[type]} [description]
  44230. */
  44231. getBaseAxis: function () {
  44232. return this._axis;
  44233. },
  44234. /**
  44235. * @return {Array.<module:echarts/coord/Axis>}
  44236. */
  44237. getAxes: function () {
  44238. return [this._axis];
  44239. },
  44240. /**
  44241. * @return {Object} {baseAxes: [], otherAxes: []}
  44242. */
  44243. getTooltipAxes: function () {
  44244. return {baseAxes: [this.getAxis()]};
  44245. },
  44246. /**
  44247. * If contain point.
  44248. *
  44249. * @param {Array.<number>} point
  44250. * @return {boolean}
  44251. */
  44252. containPoint: function (point) {
  44253. var rect = this.getRect();
  44254. var axis = this.getAxis();
  44255. var orient = axis.orient;
  44256. if (orient === 'horizontal') {
  44257. return axis.contain(axis.toLocalCoord(point[0]))
  44258. && (point[1] >= rect.y && point[1] <= (rect.y + rect.height));
  44259. }
  44260. else {
  44261. return axis.contain(axis.toLocalCoord(point[1]))
  44262. && (point[0] >= rect.y && point[0] <= (rect.y + rect.height));
  44263. }
  44264. },
  44265. /**
  44266. * @param {Array.<number>} point
  44267. * @return {Array.<number>}
  44268. */
  44269. pointToData: function (point) {
  44270. var axis = this.getAxis();
  44271. return [axis.coordToData(axis.toLocalCoord(
  44272. point[axis.orient === 'horizontal' ? 0 : 1]
  44273. ))];
  44274. },
  44275. /**
  44276. * Convert the series data to concrete point.
  44277. *
  44278. * @param {number|Array.<number>} val
  44279. * @return {Array.<number>}
  44280. */
  44281. dataToPoint: function (val) {
  44282. var axis = this.getAxis();
  44283. var rect = this.getRect();
  44284. var pt = [];
  44285. var idx = axis.orient === 'horizontal' ? 0 : 1;
  44286. if (val instanceof Array) {
  44287. val = val[0];
  44288. }
  44289. pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
  44290. pt[1 - idx] = idx === 0 ? (rect.y + rect.height / 2) : (rect.x + rect.width / 2);
  44291. return pt;
  44292. }
  44293. };
  44294. module.exports = Single;
  44295. /***/ },
  44296. /* 294 */
  44297. /***/ function(module, exports, __webpack_require__) {
  44298. var zrUtil = __webpack_require__(4);
  44299. var Axis = __webpack_require__(100);
  44300. /**
  44301. * @constructor module:echarts/coord/single/SingleAxis
  44302. * @extends {module:echarts/coord/Axis}
  44303. * @param {string} dim
  44304. * @param {*} scale
  44305. * @param {Array.<number>} coordExtent
  44306. * @param {string} axisType
  44307. * @param {string} position
  44308. */
  44309. var SingleAxis = function (dim, scale, coordExtent, axisType, position) {
  44310. Axis.call(this, dim, scale, coordExtent);
  44311. /**
  44312. * Axis type
  44313. * - 'category'
  44314. * - 'value'
  44315. * - 'time'
  44316. * - 'log'
  44317. * @type {string}
  44318. */
  44319. this.type = axisType || 'value';
  44320. /**
  44321. * Axis position
  44322. * - 'top'
  44323. * - 'bottom'
  44324. * - 'left'
  44325. * - 'right'
  44326. * @type {string}
  44327. */
  44328. this.position = position || 'bottom';
  44329. /**
  44330. * Axis orient
  44331. * - 'horizontal'
  44332. * - 'vertical'
  44333. * @type {[type]}
  44334. */
  44335. this.orient = null;
  44336. /**
  44337. * @type {number}
  44338. */
  44339. this._labelInterval = null;
  44340. };
  44341. SingleAxis.prototype = {
  44342. constructor: SingleAxis,
  44343. /**
  44344. * Axis model
  44345. * @type {module:echarts/coord/single/AxisModel}
  44346. */
  44347. model: null,
  44348. /**
  44349. * Judge the orient of the axis.
  44350. * @return {boolean}
  44351. */
  44352. isHorizontal: function () {
  44353. var position = this.position;
  44354. return position === 'top' || position === 'bottom';
  44355. },
  44356. /**
  44357. * @override
  44358. */
  44359. pointToData: function (point, clamp) {
  44360. return this.coordinateSystem.pointToData(point, clamp)[0];
  44361. },
  44362. /**
  44363. * Convert the local coord(processed by dataToCoord())
  44364. * to global coord(concrete pixel coord).
  44365. * designated by module:echarts/coord/single/Single.
  44366. * @type {Function}
  44367. */
  44368. toGlobalCoord: null,
  44369. /**
  44370. * Convert the global coord to local coord.
  44371. * designated by module:echarts/coord/single/Single.
  44372. * @type {Function}
  44373. */
  44374. toLocalCoord: null
  44375. };
  44376. zrUtil.inherits(SingleAxis, Axis);
  44377. module.exports = SingleAxis;
  44378. /***/ },
  44379. /* 295 */
  44380. /***/ function(module, exports, __webpack_require__) {
  44381. var AxisBuilder = __webpack_require__(135);
  44382. var zrUtil = __webpack_require__(4);
  44383. var graphic = __webpack_require__(18);
  44384. var singleAxisHelper = __webpack_require__(296);
  44385. var getInterval = AxisBuilder.getInterval;
  44386. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  44387. var axisBuilderAttrs = [
  44388. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  44389. ];
  44390. var selfBuilderAttr = 'splitLine';
  44391. var SingleAxisView = __webpack_require__(136).extend({
  44392. type: 'singleAxis',
  44393. axisPointerClass: 'SingleAxisPointer',
  44394. render: function (axisModel, ecModel, api, payload) {
  44395. var group = this.group;
  44396. group.removeAll();
  44397. var layout = singleAxisHelper.layout(axisModel);
  44398. var axisBuilder = new AxisBuilder(axisModel, layout);
  44399. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  44400. group.add(axisBuilder.getGroup());
  44401. if (axisModel.get(selfBuilderAttr + '.show')) {
  44402. this['_' + selfBuilderAttr](axisModel, layout.labelInterval);
  44403. }
  44404. SingleAxisView.superCall(this, 'render', axisModel, ecModel, api, payload);
  44405. },
  44406. _splitLine: function(axisModel, labelInterval) {
  44407. var axis = axisModel.axis;
  44408. if (axis.scale.isBlank()) {
  44409. return;
  44410. }
  44411. var splitLineModel = axisModel.getModel('splitLine');
  44412. var lineStyleModel = splitLineModel.getModel('lineStyle');
  44413. var lineWidth = lineStyleModel.get('width');
  44414. var lineColors = lineStyleModel.get('color');
  44415. var lineInterval = getInterval(splitLineModel, labelInterval);
  44416. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  44417. var gridRect = axisModel.coordinateSystem.getRect();
  44418. var isHorizontal = axis.isHorizontal();
  44419. var splitLines = [];
  44420. var lineCount = 0;
  44421. var ticksCoords = axis.getTicksCoords();
  44422. var p1 = [];
  44423. var p2 = [];
  44424. for (var i = 0; i < ticksCoords.length; ++i) {
  44425. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  44426. continue;
  44427. }
  44428. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  44429. if (isHorizontal) {
  44430. p1[0] = tickCoord;
  44431. p1[1] = gridRect.y;
  44432. p2[0] = tickCoord;
  44433. p2[1] = gridRect.y + gridRect.height;
  44434. }
  44435. else {
  44436. p1[0] = gridRect.x;
  44437. p1[1] = tickCoord;
  44438. p2[0] = gridRect.x + gridRect.width;
  44439. p2[1] = tickCoord;
  44440. }
  44441. var colorIndex = (lineCount++) % lineColors.length;
  44442. splitLines[colorIndex] = splitLines[colorIndex] || [];
  44443. splitLines[colorIndex].push(new graphic.Line(
  44444. graphic.subPixelOptimizeLine({
  44445. shape: {
  44446. x1: p1[0],
  44447. y1: p1[1],
  44448. x2: p2[0],
  44449. y2: p2[1]
  44450. },
  44451. style: {
  44452. lineWidth: lineWidth
  44453. },
  44454. silent: true
  44455. })));
  44456. }
  44457. for (var i = 0; i < splitLines.length; ++i) {
  44458. this.group.add(graphic.mergePath(splitLines[i], {
  44459. style: {
  44460. stroke: lineColors[i % lineColors.length],
  44461. lineDash: lineStyleModel.getLineDash(lineWidth),
  44462. lineWidth: lineWidth
  44463. },
  44464. silent: true
  44465. }));
  44466. }
  44467. }
  44468. });
  44469. module.exports = SingleAxisView;
  44470. /***/ },
  44471. /* 296 */
  44472. /***/ function(module, exports, __webpack_require__) {
  44473. var zrUtil = __webpack_require__(4);
  44474. var helper = {};
  44475. /**
  44476. * @param {Object} opt {labelInside}
  44477. * @return {Object} {
  44478. * position, rotation, labelDirection, labelOffset,
  44479. * tickDirection, labelRotate, labelInterval, z2
  44480. * }
  44481. */
  44482. helper.layout = function (axisModel, opt) {
  44483. opt = opt || {};
  44484. var single = axisModel.coordinateSystem;
  44485. var axis = axisModel.axis;
  44486. var layout = {};
  44487. var axisPosition = axis.position;
  44488. var orient = axis.orient;
  44489. var rect = single.getRect();
  44490. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  44491. var positionMap = {
  44492. horizontal: {top: rectBound[2], bottom: rectBound[3]},
  44493. vertical: {left: rectBound[0], right: rectBound[1]}
  44494. };
  44495. layout.position = [
  44496. orient === 'vertical'
  44497. ? positionMap.vertical[axisPosition]
  44498. : rectBound[0],
  44499. orient === 'horizontal'
  44500. ? positionMap.horizontal[axisPosition]
  44501. : rectBound[3]
  44502. ];
  44503. var r = {horizontal: 0, vertical: 1};
  44504. layout.rotation = Math.PI / 2 * r[orient];
  44505. var directionMap = {top: -1, bottom: 1, right: 1, left: -1};
  44506. layout.labelDirection = layout.tickDirection
  44507. = layout.nameDirection
  44508. = directionMap[axisPosition];
  44509. if (axisModel.get('axisTick.inside')) {
  44510. layout.tickDirection = -layout.tickDirection;
  44511. }
  44512. if (zrUtil.retrieve(opt.labelInside, axisModel.get('axisLabel.inside'))) {
  44513. layout.labelDirection = -layout.labelDirection;
  44514. }
  44515. var labelRotation = opt.rotate;
  44516. labelRotation == null && (labelRotation = axisModel.get('axisLabel.rotate'));
  44517. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  44518. layout.labelInterval = axis.getLabelInterval();
  44519. layout.z2 = 1;
  44520. return layout;
  44521. };
  44522. module.exports = helper;
  44523. /***/ },
  44524. /* 297 */
  44525. /***/ function(module, exports, __webpack_require__) {
  44526. var ComponentModel = __webpack_require__(69);
  44527. var axisModelCreator = __webpack_require__(131);
  44528. var zrUtil = __webpack_require__(4);
  44529. var AxisModel = ComponentModel.extend({
  44530. type: 'singleAxis',
  44531. layoutMode: 'box',
  44532. /**
  44533. * @type {module:echarts/coord/single/SingleAxis}
  44534. */
  44535. axis: null,
  44536. /**
  44537. * @type {module:echarts/coord/single/Single}
  44538. */
  44539. coordinateSystem: null,
  44540. /**
  44541. * @override
  44542. */
  44543. getCoordSysModel: function () {
  44544. return this;
  44545. }
  44546. });
  44547. var defaultOption = {
  44548. left: '5%',
  44549. top: '5%',
  44550. right: '5%',
  44551. bottom: '5%',
  44552. type: 'value',
  44553. position: 'bottom',
  44554. orient: 'horizontal',
  44555. axisLine: {
  44556. show: true,
  44557. lineStyle: {
  44558. width: 2,
  44559. type: 'solid'
  44560. }
  44561. },
  44562. // Single coordinate system and single axis is the,
  44563. // which is used as the parent tooltip model.
  44564. // same model, so we set default tooltip show as true.
  44565. tooltip: {
  44566. show: true
  44567. },
  44568. axisTick: {
  44569. show: true,
  44570. length: 6,
  44571. lineStyle: {
  44572. width: 2
  44573. }
  44574. },
  44575. axisLabel: {
  44576. show: true,
  44577. interval: 'auto'
  44578. },
  44579. splitLine: {
  44580. show: true,
  44581. lineStyle: {
  44582. type: 'dashed',
  44583. opacity: 0.2
  44584. }
  44585. }
  44586. };
  44587. function getAxisType(axisName, option) {
  44588. return option.type || (option.data ? 'category' : 'value');
  44589. }
  44590. zrUtil.merge(AxisModel.prototype, __webpack_require__(112));
  44591. axisModelCreator('single', AxisModel, getAxisType, defaultOption);
  44592. module.exports = AxisModel;
  44593. /***/ },
  44594. /* 298 */
  44595. /***/ function(module, exports, __webpack_require__) {
  44596. var echarts = __webpack_require__(1);
  44597. var axisPointerModelHelper = __webpack_require__(137);
  44598. var axisTrigger = __webpack_require__(299);
  44599. var zrUtil = __webpack_require__(4);
  44600. __webpack_require__(301);
  44601. __webpack_require__(302);
  44602. // CartesianAxisPointer is not supposed to be required here. But consider
  44603. // echarts.simple.js and online build tooltip, which only require gridSimple,
  44604. // CartesianAxisPointer should be able to required somewhere.
  44605. __webpack_require__(304);
  44606. echarts.registerPreprocessor(function (option) {
  44607. // Always has a global axisPointerModel for default setting.
  44608. if (option) {
  44609. (!option.axisPointer || option.axisPointer.length === 0)
  44610. && (option.axisPointer = {});
  44611. var link = option.axisPointer.link;
  44612. // Normalize to array to avoid object mergin. But if link
  44613. // is not set, remain null/undefined, otherwise it will
  44614. // override existent link setting.
  44615. if (link && !zrUtil.isArray(link)) {
  44616. option.axisPointer.link = [link];
  44617. }
  44618. }
  44619. });
  44620. // This process should proformed after coordinate systems created
  44621. // and series data processed. So put it on statistic processing stage.
  44622. echarts.registerProcessor(echarts.PRIORITY.PROCESSOR.STATISTIC, function (ecModel, api) {
  44623. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  44624. // allAxesInfo should be updated when setOption performed.
  44625. ecModel.getComponent('axisPointer').coordSysAxesInfo
  44626. = axisPointerModelHelper.collect(ecModel, api);
  44627. });
  44628. // Broadcast to all views.
  44629. echarts.registerAction({
  44630. type: 'updateAxisPointer',
  44631. event: 'updateAxisPointer',
  44632. update: ':updateAxisPointer'
  44633. }, axisTrigger);
  44634. /***/ },
  44635. /* 299 */
  44636. /***/ function(module, exports, __webpack_require__) {
  44637. var zrUtil = __webpack_require__(4);
  44638. var modelUtil = __webpack_require__(5);
  44639. var modelHelper = __webpack_require__(137);
  44640. var findPointFromSeries = __webpack_require__(300);
  44641. var each = zrUtil.each;
  44642. var curry = zrUtil.curry;
  44643. var get = modelUtil.makeGetter();
  44644. /**
  44645. * Basic logic: check all axis, if they do not demand show/highlight,
  44646. * then hide/downplay them.
  44647. *
  44648. * @param {Object} coordSysAxesInfo
  44649. * @param {Object} payload
  44650. * @param {string} [payload.currTrigger] 'click' | 'mousemove' | 'leave'
  44651. * @param {Array.<number>} [payload.x] x and y, which are mandatory, specify a point to
  44652. * trigger axisPointer and tooltip.
  44653. * @param {Array.<number>} [payload.y] x and y, which are mandatory, specify a point to
  44654. * trigger axisPointer and tooltip.
  44655. * @param {Object} [payload.seriesIndex] finder, optional, restrict target axes.
  44656. * @param {Object} [payload.dataIndex] finder, restrict target axes.
  44657. * @param {Object} [payload.axesInfo] finder, restrict target axes.
  44658. * [{
  44659. * axisDim: 'x'|'y'|'angle'|...,
  44660. * axisIndex: ...,
  44661. * value: ...
  44662. * }, ...]
  44663. * @param {Function} [payload.dispatchAction]
  44664. * @param {Object} [payload.tooltipOption]
  44665. * @param {Object|Array.<number>|Function} [payload.position] Tooltip position,
  44666. * which can be specified in dispatchAction
  44667. * @param {module:echarts/model/Global} ecModel
  44668. * @param {module:echarts/ExtensionAPI} api
  44669. * @return {Object} content of event obj for echarts.connect.
  44670. */
  44671. function axisTrigger(payload, ecModel, api) {
  44672. var currTrigger = payload.currTrigger;
  44673. var point = [payload.x, payload.y];
  44674. var finder = payload;
  44675. var dispatchAction = payload.dispatchAction || zrUtil.bind(api.dispatchAction, api);
  44676. var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo;
  44677. if (illegalPoint(point)) {
  44678. // Used in the default behavior of `connection`: use the sample seriesIndex
  44679. // and dataIndex. And also used in the tooltipView trigger.
  44680. point = findPointFromSeries({
  44681. seriesIndex: finder.seriesIndex,
  44682. // Do not use dataIndexInside from other ec instance.
  44683. // FIXME: auto detect it?
  44684. dataIndex: finder.dataIndex
  44685. }, ecModel).point;
  44686. }
  44687. var isIllegalPoint = illegalPoint(point);
  44688. // Axis and value can be specified when calling dispatchAction({type: 'updateAxisPointer'}).
  44689. // Notice: In this case, it is difficult to get the `point` (which is necessary to show
  44690. // tooltip, so if point is not given, we just use the point found by sample seriesIndex
  44691. // and dataIndex.
  44692. var inputAxesInfo = finder.axesInfo;
  44693. var axesInfo = coordSysAxesInfo.axesInfo;
  44694. var shouldHide = currTrigger === 'leave' || illegalPoint(point);
  44695. var outputFinder = {};
  44696. var showValueMap = {};
  44697. var dataByCoordSys = {list: [], map: {}};
  44698. var updaters = {
  44699. showPointer: curry(showPointer, showValueMap),
  44700. showTooltip: curry(showTooltip, dataByCoordSys)
  44701. };
  44702. // Process for triggered axes.
  44703. each(coordSysAxesInfo.coordSysMap, function (coordSys, coordSysKey) {
  44704. // If a point given, it must be contained by the coordinate system.
  44705. var coordSysContainsPoint = isIllegalPoint || coordSys.containPoint(point);
  44706. each(coordSysAxesInfo.coordSysAxesInfo[coordSysKey], function (axisInfo, key) {
  44707. var axis = axisInfo.axis;
  44708. var inputAxisInfo = findInputAxisInfo(inputAxesInfo, axisInfo);
  44709. // If no inputAxesInfo, no axis is restricted.
  44710. if (!shouldHide && coordSysContainsPoint && (!inputAxesInfo || inputAxisInfo)) {
  44711. var val = inputAxisInfo && inputAxisInfo.value;
  44712. if (val == null && !isIllegalPoint) {
  44713. val = axis.pointToData(point);
  44714. }
  44715. val != null && processOnAxis(axisInfo, val, updaters, false, outputFinder);
  44716. }
  44717. });
  44718. });
  44719. // Process for linked axes.
  44720. var linkTriggers = {};
  44721. each(axesInfo, function (tarAxisInfo, tarKey) {
  44722. var linkGroup = tarAxisInfo.linkGroup;
  44723. // If axis has been triggered in the previous stage, it should not be triggered by link.
  44724. if (linkGroup && !showValueMap[tarKey]) {
  44725. each(linkGroup.axesInfo, function (srcAxisInfo, srcKey) {
  44726. var srcValItem = showValueMap[srcKey];
  44727. // If srcValItem exist, source axis is triggered, so link to target axis.
  44728. if (srcAxisInfo !== tarAxisInfo && srcValItem) {
  44729. var val = srcValItem.value;
  44730. linkGroup.mapper && (val = tarAxisInfo.axis.scale.parse(linkGroup.mapper(
  44731. val, makeMapperParam(srcAxisInfo), makeMapperParam(tarAxisInfo)
  44732. )));
  44733. linkTriggers[tarAxisInfo.key] = val;
  44734. }
  44735. });
  44736. }
  44737. });
  44738. each(linkTriggers, function (val, tarKey) {
  44739. processOnAxis(axesInfo[tarKey], val, updaters, true, outputFinder);
  44740. });
  44741. updateModelActually(showValueMap, axesInfo, outputFinder);
  44742. dispatchTooltipActually(dataByCoordSys, point, payload, dispatchAction);
  44743. dispatchHighDownActually(axesInfo, dispatchAction, api);
  44744. return outputFinder;
  44745. }
  44746. function processOnAxis(axisInfo, newValue, updaters, dontSnap, outputFinder) {
  44747. var axis = axisInfo.axis;
  44748. if (axis.scale.isBlank() || !axis.containData(newValue)) {
  44749. return;
  44750. }
  44751. if (!axisInfo.involveSeries) {
  44752. updaters.showPointer(axisInfo, newValue);
  44753. return;
  44754. }
  44755. // Heavy calculation. So put it after axis.containData checking.
  44756. var payloadInfo = buildPayloadsBySeries(newValue, axisInfo);
  44757. var payloadBatch = payloadInfo.payloadBatch;
  44758. var snapToValue = payloadInfo.snapToValue;
  44759. // Fill content of event obj for echarts.connect.
  44760. // By defualt use the first involved series data as a sample to connect.
  44761. if (payloadBatch[0] && outputFinder.seriesIndex == null) {
  44762. zrUtil.extend(outputFinder, payloadBatch[0]);
  44763. }
  44764. // If no linkSource input, this process is for collecting link
  44765. // target, where snap should not be accepted.
  44766. if (!dontSnap && axisInfo.snap) {
  44767. if (axis.containData(snapToValue) && snapToValue != null) {
  44768. newValue = snapToValue;
  44769. }
  44770. }
  44771. updaters.showPointer(axisInfo, newValue, payloadBatch, outputFinder);
  44772. // Tooltip should always be snapToValue, otherwise there will be
  44773. // incorrect "axis value ~ series value" mapping displayed in tooltip.
  44774. updaters.showTooltip(axisInfo, payloadInfo, snapToValue);
  44775. }
  44776. function buildPayloadsBySeries(value, axisInfo) {
  44777. var axis = axisInfo.axis;
  44778. var dim = axis.dim;
  44779. var snapToValue = value;
  44780. var payloadBatch = [];
  44781. var minDist = Number.MAX_VALUE;
  44782. var minDiff = -1;
  44783. each(axisInfo.seriesModels, function (series, idx) {
  44784. var dataDim = series.coordDimToDataDim(dim);
  44785. var seriesNestestValue;
  44786. var dataIndices;
  44787. if (series.getAxisTooltipData) {
  44788. var result = series.getAxisTooltipData(dataDim, value, axis);
  44789. dataIndices = result.dataIndices;
  44790. seriesNestestValue = result.nestestValue;
  44791. }
  44792. else {
  44793. dataIndices = series.getData().indicesOfNearest(
  44794. dataDim[0],
  44795. value,
  44796. // Add a threshold to avoid find the wrong dataIndex
  44797. // when data length is not same.
  44798. false, axis.type === 'category' ? 0.5 : null
  44799. );
  44800. if (!dataIndices.length) {
  44801. return;
  44802. }
  44803. seriesNestestValue = series.getData().get(dataDim[0], dataIndices[0]);
  44804. }
  44805. if (seriesNestestValue == null || !isFinite(seriesNestestValue)) {
  44806. return;
  44807. }
  44808. var diff = value - seriesNestestValue;
  44809. var dist = Math.abs(diff);
  44810. // Consider category case
  44811. if (dist <= minDist) {
  44812. if (dist < minDist || (diff >= 0 && minDiff < 0)) {
  44813. minDist = dist;
  44814. minDiff = diff;
  44815. snapToValue = seriesNestestValue;
  44816. payloadBatch.length = 0;
  44817. }
  44818. each(dataIndices, function (dataIndex) {
  44819. payloadBatch.push({
  44820. seriesIndex: series.seriesIndex,
  44821. dataIndexInside: dataIndex,
  44822. dataIndex: series.getData().getRawIndex(dataIndex)
  44823. });
  44824. });
  44825. }
  44826. });
  44827. return {
  44828. payloadBatch: payloadBatch,
  44829. snapToValue: snapToValue
  44830. };
  44831. }
  44832. function showPointer(showValueMap, axisInfo, value, payloadBatch) {
  44833. showValueMap[axisInfo.key] = {value: value, payloadBatch: payloadBatch};
  44834. }
  44835. function showTooltip(dataByCoordSys, axisInfo, payloadInfo, value) {
  44836. var payloadBatch = payloadInfo.payloadBatch;
  44837. var axis = axisInfo.axis;
  44838. var axisModel = axis.model;
  44839. var axisPointerModel = axisInfo.axisPointerModel;
  44840. // If no data, do not create anything in dataByCoordSys,
  44841. // whose length will be used to judge whether dispatch action.
  44842. if (!axisInfo.triggerTooltip || !payloadBatch.length) {
  44843. return;
  44844. }
  44845. var coordSysModel = axisInfo.coordSys.model;
  44846. var coordSysKey = modelHelper.makeKey(coordSysModel);
  44847. var coordSysItem = dataByCoordSys.map[coordSysKey];
  44848. if (!coordSysItem) {
  44849. coordSysItem = dataByCoordSys.map[coordSysKey] = {
  44850. coordSysId: coordSysModel.id,
  44851. coordSysIndex: coordSysModel.componentIndex,
  44852. coordSysType: coordSysModel.type,
  44853. coordSysMainType: coordSysModel.mainType,
  44854. dataByAxis: []
  44855. };
  44856. dataByCoordSys.list.push(coordSysItem);
  44857. }
  44858. coordSysItem.dataByAxis.push({
  44859. axisDim: axis.dim,
  44860. axisIndex: axisModel.componentIndex,
  44861. axisType: axisModel.type,
  44862. axisId: axisModel.id,
  44863. value: value,
  44864. // Caustion: viewHelper.getValueLabel is actually on "view stage", which
  44865. // depends that all models have been updated. So it should not be performed
  44866. // here. Considering axisPointerModel used here is volatile, which is hard
  44867. // to be retrieve in TooltipView, we prepare parameters here.
  44868. valueLabelOpt: {
  44869. precision: axisPointerModel.get('label.precision'),
  44870. formatter: axisPointerModel.get('label.formatter')
  44871. },
  44872. seriesDataIndices: payloadBatch.slice()
  44873. });
  44874. }
  44875. function updateModelActually(showValueMap, axesInfo, outputFinder) {
  44876. var outputAxesInfo = outputFinder.axesInfo = [];
  44877. // Basic logic: If no 'show' required, 'hide' this axisPointer.
  44878. each(axesInfo, function (axisInfo, key) {
  44879. var option = axisInfo.axisPointerModel.option;
  44880. var valItem = showValueMap[key];
  44881. if (valItem) {
  44882. !axisInfo.useHandle && (option.status = 'show');
  44883. option.value = valItem.value;
  44884. // For label formatter param and highlight.
  44885. option.seriesDataIndices = (valItem.payloadBatch || []).slice();
  44886. }
  44887. // When always show (e.g., handle used), remain
  44888. // original value and status.
  44889. else {
  44890. // If hide, value still need to be set, consider
  44891. // click legend to toggle axis blank.
  44892. !axisInfo.useHandle && (option.status = 'hide');
  44893. }
  44894. // If status is 'hide', should be no info in payload.
  44895. option.status === 'show' && outputAxesInfo.push({
  44896. axisDim: axisInfo.axis.dim,
  44897. axisIndex: axisInfo.axis.model.componentIndex,
  44898. value: option.value
  44899. });
  44900. });
  44901. }
  44902. function dispatchTooltipActually(dataByCoordSys, point, payload, dispatchAction) {
  44903. // Basic logic: If no showTip required, hideTip will be dispatched.
  44904. if (illegalPoint(point) || !dataByCoordSys.list.length) {
  44905. dispatchAction({type: 'hideTip'});
  44906. return;
  44907. }
  44908. // In most case only one axis (or event one series is used). It is
  44909. // convinient to fetch payload.seriesIndex and payload.dataIndex
  44910. // dirtectly. So put the first seriesIndex and dataIndex of the first
  44911. // axis on the payload.
  44912. var sampleItem = ((dataByCoordSys.list[0].dataByAxis[0] || {}).seriesDataIndices || [])[0] || {};
  44913. dispatchAction({
  44914. type: 'showTip',
  44915. escapeConnect: true,
  44916. x: point[0],
  44917. y: point[1],
  44918. tooltipOption: payload.tooltipOption,
  44919. position: payload.position,
  44920. dataIndexInside: sampleItem.dataIndexInside,
  44921. dataIndex: sampleItem.dataIndex,
  44922. seriesIndex: sampleItem.seriesIndex,
  44923. dataByCoordSys: dataByCoordSys.list
  44924. });
  44925. }
  44926. function dispatchHighDownActually(axesInfo, dispatchAction, api) {
  44927. // FIXME
  44928. // highlight status modification shoule be a stage of main process?
  44929. // (Consider confilct (e.g., legend and axisPointer) and setOption)
  44930. var zr = api.getZr();
  44931. var highDownKey = 'axisPointerLastHighlights';
  44932. var lastHighlights = get(zr)[highDownKey] || {};
  44933. var newHighlights = get(zr)[highDownKey] = {};
  44934. // Update highlight/downplay status according to axisPointer model.
  44935. // Build hash map and remove duplicate incidentally.
  44936. each(axesInfo, function (axisInfo, key) {
  44937. var option = axisInfo.axisPointerModel.option;
  44938. option.status === 'show' && each(option.seriesDataIndices, function (batchItem) {
  44939. var key = batchItem.seriesIndex + ' | ' + batchItem.dataIndex;
  44940. newHighlights[key] = batchItem;
  44941. });
  44942. });
  44943. // Diff.
  44944. var toHighlight = [];
  44945. var toDownplay = [];
  44946. zrUtil.each(lastHighlights, function (batchItem, key) {
  44947. !newHighlights[key] && toDownplay.push(batchItem);
  44948. });
  44949. zrUtil.each(newHighlights, function (batchItem, key) {
  44950. !lastHighlights[key] && toHighlight.push(batchItem);
  44951. });
  44952. toDownplay.length && api.dispatchAction({
  44953. type: 'downplay', escapeConnect: true, batch: toDownplay
  44954. });
  44955. toHighlight.length && api.dispatchAction({
  44956. type: 'highlight', escapeConnect: true, batch: toHighlight
  44957. });
  44958. }
  44959. function findInputAxisInfo(inputAxesInfo, axisInfo) {
  44960. for (var i = 0; i < (inputAxesInfo || []).length; i++) {
  44961. var inputAxisInfo = inputAxesInfo[i];
  44962. if (axisInfo.axis.dim === inputAxisInfo.axisDim
  44963. && axisInfo.axis.model.componentIndex === inputAxisInfo.axisIndex
  44964. ) {
  44965. return inputAxisInfo;
  44966. }
  44967. }
  44968. }
  44969. function makeMapperParam(axisInfo) {
  44970. var axisModel = axisInfo.axis.model;
  44971. var item = {};
  44972. var dim = item.axisDim = axisInfo.axis.dim;
  44973. item.axisIndex = item[dim + 'AxisIndex'] = axisModel.componentIndex;
  44974. item.axisName = item[dim + 'AxisName'] = axisModel.name;
  44975. item.axisId = item[dim + 'AxisId'] = axisModel.id;
  44976. return item;
  44977. }
  44978. function illegalPoint(point) {
  44979. return !point || point[0] == null || isNaN(point[0]) || point[1] == null || isNaN(point[1]);
  44980. }
  44981. module.exports = axisTrigger;
  44982. /***/ },
  44983. /* 300 */
  44984. /***/ function(module, exports, __webpack_require__) {
  44985. var zrUtil = __webpack_require__(4);
  44986. var modelUtil = __webpack_require__(5);
  44987. /**
  44988. * @param {Object} finder contains {seriesIndex, dataIndex, dataIndexInside}
  44989. * @param {module:echarts/model/Global} ecModel
  44990. * @return {Object} {point: [x, y], el: ...} point Will not be null.
  44991. */
  44992. module.exports = function (finder, ecModel) {
  44993. var point = [];
  44994. var seriesIndex = finder.seriesIndex;
  44995. var seriesModel;
  44996. if (seriesIndex == null || !(
  44997. seriesModel = ecModel.getSeriesByIndex(seriesIndex)
  44998. )) {
  44999. return {point: []};
  45000. }
  45001. var data = seriesModel.getData();
  45002. var dataIndex = modelUtil.queryDataIndex(data, finder);
  45003. if (dataIndex == null || zrUtil.isArray(dataIndex)) {
  45004. return {point: []};
  45005. }
  45006. var el = data.getItemGraphicEl(dataIndex);
  45007. var coordSys = seriesModel.coordinateSystem;
  45008. if (seriesModel.getTooltipPosition) {
  45009. point = seriesModel.getTooltipPosition(dataIndex) || [];
  45010. }
  45011. else if (coordSys && coordSys.dataToPoint) {
  45012. point = coordSys.dataToPoint(
  45013. data.getValues(
  45014. zrUtil.map(coordSys.dimensions, function (dim) {
  45015. return seriesModel.coordDimToDataDim(dim)[0];
  45016. }), dataIndex, true
  45017. )
  45018. ) || [];
  45019. }
  45020. else if (el) {
  45021. // Use graphic bounding rect
  45022. var rect = el.getBoundingRect().clone();
  45023. rect.applyTransform(el.transform);
  45024. point = [
  45025. rect.x + rect.width / 2,
  45026. rect.y + rect.height / 2
  45027. ];
  45028. }
  45029. return {point: point, el: el};
  45030. };
  45031. /***/ },
  45032. /* 301 */
  45033. /***/ function(module, exports, __webpack_require__) {
  45034. var echarts = __webpack_require__(1);
  45035. var AxisPointerModel = echarts.extendComponentModel({
  45036. type: 'axisPointer',
  45037. coordSysAxesInfo: null,
  45038. defaultOption: {
  45039. // 'auto' means that show when triggered by tooltip or handle.
  45040. show: 'auto',
  45041. // 'click' | 'mousemove' | 'none'
  45042. triggerOn: null, // set default in AxisPonterView.js
  45043. zlevel: 0,
  45044. z: 50,
  45045. type: 'line',
  45046. // axispointer triggered by tootip determine snap automatically,
  45047. // see `modelHelper`.
  45048. snap: false,
  45049. triggerTooltip: true,
  45050. value: null,
  45051. status: null, // Init value depends on whether handle is used.
  45052. // [group0, group1, ...]
  45053. // Each group can be: {
  45054. // mapper: function () {},
  45055. // singleTooltip: 'multiple', // 'multiple' or 'single'
  45056. // xAxisId: ...,
  45057. // yAxisName: ...,
  45058. // angleAxisIndex: ...
  45059. // }
  45060. // mapper: can be ignored.
  45061. // input: {axisInfo, value}
  45062. // output: {axisInfo, value}
  45063. link: [],
  45064. // Do not set 'auto' here, otherwise global animation: false
  45065. // will not effect at this axispointer.
  45066. animation: null,
  45067. animationDurationUpdate: 200,
  45068. lineStyle: {
  45069. color: '#aaa',
  45070. width: 1,
  45071. type: 'solid'
  45072. },
  45073. shadowStyle: {
  45074. color: 'rgba(150,150,150,0.3)'
  45075. },
  45076. label: {
  45077. show: true,
  45078. formatter: null, // string | Function
  45079. precision: 'auto', // Or a number like 0, 1, 2 ...
  45080. margin: 3,
  45081. textStyle: {
  45082. color: '#fff'
  45083. },
  45084. padding: [5, 7, 5, 7],
  45085. backgroundColor: 'auto', // default: axis line color
  45086. borderColor: null,
  45087. borderWidth: 0,
  45088. shadowBlur: 3,
  45089. shadowColor: '#aaa'
  45090. // Considering applicability, common style should
  45091. // better not have shadowOffset.
  45092. // shadowOffsetX: 0,
  45093. // shadowOffsetY: 2
  45094. },
  45095. handle: {
  45096. show: false,
  45097. 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
  45098. size: 45,
  45099. // handle margin is from symbol center to axis, which is stable when circular move.
  45100. margin: 50,
  45101. // color: '#1b8bbd'
  45102. // color: '#2f4554'
  45103. color: '#333',
  45104. shadowBlur: 3,
  45105. shadowColor: '#aaa',
  45106. shadowOffsetX: 0,
  45107. shadowOffsetY: 2,
  45108. // For mobile performance
  45109. throttle: 40
  45110. }
  45111. }
  45112. });
  45113. module.exports = AxisPointerModel;
  45114. /***/ },
  45115. /* 302 */
  45116. /***/ function(module, exports, __webpack_require__) {
  45117. var globalListener = __webpack_require__(303);
  45118. var AxisPonterView = __webpack_require__(1).extendComponentView({
  45119. type: 'axisPointer',
  45120. render: function (globalAxisPointerModel, ecModel, api) {
  45121. var globalTooltipModel = ecModel.getComponent('tooltip');
  45122. var triggerOn = globalAxisPointerModel.get('triggerOn')
  45123. || (globalTooltipModel && globalTooltipModel.get('triggerOn') || 'mousemove|click');
  45124. // Register global listener in AxisPointerView to enable
  45125. // AxisPointerView to be independent to Tooltip.
  45126. globalListener.register(
  45127. 'axisPointer',
  45128. api,
  45129. function (currTrigger, e, dispatchAction) {
  45130. // If 'none', it is not controlled by mouse totally.
  45131. if (triggerOn !== 'none'
  45132. && (currTrigger === 'leave' || triggerOn.indexOf(currTrigger) >= 0)
  45133. ) {
  45134. dispatchAction({
  45135. type: 'updateAxisPointer',
  45136. currTrigger: currTrigger,
  45137. x: e && e.offsetX,
  45138. y: e && e.offsetY
  45139. });
  45140. }
  45141. }
  45142. );
  45143. },
  45144. /**
  45145. * @override
  45146. */
  45147. remove: function (ecModel, api) {
  45148. globalListener.disopse(api.getZr(), 'axisPointer');
  45149. AxisPonterView.superApply(this._model, 'remove', arguments);
  45150. },
  45151. /**
  45152. * @override
  45153. */
  45154. dispose: function (ecModel, api) {
  45155. globalListener.unregister('axisPointer', api);
  45156. AxisPonterView.superApply(this._model, 'dispose', arguments);
  45157. }
  45158. });
  45159. /***/ },
  45160. /* 303 */
  45161. /***/ function(module, exports, __webpack_require__) {
  45162. var env = __webpack_require__(2);
  45163. var zrUtil = __webpack_require__(4);
  45164. var get = __webpack_require__(5).makeGetter();
  45165. var each = zrUtil.each;
  45166. var globalListener = {};
  45167. /**
  45168. * @param {string} key
  45169. * @param {module:echarts/ExtensionAPI} api
  45170. * @param {Function} handler
  45171. * param: {string} currTrigger
  45172. * param: {Array.<number>} point
  45173. */
  45174. globalListener.register = function (key, api, handler) {
  45175. if (env.node) {
  45176. return;
  45177. }
  45178. var zr = api.getZr();
  45179. get(zr).records || (get(zr).records = {});
  45180. initGlobalListeners(zr, api);
  45181. var record = get(zr).records[key] || (get(zr).records[key] = {});
  45182. record.handler = handler;
  45183. };
  45184. function initGlobalListeners(zr, api) {
  45185. if (get(zr).initialized) {
  45186. return;
  45187. }
  45188. get(zr).initialized = true;
  45189. useHandler('click', zrUtil.curry(doEnter, 'click'));
  45190. useHandler('mousemove', zrUtil.curry(doEnter, 'mousemove'));
  45191. // useHandler('mouseout', onLeave);
  45192. useHandler('globalout', onLeave);
  45193. function useHandler(eventType, cb) {
  45194. zr.on(eventType, function (e) {
  45195. var dis = makeDispatchAction(api);
  45196. each(get(zr).records, function (record) {
  45197. record && cb(record, e, dis.dispatchAction);
  45198. });
  45199. dispatchTooltipFinally(dis.pendings, api);
  45200. });
  45201. }
  45202. }
  45203. function dispatchTooltipFinally(pendings, api) {
  45204. var showLen = pendings.showTip.length;
  45205. var hideLen = pendings.hideTip.length;
  45206. var actuallyPayload;
  45207. if (showLen) {
  45208. actuallyPayload = pendings.showTip[showLen - 1];
  45209. }
  45210. else if (hideLen) {
  45211. actuallyPayload = pendings.hideTip[hideLen - 1];
  45212. }
  45213. if (actuallyPayload) {
  45214. actuallyPayload.dispatchAction = null;
  45215. api.dispatchAction(actuallyPayload);
  45216. }
  45217. }
  45218. function onLeave(record, e, dispatchAction) {
  45219. record.handler('leave', null, dispatchAction);
  45220. }
  45221. function doEnter(currTrigger, record, e, dispatchAction) {
  45222. record.handler(currTrigger, e, dispatchAction);
  45223. }
  45224. function makeDispatchAction(api) {
  45225. var pendings = {
  45226. showTip: [],
  45227. hideTip: []
  45228. };
  45229. // FIXME
  45230. // better approach?
  45231. // 'showTip' and 'hideTip' can be triggered by axisPointer and tooltip,
  45232. // which may be conflict, (axisPointer call showTip but tooltip call hideTip);
  45233. // So we have to add "final stage" to merge those dispatched actions.
  45234. var dispatchAction = function (payload) {
  45235. var pendingList = pendings[payload.type];
  45236. if (pendingList) {
  45237. pendingList.push(payload);
  45238. }
  45239. else {
  45240. payload.dispatchAction = dispatchAction;
  45241. api.dispatchAction(payload);
  45242. }
  45243. };
  45244. return {
  45245. dispatchAction: dispatchAction,
  45246. pendings: pendings
  45247. };
  45248. }
  45249. /**
  45250. * @param {string} key
  45251. * @param {module:echarts/ExtensionAPI} api
  45252. */
  45253. globalListener.unregister = function (key, api) {
  45254. if (env.node) {
  45255. return;
  45256. }
  45257. var zr = api.getZr();
  45258. var record = (get(zr).records || {})[key];
  45259. if (record) {
  45260. get(zr).records[key] = null;
  45261. }
  45262. };
  45263. module.exports = globalListener;
  45264. /***/ },
  45265. /* 304 */
  45266. /***/ function(module, exports, __webpack_require__) {
  45267. 'use strict';
  45268. var graphic = __webpack_require__(18);
  45269. var BaseAxisPointer = __webpack_require__(305);
  45270. var viewHelper = __webpack_require__(306);
  45271. var cartesianAxisHelper = __webpack_require__(138);
  45272. var AxisView = __webpack_require__(136);
  45273. var CartesianAxisPointer = BaseAxisPointer.extend({
  45274. /**
  45275. * @override
  45276. */
  45277. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  45278. var axis = axisModel.axis;
  45279. var grid = axis.grid;
  45280. var axisPointerType = axisPointerModel.get('type');
  45281. var otherExtent = getCartesian(grid, axis).getOtherAxis(axis).getGlobalExtent();
  45282. var pixelValue = axis.toGlobalCoord(axis.dataToCoord(value, true));
  45283. if (axisPointerType && axisPointerType !== 'none') {
  45284. var elStyle = viewHelper.buildElStyle(axisPointerModel);
  45285. var pointerOption = pointerShapeBuilder[axisPointerType](
  45286. axis, pixelValue, otherExtent, elStyle
  45287. );
  45288. pointerOption.style = elStyle;
  45289. elOption.graphicKey = pointerOption.type;
  45290. elOption.pointer = pointerOption;
  45291. }
  45292. var layoutInfo = cartesianAxisHelper.layout(grid.model, axisModel);
  45293. viewHelper.buildCartesianSingleLabelElOption(
  45294. value, elOption, layoutInfo, axisModel, axisPointerModel, api
  45295. );
  45296. },
  45297. /**
  45298. * @override
  45299. */
  45300. getHandleTransform: function (value, axisModel, axisPointerModel) {
  45301. var layoutInfo = cartesianAxisHelper.layout(axisModel.axis.grid.model, axisModel, {
  45302. labelInside: false
  45303. });
  45304. layoutInfo.labelMargin = axisPointerModel.get('handle.margin');
  45305. return {
  45306. position: viewHelper.getTransformedPosition(axisModel.axis, value, layoutInfo),
  45307. rotation: layoutInfo.rotation + (layoutInfo.labelDirection < 0 ? Math.PI : 0)
  45308. };
  45309. },
  45310. /**
  45311. * @override
  45312. */
  45313. updateHandleTransform: function (transform, delta, axisModel, axisPointerModel) {
  45314. var axis = axisModel.axis;
  45315. var grid = axis.grid;
  45316. var axisExtent = axis.getGlobalExtent(true);
  45317. var otherExtent = getCartesian(grid, axis).getOtherAxis(axis).getGlobalExtent();
  45318. var dimIndex = axis.dim === 'x' ? 0 : 1;
  45319. var currPosition = transform.position;
  45320. currPosition[dimIndex] += delta[dimIndex];
  45321. currPosition[dimIndex] = Math.min(axisExtent[1], currPosition[dimIndex]);
  45322. currPosition[dimIndex] = Math.max(axisExtent[0], currPosition[dimIndex]);
  45323. var cursorOtherValue = (otherExtent[1] + otherExtent[0]) / 2;
  45324. var cursorPoint = [cursorOtherValue, cursorOtherValue];
  45325. cursorPoint[dimIndex] = currPosition[dimIndex];
  45326. // Make tooltip do not overlap axisPointer and in the middle of the grid.
  45327. var tooltipOptions = [{verticalAlign: 'middle'}, {align: 'center'}];
  45328. return {
  45329. position: currPosition,
  45330. rotation: transform.rotation,
  45331. cursorPoint: cursorPoint,
  45332. tooltipOption: tooltipOptions[dimIndex]
  45333. };
  45334. }
  45335. });
  45336. function getCartesian(grid, axis) {
  45337. var opt = {};
  45338. opt[axis.dim + 'AxisIndex'] = axis.index;
  45339. return grid.getCartesian(opt);
  45340. }
  45341. var pointerShapeBuilder = {
  45342. line: function (axis, pixelValue, otherExtent, elStyle) {
  45343. var targetShape = viewHelper.makeLineShape(
  45344. [pixelValue, otherExtent[0]],
  45345. [pixelValue, otherExtent[1]],
  45346. getAxisDimIndex(axis)
  45347. );
  45348. graphic.subPixelOptimizeLine({
  45349. shape: targetShape,
  45350. style: elStyle
  45351. });
  45352. return {
  45353. type: 'Line',
  45354. shape: targetShape
  45355. };
  45356. },
  45357. shadow: function (axis, pixelValue, otherExtent, elStyle) {
  45358. var bandWidth = axis.getBandWidth();
  45359. var span = otherExtent[1] - otherExtent[0];
  45360. return {
  45361. type: 'Rect',
  45362. shape: viewHelper.makeRectShape(
  45363. [pixelValue - bandWidth / 2, otherExtent[0]],
  45364. [bandWidth, span],
  45365. getAxisDimIndex(axis)
  45366. )
  45367. };
  45368. }
  45369. };
  45370. function getAxisDimIndex(axis) {
  45371. return axis.dim === 'x' ? 0 : 1;
  45372. }
  45373. AxisView.registerAxisPointerClass('CartesianAxisPointer', CartesianAxisPointer);
  45374. module.exports = CartesianAxisPointer;
  45375. /***/ },
  45376. /* 305 */
  45377. /***/ function(module, exports, __webpack_require__) {
  45378. 'use strict';
  45379. var zrUtil = __webpack_require__(4);
  45380. var clazzUtil = __webpack_require__(13);
  45381. var graphic = __webpack_require__(18);
  45382. var get = __webpack_require__(5).makeGetter();
  45383. var axisPointerModelHelper = __webpack_require__(137);
  45384. var eventTool = __webpack_require__(88);
  45385. var throttle = __webpack_require__(81);
  45386. var clone = zrUtil.clone;
  45387. var bind = zrUtil.bind;
  45388. /**
  45389. * Base axis pointer class in 2D.
  45390. * Implemenents {module:echarts/component/axis/IAxisPointer}.
  45391. */
  45392. function BaseAxisPointer () {
  45393. }
  45394. BaseAxisPointer.prototype = {
  45395. /**
  45396. * @private
  45397. */
  45398. _group: null,
  45399. /**
  45400. * @private
  45401. */
  45402. _lastGraphicKey: null,
  45403. /**
  45404. * @private
  45405. */
  45406. _handle: null,
  45407. /**
  45408. * @private
  45409. */
  45410. _dragging: false,
  45411. /**
  45412. * @private
  45413. */
  45414. _lastValue: null,
  45415. /**
  45416. * @private
  45417. */
  45418. _lastStatus: null,
  45419. /**
  45420. * @private
  45421. */
  45422. _payloadInfo: null,
  45423. /**
  45424. * In px, arbitrary value. Do not set too small,
  45425. * no animation is ok for most cases.
  45426. * @protected
  45427. */
  45428. animationThreshold: 15,
  45429. /**
  45430. * @implement
  45431. */
  45432. render: function (axisModel, axisPointerModel, api, forceRender) {
  45433. var value = axisPointerModel.get('value');
  45434. var status = axisPointerModel.get('status');
  45435. // Bind them to `this`, not in closure, otherwise they will not
  45436. // be replaced when user calling setOption in not merge mode.
  45437. this._axisModel = axisModel;
  45438. this._axisPointerModel = axisPointerModel;
  45439. this._api = api;
  45440. // Optimize: `render` will be called repeatly during mouse move.
  45441. // So it is power consuming if performing `render` each time,
  45442. // especially on mobile device.
  45443. if (!forceRender
  45444. && this._lastValue === value
  45445. && this._lastStatus === status
  45446. ) {
  45447. return;
  45448. }
  45449. this._lastValue = value;
  45450. this._lastStatus = status;
  45451. var group = this._group;
  45452. var handle = this._handle;
  45453. if (!status || status === 'hide') {
  45454. // Do not clear here, for animation better.
  45455. group && group.hide();
  45456. handle && handle.hide();
  45457. return;
  45458. }
  45459. group && group.show();
  45460. handle && handle.show();
  45461. // Otherwise status is 'show'
  45462. var elOption = {};
  45463. this.makeElOption(elOption, value, axisModel, axisPointerModel, api);
  45464. // Enable change axis pointer type.
  45465. var graphicKey = elOption.graphicKey;
  45466. if (graphicKey !== this._lastGraphicKey) {
  45467. this.clear(api);
  45468. }
  45469. this._lastGraphicKey = graphicKey;
  45470. var moveAnimation = this._moveAnimation =
  45471. this.determineAnimation(axisModel, axisPointerModel);
  45472. if (!group) {
  45473. group = this._group = new graphic.Group();
  45474. this.createPointerEl(group, elOption, axisModel, axisPointerModel);
  45475. this.createLabelEl(group, elOption, axisModel, axisPointerModel);
  45476. api.getZr().add(group);
  45477. }
  45478. else {
  45479. var doUpdateProps = zrUtil.curry(updateProps, axisPointerModel, moveAnimation);
  45480. this.updatePointerEl(group, elOption, doUpdateProps, axisPointerModel);
  45481. this.updateLabelEl(group, elOption, doUpdateProps, axisPointerModel);
  45482. }
  45483. updateMandatoryProps(group, axisPointerModel, true);
  45484. this._renderHandle(value);
  45485. },
  45486. /**
  45487. * @implement
  45488. */
  45489. remove: function (api) {
  45490. this.clear(api);
  45491. },
  45492. /**
  45493. * @implement
  45494. */
  45495. dispose: function (api) {
  45496. this.clear(api);
  45497. },
  45498. /**
  45499. * @protected
  45500. */
  45501. determineAnimation: function (axisModel, axisPointerModel) {
  45502. var animation = axisPointerModel.get('animation');
  45503. var axis = axisModel.axis;
  45504. var isCategoryAxis = axis.type === 'category';
  45505. var useSnap = axisPointerModel.get('snap');
  45506. // Value axis without snap always do not snap.
  45507. if (!useSnap && !isCategoryAxis) {
  45508. return false;
  45509. }
  45510. if (animation === 'auto' || animation == null) {
  45511. var animationThreshold = this.animationThreshold;
  45512. if (isCategoryAxis && axis.getBandWidth() > animationThreshold) {
  45513. return true;
  45514. }
  45515. // It is important to auto animation when snap used. Consider if there is
  45516. // a dataZoom, animation will be disabled when too many points exist, while
  45517. // it will be enabled for better visual effect when little points exist.
  45518. if (useSnap) {
  45519. var seriesDataCount = axisPointerModelHelper.getAxisInfo(axisModel).seriesDataCount;
  45520. var axisExtent = axis.getExtent();
  45521. // Approximate band width
  45522. return Math.abs(axisExtent[0] - axisExtent[1]) / seriesDataCount > animationThreshold;
  45523. }
  45524. return false;
  45525. }
  45526. return animation === true;
  45527. },
  45528. /**
  45529. * add {pointer, label, graphicKey} to elOption
  45530. * @protected
  45531. */
  45532. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  45533. // Shoule be implemenented by sub-class.
  45534. },
  45535. /**
  45536. * @protected
  45537. */
  45538. createPointerEl: function (group, elOption, axisModel, axisPointerModel) {
  45539. var pointerOption = elOption.pointer;
  45540. if (pointerOption) {
  45541. var pointerEl = get(group).pointerEl = new graphic[pointerOption.type](
  45542. clone(elOption.pointer)
  45543. );
  45544. group.add(pointerEl);
  45545. }
  45546. },
  45547. /**
  45548. * @protected
  45549. */
  45550. createLabelEl: function (group, elOption, axisModel, axisPointerModel) {
  45551. if (elOption.label) {
  45552. var labelEl = get(group).labelEl = new graphic.Rect(
  45553. clone(elOption.label)
  45554. );
  45555. group.add(labelEl);
  45556. updateLabelShowHide(labelEl, axisPointerModel);
  45557. }
  45558. },
  45559. /**
  45560. * @protected
  45561. */
  45562. updatePointerEl: function (group, elOption, updateProps) {
  45563. var pointerEl = get(group).pointerEl;
  45564. if (pointerEl) {
  45565. pointerEl.setStyle(elOption.pointer.style);
  45566. updateProps(pointerEl, {shape: elOption.pointer.shape});
  45567. }
  45568. },
  45569. /**
  45570. * @protected
  45571. */
  45572. updateLabelEl: function (group, elOption, updateProps, axisPointerModel) {
  45573. var labelEl = get(group).labelEl;
  45574. if (labelEl) {
  45575. labelEl.setStyle(elOption.label.style);
  45576. updateProps(labelEl, {
  45577. // Consider text length change in vertical axis, animation should
  45578. // be used on shape, otherwise the effect will be weird.
  45579. shape: elOption.label.shape,
  45580. position: elOption.label.position
  45581. });
  45582. updateLabelShowHide(labelEl, axisPointerModel);
  45583. }
  45584. },
  45585. /**
  45586. * @private
  45587. */
  45588. _renderHandle: function (value) {
  45589. if (this._dragging || !this.updateHandleTransform) {
  45590. return;
  45591. }
  45592. var axisPointerModel = this._axisPointerModel;
  45593. var zr = this._api.getZr();
  45594. var handle = this._handle;
  45595. var handleModel = axisPointerModel.getModel('handle');
  45596. var status = axisPointerModel.get('status');
  45597. if (!handleModel.get('show') || !status || status === 'hide') {
  45598. handle && zr.remove(handle);
  45599. this._handle = null;
  45600. return;
  45601. }
  45602. var isInit;
  45603. if (!this._handle) {
  45604. isInit = true;
  45605. handle = this._handle = createIcon(handleModel, {
  45606. onmousemove: function (e) {
  45607. // Fot mobile devicem, prevent screen slider on the button.
  45608. eventTool.stop(e.event);
  45609. },
  45610. onmousedown: bind(this._onHandleDragMove, this, 0, 0),
  45611. drift: bind(this._onHandleDragMove, this),
  45612. ondragend: bind(this._onHandleDragEnd, this)
  45613. });
  45614. zr.add(handle);
  45615. }
  45616. updateMandatoryProps(handle, axisPointerModel, false);
  45617. // update style
  45618. var includeStyles = [
  45619. 'color', 'borderColor', 'borderWidth', 'opacity',
  45620. 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY'
  45621. ];
  45622. handle.setStyle(handleModel.getItemStyle(null, includeStyles));
  45623. // update position
  45624. var handleSize = handleModel.get('size');
  45625. if (!zrUtil.isArray(handleSize)) {
  45626. handleSize = [handleSize, handleSize];
  45627. }
  45628. handle.attr('scale', [handleSize[0] / 2, handleSize[1] / 2]);
  45629. throttle.createOrUpdate(
  45630. this,
  45631. '_doDispatchAxisPointer',
  45632. handleModel.get('throttle') || 0,
  45633. 'fixRate'
  45634. );
  45635. this._moveHandleToValue(value, isInit);
  45636. },
  45637. /**
  45638. * @private
  45639. */
  45640. _moveHandleToValue: function (value, isInit) {
  45641. updateProps(
  45642. this._axisPointerModel,
  45643. !isInit && this._moveAnimation,
  45644. this._handle,
  45645. getHandleTransProps(this.getHandleTransform(
  45646. value, this._axisModel, this._axisPointerModel
  45647. ))
  45648. );
  45649. },
  45650. /**
  45651. * @private
  45652. */
  45653. _onHandleDragMove: function (dx, dy) {
  45654. var handle = this._handle;
  45655. if (!handle) {
  45656. return;
  45657. }
  45658. this._dragging = true;
  45659. // Persistent for throttle.
  45660. var trans = this.updateHandleTransform(
  45661. getHandleTransProps(handle),
  45662. [dx, dy],
  45663. this._axisModel,
  45664. this._axisPointerModel
  45665. );
  45666. this._payloadInfo = trans;
  45667. handle.stopAnimation();
  45668. handle.attr(getHandleTransProps(trans));
  45669. get(handle).lastProp = null;
  45670. this._doDispatchAxisPointer();
  45671. },
  45672. /**
  45673. * Throttled method.
  45674. * @private
  45675. */
  45676. _doDispatchAxisPointer: function () {
  45677. var handle = this._handle;
  45678. if (!handle) {
  45679. return;
  45680. }
  45681. var payloadInfo = this._payloadInfo;
  45682. var axisModel = this._axisModel;
  45683. this._api.dispatchAction({
  45684. type: 'updateAxisPointer',
  45685. x: payloadInfo.cursorPoint[0],
  45686. y: payloadInfo.cursorPoint[1],
  45687. tooltipOption: payloadInfo.tooltipOption,
  45688. axesInfo: [{
  45689. axisDim: axisModel.axis.dim,
  45690. axisIndex: axisModel.componentIndex
  45691. }]
  45692. });
  45693. },
  45694. /**
  45695. * @private
  45696. */
  45697. _onHandleDragEnd: function (moveAnimation) {
  45698. this._dragging = false;
  45699. var handle = this._handle;
  45700. if (!handle) {
  45701. return;
  45702. }
  45703. var value = this._axisPointerModel.get('value');
  45704. // Consider snap or categroy axis, handle may be not consistent with
  45705. // axisPointer. So move handle to align the exact value position when
  45706. // drag ended.
  45707. this._moveHandleToValue(value);
  45708. // For the effect: tooltip will be shown when finger holding on handle
  45709. // button, and will be hidden after finger left handle button.
  45710. this._api.dispatchAction({
  45711. type: 'hideTip'
  45712. });
  45713. },
  45714. /**
  45715. * Should be implemenented by sub-class if support `handle`.
  45716. * @protected
  45717. * @param {number} value
  45718. * @param {module:echarts/model/Model} axisModel
  45719. * @param {module:echarts/model/Model} axisPointerModel
  45720. * @return {Object} {position: [x, y], rotation: 0}
  45721. */
  45722. getHandleTransform: null,
  45723. /**
  45724. * * Should be implemenented by sub-class if support `handle`.
  45725. * @protected
  45726. * @param {Object} transform {position, rotation}
  45727. * @param {Array.<number>} delta [dx, dy]
  45728. * @param {module:echarts/model/Model} axisModel
  45729. * @param {module:echarts/model/Model} axisPointerModel
  45730. * @return {Object} {position: [x, y], rotation: 0, cursorPoint: [x, y]}
  45731. */
  45732. updateHandleTransform: null,
  45733. /**
  45734. * @private
  45735. */
  45736. clear: function (api) {
  45737. this._lastValue = null;
  45738. this._lastStatus = null;
  45739. var zr = api.getZr();
  45740. var group = this._group;
  45741. var handle = this._handle;
  45742. if (zr && group) {
  45743. this._lastGraphicKey = null;
  45744. group && zr.remove(group);
  45745. handle && zr.remove(handle);
  45746. this._group = null;
  45747. this._handle = null;
  45748. this._payloadInfo = null;
  45749. }
  45750. },
  45751. /**
  45752. * @protected
  45753. */
  45754. doClear: function () {
  45755. // Implemented by sub-class if necessary.
  45756. },
  45757. /**
  45758. * @protected
  45759. * @param {Array.<number>} xy
  45760. * @param {Array.<number>} wh
  45761. * @param {number} [xDimIndex=0] or 1
  45762. */
  45763. buildLabel: function (xy, wh, xDimIndex) {
  45764. xDimIndex = xDimIndex || 0;
  45765. return {
  45766. x: xy[xDimIndex],
  45767. y: xy[1 - xDimIndex],
  45768. width: wh[xDimIndex],
  45769. height: wh[1 - xDimIndex]
  45770. };
  45771. }
  45772. };
  45773. BaseAxisPointer.prototype.constructor = BaseAxisPointer;
  45774. function updateProps(animationModel, moveAnimation, el, props) {
  45775. // Animation optimize.
  45776. if (!propsEqual(get(el).lastProp, props)) {
  45777. get(el).lastProp = props;
  45778. moveAnimation
  45779. ? graphic.updateProps(el, props, animationModel)
  45780. : (el.stopAnimation(), el.attr(props));
  45781. }
  45782. }
  45783. function propsEqual(lastProps, newProps) {
  45784. if (zrUtil.isObject(lastProps) && zrUtil.isObject(newProps)) {
  45785. var equals = true;
  45786. zrUtil.each(newProps, function (item, key) {
  45787. equals &= propsEqual(lastProps[key], item);
  45788. });
  45789. return !!equals;
  45790. }
  45791. else {
  45792. return lastProps === newProps;
  45793. }
  45794. }
  45795. function updateLabelShowHide(labelEl, axisPointerModel) {
  45796. labelEl[axisPointerModel.get('label.show') ? 'show' : 'hide']();
  45797. }
  45798. function getHandleTransProps(trans) {
  45799. return {
  45800. position: trans.position.slice(),
  45801. rotation: trans.rotation || 0
  45802. };
  45803. }
  45804. function createIcon(handleModel, handlers) {
  45805. var iconStr = handleModel.get('icon');
  45806. var style = {
  45807. x: -1, y: -1, width: 2, height: 2
  45808. };
  45809. var opt = zrUtil.extend({
  45810. style: {
  45811. strokeNoScale: true
  45812. },
  45813. rectHover: true,
  45814. cursor: 'move',
  45815. draggable: true
  45816. }, handlers);
  45817. return iconStr.indexOf('image://') === 0
  45818. ? (
  45819. style.image = iconStr.slice(8),
  45820. opt.style = style,
  45821. new graphic.Image(opt)
  45822. )
  45823. : graphic.makePath(
  45824. iconStr.replace('path://', ''),
  45825. opt,
  45826. style,
  45827. 'center'
  45828. );
  45829. }
  45830. function updateMandatoryProps(group, axisPointerModel, silent) {
  45831. var z = axisPointerModel.get('z');
  45832. var zlevel = axisPointerModel.get('zlevel');
  45833. group && group.traverse(function (el) {
  45834. if (el.type !== 'group') {
  45835. z != null && (el.z = z);
  45836. zlevel != null && (el.zlevel = zlevel);
  45837. el.silent = silent;
  45838. }
  45839. });
  45840. }
  45841. clazzUtil.enableClassExtend(BaseAxisPointer);
  45842. module.exports = BaseAxisPointer;
  45843. /***/ },
  45844. /* 306 */
  45845. /***/ function(module, exports, __webpack_require__) {
  45846. 'use strict';
  45847. var zrUtil = __webpack_require__(4);
  45848. var graphic = __webpack_require__(18);
  45849. var textContain = __webpack_require__(8);
  45850. var formatUtil = __webpack_require__(6);
  45851. var matrix = __webpack_require__(11);
  45852. var axisHelper = __webpack_require__(101);
  45853. var AxisBuilder = __webpack_require__(135);
  45854. var helper = {};
  45855. /**
  45856. * @param {module:echarts/model/Model} axisPointerModel
  45857. */
  45858. helper.buildElStyle = function (axisPointerModel) {
  45859. var axisPointerType = axisPointerModel.get('type');
  45860. var styleModel = axisPointerModel.getModel(axisPointerType + 'Style');
  45861. var style;
  45862. if (axisPointerType === 'line') {
  45863. style = styleModel.getLineStyle();
  45864. style.fill = null;
  45865. }
  45866. else if (axisPointerType === 'shadow') {
  45867. style = styleModel.getAreaStyle();
  45868. style.stroke = null;
  45869. }
  45870. return style;
  45871. };
  45872. /**
  45873. * @param {Function} labelPos {align, verticalAlign, position}
  45874. */
  45875. helper.buildLabelElOption = function (
  45876. elOption, axisModel, axisPointerModel, api, labelPos
  45877. ) {
  45878. var value = axisPointerModel.get('value');
  45879. var text = helper.getValueLabel(
  45880. value, axisModel.axis, axisModel.ecModel,
  45881. axisPointerModel.get('seriesDataIndices'),
  45882. {
  45883. precision: axisPointerModel.get('label.precision'),
  45884. formatter: axisPointerModel.get('label.formatter')
  45885. }
  45886. );
  45887. var labelModel = axisPointerModel.getModel('label');
  45888. var textStyleModel = labelModel.getModel('textStyle');
  45889. var paddings = formatUtil.normalizeCssArray(labelModel.get('padding') || 0);
  45890. var font = textStyleModel.getFont();
  45891. var textRect = textContain.getBoundingRect(
  45892. text, font, labelPos.textAlign, labelPos.textBaseline
  45893. );
  45894. var position = labelPos.position;
  45895. var width = textRect.width + paddings[1] + paddings[3];
  45896. var height = textRect.height + paddings[0] + paddings[2];
  45897. // Adjust by align.
  45898. var align = labelPos.align;
  45899. align === 'right' && (position[0] -= width);
  45900. align === 'center' && (position[0] -= width / 2);
  45901. var verticalAlign = labelPos.verticalAlign;
  45902. verticalAlign === 'bottom' && (position[1] -= height);
  45903. verticalAlign === 'middle' && (position[1] -= height / 2);
  45904. // Not overflow ec container
  45905. confineInContainer(position, width, height, api);
  45906. var bgColor = labelModel.get('backgroundColor');
  45907. if (!bgColor || bgColor === 'auto') {
  45908. bgColor = axisModel.get('axisLine.lineStyle.color');
  45909. }
  45910. elOption.label = {
  45911. shape: {x: 0, y: 0, width: width, height: height, r: labelModel.get('borderRadius')},
  45912. position: position.slice(),
  45913. style: {
  45914. text: text,
  45915. textFont: font,
  45916. textFill: textStyleModel.getTextColor(),
  45917. textPosition: 'inside',
  45918. fill: bgColor,
  45919. stroke: labelModel.get('borderColor') || 'transparent',
  45920. lineWidth: labelModel.get('borderWidth') || 0,
  45921. shadowBlur: labelModel.get('shadowBlur'),
  45922. shadowColor: labelModel.get('shadowColor'),
  45923. shadowOffsetX: labelModel.get('shadowOffsetX'),
  45924. shadowOffsetY: labelModel.get('shadowOffsetY')
  45925. },
  45926. // Lable should be over axisPointer.
  45927. z2: 10
  45928. };
  45929. };
  45930. // Do not overflow ec container
  45931. function confineInContainer(position, width, height, api) {
  45932. var viewWidth = api.getWidth();
  45933. var viewHeight = api.getHeight();
  45934. position[0] = Math.min(position[0] + width, viewWidth) - width;
  45935. position[1] = Math.min(position[1] + height, viewHeight) - height;
  45936. position[0] = Math.max(position[0], 0);
  45937. position[1] = Math.max(position[1], 0);
  45938. }
  45939. /**
  45940. * @param {number} value
  45941. * @param {module:echarts/coord/Axis} axis
  45942. * @param {module:echarts/model/Global} ecModel
  45943. * @param {Object} opt
  45944. * @param {Array.<Object>} seriesDataIndices
  45945. * @param {number|string} opt.precision 'auto' or a number
  45946. * @param {string|Function} opt.formatter label formatter
  45947. */
  45948. helper.getValueLabel = function (value, axis, ecModel, seriesDataIndices, opt) {
  45949. var text = axis.scale.getLabel(
  45950. // If `precision` is set, width can be fixed (like '12.00500'), which
  45951. // helps to debounce when when moving label.
  45952. value, {precision: opt.precision}
  45953. );
  45954. var formatter = opt.formatter;
  45955. if (formatter) {
  45956. var params = {
  45957. value: axisHelper.getAxisRawValue(axis, value),
  45958. seriesData: []
  45959. };
  45960. zrUtil.each(seriesDataIndices, function (idxItem) {
  45961. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
  45962. var dataIndex = idxItem.dataIndexInside;
  45963. var dataParams = series && series.getDataParams(dataIndex);
  45964. dataParams && params.seriesData.push(dataParams);
  45965. });
  45966. if (zrUtil.isString(formatter)) {
  45967. text = formatter.replace('{value}', text);
  45968. }
  45969. else if (zrUtil.isFunction(formatter)) {
  45970. text = formatter(params);
  45971. }
  45972. }
  45973. return text;
  45974. };
  45975. /**
  45976. * @param {module:echarts/coord/Axis} axis
  45977. * @param {number} value
  45978. * @param {Object} layoutInfo {
  45979. * rotation, position, labelOffset, labelDirection, labelMargin
  45980. * }
  45981. */
  45982. helper.getTransformedPosition = function (axis, value, layoutInfo) {
  45983. var transform = matrix.create();
  45984. matrix.rotate(transform, transform, layoutInfo.rotation);
  45985. matrix.translate(transform, transform, layoutInfo.position);
  45986. return graphic.applyTransform([
  45987. axis.dataToCoord(value),
  45988. (layoutInfo.labelOffset || 0)
  45989. + (layoutInfo.labelDirection || 1) * (layoutInfo.labelMargin || 0)
  45990. ], transform);
  45991. };
  45992. helper.buildCartesianSingleLabelElOption = function (
  45993. value, elOption, layoutInfo, axisModel, axisPointerModel, api
  45994. ) {
  45995. var textLayout = AxisBuilder.innerTextLayout(
  45996. layoutInfo.rotation, 0, layoutInfo.labelDirection
  45997. );
  45998. layoutInfo.labelMargin = axisPointerModel.get('label.margin');
  45999. helper.buildLabelElOption(elOption, axisModel, axisPointerModel, api, {
  46000. position: helper.getTransformedPosition(axisModel.axis, value, layoutInfo),
  46001. align: textLayout.textAlign,
  46002. verticalAlign: textLayout.textVerticalAlign
  46003. });
  46004. };
  46005. /**
  46006. * @param {Array.<number>} p1
  46007. * @param {Array.<number>} p2
  46008. * @param {number} [xDimIndex=0] or 1
  46009. */
  46010. helper.makeLineShape = function (p1, p2, xDimIndex) {
  46011. xDimIndex = xDimIndex || 0;
  46012. return {
  46013. x1: p1[xDimIndex],
  46014. y1: p1[1 - xDimIndex],
  46015. x2: p2[xDimIndex],
  46016. y2: p2[1 - xDimIndex]
  46017. };
  46018. };
  46019. /**
  46020. * @param {Array.<number>} xy
  46021. * @param {Array.<number>} wh
  46022. * @param {number} [xDimIndex=0] or 1
  46023. */
  46024. helper.makeRectShape = function (xy, wh, xDimIndex) {
  46025. xDimIndex = xDimIndex || 0;
  46026. return {
  46027. x: xy[xDimIndex],
  46028. y: xy[1 - xDimIndex],
  46029. width: wh[xDimIndex],
  46030. height: wh[1 - xDimIndex]
  46031. };
  46032. };
  46033. helper.makeSectorShape = function (cx, cy, r0, r, startAngle, endAngle) {
  46034. return {
  46035. cx: cx,
  46036. cy: cy,
  46037. r0: r0,
  46038. r: r,
  46039. startAngle: startAngle,
  46040. endAngle: endAngle,
  46041. clockwise: true
  46042. };
  46043. };
  46044. module.exports = helper;
  46045. /***/ },
  46046. /* 307 */
  46047. /***/ function(module, exports, __webpack_require__) {
  46048. 'use strict';
  46049. var graphic = __webpack_require__(18);
  46050. var BaseAxisPointer = __webpack_require__(305);
  46051. var viewHelper = __webpack_require__(306);
  46052. var singleAxisHelper = __webpack_require__(296);
  46053. var AxisView = __webpack_require__(136);
  46054. var XY = ['x', 'y'];
  46055. var WH = ['width', 'height'];
  46056. var SingleAxisPointer = BaseAxisPointer.extend({
  46057. /**
  46058. * @override
  46059. */
  46060. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  46061. var axis = axisModel.axis;
  46062. var coordSys = axis.coordinateSystem;
  46063. var otherExtent = getGlobalExtent(coordSys, 1 - getPointDimIndex(axis));
  46064. var pixelValue = coordSys.dataToPoint(value)[0];
  46065. var axisPointerType = axisPointerModel.get('type');
  46066. if (axisPointerType && axisPointerType !== 'none') {
  46067. var elStyle = viewHelper.buildElStyle(axisPointerModel);
  46068. var pointerOption = pointerShapeBuilder[axisPointerType](
  46069. axis, pixelValue, otherExtent, elStyle
  46070. );
  46071. pointerOption.style = elStyle;
  46072. elOption.graphicKey = pointerOption.type;
  46073. elOption.pointer = pointerOption;
  46074. }
  46075. var layoutInfo = singleAxisHelper.layout(axisModel);
  46076. viewHelper.buildCartesianSingleLabelElOption(
  46077. value, elOption, layoutInfo, axisModel, axisPointerModel, api
  46078. );
  46079. },
  46080. /**
  46081. * @override
  46082. */
  46083. getHandleTransform: function (value, axisModel, axisPointerModel) {
  46084. var layoutInfo = singleAxisHelper.layout(axisModel, {labelInside: false});
  46085. layoutInfo.labelMargin = axisPointerModel.get('handle.margin');
  46086. return {
  46087. position: viewHelper.getTransformedPosition(axisModel.axis, value, layoutInfo),
  46088. rotation: layoutInfo.rotation + (layoutInfo.labelDirection < 0 ? Math.PI : 0)
  46089. };
  46090. },
  46091. /**
  46092. * @override
  46093. */
  46094. updateHandleTransform: function (transform, delta, axisModel, axisPointerModel) {
  46095. var axis = axisModel.axis;
  46096. var coordSys = axis.coordinateSystem;
  46097. var dimIndex = getPointDimIndex(axis);
  46098. var axisExtent = getGlobalExtent(coordSys, dimIndex);
  46099. var currPosition = transform.position;
  46100. currPosition[dimIndex] += delta[dimIndex];
  46101. currPosition[dimIndex] = Math.min(axisExtent[1], currPosition[dimIndex]);
  46102. currPosition[dimIndex] = Math.max(axisExtent[0], currPosition[dimIndex]);
  46103. var otherExtent = getGlobalExtent(coordSys, 1 - dimIndex);
  46104. var cursorOtherValue = (otherExtent[1] + otherExtent[0]) / 2;
  46105. var cursorPoint = [cursorOtherValue, cursorOtherValue];
  46106. cursorPoint[dimIndex] = currPosition[dimIndex];
  46107. return {
  46108. position: currPosition,
  46109. rotation: transform.rotation,
  46110. cursorPoint: cursorPoint,
  46111. tooltipOption: {
  46112. verticalAlign: 'middle'
  46113. }
  46114. };
  46115. }
  46116. });
  46117. var pointerShapeBuilder = {
  46118. line: function (axis, pixelValue, otherExtent, elStyle) {
  46119. var targetShape = viewHelper.makeLineShape(
  46120. [pixelValue, otherExtent[0]],
  46121. [pixelValue, otherExtent[1]],
  46122. getPointDimIndex(axis)
  46123. );
  46124. graphic.subPixelOptimizeLine({
  46125. shape: targetShape,
  46126. style: elStyle
  46127. });
  46128. return {
  46129. type: 'Line',
  46130. shape: targetShape
  46131. };
  46132. },
  46133. shadow: function (axis, pixelValue, otherExtent, elStyle) {
  46134. var bandWidth = axis.getBandWidth();
  46135. var span = otherExtent[1] - otherExtent[0];
  46136. return {
  46137. type: 'Rect',
  46138. shape: viewHelper.makeRectShape(
  46139. [pixelValue - bandWidth / 2, otherExtent[0]],
  46140. [bandWidth, span],
  46141. getPointDimIndex(axis)
  46142. )
  46143. };
  46144. }
  46145. };
  46146. function getPointDimIndex(axis) {
  46147. return axis.isHorizontal() ? 0 : 1;
  46148. }
  46149. function getGlobalExtent(coordSys, dimIndex) {
  46150. var rect = coordSys.getRect();
  46151. return [rect[XY[dimIndex]], rect[XY[dimIndex]] + rect[WH[dimIndex]]];
  46152. }
  46153. AxisView.registerAxisPointerClass('SingleAxisPointer', SingleAxisPointer);
  46154. module.exports = SingleAxisPointer;
  46155. /***/ },
  46156. /* 308 */
  46157. /***/ function(module, exports, __webpack_require__) {
  46158. 'use strict';
  46159. /**
  46160. * @file Define the themeRiver view's series model
  46161. * @author Deqing Li(annong035@gmail.com)
  46162. */
  46163. var completeDimensions = __webpack_require__(110);
  46164. var SeriesModel = __webpack_require__(78);
  46165. var List = __webpack_require__(98);
  46166. var zrUtil = __webpack_require__(4);
  46167. var formatUtil = __webpack_require__(6);
  46168. var encodeHTML = formatUtil.encodeHTML;
  46169. var nest = __webpack_require__(255);
  46170. var DATA_NAME_INDEX = 2;
  46171. var ThemeRiverSeries = SeriesModel.extend({
  46172. type: 'series.themeRiver',
  46173. dependencies: ['singleAxis'],
  46174. /**
  46175. * @readOnly
  46176. * @type {module:zrender/core/util#HashMap}
  46177. */
  46178. nameMap: null,
  46179. /**
  46180. * @override
  46181. */
  46182. init: function (option) {
  46183. ThemeRiverSeries.superApply(this, 'init', arguments);
  46184. // Put this function here is for the sake of consistency of code
  46185. // Enable legend selection for each data item
  46186. // Use a function instead of direct access because data reference may changed
  46187. this.legendDataProvider = function () {
  46188. return this.getRawData();
  46189. };
  46190. },
  46191. /**
  46192. * If there is no value of a certain point in the time for some event,set it value to 0.
  46193. *
  46194. * @param {Array} data initial data in the option
  46195. * @return {Array}
  46196. */
  46197. fixData: function (data) {
  46198. var rawDataLength = data.length;
  46199. // grouped data by name
  46200. var dataByName = nest()
  46201. .key(function (dataItem) {
  46202. return dataItem[2];
  46203. })
  46204. .entries(data);
  46205. // data group in each layer
  46206. var layData = zrUtil.map(dataByName, function (d) {
  46207. return {
  46208. name: d.key,
  46209. dataList: d.values
  46210. };
  46211. });
  46212. var layerNum = layData.length;
  46213. var largestLayer = -1;
  46214. var index = -1;
  46215. for (var i = 0; i < layerNum; ++i) {
  46216. var len = layData[i].dataList.length;
  46217. if (len > largestLayer) {
  46218. largestLayer = len;
  46219. index = i;
  46220. }
  46221. }
  46222. for (var k = 0; k < layerNum; ++k) {
  46223. if (k === index) {
  46224. continue;
  46225. }
  46226. var name = layData[k].name;
  46227. for (var j = 0; j < largestLayer; ++j) {
  46228. var timeValue = layData[index].dataList[j][0];
  46229. var length = layData[k].dataList.length;
  46230. var keyIndex = -1;
  46231. for (var l = 0; l < length; ++l) {
  46232. var value = layData[k].dataList[l][0];
  46233. if (value === timeValue) {
  46234. keyIndex = l;
  46235. break;
  46236. }
  46237. }
  46238. if (keyIndex === -1) {
  46239. data[rawDataLength] = [];
  46240. data[rawDataLength][0] = timeValue;
  46241. data[rawDataLength][1] = 0;
  46242. data[rawDataLength][2] = name;
  46243. rawDataLength++;
  46244. }
  46245. }
  46246. }
  46247. return data;
  46248. },
  46249. /**
  46250. * @override
  46251. * @param {Object} option the initial option that user gived
  46252. * @param {module:echarts/model/Model} ecModel the model object for themeRiver option
  46253. * @return {module:echarts/data/List}
  46254. */
  46255. getInitialData: function (option, ecModel) {
  46256. var dimensions = [];
  46257. var singleAxisModel = ecModel.queryComponents({
  46258. mainType: 'singleAxis',
  46259. index: this.get('singleAxisIndex'),
  46260. id: this.get('singleAxisId')
  46261. })[0];
  46262. var axisType = singleAxisModel.get('type');
  46263. dimensions = [
  46264. {
  46265. name: 'time',
  46266. // FIXME common?
  46267. type: axisType === 'category'
  46268. ? 'ordinal'
  46269. : axisType === 'time'
  46270. ? 'time'
  46271. : 'float'
  46272. },
  46273. {
  46274. name: 'value',
  46275. type: 'float'
  46276. },
  46277. {
  46278. name: 'name',
  46279. type: 'ordinal'
  46280. }
  46281. ];
  46282. // filter the data item with the value of label is undefined
  46283. var filterData = zrUtil.filter(option.data, function (dataItem) {
  46284. return dataItem[2] !== undefined;
  46285. });
  46286. var data = this.fixData(filterData || []);
  46287. var nameList = [];
  46288. var nameMap = this.nameMap = zrUtil.createHashMap();
  46289. var count = 0;
  46290. for (var i = 0; i < data.length; ++i) {
  46291. nameList.push(data[i][DATA_NAME_INDEX]);
  46292. if (!nameMap.get(data[i][DATA_NAME_INDEX])) {
  46293. nameMap.set(data[i][DATA_NAME_INDEX], count);
  46294. count++;
  46295. }
  46296. }
  46297. dimensions = completeDimensions(dimensions, data);
  46298. var list = new List(dimensions, this);
  46299. list.initData(data, nameList);
  46300. return list;
  46301. },
  46302. /**
  46303. * Used by single coordinate
  46304. *
  46305. * @param {string} axisDim the dimension for single coordinate
  46306. * @return {Array.<string> } specified dimensions on the axis.
  46307. */
  46308. coordDimToDataDim: function (axisDim) {
  46309. return ['time'];
  46310. },
  46311. /**
  46312. * The raw data is divided into multiple layers and each layer
  46313. * has same name.
  46314. *
  46315. * @return {Array.<Array.<number>>}
  46316. */
  46317. getLayerSeries: function () {
  46318. var data = this.getData();
  46319. var lenCount = data.count();
  46320. var indexArr = [];
  46321. for (var i = 0; i < lenCount; ++i) {
  46322. indexArr[i] = i;
  46323. }
  46324. // data group by name
  46325. var dataByName = nest()
  46326. .key(function (index) {
  46327. return data.get('name', index);
  46328. })
  46329. .entries(indexArr);
  46330. var layerSeries = zrUtil.map(dataByName, function (d) {
  46331. return {
  46332. name: d.key,
  46333. indices: d.values
  46334. };
  46335. });
  46336. for (var j = 0; j < layerSeries.length; ++j) {
  46337. layerSeries[j].indices.sort(comparer);
  46338. }
  46339. function comparer(index1, index2) {
  46340. return data.get('time', index1) - data.get('time', index2);
  46341. }
  46342. return layerSeries;
  46343. },
  46344. /**
  46345. * Get data indices for show tooltip content
  46346. *
  46347. * @param {Array.<string>|string} dim single coordinate dimension
  46348. * @param {number} value axis value
  46349. * @param {module:echarts/coord/single/SingleAxis} baseAxis single Axis used
  46350. * the themeRiver.
  46351. * @return {Object} {dataIndices, nestestValue}
  46352. */
  46353. getAxisTooltipData: function (dim, value, baseAxis) {
  46354. if (!zrUtil.isArray(dim)) {
  46355. dim = dim ? [dim] : [];
  46356. }
  46357. var data = this.getData();
  46358. var layerSeries = this.getLayerSeries();
  46359. var indices = [];
  46360. var layerNum = layerSeries.length;
  46361. var nestestValue;
  46362. for (var i = 0; i < layerNum; ++i) {
  46363. var minDist = Number.MAX_VALUE;
  46364. var nearestIdx = -1;
  46365. var pointNum = layerSeries[i].indices.length;
  46366. for (var j = 0; j < pointNum; ++j) {
  46367. var theValue = data.get(dim[0], layerSeries[i].indices[j]);
  46368. var dist = Math.abs(theValue - value);
  46369. if (dist <= minDist) {
  46370. nestestValue = theValue;
  46371. minDist = dist;
  46372. nearestIdx = layerSeries[i].indices[j];
  46373. }
  46374. }
  46375. indices.push(nearestIdx);
  46376. }
  46377. return {dataIndices: indices, nestestValue: nestestValue};
  46378. },
  46379. /**
  46380. * @override
  46381. * @param {number} dataIndex index of data
  46382. */
  46383. formatTooltip: function (dataIndex) {
  46384. var data = this.getData();
  46385. var htmlName = data.get('name', dataIndex);
  46386. var htmlValue = data.get('value', dataIndex);
  46387. if (isNaN(htmlValue) || htmlValue == null) {
  46388. htmlValue = '-';
  46389. }
  46390. return encodeHTML(htmlName + ' : ' + htmlValue);
  46391. },
  46392. defaultOption: {
  46393. zlevel: 0,
  46394. z: 2,
  46395. coordinateSystem: 'singleAxis',
  46396. // gap in axis's orthogonal orientation
  46397. boundaryGap: ['10%', '10%'],
  46398. // legendHoverLink: true,
  46399. singleAxisIndex: 0,
  46400. animationEasing: 'linear',
  46401. label: {
  46402. normal: {
  46403. margin: 4,
  46404. textAlign: 'right',
  46405. show: true,
  46406. position: 'left',
  46407. textStyle: {
  46408. color: '#000',
  46409. fontSize: 11
  46410. }
  46411. },
  46412. emphasis: {
  46413. show: true
  46414. }
  46415. }
  46416. }
  46417. });
  46418. module.exports = ThemeRiverSeries;
  46419. /***/ },
  46420. /* 309 */
  46421. /***/ function(module, exports, __webpack_require__) {
  46422. /* WEBPACK VAR INJECTION */(function(process) {/**
  46423. * @file The file used to draw themeRiver view
  46424. * @author Deqing Li(annong035@gmail.com)
  46425. */
  46426. var poly = __webpack_require__(120);
  46427. var graphic = __webpack_require__(18);
  46428. var zrUtil = __webpack_require__(4);
  46429. var DataDiffer = __webpack_require__(99);
  46430. module.exports = __webpack_require__(1).extendChartView({
  46431. type: 'themeRiver',
  46432. init: function () {
  46433. this._layers = [];
  46434. },
  46435. render: function (seriesModel, ecModel, api) {
  46436. var data = seriesModel.getData();
  46437. var rawData = seriesModel.getRawData();
  46438. if (!data.count()) {
  46439. return;
  46440. }
  46441. var group = this.group;
  46442. var layerSeries = seriesModel.getLayerSeries();
  46443. var layoutInfo = data.getLayout('layoutInfo');
  46444. var rect = layoutInfo.rect;
  46445. var boundaryGap = layoutInfo.boundaryGap;
  46446. group.attr('position', [0, rect.y + boundaryGap[0]]);
  46447. function keyGetter(item) {
  46448. return item.name;
  46449. }
  46450. var dataDiffer = new DataDiffer(
  46451. this._layersSeries || [], layerSeries,
  46452. keyGetter, keyGetter
  46453. );
  46454. var newLayersGroups = {};
  46455. dataDiffer.add(zrUtil.bind(zrUtil.curry(process, 'add'), this))
  46456. .update(zrUtil.bind(zrUtil.curry(process, 'update'), this))
  46457. .remove(zrUtil.bind(zrUtil.curry(process, 'remove'), this))
  46458. .execute();
  46459. function process(status, idx, oldIdx) {
  46460. var oldLayersGroups = this._layers;
  46461. if (status === 'remove') {
  46462. group.remove(oldLayersGroups[idx]);
  46463. return;
  46464. }
  46465. var points0 = [];
  46466. var points1 = [];
  46467. var color;
  46468. var indices = layerSeries[idx].indices;
  46469. for (var j = 0; j < indices.length; j++) {
  46470. var layout = data.getItemLayout(indices[j]);
  46471. var x = layout.x;
  46472. var y0 = layout.y0;
  46473. var y = layout.y;
  46474. points0.push([x, y0]);
  46475. points1.push([x, y0 + y]);
  46476. color = rawData.getItemVisual(indices[j], 'color');
  46477. }
  46478. var polygon;
  46479. var text;
  46480. var textLayout = data.getItemLayout(indices[0]);
  46481. var itemModel = data.getItemModel(indices[j - 1]);
  46482. var labelModel = itemModel.getModel('label.normal');
  46483. var margin = labelModel.get('margin');
  46484. if (status === 'add') {
  46485. var layerGroup = newLayersGroups[idx] = new graphic.Group();
  46486. polygon = new poly.Polygon({
  46487. shape: {
  46488. points: points0,
  46489. stackedOnPoints: points1,
  46490. smooth: 0.4,
  46491. stackedOnSmooth: 0.4,
  46492. smoothConstraint: false
  46493. },
  46494. z2: 0
  46495. });
  46496. text = new graphic.Text({
  46497. style: {
  46498. x: textLayout.x - margin,
  46499. y: textLayout.y0 + textLayout.y / 2
  46500. }
  46501. });
  46502. layerGroup.add(polygon);
  46503. layerGroup.add(text);
  46504. group.add(layerGroup);
  46505. polygon.setClipPath(createGridClipShape(polygon.getBoundingRect(), seriesModel, function () {
  46506. polygon.removeClipPath();
  46507. }));
  46508. }
  46509. else {
  46510. var layerGroup = oldLayersGroups[oldIdx];
  46511. polygon = layerGroup.childAt(0);
  46512. text = layerGroup.childAt(1);
  46513. group.add(layerGroup);
  46514. newLayersGroups[idx] = layerGroup;
  46515. graphic.updateProps(polygon, {
  46516. shape: {
  46517. points: points0,
  46518. stackedOnPoints: points1
  46519. }
  46520. }, seriesModel);
  46521. graphic.updateProps(text, {
  46522. style: {
  46523. x: textLayout.x - margin,
  46524. y: textLayout.y0 + textLayout.y / 2
  46525. }
  46526. }, seriesModel);
  46527. }
  46528. var hoverItemStyleModel = itemModel.getModel('itemStyle.emphasis');
  46529. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  46530. var textStyleModel = labelModel.getModel('textStyle');
  46531. text.setStyle({
  46532. text: labelModel.get('show')
  46533. ? seriesModel.getFormattedLabel(indices[j - 1], 'normal')
  46534. || data.getName(indices[j - 1])
  46535. : '',
  46536. textFont: textStyleModel.getFont(),
  46537. textAlign: labelModel.get('textAlign'),
  46538. textVerticalAlign: 'middle'
  46539. });
  46540. polygon.setStyle(zrUtil.extend({
  46541. fill: color
  46542. }, itemStyleModel.getItemStyle(['color'])));
  46543. graphic.setHoverStyle(polygon, hoverItemStyleModel.getItemStyle());
  46544. }
  46545. this._layersSeries = layerSeries;
  46546. this._layers = newLayersGroups;
  46547. },
  46548. dispose: function () {}
  46549. });
  46550. // add animation to the view
  46551. function createGridClipShape(rect, seriesModel, cb) {
  46552. var rectEl = new graphic.Rect({
  46553. shape: {
  46554. x: rect.x - 10,
  46555. y: rect.y - 10,
  46556. width: 0,
  46557. height: rect.height + 20
  46558. }
  46559. });
  46560. graphic.initProps(rectEl, {
  46561. shape: {
  46562. width: rect.width + 20,
  46563. height: rect.height + 20
  46564. }
  46565. }, seriesModel, cb);
  46566. return rectEl;
  46567. }
  46568. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(310)))
  46569. /***/ },
  46570. /* 310 */
  46571. /***/ function(module, exports) {
  46572. // shim for using process in browser
  46573. var process = module.exports = {};
  46574. // cached from whatever global is present so that test runners that stub it
  46575. // don't break things. But we need to wrap it in a try catch in case it is
  46576. // wrapped in strict mode code which doesn't define any globals. It's inside a
  46577. // function because try/catches deoptimize in certain engines.
  46578. var cachedSetTimeout;
  46579. var cachedClearTimeout;
  46580. function defaultSetTimout() {
  46581. throw new Error('setTimeout has not been defined');
  46582. }
  46583. function defaultClearTimeout () {
  46584. throw new Error('clearTimeout has not been defined');
  46585. }
  46586. (function () {
  46587. try {
  46588. if (typeof setTimeout === 'function') {
  46589. cachedSetTimeout = setTimeout;
  46590. } else {
  46591. cachedSetTimeout = defaultSetTimout;
  46592. }
  46593. } catch (e) {
  46594. cachedSetTimeout = defaultSetTimout;
  46595. }
  46596. try {
  46597. if (typeof clearTimeout === 'function') {
  46598. cachedClearTimeout = clearTimeout;
  46599. } else {
  46600. cachedClearTimeout = defaultClearTimeout;
  46601. }
  46602. } catch (e) {
  46603. cachedClearTimeout = defaultClearTimeout;
  46604. }
  46605. } ())
  46606. function runTimeout(fun) {
  46607. if (cachedSetTimeout === setTimeout) {
  46608. //normal enviroments in sane situations
  46609. return setTimeout(fun, 0);
  46610. }
  46611. // if setTimeout wasn't available but was latter defined
  46612. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  46613. cachedSetTimeout = setTimeout;
  46614. return setTimeout(fun, 0);
  46615. }
  46616. try {
  46617. // when when somebody has screwed with setTimeout but no I.E. maddness
  46618. return cachedSetTimeout(fun, 0);
  46619. } catch(e){
  46620. try {
  46621. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  46622. return cachedSetTimeout.call(null, fun, 0);
  46623. } catch(e){
  46624. // 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
  46625. return cachedSetTimeout.call(this, fun, 0);
  46626. }
  46627. }
  46628. }
  46629. function runClearTimeout(marker) {
  46630. if (cachedClearTimeout === clearTimeout) {
  46631. //normal enviroments in sane situations
  46632. return clearTimeout(marker);
  46633. }
  46634. // if clearTimeout wasn't available but was latter defined
  46635. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  46636. cachedClearTimeout = clearTimeout;
  46637. return clearTimeout(marker);
  46638. }
  46639. try {
  46640. // when when somebody has screwed with setTimeout but no I.E. maddness
  46641. return cachedClearTimeout(marker);
  46642. } catch (e){
  46643. try {
  46644. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  46645. return cachedClearTimeout.call(null, marker);
  46646. } catch (e){
  46647. // 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.
  46648. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  46649. return cachedClearTimeout.call(this, marker);
  46650. }
  46651. }
  46652. }
  46653. var queue = [];
  46654. var draining = false;
  46655. var currentQueue;
  46656. var queueIndex = -1;
  46657. function cleanUpNextTick() {
  46658. if (!draining || !currentQueue) {
  46659. return;
  46660. }
  46661. draining = false;
  46662. if (currentQueue.length) {
  46663. queue = currentQueue.concat(queue);
  46664. } else {
  46665. queueIndex = -1;
  46666. }
  46667. if (queue.length) {
  46668. drainQueue();
  46669. }
  46670. }
  46671. function drainQueue() {
  46672. if (draining) {
  46673. return;
  46674. }
  46675. var timeout = runTimeout(cleanUpNextTick);
  46676. draining = true;
  46677. var len = queue.length;
  46678. while(len) {
  46679. currentQueue = queue;
  46680. queue = [];
  46681. while (++queueIndex < len) {
  46682. if (currentQueue) {
  46683. currentQueue[queueIndex].run();
  46684. }
  46685. }
  46686. queueIndex = -1;
  46687. len = queue.length;
  46688. }
  46689. currentQueue = null;
  46690. draining = false;
  46691. runClearTimeout(timeout);
  46692. }
  46693. process.nextTick = function (fun) {
  46694. var args = new Array(arguments.length - 1);
  46695. if (arguments.length > 1) {
  46696. for (var i = 1; i < arguments.length; i++) {
  46697. args[i - 1] = arguments[i];
  46698. }
  46699. }
  46700. queue.push(new Item(fun, args));
  46701. if (queue.length === 1 && !draining) {
  46702. runTimeout(drainQueue);
  46703. }
  46704. };
  46705. // v8 likes predictible objects
  46706. function Item(fun, array) {
  46707. this.fun = fun;
  46708. this.array = array;
  46709. }
  46710. Item.prototype.run = function () {
  46711. this.fun.apply(null, this.array);
  46712. };
  46713. process.title = 'browser';
  46714. process.browser = true;
  46715. process.env = {};
  46716. process.argv = [];
  46717. process.version = ''; // empty string to avoid regexp issues
  46718. process.versions = {};
  46719. function noop() {}
  46720. process.on = noop;
  46721. process.addListener = noop;
  46722. process.once = noop;
  46723. process.off = noop;
  46724. process.removeListener = noop;
  46725. process.removeAllListeners = noop;
  46726. process.emit = noop;
  46727. process.binding = function (name) {
  46728. throw new Error('process.binding is not supported');
  46729. };
  46730. process.cwd = function () { return '/' };
  46731. process.chdir = function (dir) {
  46732. throw new Error('process.chdir is not supported');
  46733. };
  46734. process.umask = function() { return 0; };
  46735. /***/ },
  46736. /* 311 */
  46737. /***/ function(module, exports, __webpack_require__) {
  46738. /**
  46739. * @file Using layout algorithm transform the raw data to layout information.
  46740. * @author Deqing Li(annong035@gmail.com)
  46741. */
  46742. var zrUtil = __webpack_require__(4);
  46743. var numberUtil = __webpack_require__(7);
  46744. module.exports = function (ecModel, api) {
  46745. ecModel.eachSeriesByType('themeRiver', function (seriesModel) {
  46746. var data = seriesModel.getData();
  46747. var single = seriesModel.coordinateSystem;
  46748. var layoutInfo = {};
  46749. // use the axis boundingRect for view
  46750. var rect = single.getRect();
  46751. layoutInfo.rect = rect;
  46752. var boundaryGap = seriesModel.get('boundaryGap');
  46753. var axis = single.getAxis();
  46754. layoutInfo.boundaryGap = boundaryGap;
  46755. if (axis.orient === 'horizontal') {
  46756. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], rect.height);
  46757. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], rect.height);
  46758. var height = rect.height - boundaryGap[0] - boundaryGap[1];
  46759. themeRiverLayout(data, seriesModel, height);
  46760. }
  46761. else {
  46762. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], rect.width);
  46763. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], rect.width);
  46764. var width = rect.width - boundaryGap[0] - boundaryGap[1];
  46765. themeRiverLayout(data, seriesModel, width);
  46766. }
  46767. data.setLayout('layoutInfo', layoutInfo);
  46768. });
  46769. };
  46770. /**
  46771. * The layout information about themeriver
  46772. *
  46773. * @param {module:echarts/data/List} data data in the series
  46774. * @param {module:echarts/model/Series} seriesModel the model object of themeRiver series
  46775. * @param {number} height value used to compute every series height
  46776. */
  46777. function themeRiverLayout(data, seriesModel, height) {
  46778. if (!data.count()) {
  46779. return;
  46780. }
  46781. var coordSys = seriesModel.coordinateSystem;
  46782. // the data in each layer are organized into a series.
  46783. var layerSeries = seriesModel.getLayerSeries();
  46784. // the points in each layer.
  46785. var layerPoints = zrUtil.map(layerSeries, function (singleLayer) {
  46786. return zrUtil.map(singleLayer.indices, function (idx) {
  46787. var pt = coordSys.dataToPoint(data.get('time', idx));
  46788. pt[1] = data.get('value', idx);
  46789. return pt;
  46790. });
  46791. });
  46792. var base = computeBaseline(layerPoints);
  46793. var baseLine = base.y0;
  46794. var ky = height / base.max;
  46795. // set layout information for each item.
  46796. var n = layerSeries.length;
  46797. var m = layerSeries[0].indices.length;
  46798. var baseY0;
  46799. for (var j = 0; j < m; ++j) {
  46800. baseY0 = baseLine[j] * ky;
  46801. data.setItemLayout(layerSeries[0].indices[j], {
  46802. layerIndex: 0,
  46803. x: layerPoints[0][j][0],
  46804. y0: baseY0,
  46805. y: layerPoints[0][j][1] * ky
  46806. });
  46807. for (var i = 1; i < n; ++i) {
  46808. baseY0 += layerPoints[i - 1][j][1] * ky;
  46809. data.setItemLayout(layerSeries[i].indices[j], {
  46810. layerIndex: i,
  46811. x: layerPoints[i][j][0],
  46812. y0: baseY0,
  46813. y: layerPoints[i][j][1] * ky
  46814. });
  46815. }
  46816. }
  46817. }
  46818. /**
  46819. * Compute the baseLine of the rawdata
  46820. * Inspired by Lee Byron's paper Stacked Graphs - Geometry & Aesthetics
  46821. *
  46822. * @param {Array.<Array>} data the points in each layer
  46823. * @return {Array}
  46824. */
  46825. function computeBaseline(data) {
  46826. var layerNum = data.length;
  46827. var pointNum = data[0].length;
  46828. var sums = [];
  46829. var y0 = [];
  46830. var max = 0;
  46831. var temp;
  46832. var base = {};
  46833. for (var i = 0; i < pointNum; ++i) {
  46834. for (var j = 0, temp = 0; j < layerNum; ++j) {
  46835. temp += data[j][i][1];
  46836. }
  46837. if (temp > max) {
  46838. max = temp;
  46839. }
  46840. sums.push(temp);
  46841. }
  46842. for (var k = 0; k < pointNum; ++k) {
  46843. y0[k] = (max - sums[k]) / 2;
  46844. }
  46845. max = 0;
  46846. for (var l = 0; l < pointNum; ++l) {
  46847. var sum = sums[l] + y0[l];
  46848. if (sum > max) {
  46849. max = sum;
  46850. }
  46851. }
  46852. base.y0 = y0;
  46853. base.max = max;
  46854. return base;
  46855. }
  46856. /***/ },
  46857. /* 312 */
  46858. /***/ function(module, exports) {
  46859. /**
  46860. * @file Visual encoding for themeRiver view
  46861. * @author Deqing Li(annong035@gmail.com)
  46862. */
  46863. module.exports = function (ecModel) {
  46864. ecModel.eachSeriesByType('themeRiver', function (seriesModel) {
  46865. var data = seriesModel.getData();
  46866. var rawData = seriesModel.getRawData();
  46867. var colorList = seriesModel.get('color');
  46868. data.each(function (index) {
  46869. var name = data.getName(index);
  46870. var color = colorList[(seriesModel.nameMap.get(name) - 1) % colorList.length];
  46871. rawData.setItemVisual(index, 'color', color);
  46872. });
  46873. });
  46874. };
  46875. /***/ },
  46876. /* 313 */
  46877. /***/ function(module, exports, __webpack_require__) {
  46878. var echarts = __webpack_require__(1);
  46879. var zrUtil = __webpack_require__(4);
  46880. var graphicUtil = __webpack_require__(18);
  46881. var labelHelper = __webpack_require__(118);
  46882. var createListFromArray = __webpack_require__(109);
  46883. var barGrid = __webpack_require__(145);
  46884. var ITEM_STYLE_NORMAL_PATH = ['itemStyle', 'normal'];
  46885. var ITEM_STYLE_EMPHASIS_PATH = ['itemStyle', 'emphasis'];
  46886. var LABEL_NORMAL = ['label', 'normal'];
  46887. var LABEL_EMPHASIS = ['label', 'emphasis'];
  46888. /**
  46889. * To reduce total package size of each coordinate systems, the modules `prepareCustom`
  46890. * of each coordinate systems are not required by each coordinate systems directly, but
  46891. * required by the module `custom`.
  46892. *
  46893. * prepareInfoForCustomSeries {Function}: optional
  46894. * @return {Object} {coordSys: {...}, api: {
  46895. * coord: function (data, clamp) {}, // return point in global.
  46896. * size: function (dataSize, dataItem) {} // return size of each axis in coordSys.
  46897. * }}
  46898. */
  46899. var prepareCustoms = {
  46900. cartesian2d: __webpack_require__(314),
  46901. geo: __webpack_require__(315),
  46902. singleAxis: __webpack_require__(316),
  46903. polar: __webpack_require__(317),
  46904. calendar: __webpack_require__(318)
  46905. };
  46906. // ------
  46907. // Model
  46908. // ------
  46909. echarts.extendSeriesModel({
  46910. type: 'series.custom',
  46911. dependencies: ['grid', 'polar', 'geo', 'singleAxis', 'calendar'],
  46912. defaultOption: {
  46913. coordinateSystem: 'cartesian2d',
  46914. zlevel: 0,
  46915. z: 2,
  46916. legendHoverLink: true
  46917. // Cartesian coordinate system
  46918. // xAxisIndex: 0,
  46919. // yAxisIndex: 0,
  46920. // Polar coordinate system
  46921. // polarIndex: 0,
  46922. // Geo coordinate system
  46923. // geoIndex: 0,
  46924. // label: {}
  46925. // itemStyle: {}
  46926. },
  46927. getInitialData: function (option, ecModel) {
  46928. return createListFromArray(option.data, this, ecModel);
  46929. }
  46930. });
  46931. // -----
  46932. // View
  46933. // -----
  46934. echarts.extendChartView({
  46935. type: 'custom',
  46936. /**
  46937. * @private
  46938. * @type {module:echarts/data/List}
  46939. */
  46940. _data: null,
  46941. /**
  46942. * @override
  46943. */
  46944. render: function (customSeries, ecModel, api) {
  46945. var oldData = this._data;
  46946. var data = customSeries.getData();
  46947. var group = this.group;
  46948. var renderItem = makeRenderItem(customSeries, data, ecModel, api);
  46949. data.diff(oldData)
  46950. .add(function (newIdx) {
  46951. data.hasValue(newIdx) && createOrUpdate(
  46952. null, newIdx, renderItem(newIdx), customSeries, group, data
  46953. );
  46954. })
  46955. .update(function (newIdx, oldIdx) {
  46956. var el = oldData.getItemGraphicEl(oldIdx);
  46957. data.hasValue(newIdx)
  46958. ? createOrUpdate(
  46959. el, newIdx, renderItem(newIdx), customSeries, group, data
  46960. )
  46961. : (el && group.remove(el));
  46962. })
  46963. .remove(function (oldIdx) {
  46964. var el = oldData.getItemGraphicEl(oldIdx);
  46965. el && group.remove(el);
  46966. })
  46967. .execute();
  46968. this._data = data;
  46969. },
  46970. /**
  46971. * @override
  46972. */
  46973. dispose: zrUtil.noop
  46974. });
  46975. function createEl(elOption) {
  46976. var graphicType = elOption.type;
  46977. var el;
  46978. if (graphicType === 'path') {
  46979. var shape = elOption.shape;
  46980. el = graphicUtil.makePath(
  46981. shape.pathData,
  46982. null,
  46983. {
  46984. x: shape.x || 0,
  46985. y: shape.y || 0,
  46986. width: shape.width || 0,
  46987. height: shape.height || 0
  46988. },
  46989. 'center'
  46990. );
  46991. el.__customPathData = elOption.pathData;
  46992. }
  46993. else if (graphicType === 'image') {
  46994. el = new graphicUtil.Image({
  46995. });
  46996. el.__customImagePath = elOption.style.image;
  46997. }
  46998. else if (graphicType === 'text') {
  46999. el = new graphicUtil.Text({
  47000. });
  47001. el.__customText = elOption.style.text;
  47002. }
  47003. else {
  47004. var Clz = graphicUtil[graphicType.charAt(0).toUpperCase() + graphicType.slice(1)];
  47005. if (true) {
  47006. zrUtil.assert(Clz, 'graphic type "' + graphicType + '" can not be found.');
  47007. }
  47008. el = new Clz();
  47009. }
  47010. el.__customGraphicType = graphicType;
  47011. return el;
  47012. }
  47013. function updateEl(el, dataIndex, elOption, animatableModel, data, isInit) {
  47014. var targetProps = {};
  47015. var elOptionStyle = elOption.style || {};
  47016. elOption.shape && (targetProps.shape = zrUtil.clone(elOption.shape));
  47017. elOption.position && (targetProps.position = elOption.position.slice());
  47018. elOption.scale && (targetProps.scale = elOption.scale.slice());
  47019. elOption.origin && (targetProps.origin = elOption.origin.slice());
  47020. elOption.rotation && (targetProps.rotation = elOption.rotation);
  47021. if (el.type === 'image' && elOption.style) {
  47022. var targetStyle = targetProps.style = {};
  47023. zrUtil.each(['x', 'y', 'width', 'height'], function (prop) {
  47024. prepareStyleTransition(prop, targetStyle, elOptionStyle, el.style, isInit);
  47025. });
  47026. }
  47027. if (el.type === 'text' && elOption.style) {
  47028. var targetStyle = targetProps.style = {};
  47029. zrUtil.each(['x', 'y'], function (prop) {
  47030. prepareStyleTransition(prop, targetStyle, elOptionStyle, el.style, isInit);
  47031. });
  47032. }
  47033. if (el.type !== 'group') {
  47034. el.useStyle(elOptionStyle);
  47035. // Init animation.
  47036. if (isInit) {
  47037. el.style.opacity = 0;
  47038. var targetOpacity = elOptionStyle.opacity;
  47039. targetOpacity == null && (targetOpacity = 1);
  47040. graphicUtil.initProps(el, {style: {opacity: targetOpacity}}, animatableModel, dataIndex);
  47041. }
  47042. }
  47043. if (isInit) {
  47044. el.attr(targetProps);
  47045. }
  47046. else {
  47047. graphicUtil.updateProps(el, targetProps, animatableModel, dataIndex);
  47048. }
  47049. // z2 must not be null/undefined, otherwise sort error may occur.
  47050. el.attr({z2: elOption.z2 || 0, silent: elOption.silent});
  47051. elOption.styleEmphasis !== false && graphicUtil.setHoverStyle(el, elOption.styleEmphasis);
  47052. }
  47053. function prepareStyleTransition(prop, targetStyle, elOptionStyle, oldElStyle, isInit) {
  47054. if (elOptionStyle[prop] != null && !isInit) {
  47055. targetStyle[prop] = elOptionStyle[prop];
  47056. elOptionStyle[prop] = oldElStyle[prop];
  47057. }
  47058. }
  47059. function makeRenderItem(customSeries, data, ecModel, api) {
  47060. var renderItem = customSeries.get('renderItem');
  47061. var coordSys = customSeries.coordinateSystem;
  47062. if (true) {
  47063. zrUtil.assert(renderItem, 'series.render is required.');
  47064. zrUtil.assert(
  47065. coordSys.prepareCustoms || prepareCustoms[coordSys.type],
  47066. 'This coordSys does not support custom series.'
  47067. );
  47068. }
  47069. var prepareResult = coordSys.prepareCustoms
  47070. ? coordSys.prepareCustoms()
  47071. : prepareCustoms[coordSys.type](coordSys);
  47072. var userAPI = zrUtil.defaults({
  47073. getWidth: api.getWidth,
  47074. getHeight: api.getHeight,
  47075. getZr: api.getZr,
  47076. getDevicePixelRatio: api.getDevicePixelRatio,
  47077. value: value,
  47078. style: style,
  47079. styleEmphasis: styleEmphasis,
  47080. visual: visual,
  47081. barLayout: barLayout,
  47082. currentSeriesIndices: currentSeriesIndices,
  47083. font: font
  47084. }, prepareResult.api);
  47085. var userParams = {
  47086. context: {},
  47087. seriesId: customSeries.id,
  47088. seriesName: customSeries.name,
  47089. seriesIndex: customSeries.seriesIndex,
  47090. coordSys: prepareResult.coordSys,
  47091. dataInsideLength: data.count(),
  47092. encode: wrapEncodeDef(customSeries.getData())
  47093. };
  47094. // Do not support call `api` asynchronously without dataIndexInside input.
  47095. var currDataIndexInside;
  47096. var currDirty = true;
  47097. var currItemModel;
  47098. var currLabelNormalModel;
  47099. var currLabelEmphasisModel;
  47100. var currLabelValueDim;
  47101. var currVisualColor;
  47102. return function (dataIndexInside) {
  47103. currDataIndexInside = dataIndexInside;
  47104. currDirty = true;
  47105. return renderItem && renderItem(
  47106. zrUtil.defaults({
  47107. dataIndexInside: dataIndexInside,
  47108. dataIndex: data.getRawIndex(dataIndexInside)
  47109. }, userParams),
  47110. userAPI
  47111. ) || {};
  47112. };
  47113. // Do not update cache until api called.
  47114. function updateCache(dataIndexInside) {
  47115. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  47116. if (currDirty) {
  47117. currItemModel = data.getItemModel(dataIndexInside);
  47118. currLabelNormalModel = currItemModel.getModel(LABEL_NORMAL);
  47119. currLabelEmphasisModel = currItemModel.getModel(LABEL_EMPHASIS);
  47120. currLabelValueDim = labelHelper.findLabelValueDim(data);
  47121. currVisualColor = data.getItemVisual(dataIndexInside, 'color');
  47122. currDirty = false;
  47123. }
  47124. }
  47125. /**
  47126. * @public
  47127. * @param {nubmer|string} dim
  47128. * @param {number} [dataIndexInside=currDataIndexInside]
  47129. * @return {number|string} value
  47130. */
  47131. function value(dim, dataIndexInside) {
  47132. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  47133. return data.get(data.getDimension(dim || 0), dataIndexInside);
  47134. }
  47135. /**
  47136. * By default, `visual` is applied to style (to support visualMap).
  47137. * `visual.color` is applied at `fill`. If user want apply visual.color on `stroke`,
  47138. * it can be implemented as:
  47139. * `api.style({stroke: api.visual('color'), fill: null})`;
  47140. * @public
  47141. * @param {Object} [extra]
  47142. * @param {number} [dataIndexInside=currDataIndexInside]
  47143. */
  47144. function style(extra, dataIndexInside) {
  47145. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  47146. updateCache(dataIndexInside);
  47147. var itemStyle = currItemModel.getModel(ITEM_STYLE_NORMAL_PATH).getItemStyle();
  47148. currVisualColor != null && (itemStyle.fill = currVisualColor);
  47149. var opacity = data.getItemVisual(dataIndexInside, 'opacity');
  47150. opacity != null && (itemStyle.opacity = opacity);
  47151. labelHelper.setTextToStyle(
  47152. data, dataIndexInside, currLabelValueDim, itemStyle,
  47153. customSeries, currLabelNormalModel, currVisualColor
  47154. );
  47155. extra && zrUtil.extend(itemStyle, extra);
  47156. return itemStyle;
  47157. }
  47158. /**
  47159. * @public
  47160. * @param {Object} [extra]
  47161. * @param {number} [dataIndexInside=currDataIndexInside]
  47162. */
  47163. function styleEmphasis(extra, dataIndexInside) {
  47164. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  47165. updateCache(dataIndexInside);
  47166. var itemStyle = currItemModel.getModel(ITEM_STYLE_EMPHASIS_PATH).getItemStyle();
  47167. labelHelper.setTextToStyle(
  47168. data, dataIndexInside, currLabelValueDim, itemStyle,
  47169. customSeries, currLabelEmphasisModel, currVisualColor
  47170. );
  47171. extra && zrUtil.extend(itemStyle, extra);
  47172. return itemStyle;
  47173. }
  47174. /**
  47175. * @public
  47176. * @param {string} visualType
  47177. * @param {number} [dataIndexInside=currDataIndexInside]
  47178. */
  47179. function visual(visualType, dataIndexInside) {
  47180. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  47181. return data.getItemVisual(dataIndexInside, visualType);
  47182. }
  47183. /**
  47184. * @public
  47185. * @param {number} opt.count Positive interger.
  47186. * @param {number} [opt.barWidth]
  47187. * @param {number} [opt.barMaxWidth]
  47188. * @param {number} [opt.barGap]
  47189. * @param {number} [opt.barCategoryGap]
  47190. * @return {Object} {width, offset, offsetCenter} is not support, return undefined.
  47191. */
  47192. function barLayout(opt) {
  47193. if (coordSys.getBaseAxis) {
  47194. var baseAxis = coordSys.getBaseAxis();
  47195. return barGrid.getLayoutOnAxis(zrUtil.defaults({axis: baseAxis}, opt), api);
  47196. }
  47197. }
  47198. /**
  47199. * @public
  47200. * @return {Array.<number>}
  47201. */
  47202. function currentSeriesIndices() {
  47203. return ecModel.getCurrentSeriesIndices();
  47204. }
  47205. /**
  47206. * @public
  47207. * @param {Object} opt
  47208. * @param {string} [opt.fontStyle]
  47209. * @param {number} [opt.fontWeight]
  47210. * @param {number} [opt.fontSize]
  47211. * @param {string} [opt.fontFamily]
  47212. * @return {string} font string
  47213. */
  47214. function font(opt) {
  47215. return graphicUtil.getFont(opt, ecModel);
  47216. }
  47217. }
  47218. function wrapEncodeDef(data) {
  47219. var encodeDef = {};
  47220. zrUtil.each(data.dimensions, function (dimName, dataDimIndex) {
  47221. var dimInfo = data.getDimensionInfo(dimName);
  47222. if (!dimInfo.isExtraCoord) {
  47223. var coordDim = dimInfo.coordDim;
  47224. var dataDims = encodeDef[coordDim] = encodeDef[coordDim] || [];
  47225. dataDims[dimInfo.coordDimIndex] = dataDimIndex;
  47226. }
  47227. });
  47228. return encodeDef;
  47229. }
  47230. function createOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
  47231. el = doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data);
  47232. el && data.setItemGraphicEl(dataIndex, el);
  47233. }
  47234. function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
  47235. var elOptionType = elOption.type;
  47236. if (el
  47237. && elOptionType !== el.__customGraphicType
  47238. && (elOptionType !== 'path' || elOption.pathData !== el.__customPathData)
  47239. && (elOptionType !== 'image' || elOption.style.image !== el.__customImagePath)
  47240. && (elOptionType !== 'text' || elOption.style.text !== el.__customText)
  47241. ) {
  47242. group.remove(el);
  47243. el = null;
  47244. }
  47245. // `elOption.type` is undefined when `renderItem` returns nothing.
  47246. if (elOptionType == null) {
  47247. return;
  47248. }
  47249. var isInit = !el;
  47250. !el && (el = createEl(elOption));
  47251. updateEl(el, dataIndex, elOption, animatableModel, data, isInit);
  47252. elOptionType === 'group' && zrUtil.each(elOption.children, function (childOption, index) {
  47253. doCreateOrUpdate(el.childAt(index), dataIndex, childOption, animatableModel, el, data);
  47254. });
  47255. group.add(el);
  47256. return el;
  47257. }
  47258. /***/ },
  47259. /* 314 */
  47260. /***/ function(module, exports, __webpack_require__) {
  47261. var zrUtil = __webpack_require__(4);
  47262. function dataToCoordSize(dataSize, dataItem) {
  47263. // dataItem is necessary in log axis.
  47264. dataItem = dataItem || [0, 0];
  47265. return zrUtil.map(['x', 'y'], function (dim, dimIdx) {
  47266. var axis = this.getAxis(dim);
  47267. var val = dataItem[dimIdx];
  47268. var halfSize = dataSize[dimIdx] / 2;
  47269. return axis.type === 'category'
  47270. ? axis.getBandWidth()
  47271. : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
  47272. }, this);
  47273. }
  47274. function prepareCustom(coordSys) {
  47275. var rect = coordSys.grid.getRect();
  47276. return {
  47277. coordSys: {
  47278. // The name exposed to user is always 'cartesian2d' but not 'grid'.
  47279. type: 'cartesian2d',
  47280. x: rect.x,
  47281. y: rect.y,
  47282. width: rect.width,
  47283. height: rect.height
  47284. },
  47285. api: {
  47286. coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
  47287. size: zrUtil.bind(dataToCoordSize, coordSys)
  47288. }
  47289. };
  47290. }
  47291. module.exports = prepareCustom;
  47292. /***/ },
  47293. /* 315 */
  47294. /***/ function(module, exports, __webpack_require__) {
  47295. var zrUtil = __webpack_require__(4);
  47296. function dataToCoordSize(dataSize, dataItem) {
  47297. dataItem = dataItem || [0, 0];
  47298. return zrUtil.map([0, 1], function (dimIdx) {
  47299. var val = dataItem[dimIdx];
  47300. var halfSize = dataSize[dimIdx] / 2;
  47301. var p1 = [];
  47302. var p2 = [];
  47303. p1[dimIdx] = val - halfSize;
  47304. p2[dimIdx] = val + halfSize;
  47305. p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
  47306. return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
  47307. }, this);
  47308. }
  47309. function prepareCustom(coordSys) {
  47310. var rect = coordSys.getBoundingRect();
  47311. return {
  47312. coordSys: {
  47313. type: 'geo',
  47314. x: rect.x,
  47315. y: rect.y,
  47316. width: rect.width,
  47317. height: rect.height
  47318. },
  47319. api: {
  47320. coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
  47321. size: zrUtil.bind(dataToCoordSize, coordSys)
  47322. }
  47323. };
  47324. }
  47325. module.exports = prepareCustom;
  47326. /***/ },
  47327. /* 316 */
  47328. /***/ function(module, exports, __webpack_require__) {
  47329. var zrUtil = __webpack_require__(4);
  47330. function dataToCoordSize(dataSize, dataItem) {
  47331. // dataItem is necessary in log axis.
  47332. var axis = this.getAxis();
  47333. var val = dataItem instanceof Array ? dataItem[0] : dataItem;
  47334. var halfSize = (dataSize instanceof Array ? dataSize[0] : dataSize) / 2;
  47335. return axis.type === 'category'
  47336. ? axis.getBandWidth()
  47337. : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
  47338. }
  47339. function prepareCustom(coordSys) {
  47340. var rect = coordSys.getRect();
  47341. return {
  47342. coordSys: {
  47343. type: 'singleAxis',
  47344. x: rect.x,
  47345. y: rect.y,
  47346. width: rect.width,
  47347. height: rect.height
  47348. },
  47349. api: {
  47350. coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
  47351. size: zrUtil.bind(dataToCoordSize, coordSys)
  47352. }
  47353. };
  47354. }
  47355. module.exports = prepareCustom;
  47356. /***/ },
  47357. /* 317 */
  47358. /***/ function(module, exports, __webpack_require__) {
  47359. var zrUtil = __webpack_require__(4);
  47360. function dataToCoordSize(dataSize, dataItem) {
  47361. // dataItem is necessary in log axis.
  47362. return zrUtil.map(['Radius', 'Angle'], function (dim, dimIdx) {
  47363. var axis = this['get' + dim + 'Axis']();
  47364. var val = dataItem[dimIdx];
  47365. var halfSize = dataSize[dimIdx] / 2;
  47366. var method = 'dataTo' + dim;
  47367. var result = axis.type === 'category'
  47368. ? axis.getBandWidth()
  47369. : Math.abs(axis[method](val - halfSize) - axis[method](val + halfSize));
  47370. if (dim === 'Angle') {
  47371. result = result * Math.PI / 180;
  47372. }
  47373. return result;
  47374. }, this);
  47375. }
  47376. function prepareCustom(coordSys) {
  47377. var radiusAxis = coordSys.getRadiusAxis();
  47378. var angleAxis = coordSys.getAngleAxis();
  47379. var radius = radiusAxis.getExtent();
  47380. radius[0] > radius[1] && radius.reverse();
  47381. return {
  47382. coordSys: {
  47383. type: 'polar',
  47384. cx: coordSys.cx,
  47385. cy: coordSys.cy,
  47386. r: radius[1],
  47387. r0: radius[0]
  47388. },
  47389. api: {
  47390. coord: zrUtil.bind(function (data) {
  47391. var radius = radiusAxis.dataToRadius(data[0]);
  47392. var angle = angleAxis.dataToAngle(data[1]);
  47393. var coord = coordSys.coordToPoint([radius, angle]);
  47394. coord.push(radius, angle * Math.PI / 180);
  47395. return coord;
  47396. }),
  47397. size: zrUtil.bind(dataToCoordSize, coordSys)
  47398. }
  47399. };
  47400. }
  47401. module.exports = prepareCustom;
  47402. /***/ },
  47403. /* 318 */
  47404. /***/ function(module, exports, __webpack_require__) {
  47405. var zrUtil = __webpack_require__(4);
  47406. function prepareCustom(coordSys) {
  47407. var rect = coordSys.getRect();
  47408. var rangeInfo = coordSys.getRangeInfo();
  47409. return {
  47410. coordSys: {
  47411. type: 'calendar',
  47412. x: rect.x,
  47413. y: rect.y,
  47414. width: rect.width,
  47415. height: rect.height,
  47416. cellWidth: coordSys.getCellWidth(),
  47417. cellHeight: coordSys.getCellHeight(),
  47418. rangeInfo: {
  47419. start: rangeInfo.start,
  47420. end: rangeInfo.end,
  47421. weeks: rangeInfo.weeks,
  47422. dayCount: rangeInfo.allDay
  47423. }
  47424. },
  47425. api: {
  47426. coord: zrUtil.bind(coordSys.dataToPoint, coordSys)
  47427. }
  47428. };
  47429. }
  47430. module.exports = prepareCustom;
  47431. /***/ },
  47432. /* 319 */
  47433. /***/ function(module, exports, __webpack_require__) {
  47434. var echarts = __webpack_require__(1);
  47435. var zrUtil = __webpack_require__(4);
  47436. var modelUtil = __webpack_require__(5);
  47437. var graphicUtil = __webpack_require__(18);
  47438. var layoutUtil = __webpack_require__(71);
  47439. // -------------
  47440. // Preprocessor
  47441. // -------------
  47442. echarts.registerPreprocessor(function (option) {
  47443. var graphicOption = option.graphic;
  47444. // Convert
  47445. // {graphic: [{left: 10, type: 'circle'}, ...]}
  47446. // or
  47447. // {graphic: {left: 10, type: 'circle'}}
  47448. // to
  47449. // {graphic: [{elements: [{left: 10, type: 'circle'}, ...]}]}
  47450. if (zrUtil.isArray(graphicOption)) {
  47451. if (!graphicOption[0] || !graphicOption[0].elements) {
  47452. option.graphic = [{elements: graphicOption}];
  47453. }
  47454. else {
  47455. // Only one graphic instance can be instantiated. (We dont
  47456. // want that too many views are created in echarts._viewMap)
  47457. option.graphic = [option.graphic[0]];
  47458. }
  47459. }
  47460. else if (graphicOption && !graphicOption.elements) {
  47461. option.graphic = [{elements: [graphicOption]}];
  47462. }
  47463. });
  47464. // ------
  47465. // Model
  47466. // ------
  47467. var GraphicModel = echarts.extendComponentModel({
  47468. type: 'graphic',
  47469. defaultOption: {
  47470. // Extra properties for each elements:
  47471. //
  47472. // left/right/top/bottom: (like 12, '22%', 'center', default undefined)
  47473. // If left/rigth is set, shape.x/shape.cx/position will not be used.
  47474. // If top/bottom is set, shape.y/shape.cy/position will not be used.
  47475. // This mechanism is useful when you want to position a group/element
  47476. // against the right side or the center of this container.
  47477. //
  47478. // width/height: (can only be pixel value, default 0)
  47479. // Only be used to specify contianer(group) size, if needed. And
  47480. // can not be percentage value (like '33%'). See the reason in the
  47481. // layout algorithm below.
  47482. //
  47483. // bounding: (enum: 'all' (default) | 'raw')
  47484. // Specify how to calculate boundingRect when locating.
  47485. // 'all': Get uioned and transformed boundingRect
  47486. // from both itself and its descendants.
  47487. // This mode simplies confining a group of elements in the bounding
  47488. // of their ancester container (e.g., using 'right: 0').
  47489. // 'raw': Only use the boundingRect of itself and before transformed.
  47490. // This mode is similar to css behavior, which is useful when you
  47491. // want an element to be able to overflow its container. (Consider
  47492. // a rotated circle needs to be located in a corner.)
  47493. // Note: elements is always behind its ancestors in this elements array.
  47494. elements: [],
  47495. parentId: null
  47496. },
  47497. /**
  47498. * Save el options for the sake of the performance (only update modified graphics).
  47499. * The order is the same as those in option. (ancesters -> descendants)
  47500. *
  47501. * @private
  47502. * @type {Array.<Object>}
  47503. */
  47504. _elOptionsToUpdate: null,
  47505. /**
  47506. * @override
  47507. */
  47508. mergeOption: function (option) {
  47509. // Prevent default merge to elements
  47510. var elements = this.option.elements;
  47511. this.option.elements = null;
  47512. GraphicModel.superApply(this, 'mergeOption', arguments);
  47513. this.option.elements = elements;
  47514. },
  47515. /**
  47516. * @override
  47517. */
  47518. optionUpdated: function (newOption, isInit) {
  47519. var thisOption = this.option;
  47520. var newList = (isInit ? thisOption : newOption).elements;
  47521. var existList = thisOption.elements = isInit ? [] : thisOption.elements;
  47522. var flattenedList = [];
  47523. this._flatten(newList, flattenedList);
  47524. var mappingResult = modelUtil.mappingToExists(existList, flattenedList);
  47525. modelUtil.makeIdAndName(mappingResult);
  47526. // Clear elOptionsToUpdate
  47527. var elOptionsToUpdate = this._elOptionsToUpdate = [];
  47528. zrUtil.each(mappingResult, function (resultItem, index) {
  47529. var newElOption = resultItem.option;
  47530. if (true) {
  47531. zrUtil.assert(
  47532. zrUtil.isObject(newElOption) || resultItem.exist,
  47533. 'Empty graphic option definition'
  47534. );
  47535. }
  47536. if (!newElOption) {
  47537. return;
  47538. }
  47539. elOptionsToUpdate.push(newElOption);
  47540. setKeyInfoToNewElOption(resultItem, newElOption);
  47541. mergeNewElOptionToExist(existList, index, newElOption);
  47542. setLayoutInfoToExist(existList[index], newElOption);
  47543. }, this);
  47544. // Clean
  47545. for (var i = existList.length - 1; i >= 0; i--) {
  47546. if (existList[i] == null) {
  47547. existList.splice(i, 1);
  47548. }
  47549. else {
  47550. // $action should be volatile, otherwise option gotten from
  47551. // `getOption` will contain unexpected $action.
  47552. delete existList[i].$action;
  47553. }
  47554. }
  47555. },
  47556. /**
  47557. * Convert
  47558. * [{
  47559. * type: 'group',
  47560. * id: 'xx',
  47561. * children: [{type: 'circle'}, {type: 'polygon'}]
  47562. * }]
  47563. * to
  47564. * [
  47565. * {type: 'group', id: 'xx'},
  47566. * {type: 'circle', parentId: 'xx'},
  47567. * {type: 'polygon', parentId: 'xx'}
  47568. * ]
  47569. *
  47570. * @private
  47571. * @param {Array.<Object>} optionList option list
  47572. * @param {Array.<Object>} result result of flatten
  47573. * @param {Object} parentOption parent option
  47574. */
  47575. _flatten: function (optionList, result, parentOption) {
  47576. zrUtil.each(optionList, function (option) {
  47577. if (!option) {
  47578. return;
  47579. }
  47580. if (parentOption) {
  47581. option.parentOption = parentOption;
  47582. }
  47583. result.push(option);
  47584. var children = option.children;
  47585. if (option.type === 'group' && children) {
  47586. this._flatten(children, result, option);
  47587. }
  47588. // Deleting for JSON output, and for not affecting group creation.
  47589. delete option.children;
  47590. }, this);
  47591. },
  47592. // FIXME
  47593. // Pass to view using payload? setOption has a payload?
  47594. useElOptionsToUpdate: function () {
  47595. var els = this._elOptionsToUpdate;
  47596. // Clear to avoid render duplicately when zooming.
  47597. this._elOptionsToUpdate = null;
  47598. return els;
  47599. }
  47600. });
  47601. // -----
  47602. // View
  47603. // -----
  47604. echarts.extendComponentView({
  47605. type: 'graphic',
  47606. /**
  47607. * @override
  47608. */
  47609. init: function (ecModel, api) {
  47610. /**
  47611. * @private
  47612. * @type {module:zrender/core/util.HashMap}
  47613. */
  47614. this._elMap = zrUtil.createHashMap();
  47615. /**
  47616. * @private
  47617. * @type {module:echarts/graphic/GraphicModel}
  47618. */
  47619. this._lastGraphicModel;
  47620. },
  47621. /**
  47622. * @override
  47623. */
  47624. render: function (graphicModel, ecModel, api) {
  47625. // Having leveraged between use cases and algorithm complexity, a very
  47626. // simple layout mechanism is used:
  47627. // The size(width/height) can be determined by itself or its parent (not
  47628. // implemented yet), but can not by its children. (Top-down travel)
  47629. // The location(x/y) can be determined by the bounding rect of itself
  47630. // (can including its descendants or not) and the size of its parent.
  47631. // (Bottom-up travel)
  47632. // When `chart.clear()` or `chart.setOption({...}, true)` with the same id,
  47633. // view will be reused.
  47634. if (graphicModel !== this._lastGraphicModel) {
  47635. this._clear();
  47636. }
  47637. this._lastGraphicModel = graphicModel;
  47638. this._updateElements(graphicModel, api);
  47639. this._relocate(graphicModel, api);
  47640. },
  47641. /**
  47642. * Update graphic elements.
  47643. *
  47644. * @private
  47645. * @param {Object} graphicModel graphic model
  47646. * @param {module:echarts/ExtensionAPI} api extension API
  47647. */
  47648. _updateElements: function (graphicModel, api) {
  47649. var elOptionsToUpdate = graphicModel.useElOptionsToUpdate();
  47650. if (!elOptionsToUpdate) {
  47651. return;
  47652. }
  47653. var elMap = this._elMap;
  47654. var rootGroup = this.group;
  47655. // Top-down tranverse to assign graphic settings to each elements.
  47656. zrUtil.each(elOptionsToUpdate, function (elOption) {
  47657. var $action = elOption.$action;
  47658. var id = elOption.id;
  47659. var existEl = elMap.get(id);
  47660. var parentId = elOption.parentId;
  47661. var targetElParent = parentId != null ? elMap.get(parentId) : rootGroup;
  47662. // In top/bottom mode, textVertical should not be used. And textBaseline
  47663. // should not be 'alphabetic', which cause inaccurately locating.
  47664. if (elOption.hv && elOption.hv[1] && elOption.type === 'text') {
  47665. elOption.style = zrUtil.defaults({textBaseline: 'middle'}, elOption.style);
  47666. elOption.style.textVerticalAlign = null;
  47667. }
  47668. // Remove unnecessary props to avoid potential problems.
  47669. var elOptionCleaned = getCleanedElOption(elOption);
  47670. // For simple, do not support parent change, otherwise reorder is needed.
  47671. if (true) {
  47672. existEl && zrUtil.assert(
  47673. targetElParent === existEl.parent,
  47674. 'Changing parent is not supported.'
  47675. );
  47676. }
  47677. if (!$action || $action === 'merge') {
  47678. existEl
  47679. ? existEl.attr(elOptionCleaned)
  47680. : createEl(id, targetElParent, elOptionCleaned, elMap);
  47681. }
  47682. else if ($action === 'replace') {
  47683. removeEl(existEl, elMap);
  47684. createEl(id, targetElParent, elOptionCleaned, elMap);
  47685. }
  47686. else if ($action === 'remove') {
  47687. removeEl(existEl, elMap);
  47688. }
  47689. var el = elMap.get(id);
  47690. if (el) {
  47691. el.__ecGraphicWidth = elOption.width;
  47692. el.__ecGraphicHeight = elOption.height;
  47693. }
  47694. });
  47695. },
  47696. /**
  47697. * Locate graphic elements.
  47698. *
  47699. * @private
  47700. * @param {Object} graphicModel graphic model
  47701. * @param {module:echarts/ExtensionAPI} api extension API
  47702. */
  47703. _relocate: function (graphicModel, api) {
  47704. var elOptions = graphicModel.option.elements;
  47705. var rootGroup = this.group;
  47706. var elMap = this._elMap;
  47707. // Bottom-up tranvese all elements (consider ec resize) to locate elements.
  47708. for (var i = elOptions.length - 1; i >= 0; i--) {
  47709. var elOption = elOptions[i];
  47710. var el = elMap.get(elOption.id);
  47711. if (!el) {
  47712. continue;
  47713. }
  47714. var parentEl = el.parent;
  47715. var containerInfo = parentEl === rootGroup
  47716. ? {
  47717. width: api.getWidth(),
  47718. height: api.getHeight()
  47719. }
  47720. : { // Like 'position:absolut' in css, default 0.
  47721. width: parentEl.__ecGraphicWidth || 0,
  47722. height: parentEl.__ecGraphicHeight || 0
  47723. };
  47724. layoutUtil.positionElement(
  47725. el, elOption, containerInfo, null,
  47726. {hv: elOption.hv, boundingMode: elOption.bounding}
  47727. );
  47728. }
  47729. },
  47730. /**
  47731. * Clear all elements.
  47732. *
  47733. * @private
  47734. */
  47735. _clear: function () {
  47736. var elMap = this._elMap;
  47737. elMap.each(function (el) {
  47738. removeEl(el, elMap);
  47739. });
  47740. this._elMap = zrUtil.createHashMap();
  47741. },
  47742. /**
  47743. * @override
  47744. */
  47745. dispose: function () {
  47746. this._clear();
  47747. }
  47748. });
  47749. function createEl(id, targetElParent, elOption, elMap) {
  47750. var graphicType = elOption.type;
  47751. if (true) {
  47752. zrUtil.assert(graphicType, 'graphic type MUST be set');
  47753. }
  47754. var Clz = graphicUtil[graphicType.charAt(0).toUpperCase() + graphicType.slice(1)];
  47755. if (true) {
  47756. zrUtil.assert(Clz, 'graphic type can not be found');
  47757. }
  47758. var el = new Clz(elOption);
  47759. targetElParent.add(el);
  47760. elMap.set(id, el);
  47761. el.__ecGraphicId = id;
  47762. }
  47763. function removeEl(existEl, elMap) {
  47764. var existElParent = existEl && existEl.parent;
  47765. if (existElParent) {
  47766. existEl.type === 'group' && existEl.traverse(function (el) {
  47767. removeEl(el, elMap);
  47768. });
  47769. elMap.removeKey(existEl.__ecGraphicId);
  47770. existElParent.remove(existEl);
  47771. }
  47772. }
  47773. // Remove unnecessary props to avoid potential problems.
  47774. function getCleanedElOption(elOption) {
  47775. elOption = zrUtil.extend({}, elOption);
  47776. zrUtil.each(
  47777. ['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
  47778. function (name) {
  47779. delete elOption[name];
  47780. }
  47781. );
  47782. return elOption;
  47783. }
  47784. function isSetLoc(obj, props) {
  47785. var isSet;
  47786. zrUtil.each(props, function (prop) {
  47787. obj[prop] != null && obj[prop] !== 'auto' && (isSet = true);
  47788. });
  47789. return isSet;
  47790. }
  47791. function setKeyInfoToNewElOption(resultItem, newElOption) {
  47792. var existElOption = resultItem.exist;
  47793. // Set id and type after id assigned.
  47794. newElOption.id = resultItem.keyInfo.id;
  47795. !newElOption.type && existElOption && (newElOption.type = existElOption.type);
  47796. // Set parent id if not specified
  47797. if (newElOption.parentId == null) {
  47798. var newElParentOption = newElOption.parentOption;
  47799. if (newElParentOption) {
  47800. newElOption.parentId = newElParentOption.id;
  47801. }
  47802. else if (existElOption) {
  47803. newElOption.parentId = existElOption.parentId;
  47804. }
  47805. }
  47806. // Clear
  47807. newElOption.parentOption = null;
  47808. }
  47809. function mergeNewElOptionToExist(existList, index, newElOption) {
  47810. // Update existing options, for `getOption` feature.
  47811. var newElOptCopy = zrUtil.extend({}, newElOption);
  47812. var existElOption = existList[index];
  47813. var $action = newElOption.$action || 'merge';
  47814. if ($action === 'merge') {
  47815. if (existElOption) {
  47816. if (true) {
  47817. var newType = newElOption.type;
  47818. zrUtil.assert(
  47819. !newType || existElOption.type === newType,
  47820. 'Please set $action: "replace" to change `type`'
  47821. );
  47822. }
  47823. // We can ensure that newElOptCopy and existElOption are not
  47824. // the same object, so `merge` will not change newElOptCopy.
  47825. zrUtil.merge(existElOption, newElOptCopy, true);
  47826. // Rigid body, use ignoreSize.
  47827. layoutUtil.mergeLayoutParam(existElOption, newElOptCopy, {ignoreSize: true});
  47828. // Will be used in render.
  47829. layoutUtil.copyLayoutParams(newElOption, existElOption);
  47830. }
  47831. else {
  47832. existList[index] = newElOptCopy;
  47833. }
  47834. }
  47835. else if ($action === 'replace') {
  47836. existList[index] = newElOptCopy;
  47837. }
  47838. else if ($action === 'remove') {
  47839. // null will be cleaned later.
  47840. existElOption && (existList[index] = null);
  47841. }
  47842. }
  47843. function setLayoutInfoToExist(existItem, newElOption) {
  47844. if (!existItem) {
  47845. return;
  47846. }
  47847. existItem.hv = newElOption.hv = [
  47848. // Rigid body, dont care `width`.
  47849. isSetLoc(newElOption, ['left', 'right']),
  47850. // Rigid body, dont care `height`.
  47851. isSetLoc(newElOption, ['top', 'bottom'])
  47852. ];
  47853. // Give default group size. Otherwise layout error may occur.
  47854. if (existItem.type === 'group') {
  47855. existItem.width == null && (existItem.width = newElOption.width = 0);
  47856. existItem.height == null && (existItem.height = newElOption.height = 0);
  47857. }
  47858. }
  47859. /***/ },
  47860. /* 320 */
  47861. /***/ function(module, exports, __webpack_require__) {
  47862. __webpack_require__(124);
  47863. __webpack_require__(304);
  47864. __webpack_require__(298);
  47865. /***/ },
  47866. /* 321 */
  47867. /***/ function(module, exports, __webpack_require__) {
  47868. /**
  47869. * Legend component entry file8
  47870. */
  47871. __webpack_require__(322);
  47872. __webpack_require__(323);
  47873. __webpack_require__(324);
  47874. var echarts = __webpack_require__(1);
  47875. // Series Filter
  47876. echarts.registerProcessor(__webpack_require__(326));
  47877. /***/ },
  47878. /* 322 */
  47879. /***/ function(module, exports, __webpack_require__) {
  47880. 'use strict';
  47881. var zrUtil = __webpack_require__(4);
  47882. var Model = __webpack_require__(12);
  47883. var LegendModel = __webpack_require__(1).extendComponentModel({
  47884. type: 'legend',
  47885. dependencies: ['series'],
  47886. layoutMode: {
  47887. type: 'box',
  47888. ignoreSize: true
  47889. },
  47890. init: function (option, parentModel, ecModel) {
  47891. this.mergeDefaultAndTheme(option, ecModel);
  47892. option.selected = option.selected || {};
  47893. },
  47894. mergeOption: function (option) {
  47895. LegendModel.superCall(this, 'mergeOption', option);
  47896. },
  47897. optionUpdated: function () {
  47898. this._updateData(this.ecModel);
  47899. var legendData = this._data;
  47900. // If selectedMode is single, try to select one
  47901. if (legendData[0] && this.get('selectedMode') === 'single') {
  47902. var hasSelected = false;
  47903. // If has any selected in option.selected
  47904. for (var i = 0; i < legendData.length; i++) {
  47905. var name = legendData[i].get('name');
  47906. if (this.isSelected(name)) {
  47907. // Force to unselect others
  47908. this.select(name);
  47909. hasSelected = true;
  47910. break;
  47911. }
  47912. }
  47913. // Try select the first if selectedMode is single
  47914. !hasSelected && this.select(legendData[0].get('name'));
  47915. }
  47916. },
  47917. _updateData: function (ecModel) {
  47918. var legendData = zrUtil.map(this.get('data') || [], function (dataItem) {
  47919. // Can be string or number
  47920. if (typeof dataItem === 'string' || typeof dataItem === 'number') {
  47921. dataItem = {
  47922. name: dataItem
  47923. };
  47924. }
  47925. return new Model(dataItem, this, this.ecModel);
  47926. }, this);
  47927. this._data = legendData;
  47928. var availableNames = zrUtil.map(ecModel.getSeries(), function (series) {
  47929. return series.name;
  47930. });
  47931. ecModel.eachSeries(function (seriesModel) {
  47932. if (seriesModel.legendDataProvider) {
  47933. var data = seriesModel.legendDataProvider();
  47934. availableNames = availableNames.concat(data.mapArray(data.getName));
  47935. }
  47936. });
  47937. /**
  47938. * @type {Array.<string>}
  47939. * @private
  47940. */
  47941. this._availableNames = availableNames;
  47942. },
  47943. /**
  47944. * @return {Array.<module:echarts/model/Model>}
  47945. */
  47946. getData: function () {
  47947. return this._data;
  47948. },
  47949. /**
  47950. * @param {string} name
  47951. */
  47952. select: function (name) {
  47953. var selected = this.option.selected;
  47954. var selectedMode = this.get('selectedMode');
  47955. if (selectedMode === 'single') {
  47956. var data = this._data;
  47957. zrUtil.each(data, function (dataItem) {
  47958. selected[dataItem.get('name')] = false;
  47959. });
  47960. }
  47961. selected[name] = true;
  47962. },
  47963. /**
  47964. * @param {string} name
  47965. */
  47966. unSelect: function (name) {
  47967. if (this.get('selectedMode') !== 'single') {
  47968. this.option.selected[name] = false;
  47969. }
  47970. },
  47971. /**
  47972. * @param {string} name
  47973. */
  47974. toggleSelected: function (name) {
  47975. var selected = this.option.selected;
  47976. // Default is true
  47977. if (!selected.hasOwnProperty(name)) {
  47978. selected[name] = true;
  47979. }
  47980. this[selected[name] ? 'unSelect' : 'select'](name);
  47981. },
  47982. /**
  47983. * @param {string} name
  47984. */
  47985. isSelected: function (name) {
  47986. var selected = this.option.selected;
  47987. return !(selected.hasOwnProperty(name) && !selected[name])
  47988. && zrUtil.indexOf(this._availableNames, name) >= 0;
  47989. },
  47990. defaultOption: {
  47991. // 一级层叠
  47992. zlevel: 0,
  47993. // 二级层叠
  47994. z: 4,
  47995. show: true,
  47996. // 布局方式,默认为水平布局,可选为:
  47997. // 'horizontal' | 'vertical'
  47998. orient: 'horizontal',
  47999. left: 'center',
  48000. // right: 'center',
  48001. top: 'top',
  48002. // bottom: 'top',
  48003. // 水平对齐
  48004. // 'auto' | 'left' | 'right'
  48005. // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐
  48006. align: 'auto',
  48007. backgroundColor: 'rgba(0,0,0,0)',
  48008. // 图例边框颜色
  48009. borderColor: '#ccc',
  48010. // 图例边框线宽,单位px,默认为0(无边框)
  48011. borderWidth: 0,
  48012. // 图例内边距,单位px,默认各方向内边距为5,
  48013. // 接受数组分别设定上右下左边距,同css
  48014. padding: 5,
  48015. // 各个item之间的间隔,单位px,默认为10,
  48016. // 横向布局时为水平间隔,纵向布局时为纵向间隔
  48017. itemGap: 10,
  48018. // 图例图形宽度
  48019. itemWidth: 25,
  48020. // 图例图形高度
  48021. itemHeight: 14,
  48022. // 图例关闭时候的颜色
  48023. inactiveColor: '#ccc',
  48024. textStyle: {
  48025. // 图例文字颜色
  48026. color: '#333'
  48027. },
  48028. // formatter: '',
  48029. // 选择模式,默认开启图例开关
  48030. selectedMode: true,
  48031. // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入
  48032. // selected: null,
  48033. // 图例内容(详见legend.data,数组中每一项代表一个item
  48034. // data: [],
  48035. // Tooltip 相关配置
  48036. tooltip: {
  48037. show: false
  48038. }
  48039. }
  48040. });
  48041. module.exports = LegendModel;
  48042. /***/ },
  48043. /* 323 */
  48044. /***/ function(module, exports, __webpack_require__) {
  48045. /**
  48046. * @file Legend action
  48047. */
  48048. var echarts = __webpack_require__(1);
  48049. var zrUtil = __webpack_require__(4);
  48050. function legendSelectActionHandler(methodName, payload, ecModel) {
  48051. var selectedMap = {};
  48052. var isToggleSelect = methodName === 'toggleSelected';
  48053. var isSelected;
  48054. // Update all legend components
  48055. ecModel.eachComponent('legend', function (legendModel) {
  48056. if (isToggleSelect && isSelected != null) {
  48057. // Force other legend has same selected status
  48058. // Or the first is toggled to true and other are toggled to false
  48059. // In the case one legend has some item unSelected in option. And if other legend
  48060. // doesn't has the item, they will assume it is selected.
  48061. legendModel[isSelected ? 'select' : 'unSelect'](payload.name);
  48062. }
  48063. else {
  48064. legendModel[methodName](payload.name);
  48065. isSelected = legendModel.isSelected(payload.name);
  48066. }
  48067. var legendData = legendModel.getData();
  48068. zrUtil.each(legendData, function (model) {
  48069. var name = model.get('name');
  48070. // Wrap element
  48071. if (name === '\n' || name === '') {
  48072. return;
  48073. }
  48074. var isItemSelected = legendModel.isSelected(name);
  48075. if (selectedMap.hasOwnProperty(name)) {
  48076. // Unselected if any legend is unselected
  48077. selectedMap[name] = selectedMap[name] && isItemSelected;
  48078. }
  48079. else {
  48080. selectedMap[name] = isItemSelected;
  48081. }
  48082. });
  48083. });
  48084. // Return the event explicitly
  48085. return {
  48086. name: payload.name,
  48087. selected: selectedMap
  48088. };
  48089. }
  48090. /**
  48091. * @event legendToggleSelect
  48092. * @type {Object}
  48093. * @property {string} type 'legendToggleSelect'
  48094. * @property {string} [from]
  48095. * @property {string} name Series name or data item name
  48096. */
  48097. echarts.registerAction(
  48098. 'legendToggleSelect', 'legendselectchanged',
  48099. zrUtil.curry(legendSelectActionHandler, 'toggleSelected')
  48100. );
  48101. /**
  48102. * @event legendSelect
  48103. * @type {Object}
  48104. * @property {string} type 'legendSelect'
  48105. * @property {string} name Series name or data item name
  48106. */
  48107. echarts.registerAction(
  48108. 'legendSelect', 'legendselected',
  48109. zrUtil.curry(legendSelectActionHandler, 'select')
  48110. );
  48111. /**
  48112. * @event legendUnSelect
  48113. * @type {Object}
  48114. * @property {string} type 'legendUnSelect'
  48115. * @property {string} name Series name or data item name
  48116. */
  48117. echarts.registerAction(
  48118. 'legendUnSelect', 'legendunselected',
  48119. zrUtil.curry(legendSelectActionHandler, 'unSelect')
  48120. );
  48121. /***/ },
  48122. /* 324 */
  48123. /***/ function(module, exports, __webpack_require__) {
  48124. var zrUtil = __webpack_require__(4);
  48125. var symbolCreator = __webpack_require__(111);
  48126. var graphic = __webpack_require__(18);
  48127. var listComponentHelper = __webpack_require__(325);
  48128. var curry = zrUtil.curry;
  48129. function dispatchSelectAction(name, api) {
  48130. api.dispatchAction({
  48131. type: 'legendToggleSelect',
  48132. name: name
  48133. });
  48134. }
  48135. function dispatchHighlightAction(seriesModel, dataName, api) {
  48136. // If element hover will move to a hoverLayer.
  48137. var el = api.getZr().storage.getDisplayList()[0];
  48138. if (!(el && el.useHoverLayer)) {
  48139. seriesModel.get('legendHoverLink') && api.dispatchAction({
  48140. type: 'highlight',
  48141. seriesName: seriesModel.name,
  48142. name: dataName
  48143. });
  48144. }
  48145. }
  48146. function dispatchDownplayAction(seriesModel, dataName, api) {
  48147. // If element hover will move to a hoverLayer.
  48148. var el = api.getZr().storage.getDisplayList()[0];
  48149. if (!(el && el.useHoverLayer)) {
  48150. seriesModel.get('legendHoverLink') && api.dispatchAction({
  48151. type: 'downplay',
  48152. seriesName: seriesModel.name,
  48153. name: dataName
  48154. });
  48155. }
  48156. }
  48157. module.exports = __webpack_require__(1).extendComponentView({
  48158. type: 'legend',
  48159. init: function () {
  48160. this._symbolTypeStore = {};
  48161. },
  48162. render: function (legendModel, ecModel, api) {
  48163. var group = this.group;
  48164. group.removeAll();
  48165. if (!legendModel.get('show')) {
  48166. return;
  48167. }
  48168. var selectMode = legendModel.get('selectedMode');
  48169. var itemAlign = legendModel.get('align');
  48170. if (itemAlign === 'auto') {
  48171. itemAlign = (legendModel.get('left') === 'right'
  48172. && legendModel.get('orient') === 'vertical')
  48173. ? 'right' : 'left';
  48174. }
  48175. var legendDrawedMap = zrUtil.createHashMap();
  48176. zrUtil.each(legendModel.getData(), function (itemModel) {
  48177. var name = itemModel.get('name');
  48178. // Use empty string or \n as a newline string
  48179. if (name === '' || name === '\n') {
  48180. group.add(new graphic.Group({
  48181. newline: true
  48182. }));
  48183. return;
  48184. }
  48185. var seriesModel = ecModel.getSeriesByName(name)[0];
  48186. if (legendDrawedMap.get(name)) {
  48187. // Have been drawed
  48188. return;
  48189. }
  48190. // Series legend
  48191. if (seriesModel) {
  48192. var data = seriesModel.getData();
  48193. var color = data.getVisual('color');
  48194. // If color is a callback function
  48195. if (typeof color === 'function') {
  48196. // Use the first data
  48197. color = color(seriesModel.getDataParams(0));
  48198. }
  48199. // Using rect symbol defaultly
  48200. var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect';
  48201. var symbolType = data.getVisual('symbol');
  48202. var itemGroup = this._createItem(
  48203. name, itemModel, legendModel,
  48204. legendSymbolType, symbolType,
  48205. itemAlign, color,
  48206. selectMode
  48207. );
  48208. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  48209. .on('mouseover', curry(dispatchHighlightAction, seriesModel, null, api))
  48210. .on('mouseout', curry(dispatchDownplayAction, seriesModel, null, api));
  48211. legendDrawedMap.set(name, true);
  48212. }
  48213. else {
  48214. // Data legend of pie, funnel
  48215. ecModel.eachRawSeries(function (seriesModel) {
  48216. // In case multiple series has same data name
  48217. if (legendDrawedMap.get(name)) {
  48218. return;
  48219. }
  48220. if (seriesModel.legendDataProvider) {
  48221. var data = seriesModel.legendDataProvider();
  48222. var idx = data.indexOfName(name);
  48223. if (idx < 0) {
  48224. return;
  48225. }
  48226. var color = data.getItemVisual(idx, 'color');
  48227. var legendSymbolType = 'roundRect';
  48228. var itemGroup = this._createItem(
  48229. name, itemModel, legendModel,
  48230. legendSymbolType, null,
  48231. itemAlign, color,
  48232. selectMode
  48233. );
  48234. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  48235. // FIXME Should not specify the series name
  48236. .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api))
  48237. .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api));
  48238. legendDrawedMap.set(name, true);
  48239. }
  48240. }, this);
  48241. }
  48242. if (true) {
  48243. if (!legendDrawedMap.get(name)) {
  48244. console.warn(name + ' series not exists. Legend data should be same with series name or data name.');
  48245. }
  48246. }
  48247. }, this);
  48248. listComponentHelper.layout(group, legendModel, api);
  48249. // Render background after group is layout
  48250. // FIXME
  48251. listComponentHelper.addBackground(group, legendModel);
  48252. },
  48253. _createItem: function (
  48254. name, itemModel, legendModel,
  48255. legendSymbolType, symbolType,
  48256. itemAlign, color, selectMode
  48257. ) {
  48258. var itemWidth = legendModel.get('itemWidth');
  48259. var itemHeight = legendModel.get('itemHeight');
  48260. var inactiveColor = legendModel.get('inactiveColor');
  48261. var isSelected = legendModel.isSelected(name);
  48262. var itemGroup = new graphic.Group();
  48263. var textStyleModel = itemModel.getModel('textStyle');
  48264. var itemIcon = itemModel.get('icon');
  48265. var tooltipModel = itemModel.getModel('tooltip');
  48266. var legendGlobalTooltipModel = tooltipModel.parentModel;
  48267. // Use user given icon first
  48268. legendSymbolType = itemIcon || legendSymbolType;
  48269. itemGroup.add(symbolCreator.createSymbol(
  48270. legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : inactiveColor
  48271. ));
  48272. // Compose symbols
  48273. // PENDING
  48274. if (!itemIcon && symbolType
  48275. // At least show one symbol, can't be all none
  48276. && ((symbolType !== legendSymbolType) || symbolType == 'none')
  48277. ) {
  48278. var size = itemHeight * 0.8;
  48279. if (symbolType === 'none') {
  48280. symbolType = 'circle';
  48281. }
  48282. // Put symbol in the center
  48283. itemGroup.add(symbolCreator.createSymbol(
  48284. symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size,
  48285. isSelected ? color : inactiveColor
  48286. ));
  48287. }
  48288. // Text
  48289. var textX = itemAlign === 'left' ? itemWidth + 5 : -5;
  48290. var textAlign = itemAlign;
  48291. var formatter = legendModel.get('formatter');
  48292. var content = name;
  48293. if (typeof formatter === 'string' && formatter) {
  48294. content = formatter.replace('{name}', name != null ? name : '');
  48295. }
  48296. else if (typeof formatter === 'function') {
  48297. content = formatter(name);
  48298. }
  48299. var text = new graphic.Text({
  48300. style: {
  48301. text: content,
  48302. x: textX,
  48303. y: itemHeight / 2,
  48304. fill: isSelected ? textStyleModel.getTextColor() : inactiveColor,
  48305. textFont: textStyleModel.getFont(),
  48306. textAlign: textAlign,
  48307. textVerticalAlign: 'middle'
  48308. }
  48309. });
  48310. itemGroup.add(text);
  48311. // Add a invisible rect to increase the area of mouse hover
  48312. var hitRect = new graphic.Rect({
  48313. shape: itemGroup.getBoundingRect(),
  48314. invisible: true,
  48315. tooltip: tooltipModel.get('show') ? zrUtil.extend({
  48316. content: name,
  48317. // Defaul formatter
  48318. formatter: legendGlobalTooltipModel.get('formatter', true) || function () {
  48319. return name;
  48320. },
  48321. formatterParams: {
  48322. componentType: 'legend',
  48323. legendIndex: legendModel.componentIndex,
  48324. name: name,
  48325. $vars: ['name']
  48326. }
  48327. }, tooltipModel.option) : null
  48328. });
  48329. itemGroup.add(hitRect);
  48330. itemGroup.eachChild(function (child) {
  48331. child.silent = true;
  48332. });
  48333. hitRect.silent = !selectMode;
  48334. this.group.add(itemGroup);
  48335. graphic.setHoverStyle(itemGroup);
  48336. return itemGroup;
  48337. }
  48338. });
  48339. /***/ },
  48340. /* 325 */
  48341. /***/ function(module, exports, __webpack_require__) {
  48342. // List layout
  48343. var layout = __webpack_require__(71);
  48344. var formatUtil = __webpack_require__(6);
  48345. var graphic = __webpack_require__(18);
  48346. function positionGroup(group, model, api) {
  48347. layout.positionElement(
  48348. group, model.getBoxLayoutParams(),
  48349. {
  48350. width: api.getWidth(),
  48351. height: api.getHeight()
  48352. },
  48353. model.get('padding')
  48354. );
  48355. }
  48356. module.exports = {
  48357. /**
  48358. * Layout list like component.
  48359. * It will box layout each items in group of component and then position the whole group in the viewport
  48360. * @param {module:zrender/group/Group} group
  48361. * @param {module:echarts/model/Component} componentModel
  48362. * @param {module:echarts/ExtensionAPI}
  48363. */
  48364. layout: function (group, componentModel, api) {
  48365. var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), {
  48366. width: api.getWidth(),
  48367. height: api.getHeight()
  48368. }, componentModel.get('padding'));
  48369. layout.box(
  48370. componentModel.get('orient'),
  48371. group,
  48372. componentModel.get('itemGap'),
  48373. rect.width,
  48374. rect.height
  48375. );
  48376. positionGroup(group, componentModel, api);
  48377. },
  48378. addBackground: function (group, componentModel) {
  48379. var padding = formatUtil.normalizeCssArray(
  48380. componentModel.get('padding')
  48381. );
  48382. var boundingRect = group.getBoundingRect();
  48383. var style = componentModel.getItemStyle(['color', 'opacity']);
  48384. style.fill = componentModel.get('backgroundColor');
  48385. var rect = new graphic.Rect({
  48386. shape: {
  48387. x: boundingRect.x - padding[3],
  48388. y: boundingRect.y - padding[0],
  48389. width: boundingRect.width + padding[1] + padding[3],
  48390. height: boundingRect.height + padding[0] + padding[2]
  48391. },
  48392. style: style,
  48393. silent: true,
  48394. z2: -1
  48395. });
  48396. graphic.subPixelOptimizeRect(rect);
  48397. group.add(rect);
  48398. }
  48399. };
  48400. /***/ },
  48401. /* 326 */
  48402. /***/ function(module, exports) {
  48403. module.exports = function (ecModel) {
  48404. var legendModels = ecModel.findComponents({
  48405. mainType: 'legend'
  48406. });
  48407. if (legendModels && legendModels.length) {
  48408. ecModel.filterSeries(function (series) {
  48409. // If in any legend component the status is not selected.
  48410. // Because in legend series is assumed selected when it is not in the legend data.
  48411. for (var i = 0; i < legendModels.length; i++) {
  48412. if (!legendModels[i].isSelected(series.name)) {
  48413. return false;
  48414. }
  48415. }
  48416. return true;
  48417. });
  48418. }
  48419. };
  48420. /***/ },
  48421. /* 327 */
  48422. /***/ function(module, exports, __webpack_require__) {
  48423. // FIXME Better way to pack data in graphic element
  48424. __webpack_require__(298);
  48425. __webpack_require__(328);
  48426. __webpack_require__(329);
  48427. // Show tip action
  48428. /**
  48429. * @action
  48430. * @property {string} type
  48431. * @property {number} seriesIndex
  48432. * @property {number} dataIndex
  48433. * @property {number} [x]
  48434. * @property {number} [y]
  48435. */
  48436. __webpack_require__(1).registerAction(
  48437. {
  48438. type: 'showTip',
  48439. event: 'showTip',
  48440. update: 'tooltip:manuallyShowTip'
  48441. },
  48442. // noop
  48443. function () {}
  48444. );
  48445. // Hide tip action
  48446. __webpack_require__(1).registerAction(
  48447. {
  48448. type: 'hideTip',
  48449. event: 'hideTip',
  48450. update: 'tooltip:manuallyHideTip'
  48451. },
  48452. // noop
  48453. function () {}
  48454. );
  48455. /***/ },
  48456. /* 328 */
  48457. /***/ function(module, exports, __webpack_require__) {
  48458. __webpack_require__(1).extendComponentModel({
  48459. type: 'tooltip',
  48460. dependencies: ['axisPointer'],
  48461. defaultOption: {
  48462. zlevel: 0,
  48463. z: 8,
  48464. show: true,
  48465. // tooltip主体内容
  48466. showContent: true,
  48467. // 'trigger' only works on coordinate system.
  48468. // 'item' | 'axis' | 'none'
  48469. trigger: 'item',
  48470. // 'click' | 'mousemove' | 'none'
  48471. triggerOn: 'mousemove|click',
  48472. alwaysShowContent: false,
  48473. displayMode: 'single', // 'single' | 'multipleByCoordSys'
  48474. // 位置 {Array} | {Function}
  48475. // position: null
  48476. // Consider triggered from axisPointer handle, verticalAlign should be 'middle'
  48477. // align: null,
  48478. // verticalAlign: null,
  48479. // 是否约束 content 在 viewRect 中。默认 false 是为了兼容以前版本。
  48480. confine: false,
  48481. // 内容格式器:{string}(Template) ¦ {Function}
  48482. // formatter: null
  48483. showDelay: 0,
  48484. // 隐藏延迟,单位ms
  48485. hideDelay: 100,
  48486. // 动画变换时间,单位s
  48487. transitionDuration: 0.4,
  48488. enterable: false,
  48489. // 提示背景颜色,默认为透明度为0.7的黑色
  48490. backgroundColor: 'rgba(50,50,50,0.7)',
  48491. // 提示边框颜色
  48492. borderColor: '#333',
  48493. // 提示边框圆角,单位px,默认为4
  48494. borderRadius: 4,
  48495. // 提示边框线宽,单位px,默认为0(无边框)
  48496. borderWidth: 0,
  48497. // 提示内边距,单位px,默认各方向内边距为5,
  48498. // 接受数组分别设定上右下左边距,同css
  48499. padding: 5,
  48500. // Extra css text
  48501. extraCssText: '',
  48502. // 坐标轴指示器,坐标轴触发有效
  48503. axisPointer: {
  48504. // 默认为直线
  48505. // 可选为:'line' | 'shadow' | 'cross'
  48506. type: 'line',
  48507. // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选
  48508. // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto'
  48509. // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴
  48510. // 极坐标系会默认选择 angle 轴
  48511. axis: 'auto',
  48512. animation: 'auto',
  48513. animationDurationUpdate: 200,
  48514. animationEasingUpdate: 'exponentialOut',
  48515. crossStyle: {
  48516. color: '#999',
  48517. width: 1,
  48518. type: 'dashed',
  48519. // TODO formatter
  48520. textStyle: {}
  48521. }
  48522. // lineStyle and shadowStyle should not be specified here,
  48523. // otherwise it will always override those styles on option.axisPointer.
  48524. },
  48525. textStyle: {
  48526. color: '#fff',
  48527. fontSize: 14
  48528. }
  48529. }
  48530. });
  48531. /***/ },
  48532. /* 329 */
  48533. /***/ function(module, exports, __webpack_require__) {
  48534. var TooltipContent = __webpack_require__(330);
  48535. var zrUtil = __webpack_require__(4);
  48536. var formatUtil = __webpack_require__(6);
  48537. var numberUtil = __webpack_require__(7);
  48538. var graphic = __webpack_require__(18);
  48539. var findPointFromSeries = __webpack_require__(300);
  48540. var layoutUtil = __webpack_require__(71);
  48541. var env = __webpack_require__(2);
  48542. var Model = __webpack_require__(12);
  48543. var globalListener = __webpack_require__(303);
  48544. var axisHelper = __webpack_require__(101);
  48545. var axisPointerViewHelper = __webpack_require__(306);
  48546. var bind = zrUtil.bind;
  48547. var each = zrUtil.each;
  48548. var parsePercent = numberUtil.parsePercent;
  48549. var proxyRect = new graphic.Rect({
  48550. shape: {x: -1, y: -1, width: 2, height: 2}
  48551. });
  48552. __webpack_require__(1).extendComponentView({
  48553. type: 'tooltip',
  48554. init: function (ecModel, api) {
  48555. if (env.node) {
  48556. return;
  48557. }
  48558. var tooltipContent = new TooltipContent(api.getDom(), api);
  48559. this._tooltipContent = tooltipContent;
  48560. },
  48561. render: function (tooltipModel, ecModel, api) {
  48562. if (env.node) {
  48563. return;
  48564. }
  48565. // Reset
  48566. this.group.removeAll();
  48567. /**
  48568. * @private
  48569. * @type {module:echarts/component/tooltip/TooltipModel}
  48570. */
  48571. this._tooltipModel = tooltipModel;
  48572. /**
  48573. * @private
  48574. * @type {module:echarts/model/Global}
  48575. */
  48576. this._ecModel = ecModel;
  48577. /**
  48578. * @private
  48579. * @type {module:echarts/ExtensionAPI}
  48580. */
  48581. this._api = api;
  48582. /**
  48583. * Should be cleaned when render.
  48584. * @private
  48585. * @type {Array.<Array.<Object>>}
  48586. */
  48587. this._lastDataByCoordSys = null;
  48588. /**
  48589. * @private
  48590. * @type {boolean}
  48591. */
  48592. this._alwaysShowContent = tooltipModel.get('alwaysShowContent');
  48593. var tooltipContent = this._tooltipContent;
  48594. tooltipContent.update();
  48595. tooltipContent.setEnterable(tooltipModel.get('enterable'));
  48596. this._initGlobalListener();
  48597. this._keepShow();
  48598. },
  48599. _initGlobalListener: function () {
  48600. var tooltipModel = this._tooltipModel;
  48601. var triggerOn = tooltipModel.get('triggerOn');
  48602. globalListener.register(
  48603. 'itemTooltip',
  48604. this._api,
  48605. bind(function (currTrigger, e, dispatchAction) {
  48606. // If 'none', it is not controlled by mouse totally.
  48607. if (triggerOn !== 'none') {
  48608. if (triggerOn.indexOf(currTrigger) >= 0) {
  48609. this._tryShow(e, dispatchAction);
  48610. }
  48611. else if (currTrigger === 'leave') {
  48612. this._hide(dispatchAction);
  48613. }
  48614. }
  48615. }, this)
  48616. );
  48617. },
  48618. _keepShow: function () {
  48619. var tooltipModel = this._tooltipModel;
  48620. var ecModel = this._ecModel;
  48621. var api = this._api;
  48622. // Try to keep the tooltip show when refreshing
  48623. if (this._lastX != null
  48624. && this._lastY != null
  48625. // When user is willing to control tooltip totally using API,
  48626. // self.manuallyShowTip({x, y}) might cause tooltip hide,
  48627. // which is not expected.
  48628. && tooltipModel.get('triggerOn') !== 'none'
  48629. ) {
  48630. var self = this;
  48631. clearTimeout(this._refreshUpdateTimeout);
  48632. this._refreshUpdateTimeout = setTimeout(function () {
  48633. // Show tip next tick after other charts are rendered
  48634. // In case highlight action has wrong result
  48635. // FIXME
  48636. self.manuallyShowTip(tooltipModel, ecModel, api, {
  48637. x: self._lastX,
  48638. y: self._lastY
  48639. });
  48640. });
  48641. }
  48642. },
  48643. /**
  48644. * Show tip manually by
  48645. * dispatchAction({
  48646. * type: 'showTip',
  48647. * x: 10,
  48648. * y: 10
  48649. * });
  48650. * Or
  48651. * dispatchAction({
  48652. * type: 'showTip',
  48653. * seriesIndex: 0,
  48654. * dataIndex or dataIndexInside or name
  48655. * });
  48656. *
  48657. * TODO Batch
  48658. */
  48659. manuallyShowTip: function (tooltipModel, ecModel, api, payload) {
  48660. if (payload.from === this.uid || env.node) {
  48661. return;
  48662. }
  48663. var dispatchAction = makeDispatchAction(payload, api);
  48664. // Reset ticket
  48665. this._ticket = '';
  48666. // When triggered from axisPointer.
  48667. var dataByCoordSys = payload.dataByCoordSys;
  48668. if (payload.tooltip && payload.x != null && payload.y != null) {
  48669. var el = proxyRect;
  48670. el.position = [payload.x, payload.y];
  48671. el.update();
  48672. el.tooltip = payload.tooltip;
  48673. // Manually show tooltip while view is not using zrender elements.
  48674. this._tryShow({
  48675. offsetX: payload.x,
  48676. offsetY: payload.y,
  48677. target: el
  48678. }, dispatchAction);
  48679. }
  48680. else if (dataByCoordSys) {
  48681. this._tryShow({
  48682. offsetX: payload.x,
  48683. offsetY: payload.y,
  48684. position: payload.position,
  48685. event: {},
  48686. dataByCoordSys: payload.dataByCoordSys,
  48687. tooltipOption: payload.tooltipOption
  48688. }, dispatchAction);
  48689. }
  48690. else if (payload.seriesIndex != null) {
  48691. if (this._manuallyAxisShowTip(tooltipModel, ecModel, api, payload)) {
  48692. return;
  48693. }
  48694. var pointInfo = findPointFromSeries(payload, ecModel);
  48695. var cx = pointInfo.point[0];
  48696. var cy = pointInfo.point[1];
  48697. if (cx != null && cy != null) {
  48698. this._tryShow({
  48699. offsetX: cx,
  48700. offsetY: cy,
  48701. position: payload.position,
  48702. target: pointInfo.el,
  48703. event: {}
  48704. }, dispatchAction);
  48705. }
  48706. }
  48707. else if (payload.x != null && payload.y != null) {
  48708. // FIXME
  48709. // should wrap dispatchAction like `axisPointer/globalListener` ?
  48710. api.dispatchAction({
  48711. type: 'updateAxisPointer',
  48712. x: payload.x,
  48713. y: payload.y
  48714. });
  48715. this._tryShow({
  48716. offsetX: payload.x,
  48717. offsetY: payload.y,
  48718. position: payload.position,
  48719. target: api.getZr().findHover(payload.x, payload.y).target,
  48720. event: {}
  48721. }, dispatchAction);
  48722. }
  48723. },
  48724. manuallyHideTip: function (tooltipModel, ecModel, api, payload) {
  48725. var tooltipContent = this._tooltipContent;
  48726. if (!this._alwaysShowContent) {
  48727. tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
  48728. }
  48729. this._lastX = this._lastY = null;
  48730. if (payload.from !== this.uid) {
  48731. this._hide(makeDispatchAction(payload, api));
  48732. }
  48733. },
  48734. // Be compatible with previous design, that is, when tooltip.type is 'axis' and
  48735. // dispatchAction 'showTip' with seriesIndex and dataIndex will trigger axis pointer
  48736. // and tooltip.
  48737. _manuallyAxisShowTip: function (tooltipModel, ecModel, api, payload) {
  48738. var seriesIndex = payload.seriesIndex;
  48739. var dataIndex = payload.dataIndex;
  48740. var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo;
  48741. if (seriesIndex == null || dataIndex == null || coordSysAxesInfo == null) {
  48742. return;
  48743. }
  48744. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  48745. if (!seriesModel) {
  48746. return;
  48747. }
  48748. var data = seriesModel.getData();
  48749. var tooltipModel = buildTooltipModel([
  48750. data.getItemModel(dataIndex),
  48751. seriesModel,
  48752. (seriesModel.coordinateSystem || {}).model,
  48753. tooltipModel
  48754. ]);
  48755. if (tooltipModel.get('trigger') !== 'axis') {
  48756. return;
  48757. }
  48758. api.dispatchAction({
  48759. type: 'updateAxisPointer',
  48760. seriesIndex: seriesIndex,
  48761. dataIndex: dataIndex,
  48762. position: payload.position
  48763. });
  48764. return true;
  48765. },
  48766. _tryShow: function (e, dispatchAction) {
  48767. var el = e.target;
  48768. var tooltipModel = this._tooltipModel;
  48769. if (!tooltipModel) {
  48770. return;
  48771. }
  48772. // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed
  48773. this._lastX = e.offsetX;
  48774. this._lastY = e.offsetY;
  48775. var dataByCoordSys = e.dataByCoordSys;
  48776. if (dataByCoordSys && dataByCoordSys.length) {
  48777. this._showAxisTooltip(dataByCoordSys, e);
  48778. }
  48779. // Always show item tooltip if mouse is on the element with dataIndex
  48780. else if (el && el.dataIndex != null) {
  48781. this._lastDataByCoordSys = null;
  48782. this._showSeriesItemTooltip(e, el, dispatchAction);
  48783. }
  48784. // Tooltip provided directly. Like legend.
  48785. else if (el && el.tooltip) {
  48786. this._lastDataByCoordSys = null;
  48787. this._showComponentItemTooltip(e, el, dispatchAction);
  48788. }
  48789. else {
  48790. this._lastDataByCoordSys = null;
  48791. this._hide(dispatchAction);
  48792. }
  48793. },
  48794. _showOrMove: function (tooltipModel, cb) {
  48795. // showDelay is used in this case: tooltip.enterable is set
  48796. // as true. User intent to move mouse into tooltip and click
  48797. // something. `showDelay` makes it easyer to enter the content
  48798. // but tooltip do not move immediately.
  48799. var delay = tooltipModel.get('showDelay');
  48800. cb = zrUtil.bind(cb, this);
  48801. clearTimeout(this._showTimout);
  48802. delay > 0
  48803. ? (this._showTimout = setTimeout(cb, delay))
  48804. : cb();
  48805. },
  48806. _showAxisTooltip: function (dataByCoordSys, e) {
  48807. var ecModel = this._ecModel;
  48808. var globalTooltipModel = this._tooltipModel;
  48809. var point = [e.offsetX, e.offsetY];
  48810. var singleDefaultHTML = [];
  48811. var singleParamsList = [];
  48812. var singleTooltipModel = buildTooltipModel([
  48813. e.tooltipOption,
  48814. globalTooltipModel
  48815. ]);
  48816. each(dataByCoordSys, function (itemCoordSys) {
  48817. // var coordParamList = [];
  48818. // var coordDefaultHTML = [];
  48819. // var coordTooltipModel = buildTooltipModel([
  48820. // e.tooltipOption,
  48821. // itemCoordSys.tooltipOption,
  48822. // ecModel.getComponent(itemCoordSys.coordSysMainType, itemCoordSys.coordSysIndex),
  48823. // globalTooltipModel
  48824. // ]);
  48825. // var displayMode = coordTooltipModel.get('displayMode');
  48826. // var paramsList = displayMode === 'single' ? singleParamsList : [];
  48827. each(itemCoordSys.dataByAxis, function (item) {
  48828. var axisModel = ecModel.getComponent(item.axisDim + 'Axis', item.axisIndex);
  48829. var axisValue = item.value;
  48830. var seriesDefaultHTML = [];
  48831. if (!axisModel || axisValue == null) {
  48832. return;
  48833. }
  48834. var valueLabel = axisPointerViewHelper.getValueLabel(
  48835. axisValue, axisModel.axis, ecModel,
  48836. item.seriesDataIndices,
  48837. item.valueLabelOpt
  48838. );
  48839. zrUtil.each(item.seriesDataIndices, function (idxItem) {
  48840. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
  48841. var dataIndex = idxItem.dataIndexInside;
  48842. var dataParams = series && series.getDataParams(dataIndex);
  48843. dataParams.axisDim = item.axisDim;
  48844. dataParams.axisIndex = item.axisIndex;
  48845. dataParams.axisType = item.axisType;
  48846. dataParams.axisId = item.axisId;
  48847. dataParams.axisValue = axisHelper.getAxisRawValue(axisModel.axis, axisValue);
  48848. dataParams.axisValueLabel = valueLabel;
  48849. if (dataParams) {
  48850. singleParamsList.push(dataParams);
  48851. seriesDefaultHTML.push(series.formatTooltip(dataIndex, true));
  48852. }
  48853. });
  48854. // Default tooltip content
  48855. // FIXME
  48856. // (1) shold be the first data which has name?
  48857. // (2) themeRiver, firstDataIndex is array, and first line is unnecessary.
  48858. var firstLine = valueLabel;
  48859. singleDefaultHTML.push(
  48860. (firstLine ? formatUtil.encodeHTML(firstLine) + '<br />' : '')
  48861. + seriesDefaultHTML.join('<br />')
  48862. );
  48863. });
  48864. }, this);
  48865. // In most case, the second axis is shown upper than the first one.
  48866. singleDefaultHTML.reverse();
  48867. singleDefaultHTML = singleDefaultHTML.join('<br /><br />');
  48868. var positionExpr = e.position;
  48869. this._showOrMove(singleTooltipModel, function () {
  48870. if (this._updateContentNotChangedOnAxis(dataByCoordSys)) {
  48871. this._updatePosition(
  48872. singleTooltipModel,
  48873. positionExpr,
  48874. point[0], point[1],
  48875. this._tooltipContent,
  48876. singleParamsList
  48877. );
  48878. }
  48879. else {
  48880. this._showTooltipContent(
  48881. singleTooltipModel, singleDefaultHTML, singleParamsList, Math.random(),
  48882. point[0], point[1], positionExpr
  48883. );
  48884. }
  48885. });
  48886. // Do not trigger events here, because this branch only be entered
  48887. // from dispatchAction.
  48888. },
  48889. _showSeriesItemTooltip: function (e, el, dispatchAction) {
  48890. var ecModel = this._ecModel;
  48891. // Use dataModel in element if possible
  48892. // Used when mouseover on a element like markPoint or edge
  48893. // In which case, the data is not main data in series.
  48894. var seriesIndex = el.seriesIndex;
  48895. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  48896. // For example, graph link.
  48897. var dataModel = el.dataModel || seriesModel;
  48898. var dataIndex = el.dataIndex;
  48899. var dataType = el.dataType;
  48900. var data = dataModel.getData();
  48901. var tooltipModel = buildTooltipModel([
  48902. data.getItemModel(dataIndex),
  48903. dataModel,
  48904. seriesModel && (seriesModel.coordinateSystem || {}).model,
  48905. this._tooltipModel
  48906. ]);
  48907. var tooltipTrigger = tooltipModel.get('trigger');
  48908. if (tooltipTrigger != null && tooltipTrigger !== 'item') {
  48909. return;
  48910. }
  48911. var params = dataModel.getDataParams(dataIndex, dataType);
  48912. var defaultHtml = dataModel.formatTooltip(dataIndex, false, dataType);
  48913. var asyncTicket = 'item_' + dataModel.name + '_' + dataIndex;
  48914. this._showOrMove(tooltipModel, function () {
  48915. this._showTooltipContent(
  48916. tooltipModel, defaultHtml, params, asyncTicket,
  48917. e.offsetX, e.offsetY, e.position, e.target
  48918. );
  48919. });
  48920. // FIXME
  48921. // duplicated showtip if manuallyShowTip is called from dispatchAction.
  48922. dispatchAction({
  48923. type: 'showTip',
  48924. dataIndexInside: dataIndex,
  48925. dataIndex: data.getRawIndex(dataIndex),
  48926. seriesIndex: seriesIndex,
  48927. from: this.uid
  48928. });
  48929. },
  48930. _showComponentItemTooltip: function (e, el, dispatchAction) {
  48931. var tooltipOpt = el.tooltip;
  48932. if (typeof tooltipOpt === 'string') {
  48933. var content = tooltipOpt;
  48934. tooltipOpt = {
  48935. content: content,
  48936. // Fixed formatter
  48937. formatter: content
  48938. };
  48939. }
  48940. var subTooltipModel = new Model(tooltipOpt, this._tooltipModel, this._ecModel);
  48941. var defaultHtml = subTooltipModel.get('content');
  48942. var asyncTicket = Math.random();
  48943. // Do not check whether `trigger` is 'none' here, because `trigger`
  48944. // only works on cooridinate system. In fact, we have not found case
  48945. // that requires setting `trigger` nothing on component yet.
  48946. this._showOrMove(subTooltipModel, function () {
  48947. this._showTooltipContent(
  48948. subTooltipModel, defaultHtml, subTooltipModel.get('formatterParams') || {},
  48949. asyncTicket, e.offsetX, e.offsetY, e.position, el
  48950. );
  48951. });
  48952. // If not dispatch showTip, tip may be hide triggered by axis.
  48953. dispatchAction({
  48954. type: 'showTip',
  48955. from: this.uid
  48956. });
  48957. },
  48958. _showTooltipContent: function (
  48959. tooltipModel, defaultHtml, params, asyncTicket, x, y, positionExpr, el
  48960. ) {
  48961. // Reset ticket
  48962. this._ticket = '';
  48963. if (!tooltipModel.get('showContent') || !tooltipModel.get('show')) {
  48964. return;
  48965. }
  48966. var tooltipContent = this._tooltipContent;
  48967. var formatter = tooltipModel.get('formatter');
  48968. positionExpr = positionExpr || tooltipModel.get('position');
  48969. var html = defaultHtml;
  48970. if (formatter && typeof formatter === 'string') {
  48971. html = formatUtil.formatTpl(formatter, params, true);
  48972. }
  48973. else if (typeof formatter === 'function') {
  48974. var callback = bind(function (cbTicket, html) {
  48975. if (cbTicket === this._ticket) {
  48976. tooltipContent.setContent(html);
  48977. this._updatePosition(
  48978. tooltipModel, positionExpr, x, y, tooltipContent, params, el
  48979. );
  48980. }
  48981. }, this);
  48982. this._ticket = asyncTicket;
  48983. html = formatter(params, asyncTicket, callback);
  48984. }
  48985. tooltipContent.setContent(html);
  48986. tooltipContent.show(tooltipModel);
  48987. this._updatePosition(
  48988. tooltipModel, positionExpr, x, y, tooltipContent, params, el
  48989. );
  48990. },
  48991. /**
  48992. * @param {string|Function|Array.<number>} positionExpr
  48993. * @param {number} x Mouse x
  48994. * @param {number} y Mouse y
  48995. * @param {boolean} confine Whether confine tooltip content in view rect.
  48996. * @param {Object|<Array.<Object>} params
  48997. * @param {module:zrender/Element} el target element
  48998. * @param {module:echarts/ExtensionAPI} api
  48999. * @return {Array.<number>}
  49000. */
  49001. _updatePosition: function (tooltipModel, positionExpr, x, y, content, params, el) {
  49002. var viewWidth = this._api.getWidth();
  49003. var viewHeight = this._api.getHeight();
  49004. positionExpr = positionExpr || tooltipModel.get('position');
  49005. var contentSize = content.getSize();
  49006. var align = tooltipModel.get('align');
  49007. var vAlign = tooltipModel.get('verticalAlign');
  49008. var rect = el && el.getBoundingRect().clone();
  49009. el && rect.applyTransform(el.transform);
  49010. if (typeof positionExpr === 'function') {
  49011. // Callback of position can be an array or a string specify the position
  49012. positionExpr = positionExpr([x, y], params, content.el, rect, {
  49013. viewSize: [viewWidth, viewHeight],
  49014. contentSize: contentSize.slice()
  49015. });
  49016. }
  49017. if (zrUtil.isArray(positionExpr)) {
  49018. x = parsePercent(positionExpr[0], viewWidth);
  49019. y = parsePercent(positionExpr[1], viewHeight);
  49020. }
  49021. else if (zrUtil.isObject(positionExpr)) {
  49022. positionExpr.width = contentSize[0];
  49023. positionExpr.height = contentSize[1];
  49024. var layoutRect = layoutUtil.getLayoutRect(
  49025. positionExpr, {width: viewWidth, height: viewHeight}
  49026. );
  49027. x = layoutRect.x;
  49028. y = layoutRect.y;
  49029. align = null;
  49030. // When positionExpr is left/top/right/bottom,
  49031. // align and verticalAlign will not work.
  49032. vAlign = null;
  49033. }
  49034. // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
  49035. else if (typeof positionExpr === 'string' && el) {
  49036. var pos = calcTooltipPosition(
  49037. positionExpr, rect, contentSize
  49038. );
  49039. x = pos[0];
  49040. y = pos[1];
  49041. }
  49042. else {
  49043. var pos = refixTooltipPosition(
  49044. x, y, content.el, viewWidth, viewHeight, align ? null : 20, vAlign ? null : 20
  49045. );
  49046. x = pos[0];
  49047. y = pos[1];
  49048. }
  49049. align && (x -= isCenterAlign(align) ? contentSize[0] / 2 : align === 'right' ? contentSize[0] : 0);
  49050. vAlign && (y -= isCenterAlign(vAlign) ? contentSize[1] / 2 : vAlign === 'bottom' ? contentSize[1] : 0);
  49051. if (tooltipModel.get('confine')) {
  49052. var pos = confineTooltipPosition(
  49053. x, y, content.el, viewWidth, viewHeight
  49054. );
  49055. x = pos[0];
  49056. y = pos[1];
  49057. }
  49058. content.moveTo(x, y);
  49059. },
  49060. // FIXME
  49061. // Should we remove this but leave this to user?
  49062. _updateContentNotChangedOnAxis: function (dataByCoordSys) {
  49063. var lastCoordSys = this._lastDataByCoordSys;
  49064. var contentNotChanged = !!lastCoordSys
  49065. && lastCoordSys.length === dataByCoordSys.length;
  49066. contentNotChanged && each(lastCoordSys, function (lastItemCoordSys, indexCoordSys) {
  49067. var lastDataByAxis = lastItemCoordSys.dataByAxis || {};
  49068. var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {};
  49069. var thisDataByAxis = thisItemCoordSys.dataByAxis || [];
  49070. contentNotChanged &= lastDataByAxis.length === thisDataByAxis.length;
  49071. contentNotChanged && each(lastDataByAxis, function (lastItem, indexAxis) {
  49072. var thisItem = thisDataByAxis[indexAxis] || {};
  49073. var lastIndices = lastItem.seriesDataIndices || [];
  49074. var newIndices = thisItem.seriesDataIndices || [];
  49075. contentNotChanged &=
  49076. lastItem.value === thisItem.value
  49077. && lastItem.axisType === thisItem.axisType
  49078. && lastItem.axisId === thisItem.axisId
  49079. && lastIndices.length === newIndices.length;
  49080. contentNotChanged && each(lastIndices, function (lastIdxItem, j) {
  49081. var newIdxItem = newIndices[j];
  49082. contentNotChanged &=
  49083. lastIdxItem.seriesIndex === newIdxItem.seriesIndex
  49084. && lastIdxItem.dataIndex === newIdxItem.dataIndex;
  49085. });
  49086. });
  49087. });
  49088. this._lastDataByCoordSys = dataByCoordSys;
  49089. return !!contentNotChanged;
  49090. },
  49091. _hide: function (dispatchAction) {
  49092. // Do not directly hideLater here, because this behavior may be prevented
  49093. // in dispatchAction when showTip is dispatched.
  49094. // FIXME
  49095. // duplicated hideTip if manuallyHideTip is called from dispatchAction.
  49096. this._lastDataByCoordSys = null;
  49097. dispatchAction({
  49098. type: 'hideTip',
  49099. from: this.uid
  49100. });
  49101. },
  49102. dispose: function (ecModel, api) {
  49103. if (env.node) {
  49104. return;
  49105. }
  49106. this._tooltipContent.hide();
  49107. globalListener.unregister('itemTooltip', api);
  49108. }
  49109. });
  49110. /**
  49111. * @param {Array.<Object|module:echarts/model/Model>} modelCascade
  49112. * From top to bottom. (the last one should be globalTooltipModel);
  49113. */
  49114. function buildTooltipModel(modelCascade) {
  49115. var resultModel = modelCascade.pop();
  49116. while (modelCascade.length) {
  49117. var tooltipOpt = modelCascade.pop();
  49118. if (tooltipOpt) {
  49119. if (tooltipOpt instanceof Model) {
  49120. tooltipOpt = tooltipOpt.get('tooltip', true);
  49121. }
  49122. // In each data item tooltip can be simply write:
  49123. // {
  49124. // value: 10,
  49125. // tooltip: 'Something you need to know'
  49126. // }
  49127. if (typeof tooltipOpt === 'string') {
  49128. tooltipOpt = {formatter: tooltipOpt};
  49129. }
  49130. resultModel = new Model(tooltipOpt, resultModel, resultModel.ecModel);
  49131. }
  49132. }
  49133. return resultModel;
  49134. }
  49135. function makeDispatchAction(payload, api) {
  49136. return payload.dispatchAction || zrUtil.bind(api.dispatchAction, api);
  49137. }
  49138. function refixTooltipPosition(x, y, el, viewWidth, viewHeight, gapH, gapV) {
  49139. var width = el.clientWidth;
  49140. var height = el.clientHeight;
  49141. if (gapH != null) {
  49142. if (x + width + gapH > viewWidth) {
  49143. x -= width + gapH;
  49144. }
  49145. else {
  49146. x += gapH;
  49147. }
  49148. }
  49149. if (gapV != null) {
  49150. if (y + height + gapV > viewHeight) {
  49151. y -= height + gapV;
  49152. }
  49153. else {
  49154. y += gapV;
  49155. }
  49156. }
  49157. return [x, y];
  49158. }
  49159. function confineTooltipPosition(x, y, el, viewWidth, viewHeight) {
  49160. var width = el.clientWidth;
  49161. var height = el.clientHeight;
  49162. x = Math.min(x + width, viewWidth) - width;
  49163. y = Math.min(y + height, viewHeight) - height;
  49164. x = Math.max(x, 0);
  49165. y = Math.max(y, 0);
  49166. return [x, y];
  49167. }
  49168. function calcTooltipPosition(position, rect, contentSize) {
  49169. var domWidth = contentSize[0];
  49170. var domHeight = contentSize[1];
  49171. var gap = 5;
  49172. var x = 0;
  49173. var y = 0;
  49174. var rectWidth = rect.width;
  49175. var rectHeight = rect.height;
  49176. switch (position) {
  49177. case 'inside':
  49178. x = rect.x + rectWidth / 2 - domWidth / 2;
  49179. y = rect.y + rectHeight / 2 - domHeight / 2;
  49180. break;
  49181. case 'top':
  49182. x = rect.x + rectWidth / 2 - domWidth / 2;
  49183. y = rect.y - domHeight - gap;
  49184. break;
  49185. case 'bottom':
  49186. x = rect.x + rectWidth / 2 - domWidth / 2;
  49187. y = rect.y + rectHeight + gap;
  49188. break;
  49189. case 'left':
  49190. x = rect.x - domWidth - gap;
  49191. y = rect.y + rectHeight / 2 - domHeight / 2;
  49192. break;
  49193. case 'right':
  49194. x = rect.x + rectWidth + gap;
  49195. y = rect.y + rectHeight / 2 - domHeight / 2;
  49196. }
  49197. return [x, y];
  49198. }
  49199. function isCenterAlign(align) {
  49200. return align === 'center' || align === 'middle';
  49201. }
  49202. /***/ },
  49203. /* 330 */
  49204. /***/ function(module, exports, __webpack_require__) {
  49205. /**
  49206. * @module echarts/component/tooltip/TooltipContent
  49207. */
  49208. var zrUtil = __webpack_require__(4);
  49209. var zrColor = __webpack_require__(31);
  49210. var eventUtil = __webpack_require__(88);
  49211. var formatUtil = __webpack_require__(6);
  49212. var each = zrUtil.each;
  49213. var toCamelCase = formatUtil.toCamelCase;
  49214. var env = __webpack_require__(2);
  49215. var vendors = ['', '-webkit-', '-moz-', '-o-'];
  49216. var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;z-index:9999999;';
  49217. /**
  49218. * @param {number} duration
  49219. * @return {string}
  49220. * @inner
  49221. */
  49222. function assembleTransition(duration) {
  49223. var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)';
  49224. var transitionText = 'left ' + duration + 's ' + transitionCurve + ','
  49225. + 'top ' + duration + 's ' + transitionCurve;
  49226. return zrUtil.map(vendors, function (vendorPrefix) {
  49227. return vendorPrefix + 'transition:' + transitionText;
  49228. }).join(';');
  49229. }
  49230. /**
  49231. * @param {Object} textStyle
  49232. * @return {string}
  49233. * @inner
  49234. */
  49235. function assembleFont(textStyleModel) {
  49236. var cssText = [];
  49237. var fontSize = textStyleModel.get('fontSize');
  49238. var color = textStyleModel.getTextColor();
  49239. color && cssText.push('color:' + color);
  49240. cssText.push('font:' + textStyleModel.getFont());
  49241. fontSize &&
  49242. cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px');
  49243. each(['decoration', 'align'], function (name) {
  49244. var val = textStyleModel.get(name);
  49245. val && cssText.push('text-' + name + ':' + val);
  49246. });
  49247. return cssText.join(';');
  49248. }
  49249. /**
  49250. * @param {Object} tooltipModel
  49251. * @return {string}
  49252. * @inner
  49253. */
  49254. function assembleCssText(tooltipModel) {
  49255. var cssText = [];
  49256. var transitionDuration = tooltipModel.get('transitionDuration');
  49257. var backgroundColor = tooltipModel.get('backgroundColor');
  49258. var textStyleModel = tooltipModel.getModel('textStyle');
  49259. var padding = tooltipModel.get('padding');
  49260. // Animation transition. Do not animate when transitionDuration is 0.
  49261. transitionDuration &&
  49262. cssText.push(assembleTransition(transitionDuration));
  49263. if (backgroundColor) {
  49264. if (env.canvasSupported) {
  49265. cssText.push('background-Color:' + backgroundColor);
  49266. }
  49267. else {
  49268. // for ie
  49269. cssText.push(
  49270. 'background-Color:#' + zrColor.toHex(backgroundColor)
  49271. );
  49272. cssText.push('filter:alpha(opacity=70)');
  49273. }
  49274. }
  49275. // Border style
  49276. each(['width', 'color', 'radius'], function (name) {
  49277. var borderName = 'border-' + name;
  49278. var camelCase = toCamelCase(borderName);
  49279. var val = tooltipModel.get(camelCase);
  49280. val != null &&
  49281. cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px'));
  49282. });
  49283. // Text style
  49284. cssText.push(assembleFont(textStyleModel));
  49285. // Padding
  49286. if (padding != null) {
  49287. cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px');
  49288. }
  49289. return cssText.join(';') + ';';
  49290. }
  49291. /**
  49292. * @alias module:echarts/component/tooltip/TooltipContent
  49293. * @constructor
  49294. */
  49295. function TooltipContent(container, api) {
  49296. var el = document.createElement('div');
  49297. var zr = this._zr = api.getZr();
  49298. this.el = el;
  49299. this._x = api.getWidth() / 2;
  49300. this._y = api.getHeight() / 2;
  49301. container.appendChild(el);
  49302. this._container = container;
  49303. this._show = false;
  49304. /**
  49305. * @private
  49306. */
  49307. this._hideTimeout;
  49308. var self = this;
  49309. el.onmouseenter = function () {
  49310. // clear the timeout in hideLater and keep showing tooltip
  49311. if (self._enterable) {
  49312. clearTimeout(self._hideTimeout);
  49313. self._show = true;
  49314. }
  49315. self._inContent = true;
  49316. };
  49317. el.onmousemove = function (e) {
  49318. e = e || window.event;
  49319. if (!self._enterable) {
  49320. // Try trigger zrender event to avoid mouse
  49321. // in and out shape too frequently
  49322. var handler = zr.handler;
  49323. eventUtil.normalizeEvent(container, e, true);
  49324. handler.dispatch('mousemove', e);
  49325. }
  49326. };
  49327. el.onmouseleave = function () {
  49328. if (self._enterable) {
  49329. if (self._show) {
  49330. self.hideLater(self._hideDelay);
  49331. }
  49332. }
  49333. self._inContent = false;
  49334. };
  49335. }
  49336. TooltipContent.prototype = {
  49337. constructor: TooltipContent,
  49338. /**
  49339. * @private
  49340. * @type {boolean}
  49341. */
  49342. _enterable: true,
  49343. /**
  49344. * Update when tooltip is rendered
  49345. */
  49346. update: function () {
  49347. // FIXME
  49348. // Move this logic to ec main?
  49349. var container = this._container;
  49350. var stl = container.currentStyle
  49351. || document.defaultView.getComputedStyle(container);
  49352. var domStyle = container.style;
  49353. if (domStyle.position !== 'absolute' && stl.position !== 'absolute') {
  49354. domStyle.position = 'relative';
  49355. }
  49356. // Hide the tooltip
  49357. // PENDING
  49358. // this.hide();
  49359. },
  49360. show: function (tooltipModel) {
  49361. clearTimeout(this._hideTimeout);
  49362. var el = this.el;
  49363. el.style.cssText = gCssText + assembleCssText(tooltipModel)
  49364. // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
  49365. + ';left:' + this._x + 'px;top:' + this._y + 'px;'
  49366. + (tooltipModel.get('extraCssText') || '');
  49367. el.style.display = el.innerHTML ? 'block' : 'none';
  49368. this._show = true;
  49369. },
  49370. setContent: function (content) {
  49371. this.el.innerHTML = content == null ? '' : content;
  49372. },
  49373. setEnterable: function (enterable) {
  49374. this._enterable = enterable;
  49375. },
  49376. getSize: function () {
  49377. var el = this.el;
  49378. return [el.clientWidth, el.clientHeight];
  49379. },
  49380. moveTo: function (x, y) {
  49381. // xy should be based on canvas root. But tooltipContent is
  49382. // the sibling of canvas root. So padding of ec container
  49383. // should be considered here.
  49384. var zr = this._zr;
  49385. var viewportRoot;
  49386. if (zr && zr.painter && (viewportRoot = zr.painter.getViewportRoot())) {
  49387. x += viewportRoot.offsetLeft || 0;
  49388. y += viewportRoot.offsetTop || 0;
  49389. }
  49390. var style = this.el.style;
  49391. style.left = x + 'px';
  49392. style.top = y + 'px';
  49393. this._x = x;
  49394. this._y = y;
  49395. },
  49396. hide: function () {
  49397. this.el.style.display = 'none';
  49398. this._show = false;
  49399. },
  49400. hideLater: function (time) {
  49401. if (this._show && !(this._inContent && this._enterable)) {
  49402. if (time) {
  49403. this._hideDelay = time;
  49404. // Set show false to avoid invoke hideLater mutiple times
  49405. this._show = false;
  49406. this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time);
  49407. }
  49408. else {
  49409. this.hide();
  49410. }
  49411. }
  49412. },
  49413. isShow: function () {
  49414. return this._show;
  49415. }
  49416. };
  49417. module.exports = TooltipContent;
  49418. /***/ },
  49419. /* 331 */
  49420. /***/ function(module, exports, __webpack_require__) {
  49421. 'use strict';
  49422. var zrUtil = __webpack_require__(4);
  49423. __webpack_require__(332);
  49424. __webpack_require__(338);
  49425. __webpack_require__(340);
  49426. __webpack_require__(298);
  49427. __webpack_require__(342);
  49428. // For reducing size of echarts.min, barLayoutPolar is required by polar.
  49429. __webpack_require__(1).registerLayout(zrUtil.curry(__webpack_require__(343), 'bar'));
  49430. // Polar view
  49431. __webpack_require__(1).extendComponentView({
  49432. type: 'polar'
  49433. });
  49434. /***/ },
  49435. /* 332 */
  49436. /***/ function(module, exports, __webpack_require__) {
  49437. // TODO Axis scale
  49438. var Polar = __webpack_require__(333);
  49439. var numberUtil = __webpack_require__(7);
  49440. var zrUtil = __webpack_require__(4);
  49441. var axisHelper = __webpack_require__(101);
  49442. var niceScaleExtent = axisHelper.niceScaleExtent;
  49443. // 依赖 PolarModel 做预处理
  49444. __webpack_require__(336);
  49445. /**
  49446. * Resize method bound to the polar
  49447. * @param {module:echarts/coord/polar/PolarModel} polarModel
  49448. * @param {module:echarts/ExtensionAPI} api
  49449. */
  49450. function resizePolar(polarModel, api) {
  49451. var center = polarModel.get('center');
  49452. var radius = polarModel.get('radius');
  49453. var width = api.getWidth();
  49454. var height = api.getHeight();
  49455. var parsePercent = numberUtil.parsePercent;
  49456. this.cx = parsePercent(center[0], width);
  49457. this.cy = parsePercent(center[1], height);
  49458. var radiusAxis = this.getRadiusAxis();
  49459. var size = Math.min(width, height) / 2;
  49460. // var idx = radiusAxis.inverse ? 1 : 0;
  49461. radiusAxis.setExtent(0, parsePercent(radius, size));
  49462. }
  49463. /**
  49464. * Update polar
  49465. */
  49466. function updatePolarScale(ecModel, api) {
  49467. var polar = this;
  49468. var angleAxis = polar.getAngleAxis();
  49469. var radiusAxis = polar.getRadiusAxis();
  49470. // Reset scale
  49471. angleAxis.scale.setExtent(Infinity, -Infinity);
  49472. radiusAxis.scale.setExtent(Infinity, -Infinity);
  49473. ecModel.eachSeries(function (seriesModel) {
  49474. if (seriesModel.coordinateSystem === polar) {
  49475. var data = seriesModel.getData();
  49476. radiusAxis.scale.unionExtentFromData(data, 'radius');
  49477. angleAxis.scale.unionExtentFromData(data, 'angle');
  49478. }
  49479. });
  49480. niceScaleExtent(angleAxis.scale, angleAxis.model);
  49481. niceScaleExtent(radiusAxis.scale, radiusAxis.model);
  49482. // Fix extent of category angle axis
  49483. if (angleAxis.type === 'category' && !angleAxis.onBand) {
  49484. var extent = angleAxis.getExtent();
  49485. var diff = 360 / angleAxis.scale.count();
  49486. angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
  49487. angleAxis.setExtent(extent[0], extent[1]);
  49488. }
  49489. }
  49490. /**
  49491. * Set common axis properties
  49492. * @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  49493. * @param {module:echarts/coord/polar/AxisModel}
  49494. * @inner
  49495. */
  49496. function setAxis(axis, axisModel) {
  49497. axis.type = axisModel.get('type');
  49498. axis.scale = axisHelper.createScaleByModel(axisModel);
  49499. axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
  49500. // FIXME Radius axis not support inverse axis
  49501. if (axisModel.mainType === 'angleAxis') {
  49502. var startAngle = axisModel.get('startAngle');
  49503. axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise');
  49504. axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
  49505. }
  49506. // Inject axis instance
  49507. axisModel.axis = axis;
  49508. axis.model = axisModel;
  49509. }
  49510. var polarCreator = {
  49511. dimensions: Polar.prototype.dimensions,
  49512. create: function (ecModel, api) {
  49513. var polarList = [];
  49514. ecModel.eachComponent('polar', function (polarModel, idx) {
  49515. var polar = new Polar(idx);
  49516. // Inject resize and update method
  49517. polar.resize = resizePolar;
  49518. polar.update = updatePolarScale;
  49519. var radiusAxis = polar.getRadiusAxis();
  49520. var angleAxis = polar.getAngleAxis();
  49521. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  49522. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  49523. setAxis(radiusAxis, radiusAxisModel);
  49524. setAxis(angleAxis, angleAxisModel);
  49525. polar.resize(polarModel, api);
  49526. polarList.push(polar);
  49527. polarModel.coordinateSystem = polar;
  49528. polar.model = polarModel;
  49529. });
  49530. // Inject coordinateSystem to series
  49531. ecModel.eachSeries(function (seriesModel) {
  49532. if (seriesModel.get('coordinateSystem') === 'polar') {
  49533. var polarModel = ecModel.queryComponents({
  49534. mainType: 'polar',
  49535. index: seriesModel.get('polarIndex'),
  49536. id: seriesModel.get('polarId')
  49537. })[0];
  49538. if (true) {
  49539. if (!polarModel) {
  49540. throw new Error(
  49541. 'Polar "' + zrUtil.retrieve(
  49542. seriesModel.get('polarIndex'),
  49543. seriesModel.get('polarId'),
  49544. 0
  49545. ) + '" not found'
  49546. );
  49547. }
  49548. }
  49549. seriesModel.coordinateSystem = polarModel.coordinateSystem;
  49550. }
  49551. });
  49552. return polarList;
  49553. }
  49554. };
  49555. __webpack_require__(76).register('polar', polarCreator);
  49556. /***/ },
  49557. /* 333 */
  49558. /***/ function(module, exports, __webpack_require__) {
  49559. 'use strict';
  49560. /**
  49561. * @module echarts/coord/polar/Polar
  49562. */
  49563. var RadiusAxis = __webpack_require__(334);
  49564. var AngleAxis = __webpack_require__(335);
  49565. /**
  49566. * @alias {module:echarts/coord/polar/Polar}
  49567. * @constructor
  49568. * @param {string} name
  49569. */
  49570. var Polar = function (name) {
  49571. /**
  49572. * @type {string}
  49573. */
  49574. this.name = name || '';
  49575. /**
  49576. * x of polar center
  49577. * @type {number}
  49578. */
  49579. this.cx = 0;
  49580. /**
  49581. * y of polar center
  49582. * @type {number}
  49583. */
  49584. this.cy = 0;
  49585. /**
  49586. * @type {module:echarts/coord/polar/RadiusAxis}
  49587. * @private
  49588. */
  49589. this._radiusAxis = new RadiusAxis();
  49590. /**
  49591. * @type {module:echarts/coord/polar/AngleAxis}
  49592. * @private
  49593. */
  49594. this._angleAxis = new AngleAxis();
  49595. this._radiusAxis.polar = this._angleAxis.polar = this;
  49596. };
  49597. Polar.prototype = {
  49598. type: 'polar',
  49599. axisPointerEnabled: true,
  49600. constructor: Polar,
  49601. /**
  49602. * @param {Array.<string>}
  49603. * @readOnly
  49604. */
  49605. dimensions: ['radius', 'angle'],
  49606. /**
  49607. * @type {module:echarts/coord/PolarModel}
  49608. */
  49609. model: null,
  49610. /**
  49611. * If contain coord
  49612. * @param {Array.<number>} point
  49613. * @return {boolean}
  49614. */
  49615. containPoint: function (point) {
  49616. var coord = this.pointToCoord(point);
  49617. return this._radiusAxis.contain(coord[0])
  49618. && this._angleAxis.contain(coord[1]);
  49619. },
  49620. /**
  49621. * If contain data
  49622. * @param {Array.<number>} data
  49623. * @return {boolean}
  49624. */
  49625. containData: function (data) {
  49626. return this._radiusAxis.containData(data[0])
  49627. && this._angleAxis.containData(data[1]);
  49628. },
  49629. /**
  49630. * @param {string} dim
  49631. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  49632. */
  49633. getAxis: function (dim) {
  49634. return this['_' + dim + 'Axis'];
  49635. },
  49636. /**
  49637. * @return {Array.<module:echarts/coord/Axis>}
  49638. */
  49639. getAxes: function () {
  49640. return [this._radiusAxis, this._angleAxis];
  49641. },
  49642. /**
  49643. * Get axes by type of scale
  49644. * @param {string} scaleType
  49645. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  49646. */
  49647. getAxesByScale: function (scaleType) {
  49648. var axes = [];
  49649. var angleAxis = this._angleAxis;
  49650. var radiusAxis = this._radiusAxis;
  49651. angleAxis.scale.type === scaleType && axes.push(angleAxis);
  49652. radiusAxis.scale.type === scaleType && axes.push(radiusAxis);
  49653. return axes;
  49654. },
  49655. /**
  49656. * @return {module:echarts/coord/polar/AngleAxis}
  49657. */
  49658. getAngleAxis: function () {
  49659. return this._angleAxis;
  49660. },
  49661. /**
  49662. * @return {module:echarts/coord/polar/RadiusAxis}
  49663. */
  49664. getRadiusAxis: function () {
  49665. return this._radiusAxis;
  49666. },
  49667. /**
  49668. * @param {module:echarts/coord/polar/Axis}
  49669. * @return {module:echarts/coord/polar/Axis}
  49670. */
  49671. getOtherAxis: function (axis) {
  49672. var angleAxis = this._angleAxis;
  49673. return axis === angleAxis ? this._radiusAxis : angleAxis;
  49674. },
  49675. /**
  49676. * Base axis will be used on stacking.
  49677. *
  49678. * @return {module:echarts/coord/polar/Axis}
  49679. */
  49680. getBaseAxis: function () {
  49681. return this.getAxesByScale('ordinal')[0]
  49682. || this.getAxesByScale('time')[0]
  49683. || this.getAngleAxis();
  49684. },
  49685. /**
  49686. * @param {string} [dim] 'radius' or 'angle' or 'auto' or null/undefined
  49687. * @return {Object} {baseAxes: [], otherAxes: []}
  49688. */
  49689. getTooltipAxes: function (dim) {
  49690. var baseAxis = (dim != null && dim !== 'auto')
  49691. ? this.getAxis(dim) : this.getBaseAxis();
  49692. return {
  49693. baseAxes: [baseAxis],
  49694. otherAxes: [this.getOtherAxis(baseAxis)]
  49695. };
  49696. },
  49697. /**
  49698. * Convert series data to a list of (x, y) points
  49699. * @param {module:echarts/data/List} data
  49700. * @return {Array}
  49701. * Return list of coordinates. For example:
  49702. * `[[10, 10], [20, 20], [30, 30]]`
  49703. */
  49704. dataToPoints: function (data) {
  49705. return data.mapArray(this.dimensions, function (radius, angle) {
  49706. return this.dataToPoint([radius, angle]);
  49707. }, true, this);
  49708. },
  49709. /**
  49710. * Convert a single data item to (x, y) point.
  49711. * Parameter data is an array which the first element is radius and the second is angle
  49712. * @param {Array.<number>} data
  49713. * @param {boolean} [clamp=false]
  49714. * @return {Array.<number>}
  49715. */
  49716. dataToPoint: function (data, clamp) {
  49717. return this.coordToPoint([
  49718. this._radiusAxis.dataToRadius(data[0], clamp),
  49719. this._angleAxis.dataToAngle(data[1], clamp)
  49720. ]);
  49721. },
  49722. /**
  49723. * Convert a (x, y) point to data
  49724. * @param {Array.<number>} point
  49725. * @param {boolean} [clamp=false]
  49726. * @return {Array.<number>}
  49727. */
  49728. pointToData: function (point, clamp) {
  49729. var coord = this.pointToCoord(point);
  49730. return [
  49731. this._radiusAxis.radiusToData(coord[0], clamp),
  49732. this._angleAxis.angleToData(coord[1], clamp)
  49733. ];
  49734. },
  49735. /**
  49736. * Convert a (x, y) point to (radius, angle) coord
  49737. * @param {Array.<number>} point
  49738. * @return {Array.<number>}
  49739. */
  49740. pointToCoord: function (point) {
  49741. var dx = point[0] - this.cx;
  49742. var dy = point[1] - this.cy;
  49743. var angleAxis = this.getAngleAxis();
  49744. var extent = angleAxis.getExtent();
  49745. var minAngle = Math.min(extent[0], extent[1]);
  49746. var maxAngle = Math.max(extent[0], extent[1]);
  49747. // Fix fixed extent in polarCreator
  49748. // FIXME
  49749. angleAxis.inverse
  49750. ? (minAngle = maxAngle - 360)
  49751. : (maxAngle = minAngle + 360);
  49752. var radius = Math.sqrt(dx * dx + dy * dy);
  49753. dx /= radius;
  49754. dy /= radius;
  49755. var radian = Math.atan2(-dy, dx) / Math.PI * 180;
  49756. // move to angleExtent
  49757. var dir = radian < minAngle ? 1 : -1;
  49758. while (radian < minAngle || radian > maxAngle) {
  49759. radian += dir * 360;
  49760. }
  49761. return [radius, radian];
  49762. },
  49763. /**
  49764. * Convert a (radius, angle) coord to (x, y) point
  49765. * @param {Array.<number>} coord
  49766. * @return {Array.<number>}
  49767. */
  49768. coordToPoint: function (coord) {
  49769. var radius = coord[0];
  49770. var radian = coord[1] / 180 * Math.PI;
  49771. var x = Math.cos(radian) * radius + this.cx;
  49772. // Inverse the y
  49773. var y = -Math.sin(radian) * radius + this.cy;
  49774. return [x, y];
  49775. }
  49776. };
  49777. module.exports = Polar;
  49778. /***/ },
  49779. /* 334 */
  49780. /***/ function(module, exports, __webpack_require__) {
  49781. 'use strict';
  49782. var zrUtil = __webpack_require__(4);
  49783. var Axis = __webpack_require__(100);
  49784. function RadiusAxis(scale, radiusExtent) {
  49785. Axis.call(this, 'radius', scale, radiusExtent);
  49786. /**
  49787. * Axis type
  49788. * - 'category'
  49789. * - 'value'
  49790. * - 'time'
  49791. * - 'log'
  49792. * @type {string}
  49793. */
  49794. this.type = 'category';
  49795. }
  49796. RadiusAxis.prototype = {
  49797. constructor: RadiusAxis,
  49798. /**
  49799. * @override
  49800. */
  49801. pointToData: function (point, clamp) {
  49802. return this.polar.pointToData(point, clamp)[this.dim === 'radius' ? 0 : 1];
  49803. },
  49804. dataToRadius: Axis.prototype.dataToCoord,
  49805. radiusToData: Axis.prototype.coordToData
  49806. };
  49807. zrUtil.inherits(RadiusAxis, Axis);
  49808. module.exports = RadiusAxis;
  49809. /***/ },
  49810. /* 335 */
  49811. /***/ function(module, exports, __webpack_require__) {
  49812. 'use strict';
  49813. var zrUtil = __webpack_require__(4);
  49814. var Axis = __webpack_require__(100);
  49815. function AngleAxis(scale, angleExtent) {
  49816. angleExtent = angleExtent || [0, 360];
  49817. Axis.call(this, 'angle', scale, angleExtent);
  49818. /**
  49819. * Axis type
  49820. * - 'category'
  49821. * - 'value'
  49822. * - 'time'
  49823. * - 'log'
  49824. * @type {string}
  49825. */
  49826. this.type = 'category';
  49827. }
  49828. AngleAxis.prototype = {
  49829. constructor: AngleAxis,
  49830. /**
  49831. * @override
  49832. */
  49833. pointToData: function (point, clamp) {
  49834. return this.polar.pointToData(point, clamp)[this.dim === 'radius' ? 0 : 1];
  49835. },
  49836. dataToAngle: Axis.prototype.dataToCoord,
  49837. angleToData: Axis.prototype.coordToData
  49838. };
  49839. zrUtil.inherits(AngleAxis, Axis);
  49840. module.exports = AngleAxis;
  49841. /***/ },
  49842. /* 336 */
  49843. /***/ function(module, exports, __webpack_require__) {
  49844. 'use strict';
  49845. __webpack_require__(337);
  49846. __webpack_require__(1).extendComponentModel({
  49847. type: 'polar',
  49848. dependencies: ['polarAxis', 'angleAxis'],
  49849. /**
  49850. * @type {module:echarts/coord/polar/Polar}
  49851. */
  49852. coordinateSystem: null,
  49853. /**
  49854. * @param {string} axisType
  49855. * @return {module:echarts/coord/polar/AxisModel}
  49856. */
  49857. findAxisModel: function (axisType) {
  49858. var foundAxisModel;
  49859. var ecModel = this.ecModel;
  49860. ecModel.eachComponent(axisType, function (axisModel) {
  49861. if (axisModel.getCoordSysModel() === this) {
  49862. foundAxisModel = axisModel;
  49863. }
  49864. }, this);
  49865. return foundAxisModel;
  49866. },
  49867. defaultOption: {
  49868. zlevel: 0,
  49869. z: 0,
  49870. center: ['50%', '50%'],
  49871. radius: '80%'
  49872. }
  49873. });
  49874. /***/ },
  49875. /* 337 */
  49876. /***/ function(module, exports, __webpack_require__) {
  49877. 'use strict';
  49878. var zrUtil = __webpack_require__(4);
  49879. var ComponentModel = __webpack_require__(69);
  49880. var axisModelCreator = __webpack_require__(131);
  49881. var PolarAxisModel = ComponentModel.extend({
  49882. type: 'polarAxis',
  49883. /**
  49884. * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  49885. */
  49886. axis: null,
  49887. /**
  49888. * @override
  49889. */
  49890. getCoordSysModel: function () {
  49891. return this.ecModel.queryComponents({
  49892. mainType: 'polar',
  49893. index: this.option.polarIndex,
  49894. id: this.option.polarId
  49895. })[0];
  49896. }
  49897. });
  49898. zrUtil.merge(PolarAxisModel.prototype, __webpack_require__(112));
  49899. var polarAxisDefaultExtendedOption = {
  49900. angle: {
  49901. // polarIndex: 0,
  49902. // polarId: '',
  49903. startAngle: 90,
  49904. clockwise: true,
  49905. splitNumber: 12,
  49906. axisLabel: {
  49907. rotate: false
  49908. }
  49909. },
  49910. radius: {
  49911. // polarIndex: 0,
  49912. // polarId: '',
  49913. splitNumber: 5
  49914. }
  49915. };
  49916. function getAxisType(axisDim, option) {
  49917. // Default axis with data is category axis
  49918. return option.type || (option.data ? 'category' : 'value');
  49919. }
  49920. axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle);
  49921. axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius);
  49922. /***/ },
  49923. /* 338 */
  49924. /***/ function(module, exports, __webpack_require__) {
  49925. 'use strict';
  49926. __webpack_require__(332);
  49927. __webpack_require__(339);
  49928. /***/ },
  49929. /* 339 */
  49930. /***/ function(module, exports, __webpack_require__) {
  49931. 'use strict';
  49932. var zrUtil = __webpack_require__(4);
  49933. var graphic = __webpack_require__(18);
  49934. var Model = __webpack_require__(12);
  49935. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea'];
  49936. function getAxisLineShape(polar, r0, r, angle) {
  49937. var start = polar.coordToPoint([r0, angle]);
  49938. var end = polar.coordToPoint([r, angle]);
  49939. return {
  49940. x1: start[0],
  49941. y1: start[1],
  49942. x2: end[0],
  49943. y2: end[1]
  49944. };
  49945. }
  49946. __webpack_require__(136).extend({
  49947. type: 'angleAxis',
  49948. axisPointerClass: 'PolarAxisPointer',
  49949. render: function (angleAxisModel, ecModel) {
  49950. this.group.removeAll();
  49951. if (!angleAxisModel.get('show')) {
  49952. return;
  49953. }
  49954. var angleAxis = angleAxisModel.axis;
  49955. var polar = angleAxis.polar;
  49956. var radiusExtent = polar.getRadiusAxis().getExtent();
  49957. var ticksAngles = angleAxis.getTicksCoords();
  49958. if (angleAxis.type !== 'category') {
  49959. // Remove the last tick which will overlap the first tick
  49960. ticksAngles.pop();
  49961. }
  49962. zrUtil.each(elementList, function (name) {
  49963. if (angleAxisModel.get(name +'.show')
  49964. && (!angleAxis.scale.isBlank() || name === 'axisLine')
  49965. ) {
  49966. this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent);
  49967. }
  49968. }, this);
  49969. },
  49970. /**
  49971. * @private
  49972. */
  49973. _axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  49974. var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle');
  49975. var circle = new graphic.Circle({
  49976. shape: {
  49977. cx: polar.cx,
  49978. cy: polar.cy,
  49979. r: radiusExtent[1]
  49980. },
  49981. style: lineStyleModel.getLineStyle(),
  49982. z2: 1,
  49983. silent: true
  49984. });
  49985. circle.style.fill = null;
  49986. this.group.add(circle);
  49987. },
  49988. /**
  49989. * @private
  49990. */
  49991. _axisTick: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  49992. var tickModel = angleAxisModel.getModel('axisTick');
  49993. var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
  49994. var lines = zrUtil.map(ticksAngles, function (tickAngle) {
  49995. return new graphic.Line({
  49996. shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle)
  49997. });
  49998. });
  49999. this.group.add(graphic.mergePath(
  50000. lines, {
  50001. style: zrUtil.defaults(
  50002. tickModel.getModel('lineStyle').getLineStyle(),
  50003. {
  50004. stroke: angleAxisModel.get('axisLine.lineStyle.color')
  50005. }
  50006. )
  50007. }
  50008. ));
  50009. },
  50010. /**
  50011. * @private
  50012. */
  50013. _axisLabel: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  50014. var axis = angleAxisModel.axis;
  50015. var categoryData = angleAxisModel.get('data');
  50016. var labelModel = angleAxisModel.getModel('axisLabel');
  50017. var axisTextStyleModel = labelModel.getModel('textStyle');
  50018. var labels = angleAxisModel.getFormattedLabels();
  50019. var labelMargin = labelModel.get('margin');
  50020. var labelsAngles = axis.getLabelsCoords();
  50021. // Use length of ticksAngles because it may remove the last tick to avoid overlapping
  50022. for (var i = 0; i < ticksAngles.length; i++) {
  50023. var r = radiusExtent[1];
  50024. var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]);
  50025. var cx = polar.cx;
  50026. var cy = polar.cy;
  50027. var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3
  50028. ? 'center' : (p[0] > cx ? 'left' : 'right');
  50029. var labelTextBaseline = Math.abs(p[1] - cy) / r < 0.3
  50030. ? 'middle' : (p[1] > cy ? 'top' : 'bottom');
  50031. var textStyleModel = axisTextStyleModel;
  50032. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  50033. textStyleModel = new Model(
  50034. categoryData[i].textStyle, axisTextStyleModel
  50035. );
  50036. }
  50037. this.group.add(new graphic.Text({
  50038. style: {
  50039. x: p[0],
  50040. y: p[1],
  50041. fill: textStyleModel.getTextColor() || angleAxisModel.get('axisLine.lineStyle.color'),
  50042. text: labels[i],
  50043. textAlign: labelTextAlign,
  50044. textVerticalAlign: labelTextBaseline,
  50045. textFont: textStyleModel.getFont()
  50046. },
  50047. silent: true
  50048. }));
  50049. }
  50050. },
  50051. /**
  50052. * @private
  50053. */
  50054. _splitLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  50055. var splitLineModel = angleAxisModel.getModel('splitLine');
  50056. var lineStyleModel = splitLineModel.getModel('lineStyle');
  50057. var lineColors = lineStyleModel.get('color');
  50058. var lineCount = 0;
  50059. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  50060. var splitLines = [];
  50061. for (var i = 0; i < ticksAngles.length; i++) {
  50062. var colorIndex = (lineCount++) % lineColors.length;
  50063. splitLines[colorIndex] = splitLines[colorIndex] || [];
  50064. splitLines[colorIndex].push(new graphic.Line({
  50065. shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i])
  50066. }));
  50067. }
  50068. // Simple optimization
  50069. // Batching the lines if color are the same
  50070. for (var i = 0; i < splitLines.length; i++) {
  50071. this.group.add(graphic.mergePath(splitLines[i], {
  50072. style: zrUtil.defaults({
  50073. stroke: lineColors[i % lineColors.length]
  50074. }, lineStyleModel.getLineStyle()),
  50075. silent: true,
  50076. z: angleAxisModel.get('z')
  50077. }));
  50078. }
  50079. },
  50080. /**
  50081. * @private
  50082. */
  50083. _splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  50084. var splitAreaModel = angleAxisModel.getModel('splitArea');
  50085. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  50086. var areaColors = areaStyleModel.get('color');
  50087. var lineCount = 0;
  50088. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  50089. var splitAreas = [];
  50090. var RADIAN = Math.PI / 180;
  50091. var prevAngle = -ticksAngles[0] * RADIAN;
  50092. var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
  50093. var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
  50094. var clockwise = angleAxisModel.get('clockwise');
  50095. for (var i = 1; i < ticksAngles.length; i++) {
  50096. var colorIndex = (lineCount++) % areaColors.length;
  50097. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  50098. splitAreas[colorIndex].push(new graphic.Sector({
  50099. shape: {
  50100. cx: polar.cx,
  50101. cy: polar.cy,
  50102. r0: r0,
  50103. r: r1,
  50104. startAngle: prevAngle,
  50105. endAngle: -ticksAngles[i] * RADIAN,
  50106. clockwise: clockwise
  50107. },
  50108. silent: true
  50109. }));
  50110. prevAngle = -ticksAngles[i] * RADIAN;
  50111. }
  50112. // Simple optimization
  50113. // Batching the lines if color are the same
  50114. for (var i = 0; i < splitAreas.length; i++) {
  50115. this.group.add(graphic.mergePath(splitAreas[i], {
  50116. style: zrUtil.defaults({
  50117. fill: areaColors[i % areaColors.length]
  50118. }, areaStyleModel.getAreaStyle()),
  50119. silent: true
  50120. }));
  50121. }
  50122. }
  50123. });
  50124. /***/ },
  50125. /* 340 */
  50126. /***/ function(module, exports, __webpack_require__) {
  50127. __webpack_require__(332);
  50128. __webpack_require__(341);
  50129. /***/ },
  50130. /* 341 */
  50131. /***/ function(module, exports, __webpack_require__) {
  50132. 'use strict';
  50133. var zrUtil = __webpack_require__(4);
  50134. var graphic = __webpack_require__(18);
  50135. var AxisBuilder = __webpack_require__(135);
  50136. var axisBuilderAttrs = [
  50137. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  50138. ];
  50139. var selfBuilderAttrs = [
  50140. 'splitLine', 'splitArea'
  50141. ];
  50142. __webpack_require__(136).extend({
  50143. type: 'radiusAxis',
  50144. axisPointerClass: 'PolarAxisPointer',
  50145. render: function (radiusAxisModel, ecModel) {
  50146. this.group.removeAll();
  50147. if (!radiusAxisModel.get('show')) {
  50148. return;
  50149. }
  50150. var radiusAxis = radiusAxisModel.axis;
  50151. var polar = radiusAxis.polar;
  50152. var angleAxis = polar.getAngleAxis();
  50153. var ticksCoords = radiusAxis.getTicksCoords();
  50154. var axisAngle = angleAxis.getExtent()[0];
  50155. var radiusExtent = radiusAxis.getExtent();
  50156. var layout = layoutAxis(polar, radiusAxisModel, axisAngle);
  50157. var axisBuilder = new AxisBuilder(radiusAxisModel, layout);
  50158. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  50159. this.group.add(axisBuilder.getGroup());
  50160. zrUtil.each(selfBuilderAttrs, function (name) {
  50161. if (radiusAxisModel.get(name +'.show') && !radiusAxis.scale.isBlank()) {
  50162. this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords);
  50163. }
  50164. }, this);
  50165. },
  50166. /**
  50167. * @private
  50168. */
  50169. _splitLine: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  50170. var splitLineModel = radiusAxisModel.getModel('splitLine');
  50171. var lineStyleModel = splitLineModel.getModel('lineStyle');
  50172. var lineColors = lineStyleModel.get('color');
  50173. var lineCount = 0;
  50174. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  50175. var splitLines = [];
  50176. for (var i = 0; i < ticksCoords.length; i++) {
  50177. var colorIndex = (lineCount++) % lineColors.length;
  50178. splitLines[colorIndex] = splitLines[colorIndex] || [];
  50179. splitLines[colorIndex].push(new graphic.Circle({
  50180. shape: {
  50181. cx: polar.cx,
  50182. cy: polar.cy,
  50183. r: ticksCoords[i]
  50184. },
  50185. silent: true
  50186. }));
  50187. }
  50188. // Simple optimization
  50189. // Batching the lines if color are the same
  50190. for (var i = 0; i < splitLines.length; i++) {
  50191. this.group.add(graphic.mergePath(splitLines[i], {
  50192. style: zrUtil.defaults({
  50193. stroke: lineColors[i % lineColors.length],
  50194. fill: null
  50195. }, lineStyleModel.getLineStyle()),
  50196. silent: true
  50197. }));
  50198. }
  50199. },
  50200. /**
  50201. * @private
  50202. */
  50203. _splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  50204. var splitAreaModel = radiusAxisModel.getModel('splitArea');
  50205. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  50206. var areaColors = areaStyleModel.get('color');
  50207. var lineCount = 0;
  50208. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  50209. var splitAreas = [];
  50210. var prevRadius = ticksCoords[0];
  50211. for (var i = 1; i < ticksCoords.length; i++) {
  50212. var colorIndex = (lineCount++) % areaColors.length;
  50213. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  50214. splitAreas[colorIndex].push(new graphic.Sector({
  50215. shape: {
  50216. cx: polar.cx,
  50217. cy: polar.cy,
  50218. r0: prevRadius,
  50219. r: ticksCoords[i],
  50220. startAngle: 0,
  50221. endAngle: Math.PI * 2
  50222. },
  50223. silent: true
  50224. }));
  50225. prevRadius = ticksCoords[i];
  50226. }
  50227. // Simple optimization
  50228. // Batching the lines if color are the same
  50229. for (var i = 0; i < splitAreas.length; i++) {
  50230. this.group.add(graphic.mergePath(splitAreas[i], {
  50231. style: zrUtil.defaults({
  50232. fill: areaColors[i % areaColors.length]
  50233. }, areaStyleModel.getAreaStyle()),
  50234. silent: true
  50235. }));
  50236. }
  50237. }
  50238. });
  50239. /**
  50240. * @inner
  50241. */
  50242. function layoutAxis(polar, radiusAxisModel, axisAngle) {
  50243. return {
  50244. position: [polar.cx, polar.cy],
  50245. rotation: axisAngle / 180 * Math.PI,
  50246. labelDirection: -1,
  50247. tickDirection: -1,
  50248. nameDirection: 1,
  50249. labelRotate: radiusAxisModel.getModel('axisLabel').get('rotate'),
  50250. // Over splitLine and splitArea
  50251. z2: 1
  50252. };
  50253. }
  50254. /***/ },
  50255. /* 342 */
  50256. /***/ function(module, exports, __webpack_require__) {
  50257. 'use strict';
  50258. var formatUtil = __webpack_require__(6);
  50259. var BaseAxisPointer = __webpack_require__(305);
  50260. var graphic = __webpack_require__(18);
  50261. var viewHelper = __webpack_require__(306);
  50262. var matrix = __webpack_require__(11);
  50263. var AxisBuilder = __webpack_require__(135);
  50264. var AxisView = __webpack_require__(136);
  50265. var PolarAxisPointer = BaseAxisPointer.extend({
  50266. /**
  50267. * @override
  50268. */
  50269. makeElOption: function (elOption, value, axisModel, axisPointerModel, api) {
  50270. var axis = axisModel.axis;
  50271. if (axis.dim === 'angle') {
  50272. this.animationThreshold = Math.PI / 18;
  50273. }
  50274. var polar = axis.polar;
  50275. var otherAxis = polar.getOtherAxis(axis);
  50276. var otherExtent = otherAxis.getExtent();
  50277. var coordValue;
  50278. coordValue = axis['dataTo' + formatUtil.capitalFirst(axis.dim)](value);
  50279. var axisPointerType = axisPointerModel.get('type');
  50280. if (axisPointerType && axisPointerType !== 'none') {
  50281. var elStyle = viewHelper.buildElStyle(axisPointerModel);
  50282. var pointerOption = pointerShapeBuilder[axisPointerType](
  50283. axis, polar, coordValue, otherExtent, elStyle
  50284. );
  50285. pointerOption.style = elStyle;
  50286. elOption.graphicKey = pointerOption.type;
  50287. elOption.pointer = pointerOption;
  50288. }
  50289. var labelMargin = axisPointerModel.get('label.margin');
  50290. var labelPos = getLabelPosition(value, axisModel, axisPointerModel, polar, labelMargin);
  50291. viewHelper.buildLabelElOption(elOption, axisModel, axisPointerModel, api, labelPos);
  50292. }
  50293. // Do not support handle, utill any user requires it.
  50294. });
  50295. function getLabelPosition(value, axisModel, axisPointerModel, polar, labelMargin) {
  50296. var axis = axisModel.axis;
  50297. var coord = axis.dataToCoord(value);
  50298. var axisAngle = polar.getAngleAxis().getExtent()[0];
  50299. axisAngle = axisAngle / 180 * Math.PI;
  50300. var radiusExtent = polar.getRadiusAxis().getExtent();
  50301. var position;
  50302. var align;
  50303. var verticalAlign;
  50304. if (axis.dim === 'radius') {
  50305. var transform = matrix.create();
  50306. matrix.rotate(transform, transform, axisAngle);
  50307. matrix.translate(transform, transform, [polar.cx, polar.cy]);
  50308. position = graphic.applyTransform([coord, -labelMargin], transform);
  50309. var labelRotation = axisModel.getModel('axisLabel').get('rotate') || 0;
  50310. var labelLayout = AxisBuilder.innerTextLayout(
  50311. axisAngle, labelRotation * Math.PI / 180, -1
  50312. );
  50313. align = labelLayout.textAlign;
  50314. verticalAlign = labelLayout.textVerticalAlign;
  50315. }
  50316. else { // angle axis
  50317. var r = radiusExtent[1];
  50318. position = polar.coordToPoint([r + labelMargin, coord]);
  50319. var cx = polar.cx;
  50320. var cy = polar.cy;
  50321. align = Math.abs(position[0] - cx) / r < 0.3
  50322. ? 'center' : (position[0] > cx ? 'left' : 'right');
  50323. verticalAlign = Math.abs(position[1] - cy) / r < 0.3
  50324. ? 'middle' : (position[1] > cy ? 'top' : 'bottom');
  50325. }
  50326. return {
  50327. position: position,
  50328. align: align,
  50329. verticalAlign: verticalAlign
  50330. };
  50331. }
  50332. var pointerShapeBuilder = {
  50333. line: function (axis, polar, coordValue, otherExtent, elStyle) {
  50334. return axis.dim === 'angle'
  50335. ? {
  50336. type: 'Line',
  50337. shape: viewHelper.makeLineShape(
  50338. polar.coordToPoint([otherExtent[0], coordValue]),
  50339. polar.coordToPoint([otherExtent[1], coordValue])
  50340. )
  50341. }
  50342. : {
  50343. type: 'Circle',
  50344. shape: {
  50345. cx: polar.cx,
  50346. cy: polar.cy,
  50347. r: coordValue
  50348. }
  50349. };
  50350. },
  50351. shadow: function (axis, polar, coordValue, otherExtent, elStyle) {
  50352. var bandWidth = axis.getBandWidth();
  50353. var radian = Math.PI / 180;
  50354. return axis.dim === 'angle'
  50355. ? {
  50356. type: 'Sector',
  50357. shape: viewHelper.makeSectorShape(
  50358. polar.cx, polar.cy,
  50359. otherExtent[0], otherExtent[1],
  50360. // In ECharts y is negative if angle is positive
  50361. (-coordValue - bandWidth / 2) * radian,
  50362. (-coordValue + bandWidth / 2) * radian
  50363. )
  50364. }
  50365. : {
  50366. type: 'Sector',
  50367. shape: viewHelper.makeSectorShape(
  50368. polar.cx, polar.cy,
  50369. coordValue - bandWidth / 2,
  50370. coordValue + bandWidth / 2,
  50371. 0, Math.PI * 2
  50372. )
  50373. };
  50374. }
  50375. };
  50376. AxisView.registerAxisPointerClass('PolarAxisPointer', PolarAxisPointer);
  50377. module.exports = PolarAxisPointer;
  50378. /***/ },
  50379. /* 343 */
  50380. /***/ function(module, exports, __webpack_require__) {
  50381. 'use strict';
  50382. var zrUtil = __webpack_require__(4);
  50383. var parsePercent = __webpack_require__(7).parsePercent;
  50384. function getSeriesStackId(seriesModel) {
  50385. return seriesModel.get('stack')
  50386. || '__ec_stack_' + seriesModel.seriesIndex;
  50387. }
  50388. function getAxisKey(axis) {
  50389. return axis.dim;
  50390. }
  50391. /**
  50392. * @param {string} seriesType
  50393. * @param {module:echarts/model/Global} ecModel
  50394. * @param {module:echarts/ExtensionAPI} api
  50395. */
  50396. function barLayoutPolar(seriesType, ecModel, api) {
  50397. var width = api.getWidth();
  50398. var height = api.getHeight();
  50399. var lastStackCoords = {};
  50400. var lastStackCoordsOrigin = {};
  50401. var barWidthAndOffset = calRadialBar(
  50402. zrUtil.filter(
  50403. ecModel.getSeriesByType(seriesType),
  50404. function (seriesModel) {
  50405. return !ecModel.isSeriesFiltered(seriesModel)
  50406. && seriesModel.coordinateSystem
  50407. && seriesModel.coordinateSystem.type === 'polar';
  50408. }
  50409. )
  50410. );
  50411. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  50412. // Check series coordinate, do layout for polar only
  50413. if (seriesModel.coordinateSystem.type !== 'polar') {
  50414. return;
  50415. }
  50416. var data = seriesModel.getData();
  50417. var polar = seriesModel.coordinateSystem;
  50418. var angleAxis = polar.getAngleAxis();
  50419. var baseAxis = polar.getBaseAxis();
  50420. var stackId = getSeriesStackId(seriesModel);
  50421. var columnLayoutInfo
  50422. = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
  50423. var columnOffset = columnLayoutInfo.offset;
  50424. var columnWidth = columnLayoutInfo.width;
  50425. var valueAxis = polar.getOtherAxis(baseAxis);
  50426. var center = seriesModel.get('center') || ['50%', '50%'];
  50427. var cx = parsePercent(center[0], width);
  50428. var cy = parsePercent(center[1], height);
  50429. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  50430. var barMinAngle = seriesModel.get('barMinAngle') || 0;
  50431. var valueAxisStart = valueAxis.getExtent()[0];
  50432. var valueMax = valueAxis.model.get('max');
  50433. var valueMin = valueAxis.model.get('min');
  50434. var coords = polar.dataToPoints(data);
  50435. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  50436. lastStackCoordsOrigin[stackId] = lastStackCoordsOrigin[stackId] || []; // Fix #4243
  50437. data.each(valueAxis.dim, function (value, idx) {
  50438. if (isNaN(value)) {
  50439. return;
  50440. }
  50441. if (!lastStackCoords[stackId][idx]) {
  50442. lastStackCoords[stackId][idx] = {
  50443. p: valueAxisStart, // Positive stack
  50444. n: valueAxisStart // Negative stack
  50445. };
  50446. lastStackCoordsOrigin[stackId][idx] = {
  50447. p: valueAxisStart, // Positive stack
  50448. n: valueAxisStart // Negative stack
  50449. };
  50450. }
  50451. var sign = value >= 0 ? 'p' : 'n';
  50452. var coord = polar.pointToCoord(coords[idx]);
  50453. var lastCoordOrigin = lastStackCoordsOrigin[stackId][idx][sign];
  50454. var r0;
  50455. var r;
  50456. var startAngle;
  50457. var endAngle;
  50458. if (valueAxis.dim === 'radius') {
  50459. // radial sector
  50460. r0 = lastCoordOrigin;
  50461. r = coord[0];
  50462. startAngle = (-coord[1] + columnOffset) * Math.PI / 180;
  50463. endAngle = startAngle + columnWidth * Math.PI / 180;
  50464. if (Math.abs(r) < barMinHeight) {
  50465. r = r0 + (r < 0 ? -1 : 1) * barMinHeight;
  50466. }
  50467. lastStackCoordsOrigin[stackId][idx][sign] = r;
  50468. }
  50469. else {
  50470. // tangential sector
  50471. r0 = coord[0] + columnOffset;
  50472. r = r0 + columnWidth;
  50473. // clamp data if min or max is defined for valueAxis
  50474. if (valueMax != null) {
  50475. value = Math.min(value, valueMax);
  50476. }
  50477. if (valueMin != null) {
  50478. value = Math.max(value, valueMin);
  50479. }
  50480. var angle = angleAxis.dataToAngle(value);
  50481. if (Math.abs(angle - lastCoordOrigin) < barMinAngle) {
  50482. angle = lastCoordOrigin - (value < 0 ? -1 : 1)
  50483. * barMinAngle;
  50484. }
  50485. startAngle = -lastCoordOrigin * Math.PI / 180;
  50486. endAngle = -angle * Math.PI / 180;
  50487. // if the previous stack is at the end of the ring,
  50488. // add a round to differentiate it from origin
  50489. var extent = angleAxis.getExtent();
  50490. var stackCoord = angle;
  50491. if (stackCoord === extent[0] && value > 0) {
  50492. stackCoord = extent[1];
  50493. }
  50494. else if (stackCoord === extent[1] && value < 0) {
  50495. stackCoord = extent[0];
  50496. }
  50497. lastStackCoordsOrigin[stackId][idx][sign] = stackCoord;
  50498. }
  50499. data.setItemLayout(idx, {
  50500. cx: cx,
  50501. cy: cy,
  50502. r0: r0,
  50503. r: r,
  50504. startAngle: startAngle,
  50505. endAngle: endAngle
  50506. });
  50507. }, true);
  50508. }, this);
  50509. }
  50510. /**
  50511. * Calculate bar width and offset for radial bar charts
  50512. */
  50513. function calRadialBar(barSeries, api) {
  50514. // Columns info on each category axis. Key is polar name
  50515. var columnsMap = {};
  50516. zrUtil.each(barSeries, function (seriesModel, idx) {
  50517. var data = seriesModel.getData();
  50518. var polar = seriesModel.coordinateSystem;
  50519. var baseAxis = polar.getBaseAxis();
  50520. var axisExtent = baseAxis.getExtent();
  50521. var bandWidth = baseAxis.type === 'category'
  50522. ? baseAxis.getBandWidth()
  50523. : (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
  50524. var columnsOnAxis = columnsMap[getAxisKey(baseAxis)] || {
  50525. bandWidth: bandWidth,
  50526. remainedWidth: bandWidth,
  50527. autoWidthCount: 0,
  50528. categoryGap: '20%',
  50529. gap: '30%',
  50530. stacks: {}
  50531. };
  50532. var stacks = columnsOnAxis.stacks;
  50533. columnsMap[getAxisKey(baseAxis)] = columnsOnAxis;
  50534. var stackId = getSeriesStackId(seriesModel);
  50535. if (!stacks[stackId]) {
  50536. columnsOnAxis.autoWidthCount++;
  50537. }
  50538. stacks[stackId] = stacks[stackId] || {
  50539. width: 0,
  50540. maxWidth: 0
  50541. };
  50542. var barWidth = parsePercent(
  50543. seriesModel.get('barWidth'),
  50544. bandWidth
  50545. );
  50546. var barMaxWidth = parsePercent(
  50547. seriesModel.get('barMaxWidth'),
  50548. bandWidth
  50549. );
  50550. var barGap = seriesModel.get('barGap');
  50551. var barCategoryGap = seriesModel.get('barCategoryGap');
  50552. if (barWidth && !stacks[stackId].width) {
  50553. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  50554. stacks[stackId].width = barWidth;
  50555. columnsOnAxis.remainedWidth -= barWidth;
  50556. }
  50557. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  50558. (barGap != null) && (columnsOnAxis.gap = barGap);
  50559. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  50560. });
  50561. var result = {};
  50562. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  50563. result[coordSysName] = {};
  50564. var stacks = columnsOnAxis.stacks;
  50565. var bandWidth = columnsOnAxis.bandWidth;
  50566. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  50567. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  50568. var remainedWidth = columnsOnAxis.remainedWidth;
  50569. var autoWidthCount = columnsOnAxis.autoWidthCount;
  50570. var autoWidth = (remainedWidth - categoryGap)
  50571. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  50572. autoWidth = Math.max(autoWidth, 0);
  50573. // Find if any auto calculated bar exceeded maxBarWidth
  50574. zrUtil.each(stacks, function (column, stack) {
  50575. var maxWidth = column.maxWidth;
  50576. if (maxWidth && maxWidth < autoWidth) {
  50577. maxWidth = Math.min(maxWidth, remainedWidth);
  50578. if (column.width) {
  50579. maxWidth = Math.min(maxWidth, column.width);
  50580. }
  50581. remainedWidth -= maxWidth;
  50582. column.width = maxWidth;
  50583. autoWidthCount--;
  50584. }
  50585. });
  50586. // Recalculate width again
  50587. autoWidth = (remainedWidth - categoryGap)
  50588. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  50589. autoWidth = Math.max(autoWidth, 0);
  50590. var widthSum = 0;
  50591. var lastColumn;
  50592. zrUtil.each(stacks, function (column, idx) {
  50593. if (!column.width) {
  50594. column.width = autoWidth;
  50595. }
  50596. lastColumn = column;
  50597. widthSum += column.width * (1 + barGapPercent);
  50598. });
  50599. if (lastColumn) {
  50600. widthSum -= lastColumn.width * barGapPercent;
  50601. }
  50602. var offset = -widthSum / 2;
  50603. zrUtil.each(stacks, function (column, stackId) {
  50604. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  50605. offset: offset,
  50606. width: column.width
  50607. };
  50608. offset += column.width * (1 + barGapPercent);
  50609. });
  50610. });
  50611. return result;
  50612. }
  50613. module.exports = barLayoutPolar;
  50614. /***/ },
  50615. /* 344 */
  50616. /***/ function(module, exports, __webpack_require__) {
  50617. __webpack_require__(345);
  50618. __webpack_require__(171);
  50619. __webpack_require__(346);
  50620. __webpack_require__(187);
  50621. var echarts = __webpack_require__(1);
  50622. var zrUtil = __webpack_require__(4);
  50623. function makeAction(method, actionInfo) {
  50624. actionInfo.update = 'updateView';
  50625. echarts.registerAction(actionInfo, function (payload, ecModel) {
  50626. var selected = {};
  50627. ecModel.eachComponent(
  50628. { mainType: 'geo', query: payload},
  50629. function (geoModel) {
  50630. geoModel[method](payload.name);
  50631. var geo = geoModel.coordinateSystem;
  50632. zrUtil.each(geo.regions, function (region) {
  50633. selected[region.name] = geoModel.isSelected(region.name) || false;
  50634. });
  50635. }
  50636. );
  50637. return {
  50638. selected: selected,
  50639. name: payload.name
  50640. };
  50641. });
  50642. }
  50643. makeAction('toggleSelected', {
  50644. type: 'geoToggleSelect',
  50645. event: 'geoselectchanged'
  50646. });
  50647. makeAction('select', {
  50648. type: 'geoSelect',
  50649. event: 'geoselected'
  50650. });
  50651. makeAction('unSelect', {
  50652. type: 'geoUnSelect',
  50653. event: 'geounselected'
  50654. });
  50655. /***/ },
  50656. /* 345 */
  50657. /***/ function(module, exports, __webpack_require__) {
  50658. 'use strict';
  50659. var modelUtil = __webpack_require__(5);
  50660. var ComponentModel = __webpack_require__(69);
  50661. var Model = __webpack_require__(12);
  50662. var zrUtil = __webpack_require__(4);
  50663. var selectableMixin = __webpack_require__(148);
  50664. var geoCreator = __webpack_require__(171);
  50665. var GeoModel = ComponentModel.extend({
  50666. type: 'geo',
  50667. /**
  50668. * @type {module:echarts/coord/geo/Geo}
  50669. */
  50670. coordinateSystem: null,
  50671. layoutMode: 'box',
  50672. init: function (option) {
  50673. ComponentModel.prototype.init.apply(this, arguments);
  50674. // Default label emphasis `position` and `show`
  50675. modelUtil.defaultEmphasis(
  50676. option.label, ['position', 'show', 'textStyle', 'distance', 'formatter']
  50677. );
  50678. },
  50679. optionUpdated: function () {
  50680. var option = this.option;
  50681. var self = this;
  50682. option.regions = geoCreator.getFilledRegions(option.regions, option.map);
  50683. this._optionModelMap = zrUtil.reduce(option.regions || [], function (optionModelMap, regionOpt) {
  50684. if (regionOpt.name) {
  50685. optionModelMap.set(regionOpt.name, new Model(regionOpt, self));
  50686. }
  50687. return optionModelMap;
  50688. }, zrUtil.createHashMap());
  50689. this.updateSelectedMap(option.regions);
  50690. },
  50691. defaultOption: {
  50692. zlevel: 0,
  50693. z: 0,
  50694. show: true,
  50695. left: 'center',
  50696. top: 'center',
  50697. // width:,
  50698. // height:,
  50699. // right
  50700. // bottom
  50701. // Aspect is width / height. Inited to be geoJson bbox aspect
  50702. // This parameter is used for scale this aspect
  50703. aspectScale: 0.75,
  50704. ///// Layout with center and size
  50705. // If you wan't to put map in a fixed size box with right aspect ratio
  50706. // This two properties may more conveninet
  50707. // layoutCenter: [50%, 50%]
  50708. // layoutSize: 100
  50709. silent: false,
  50710. // Map type
  50711. map: '',
  50712. // Define left-top, right-bottom coords to control view
  50713. // For example, [ [180, 90], [-180, -90] ]
  50714. boundingCoords: null,
  50715. // Default on center of map
  50716. center: null,
  50717. zoom: 1,
  50718. scaleLimit: null,
  50719. // selectedMode: false
  50720. label: {
  50721. normal: {
  50722. show: false,
  50723. textStyle: {
  50724. color: '#000'
  50725. }
  50726. },
  50727. emphasis: {
  50728. show: true,
  50729. textStyle: {
  50730. color: 'rgb(100,0,0)'
  50731. }
  50732. }
  50733. },
  50734. itemStyle: {
  50735. normal: {
  50736. // color: 各异,
  50737. borderWidth: 0.5,
  50738. borderColor: '#444',
  50739. color: '#eee'
  50740. },
  50741. emphasis: { // 也是选中样式
  50742. color: 'rgba(255,215,0,0.8)'
  50743. }
  50744. },
  50745. regions: []
  50746. },
  50747. /**
  50748. * Get model of region
  50749. * @param {string} name
  50750. * @return {module:echarts/model/Model}
  50751. */
  50752. getRegionModel: function (name) {
  50753. return this._optionModelMap.get(name) || new Model(null, this, this.ecModel);
  50754. },
  50755. /**
  50756. * Format label
  50757. * @param {string} name Region name
  50758. * @param {string} [status='normal'] 'normal' or 'emphasis'
  50759. * @return {string}
  50760. */
  50761. getFormattedLabel: function (name, status) {
  50762. var regionModel = this.getRegionModel(name);
  50763. var formatter = regionModel.get('label.' + status + '.formatter');
  50764. var params = {
  50765. name: name
  50766. };
  50767. if (typeof formatter === 'function') {
  50768. params.status = status;
  50769. return formatter(params);
  50770. }
  50771. else if (typeof formatter === 'string') {
  50772. var serName = params.seriesName;
  50773. return formatter.replace('{a}', serName != null ? serName : '');
  50774. }
  50775. },
  50776. setZoom: function (zoom) {
  50777. this.option.zoom = zoom;
  50778. },
  50779. setCenter: function (center) {
  50780. this.option.center = center;
  50781. }
  50782. });
  50783. zrUtil.mixin(GeoModel, selectableMixin);
  50784. module.exports = GeoModel;
  50785. /***/ },
  50786. /* 346 */
  50787. /***/ function(module, exports, __webpack_require__) {
  50788. 'use strict';
  50789. var MapDraw = __webpack_require__(182);
  50790. module.exports = __webpack_require__(1).extendComponentView({
  50791. type: 'geo',
  50792. init: function (ecModel, api) {
  50793. var mapDraw = new MapDraw(api, true);
  50794. this._mapDraw = mapDraw;
  50795. this.group.add(mapDraw.group);
  50796. },
  50797. render: function (geoModel, ecModel, api, payload) {
  50798. // Not render if it is an toggleSelect action from self
  50799. if (payload && payload.type === 'geoToggleSelect'
  50800. && payload.from === this.uid
  50801. ) {
  50802. return;
  50803. }
  50804. var mapDraw = this._mapDraw;
  50805. if (geoModel.get('show')) {
  50806. mapDraw.draw(geoModel, ecModel, api, this, payload);
  50807. }
  50808. else {
  50809. this._mapDraw.group.removeAll();
  50810. }
  50811. this.group.silent = geoModel.get('silent');
  50812. },
  50813. dispose: function () {
  50814. this._mapDraw && this._mapDraw.remove();
  50815. }
  50816. });
  50817. /***/ },
  50818. /* 347 */
  50819. /***/ function(module, exports, __webpack_require__) {
  50820. /**
  50821. * Brush component entry
  50822. */
  50823. __webpack_require__(1).registerPreprocessor(
  50824. __webpack_require__(348)
  50825. );
  50826. __webpack_require__(349);
  50827. __webpack_require__(353);
  50828. __webpack_require__(354);
  50829. __webpack_require__(355);
  50830. __webpack_require__(356);
  50831. /***/ },
  50832. /* 348 */
  50833. /***/ function(module, exports, __webpack_require__) {
  50834. /**
  50835. * @file brush preprocessor
  50836. */
  50837. var zrUtil = __webpack_require__(4);
  50838. var DEFAULT_TOOLBOX_BTNS = ['rect', 'polygon', 'keep', 'clear'];
  50839. module.exports = function (option, isNew) {
  50840. var brushComponents = option && option.brush;
  50841. if (!zrUtil.isArray(brushComponents)) {
  50842. brushComponents = brushComponents ? [brushComponents] : [];
  50843. }
  50844. if (!brushComponents.length) {
  50845. return;
  50846. }
  50847. var brushComponentSpecifiedBtns = [];
  50848. zrUtil.each(brushComponents, function (brushOpt) {
  50849. var tbs = brushOpt.hasOwnProperty('toolbox')
  50850. ? brushOpt.toolbox : [];
  50851. if (tbs instanceof Array) {
  50852. brushComponentSpecifiedBtns = brushComponentSpecifiedBtns.concat(tbs);
  50853. }
  50854. });
  50855. var toolbox = option && option.toolbox;
  50856. if (zrUtil.isArray(toolbox)) {
  50857. toolbox = toolbox[0];
  50858. }
  50859. if (!toolbox) {
  50860. toolbox = {feature: {}};
  50861. option.toolbox = [toolbox];
  50862. }
  50863. var toolboxFeature = (toolbox.feature || (toolbox.feature = {}));
  50864. var toolboxBrush = toolboxFeature.brush || (toolboxFeature.brush = {});
  50865. var brushTypes = toolboxBrush.type || (toolboxBrush.type = []);
  50866. brushTypes.push.apply(brushTypes, brushComponentSpecifiedBtns);
  50867. removeDuplicate(brushTypes);
  50868. if (isNew && !brushTypes.length) {
  50869. brushTypes.push.apply(brushTypes, DEFAULT_TOOLBOX_BTNS);
  50870. }
  50871. };
  50872. function removeDuplicate(arr) {
  50873. var map = {};
  50874. zrUtil.each(arr, function (val) {
  50875. map[val] = 1;
  50876. });
  50877. arr.length = 0;
  50878. zrUtil.each(map, function (flag, val) {
  50879. arr.push(val);
  50880. });
  50881. }
  50882. /***/ },
  50883. /* 349 */
  50884. /***/ function(module, exports, __webpack_require__) {
  50885. /**
  50886. * @file Brush visual coding.
  50887. */
  50888. var echarts = __webpack_require__(1);
  50889. var visualSolution = __webpack_require__(350);
  50890. var zrUtil = __webpack_require__(4);
  50891. var BoundingRect = __webpack_require__(9);
  50892. var selector = __webpack_require__(351);
  50893. var throttle = __webpack_require__(81);
  50894. var BrushTargetManager = __webpack_require__(352);
  50895. var STATE_LIST = ['inBrush', 'outOfBrush'];
  50896. var DISPATCH_METHOD = '__ecBrushSelect';
  50897. var DISPATCH_FLAG = '__ecInBrushSelectEvent';
  50898. var PRIORITY_BRUSH = echarts.PRIORITY.VISUAL.BRUSH;
  50899. /**
  50900. * Layout for visual, the priority higher than other layout, and before brush visual.
  50901. */
  50902. echarts.registerLayout(PRIORITY_BRUSH, function (ecModel, api, payload) {
  50903. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  50904. payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(
  50905. payload.key === 'brush' ? payload.brushOption : {brushType: false}
  50906. );
  50907. var brushTargetManager = brushModel.brushTargetManager = new BrushTargetManager(brushModel.option, ecModel);
  50908. brushTargetManager.setInputRanges(brushModel.areas, ecModel);
  50909. });
  50910. });
  50911. /**
  50912. * Register the visual encoding if this modules required.
  50913. */
  50914. echarts.registerVisual(PRIORITY_BRUSH, function (ecModel, api, payload) {
  50915. var brushSelected = [];
  50916. var throttleType;
  50917. var throttleDelay;
  50918. ecModel.eachComponent({mainType: 'brush'}, function (brushModel, brushIndex) {
  50919. var thisBrushSelected = {
  50920. brushId: brushModel.id,
  50921. brushIndex: brushIndex,
  50922. brushName: brushModel.name,
  50923. areas: zrUtil.clone(brushModel.areas),
  50924. selected: []
  50925. };
  50926. // Every brush component exists in event params, convenient
  50927. // for user to find by index.
  50928. brushSelected.push(thisBrushSelected);
  50929. var brushOption = brushModel.option;
  50930. var brushLink = brushOption.brushLink;
  50931. var linkedSeriesMap = [];
  50932. var selectedDataIndexForLink = [];
  50933. var rangeInfoBySeries = [];
  50934. var hasBrushExists = 0;
  50935. if (!brushIndex) { // Only the first throttle setting works.
  50936. throttleType = brushOption.throttleType;
  50937. throttleDelay = brushOption.throttleDelay;
  50938. }
  50939. // Add boundingRect and selectors to range.
  50940. var areas = zrUtil.map(brushModel.areas, function (area) {
  50941. return bindSelector(
  50942. zrUtil.defaults(
  50943. {boundingRect: boundingRectBuilders[area.brushType](area)},
  50944. area
  50945. )
  50946. );
  50947. });
  50948. var visualMappings = visualSolution.createVisualMappings(
  50949. brushModel.option, STATE_LIST, function (mappingOption) {
  50950. mappingOption.mappingMethod = 'fixed';
  50951. }
  50952. );
  50953. zrUtil.isArray(brushLink) && zrUtil.each(brushLink, function (seriesIndex) {
  50954. linkedSeriesMap[seriesIndex] = 1;
  50955. });
  50956. function linkOthers(seriesIndex) {
  50957. return brushLink === 'all' || linkedSeriesMap[seriesIndex];
  50958. }
  50959. // If no supported brush or no brush on the series,
  50960. // all visuals should be in original state.
  50961. function brushed(rangeInfoList) {
  50962. return !!rangeInfoList.length;
  50963. }
  50964. /**
  50965. * Logic for each series: (If the logic has to be modified one day, do it carefully!)
  50966. *
  50967. * ( brushed ┬ && ┬hasBrushExist ┬ && linkOthers ) => StepA: ┬record, ┬ StepB: ┬visualByRecord.
  50968. * !brushed┘ ├hasBrushExist ┤ └nothing,┘ ├visualByRecord.
  50969. * └!hasBrushExist┘ └nothing.
  50970. * ( !brushed && ┬hasBrushExist ┬ && linkOthers ) => StepA: nothing, StepB: ┬visualByRecord.
  50971. * └!hasBrushExist┘ └nothing.
  50972. * ( brushed ┬ && !linkOthers ) => StepA: nothing, StepB: ┬visualByCheck.
  50973. * !brushed┘ └nothing.
  50974. * ( !brushed && !linkOthers ) => StepA: nothing, StepB: nothing.
  50975. */
  50976. // Step A
  50977. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  50978. var rangeInfoList = rangeInfoBySeries[seriesIndex] = [];
  50979. seriesModel.subType === 'parallel'
  50980. ? stepAParallel(seriesModel, seriesIndex, rangeInfoList)
  50981. : stepAOthers(seriesModel, seriesIndex, rangeInfoList);
  50982. });
  50983. function stepAParallel(seriesModel, seriesIndex) {
  50984. var coordSys = seriesModel.coordinateSystem;
  50985. hasBrushExists |= coordSys.hasAxisBrushed();
  50986. linkOthers(seriesIndex) && coordSys.eachActiveState(
  50987. seriesModel.getData(),
  50988. function (activeState, dataIndex) {
  50989. activeState === 'active' && (selectedDataIndexForLink[dataIndex] = 1);
  50990. }
  50991. );
  50992. }
  50993. function stepAOthers(seriesModel, seriesIndex, rangeInfoList) {
  50994. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  50995. if (!selectorsByBrushType || brushModelNotControll(brushModel, seriesIndex)) {
  50996. return;
  50997. }
  50998. zrUtil.each(areas, function (area) {
  50999. selectorsByBrushType[area.brushType]
  51000. && brushModel.brushTargetManager.controlSeries(area, seriesModel, ecModel)
  51001. && rangeInfoList.push(area);
  51002. hasBrushExists |= brushed(rangeInfoList);
  51003. });
  51004. if (linkOthers(seriesIndex) && brushed(rangeInfoList)) {
  51005. var data = seriesModel.getData();
  51006. data.each(function (dataIndex) {
  51007. if (checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)) {
  51008. selectedDataIndexForLink[dataIndex] = 1;
  51009. }
  51010. });
  51011. }
  51012. }
  51013. // Step B
  51014. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  51015. var seriesBrushSelected = {
  51016. seriesId: seriesModel.id,
  51017. seriesIndex: seriesIndex,
  51018. seriesName: seriesModel.name,
  51019. dataIndex: []
  51020. };
  51021. // Every series exists in event params, convenient
  51022. // for user to find series by seriesIndex.
  51023. thisBrushSelected.selected.push(seriesBrushSelected);
  51024. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  51025. var rangeInfoList = rangeInfoBySeries[seriesIndex];
  51026. var data = seriesModel.getData();
  51027. var getValueState = linkOthers(seriesIndex)
  51028. ? function (dataIndex) {
  51029. return selectedDataIndexForLink[dataIndex]
  51030. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  51031. : 'outOfBrush';
  51032. }
  51033. : function (dataIndex) {
  51034. return checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)
  51035. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  51036. : 'outOfBrush';
  51037. };
  51038. // If no supported brush or no brush, all visuals are in original state.
  51039. (linkOthers(seriesIndex) ? hasBrushExists : brushed(rangeInfoList))
  51040. && visualSolution.applyVisual(
  51041. STATE_LIST, visualMappings, data, getValueState
  51042. );
  51043. });
  51044. });
  51045. dispatchAction(api, throttleType, throttleDelay, brushSelected, payload);
  51046. });
  51047. function dispatchAction(api, throttleType, throttleDelay, brushSelected, payload) {
  51048. // This event will not be triggered when `setOpion`, otherwise dead lock may
  51049. // triggered when do `setOption` in event listener, which we do not find
  51050. // satisfactory way to solve yet. Some considered resolutions:
  51051. // (a) Diff with prevoius selected data ant only trigger event when changed.
  51052. // But store previous data and diff precisely (i.e., not only by dataIndex, but
  51053. // also detect value changes in selected data) might bring complexity or fragility.
  51054. // (b) Use spectial param like `silent` to suppress event triggering.
  51055. // But such kind of volatile param may be weird in `setOption`.
  51056. if (!payload) {
  51057. return;
  51058. }
  51059. var zr = api.getZr();
  51060. if (zr[DISPATCH_FLAG]) {
  51061. return;
  51062. }
  51063. if (!zr[DISPATCH_METHOD]) {
  51064. zr[DISPATCH_METHOD] = doDispatch;
  51065. }
  51066. var fn = throttle.createOrUpdate(zr, DISPATCH_METHOD, throttleDelay, throttleType);
  51067. fn(api, brushSelected);
  51068. }
  51069. function doDispatch(api, brushSelected) {
  51070. if (!api.isDisposed()) {
  51071. var zr = api.getZr();
  51072. zr[DISPATCH_FLAG] = true;
  51073. api.dispatchAction({
  51074. type: 'brushSelect',
  51075. batch: brushSelected
  51076. });
  51077. zr[DISPATCH_FLAG] = false;
  51078. }
  51079. }
  51080. function checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex) {
  51081. for (var i = 0, len = rangeInfoList.length; i < len; i++) {
  51082. var area = rangeInfoList[i];
  51083. if (selectorsByBrushType[area.brushType](
  51084. dataIndex, data, area.selectors, area
  51085. )) {
  51086. return true;
  51087. }
  51088. }
  51089. }
  51090. function getSelectorsByBrushType(seriesModel) {
  51091. var brushSelector = seriesModel.brushSelector;
  51092. if (zrUtil.isString(brushSelector)) {
  51093. var sels = [];
  51094. zrUtil.each(selector, function (selectorsByElementType, brushType) {
  51095. sels[brushType] = function (dataIndex, data, selectors, area) {
  51096. var itemLayout = data.getItemLayout(dataIndex);
  51097. return selectorsByElementType[brushSelector](itemLayout, selectors, area);
  51098. };
  51099. });
  51100. return sels;
  51101. }
  51102. else if (zrUtil.isFunction(brushSelector)) {
  51103. var bSelector = {};
  51104. zrUtil.each(selector, function (sel, brushType) {
  51105. bSelector[brushType] = brushSelector;
  51106. });
  51107. return bSelector;
  51108. }
  51109. return brushSelector;
  51110. }
  51111. function brushModelNotControll(brushModel, seriesIndex) {
  51112. var seriesIndices = brushModel.option.seriesIndex;
  51113. return seriesIndices != null
  51114. && seriesIndices !== 'all'
  51115. && (
  51116. zrUtil.isArray(seriesIndices)
  51117. ? zrUtil.indexOf(seriesIndices, seriesIndex) < 0
  51118. : seriesIndex !== seriesIndices
  51119. );
  51120. }
  51121. function bindSelector(area) {
  51122. var selectors = area.selectors = {};
  51123. zrUtil.each(selector[area.brushType], function (selFn, elType) {
  51124. // Do not use function binding or curry for performance.
  51125. selectors[elType] = function (itemLayout) {
  51126. return selFn(itemLayout, selectors, area);
  51127. };
  51128. });
  51129. return area;
  51130. }
  51131. var boundingRectBuilders = {
  51132. lineX: zrUtil.noop,
  51133. lineY: zrUtil.noop,
  51134. rect: function (area) {
  51135. return getBoundingRectFromMinMax(area.range);
  51136. },
  51137. polygon: function (area) {
  51138. var minMax;
  51139. var range = area.range;
  51140. for (var i = 0, len = range.length; i < len; i++) {
  51141. minMax = minMax || [[Infinity, -Infinity], [Infinity, -Infinity]];
  51142. var rg = range[i];
  51143. rg[0] < minMax[0][0] && (minMax[0][0] = rg[0]);
  51144. rg[0] > minMax[0][1] && (minMax[0][1] = rg[0]);
  51145. rg[1] < minMax[1][0] && (minMax[1][0] = rg[1]);
  51146. rg[1] > minMax[1][1] && (minMax[1][1] = rg[1]);
  51147. }
  51148. return minMax && getBoundingRectFromMinMax(minMax);
  51149. }
  51150. };
  51151. function getBoundingRectFromMinMax(minMax) {
  51152. return new BoundingRect(
  51153. minMax[0][0],
  51154. minMax[1][0],
  51155. minMax[0][1] - minMax[0][0],
  51156. minMax[1][1] - minMax[1][0]
  51157. );
  51158. }
  51159. /***/ },
  51160. /* 350 */
  51161. /***/ function(module, exports, __webpack_require__) {
  51162. /**
  51163. * @file Visual solution, for consistent option specification.
  51164. */
  51165. var zrUtil = __webpack_require__(4);
  51166. var VisualMapping = __webpack_require__(203);
  51167. var each = zrUtil.each;
  51168. function hasKeys(obj) {
  51169. if (obj) {
  51170. for (var name in obj){
  51171. if (obj.hasOwnProperty(name)) {
  51172. return true;
  51173. }
  51174. }
  51175. }
  51176. }
  51177. var visualSolution = {
  51178. /**
  51179. * @param {Object} option
  51180. * @param {Array.<string>} stateList
  51181. * @param {Function} [supplementVisualOption]
  51182. * @return {Object} visualMappings <state, <visualType, module:echarts/visual/VisualMapping>>
  51183. */
  51184. createVisualMappings: function (option, stateList, supplementVisualOption) {
  51185. var visualMappings = {};
  51186. each(stateList, function (state) {
  51187. var mappings = visualMappings[state] = createMappings();
  51188. each(option[state], function (visualData, visualType) {
  51189. if (!VisualMapping.isValidType(visualType)) {
  51190. return;
  51191. }
  51192. var mappingOption = {
  51193. type: visualType,
  51194. visual: visualData
  51195. };
  51196. supplementVisualOption && supplementVisualOption(mappingOption, state);
  51197. mappings[visualType] = new VisualMapping(mappingOption);
  51198. // Prepare a alpha for opacity, for some case that opacity
  51199. // is not supported, such as rendering using gradient color.
  51200. if (visualType === 'opacity') {
  51201. mappingOption = zrUtil.clone(mappingOption);
  51202. mappingOption.type = 'colorAlpha';
  51203. mappings.__hidden.__alphaForOpacity = new VisualMapping(mappingOption);
  51204. }
  51205. });
  51206. });
  51207. return visualMappings;
  51208. function createMappings() {
  51209. var Creater = function () {};
  51210. // Make sure hidden fields will not be visited by
  51211. // object iteration (with hasOwnProperty checking).
  51212. Creater.prototype.__hidden = Creater.prototype;
  51213. var obj = new Creater();
  51214. return obj;
  51215. }
  51216. },
  51217. /**
  51218. * @param {Object} thisOption
  51219. * @param {Object} newOption
  51220. * @param {Array.<string>} keys
  51221. */
  51222. replaceVisualOption: function (thisOption, newOption, keys) {
  51223. // Visual attributes merge is not supported, otherwise it
  51224. // brings overcomplicated merge logic. See #2853. So if
  51225. // newOption has anyone of these keys, all of these keys
  51226. // will be reset. Otherwise, all keys remain.
  51227. var has;
  51228. zrUtil.each(keys, function (key) {
  51229. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  51230. has = true;
  51231. }
  51232. });
  51233. has && zrUtil.each(keys, function (key) {
  51234. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  51235. thisOption[key] = zrUtil.clone(newOption[key]);
  51236. }
  51237. else {
  51238. delete thisOption[key];
  51239. }
  51240. });
  51241. },
  51242. /**
  51243. * @param {Array.<string>} stateList
  51244. * @param {Object} visualMappings <state, Object.<visualType, module:echarts/visual/VisualMapping>>
  51245. * @param {module:echarts/data/List} list
  51246. * @param {Function} getValueState param: valueOrIndex, return: state.
  51247. * @param {object} [scope] Scope for getValueState
  51248. * @param {string} [dimension] Concrete dimension, if used.
  51249. */
  51250. applyVisual: function (stateList, visualMappings, data, getValueState, scope, dimension) {
  51251. var visualTypesMap = {};
  51252. zrUtil.each(stateList, function (state) {
  51253. var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
  51254. visualTypesMap[state] = visualTypes;
  51255. });
  51256. var dataIndex;
  51257. function getVisual(key) {
  51258. return data.getItemVisual(dataIndex, key);
  51259. }
  51260. function setVisual(key, value) {
  51261. data.setItemVisual(dataIndex, key, value);
  51262. }
  51263. if (dimension == null) {
  51264. data.each(eachItem, true);
  51265. }
  51266. else {
  51267. data.each([dimension], eachItem, true);
  51268. }
  51269. function eachItem(valueOrIndex, index) {
  51270. dataIndex = dimension == null ? valueOrIndex : index;
  51271. var rawDataItem = data.getRawDataItem(dataIndex);
  51272. // Consider performance
  51273. if (rawDataItem && rawDataItem.visualMap === false) {
  51274. return;
  51275. }
  51276. var valueState = getValueState.call(scope, valueOrIndex);
  51277. var mappings = visualMappings[valueState];
  51278. var visualTypes = visualTypesMap[valueState];
  51279. for (var i = 0, len = visualTypes.length; i < len; i++) {
  51280. var type = visualTypes[i];
  51281. mappings[type] && mappings[type].applyVisual(
  51282. valueOrIndex, getVisual, setVisual
  51283. );
  51284. }
  51285. }
  51286. }
  51287. };
  51288. module.exports = visualSolution;
  51289. /***/ },
  51290. /* 351 */
  51291. /***/ function(module, exports, __webpack_require__) {
  51292. var polygonContain = __webpack_require__(175).contain;
  51293. var BoundingRect = __webpack_require__(9);
  51294. // Key of the first level is brushType: `line`, `rect`, `polygon`.
  51295. // Key of the second level is chart element type: `point`, `rect`.
  51296. // See moudule:echarts/component/helper/BrushController
  51297. // function param:
  51298. // {Object} itemLayout fetch from data.getItemLayout(dataIndex)
  51299. // {Object} selectors {point: selector, rect: selector, ...}
  51300. // {Object} area {range: [[], [], ..], boudingRect}
  51301. // function return:
  51302. // {boolean} Whether in the given brush.
  51303. var selector = {
  51304. lineX: getLineSelectors(0),
  51305. lineY: getLineSelectors(1),
  51306. rect: {
  51307. point: function (itemLayout, selectors, area) {
  51308. return area.boundingRect.contain(itemLayout[0], itemLayout[1]);
  51309. },
  51310. rect: function (itemLayout, selectors, area) {
  51311. return area.boundingRect.intersect(itemLayout);
  51312. }
  51313. },
  51314. polygon: {
  51315. point: function (itemLayout, selectors, area) {
  51316. return area.boundingRect.contain(itemLayout[0], itemLayout[1])
  51317. && polygonContain(area.range, itemLayout[0], itemLayout[1]);
  51318. },
  51319. rect: function (itemLayout, selectors, area) {
  51320. var points = area.range;
  51321. if (points.length <= 1) {
  51322. return false;
  51323. }
  51324. var x = itemLayout.x;
  51325. var y = itemLayout.y;
  51326. var width = itemLayout.width;
  51327. var height = itemLayout.height;
  51328. var p = points[0];
  51329. if (polygonContain(points, x, y)
  51330. || polygonContain(points, x + width, y)
  51331. || polygonContain(points, x, y + height)
  51332. || polygonContain(points, x + width, y + height)
  51333. || BoundingRect.create(itemLayout).contain(p[0], p[1])
  51334. || lineIntersectPolygon(x, y, x + width, y, points)
  51335. || lineIntersectPolygon(x, y, x, y + height, points)
  51336. || lineIntersectPolygon(x + width, y, x + width, y + height, points)
  51337. || lineIntersectPolygon(x, y + height, x + width, y + height, points)
  51338. ) {
  51339. return true;
  51340. }
  51341. }
  51342. }
  51343. };
  51344. function getLineSelectors(xyIndex) {
  51345. var xy = ['x', 'y'];
  51346. var wh = ['width', 'height'];
  51347. return {
  51348. point: function (itemLayout, selectors, area) {
  51349. var range = area.range;
  51350. var p = itemLayout[xyIndex];
  51351. return inLineRange(p, range);
  51352. },
  51353. rect: function (itemLayout, selectors, area) {
  51354. var range = area.range;
  51355. var layoutRange = [
  51356. itemLayout[xy[xyIndex]],
  51357. itemLayout[xy[xyIndex]] + itemLayout[wh[xyIndex]]
  51358. ];
  51359. layoutRange[1] < layoutRange[0] && layoutRange.reverse();
  51360. return inLineRange(layoutRange[0], range)
  51361. || inLineRange(layoutRange[1], range)
  51362. || inLineRange(range[0], layoutRange)
  51363. || inLineRange(range[1], layoutRange);
  51364. }
  51365. };
  51366. }
  51367. function inLineRange(p, range) {
  51368. return range[0] <= p && p <= range[1];
  51369. }
  51370. function lineIntersectPolygon(lx, ly, l2x, l2y, points) {
  51371. for (var i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
  51372. var p = points[i];
  51373. if (lineIntersect(lx, ly, l2x, l2y, p[0], p[1], p2[0], p2[1])) {
  51374. return true;
  51375. }
  51376. p2 = p;
  51377. }
  51378. }
  51379. // Code from <http://blog.csdn.net/rickliuxiao/article/details/6259322> with some fix.
  51380. // See <https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection>
  51381. function lineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
  51382. var delta = determinant(a2x - a1x, b1x - b2x, a2y - a1y, b1y - b2y);
  51383. if (nearZero(delta)) { // parallel
  51384. return false;
  51385. }
  51386. var namenda = determinant(b1x - a1x, b1x - b2x, b1y - a1y, b1y - b2y) / delta;
  51387. if (namenda < 0 || namenda > 1) {
  51388. return false;
  51389. }
  51390. var miu = determinant(a2x - a1x, b1x - a1x, a2y - a1y, b1y - a1y) / delta;
  51391. if (miu < 0 || miu > 1) {
  51392. return false;
  51393. }
  51394. return true;
  51395. }
  51396. function nearZero(val) {
  51397. return val <= (1e-6) && val >= -(1e-6);
  51398. }
  51399. function determinant(v1, v2, v3, v4) {
  51400. return v1 * v4 - v2 * v3;
  51401. }
  51402. module.exports = selector;
  51403. /***/ },
  51404. /* 352 */
  51405. /***/ function(module, exports, __webpack_require__) {
  51406. var zrUtil = __webpack_require__(4);
  51407. var graphic = __webpack_require__(18);
  51408. var modelUtil = __webpack_require__(5);
  51409. var brushHelper = __webpack_require__(246);
  51410. var each = zrUtil.each;
  51411. var indexOf = zrUtil.indexOf;
  51412. var curry = zrUtil.curry;
  51413. var COORD_CONVERTS = ['dataToPoint', 'pointToData'];
  51414. // FIXME
  51415. // how to genarialize to more coordinate systems.
  51416. var INCLUDE_FINDER_MAIN_TYPES = [
  51417. 'grid', 'xAxis', 'yAxis', 'geo', 'graph',
  51418. 'polar', 'radiusAxis', 'angleAxis', 'bmap'
  51419. ];
  51420. /**
  51421. * [option in constructor]:
  51422. * {
  51423. * Index/Id/Name of geo, xAxis, yAxis, grid: See util/model#parseFinder.
  51424. * }
  51425. *
  51426. *
  51427. * [targetInfo]:
  51428. *
  51429. * There can be multiple axes in a single targetInfo. Consider the case
  51430. * of `grid` component, a targetInfo represents a grid which contains one or more
  51431. * cartesian and one or more axes. And consider the case of parallel system,
  51432. * which has multiple axes in a coordinate system.
  51433. * Can be {
  51434. * panelId: ...,
  51435. * coordSys: <a representitive cartesian in grid (first cartesian by default)>,
  51436. * coordSyses: all cartesians.
  51437. * gridModel: <grid component>
  51438. * xAxes: correspond to coordSyses on index
  51439. * yAxes: correspond to coordSyses on index
  51440. * }
  51441. * or {
  51442. * panelId: ...,
  51443. * coordSys: <geo coord sys>
  51444. * coordSyses: [<geo coord sys>]
  51445. * geoModel: <geo component>
  51446. * }
  51447. *
  51448. *
  51449. * [panelOpt]:
  51450. *
  51451. * Make from targetInfo. Input to BrushController.
  51452. * {
  51453. * panelId: ...,
  51454. * rect: ...
  51455. * }
  51456. *
  51457. *
  51458. * [area]:
  51459. *
  51460. * Generated by BrushController or user input.
  51461. * {
  51462. * panelId: Used to locate coordInfo directly. If user inpput, no panelId.
  51463. * brushType: determine how to convert to/from coord('rect' or 'polygon' or 'lineX/Y').
  51464. * Index/Id/Name of geo, xAxis, yAxis, grid: See util/model#parseFinder.
  51465. * range: pixel range.
  51466. * coordRange: representitive coord range (the first one of coordRanges).
  51467. * coordRanges: <Array> coord ranges, used in multiple cartesian in one grid.
  51468. * }
  51469. */
  51470. /**
  51471. * @param {Object} option contains Index/Id/Name of xAxis/yAxis/geo/grid
  51472. * Each can be {number|Array.<number>}. like: {xAxisIndex: [3, 4]}
  51473. * @param {module:echarts/model/Global} ecModel
  51474. * @param {Object} [opt]
  51475. * @param {Array.<string>} [opt.include] include coordinate system types.
  51476. */
  51477. function BrushTargetManager(option, ecModel, opt) {
  51478. /**
  51479. * @private
  51480. * @type {Array.<Object>}
  51481. */
  51482. var targetInfoList = this._targetInfoList = [];
  51483. var info = {};
  51484. var foundCpts = parseFinder(ecModel, option);
  51485. each(targetInfoBuilders, function (builder, type) {
  51486. if (!opt || !opt.include || indexOf(opt.include, type) >= 0) {
  51487. builder(foundCpts, targetInfoList, info);
  51488. }
  51489. });
  51490. }
  51491. var proto = BrushTargetManager.prototype;
  51492. proto.setOutputRanges = function (areas, ecModel) {
  51493. this.matchOutputRanges(areas, ecModel, function (area, coordRange, coordSys) {
  51494. (area.coordRanges || (area.coordRanges = [])).push(coordRange);
  51495. // area.coordRange is the first of area.coordRanges
  51496. if (!area.coordRange) {
  51497. area.coordRange = coordRange;
  51498. // In 'category' axis, coord to pixel is not reversible, so we can not
  51499. // rebuild range by coordRange accrately, which may bring trouble when
  51500. // brushing only one item. So we use __rangeOffset to rebuilding range
  51501. // by coordRange. And this it only used in brush component so it is no
  51502. // need to be adapted to coordRanges.
  51503. var result = coordConvert[area.brushType](0, coordSys, coordRange);
  51504. area.__rangeOffset = {
  51505. offset: diffProcessor[area.brushType](result.values, area.range, [1, 1]),
  51506. xyMinMax: result.xyMinMax
  51507. };
  51508. }
  51509. });
  51510. };
  51511. proto.matchOutputRanges = function (areas, ecModel, cb) {
  51512. each(areas, function (area) {
  51513. var targetInfo = this.findTargetInfo(area, ecModel);
  51514. if (targetInfo && targetInfo !== true) {
  51515. zrUtil.each(
  51516. targetInfo.coordSyses,
  51517. function (coordSys) {
  51518. var result = coordConvert[area.brushType](1, coordSys, area.range);
  51519. cb(area, result.values, coordSys, ecModel);
  51520. }
  51521. );
  51522. }
  51523. }, this);
  51524. };
  51525. proto.setInputRanges = function (areas, ecModel) {
  51526. each(areas, function (area) {
  51527. var targetInfo = this.findTargetInfo(area, ecModel);
  51528. if (true) {
  51529. zrUtil.assert(
  51530. !targetInfo || targetInfo === true || area.coordRange,
  51531. 'coordRange must be specified when coord index specified.'
  51532. );
  51533. zrUtil.assert(
  51534. !targetInfo || targetInfo !== true || area.range,
  51535. 'range must be specified in global brush.'
  51536. );
  51537. }
  51538. area.range = area.range || [];
  51539. // convert coordRange to global range and set panelId.
  51540. if (targetInfo && targetInfo !== true) {
  51541. area.panelId = targetInfo.panelId;
  51542. // (1) area.range shoule always be calculate from coordRange but does
  51543. // not keep its original value, for the sake of the dataZoom scenario,
  51544. // where area.coordRange remains unchanged but area.range may be changed.
  51545. // (2) Only support converting one coordRange to pixel range in brush
  51546. // component. So do not consider `coordRanges`.
  51547. // (3) About __rangeOffset, see comment above.
  51548. var result = coordConvert[area.brushType](0, targetInfo.coordSys, area.coordRange);
  51549. var rangeOffset = area.__rangeOffset;
  51550. area.range = rangeOffset
  51551. ? diffProcessor[area.brushType](
  51552. result.values,
  51553. rangeOffset.offset,
  51554. getScales(result.xyMinMax, rangeOffset.xyMinMax)
  51555. )
  51556. : result.values;
  51557. }
  51558. }, this);
  51559. };
  51560. proto.makePanelOpts = function (api, getDefaultBrushType) {
  51561. return zrUtil.map(this._targetInfoList, function (targetInfo) {
  51562. var rect = targetInfo.getPanelRect();
  51563. return {
  51564. panelId: targetInfo.panelId,
  51565. defaultBrushType: getDefaultBrushType && getDefaultBrushType(targetInfo),
  51566. clipPath: brushHelper.makeRectPanelClipPath(rect),
  51567. isTargetByCursor: brushHelper.makeRectIsTargetByCursor(
  51568. rect, api, targetInfo.coordSysModel
  51569. ),
  51570. getLinearBrushOtherExtent: brushHelper.makeLinearBrushOtherExtent(rect)
  51571. };
  51572. });
  51573. };
  51574. proto.controlSeries = function (area, seriesModel, ecModel) {
  51575. // Check whether area is bound in coord, and series do not belong to that coord.
  51576. // If do not do this check, some brush (like lineX) will controll all axes.
  51577. var targetInfo = this.findTargetInfo(area, ecModel);
  51578. return targetInfo === true || (
  51579. targetInfo && indexOf(targetInfo.coordSyses, seriesModel.coordinateSystem) >= 0
  51580. );
  51581. };
  51582. /**
  51583. * If return Object, a coord found.
  51584. * If reutrn true, global found.
  51585. * Otherwise nothing found.
  51586. *
  51587. * @param {Object} area
  51588. * @param {Array} targetInfoList
  51589. * @return {Obejct|boolean}
  51590. */
  51591. proto.findTargetInfo = function (area, ecModel) {
  51592. var targetInfoList = this._targetInfoList;
  51593. var foundCpts = parseFinder(ecModel, area);
  51594. for (var i = 0; i < targetInfoList.length; i++) {
  51595. var targetInfo = targetInfoList[i];
  51596. var areaPanelId = area.panelId;
  51597. if (areaPanelId) {
  51598. if (targetInfo.panelId === areaPanelId) {
  51599. return targetInfo;
  51600. }
  51601. }
  51602. else {
  51603. for (var i = 0; i < targetInfoMatchers.length; i++) {
  51604. if (targetInfoMatchers[i](foundCpts, targetInfo)) {
  51605. return targetInfo;
  51606. }
  51607. }
  51608. }
  51609. }
  51610. return true;
  51611. };
  51612. function formatMinMax(minMax) {
  51613. minMax[0] > minMax[1] && minMax.reverse();
  51614. return minMax;
  51615. }
  51616. function parseFinder(ecModel, option) {
  51617. return modelUtil.parseFinder(
  51618. ecModel, option, {includeMainTypes: INCLUDE_FINDER_MAIN_TYPES}
  51619. );
  51620. }
  51621. var targetInfoBuilders = {
  51622. grid: function (foundCpts, targetInfoList) {
  51623. var xAxisModels = foundCpts.xAxisModels;
  51624. var yAxisModels = foundCpts.yAxisModels;
  51625. var gridModels = foundCpts.gridModels;
  51626. // Remove duplicated.
  51627. var gridModelMap = zrUtil.createHashMap();
  51628. var xAxesHas = {};
  51629. var yAxesHas = {};
  51630. if (!xAxisModels && !yAxisModels && !gridModels) {
  51631. return;
  51632. }
  51633. each(xAxisModels, function (axisModel) {
  51634. var gridModel = axisModel.axis.grid.model;
  51635. gridModelMap.set(gridModel.id, gridModel);
  51636. xAxesHas[gridModel.id] = true;
  51637. });
  51638. each(yAxisModels, function (axisModel) {
  51639. var gridModel = axisModel.axis.grid.model;
  51640. gridModelMap.set(gridModel.id, gridModel);
  51641. yAxesHas[gridModel.id] = true;
  51642. });
  51643. each(gridModels, function (gridModel) {
  51644. gridModelMap.set(gridModel.id, gridModel);
  51645. xAxesHas[gridModel.id] = true;
  51646. yAxesHas[gridModel.id] = true;
  51647. });
  51648. gridModelMap.each(function (gridModel) {
  51649. var grid = gridModel.coordinateSystem;
  51650. var cartesians = [];
  51651. each(grid.getCartesians(), function (cartesian, index) {
  51652. if (indexOf(xAxisModels, cartesian.getAxis('x').model) >= 0
  51653. || indexOf(yAxisModels, cartesian.getAxis('y').model) >= 0
  51654. ) {
  51655. cartesians.push(cartesian);
  51656. }
  51657. });
  51658. targetInfoList.push({
  51659. panelId: 'grid--' + gridModel.id,
  51660. gridModel: gridModel,
  51661. coordSysModel: gridModel,
  51662. // Use the first one as the representitive coordSys.
  51663. coordSys: cartesians[0],
  51664. coordSyses: cartesians,
  51665. getPanelRect: panelRectBuilder.grid,
  51666. xAxisDeclared: xAxesHas[gridModel.id],
  51667. yAxisDeclared: yAxesHas[gridModel.id]
  51668. });
  51669. });
  51670. },
  51671. geo: function (foundCpts, targetInfoList) {
  51672. each(foundCpts.geoModels, function (geoModel) {
  51673. var coordSys = geoModel.coordinateSystem;
  51674. targetInfoList.push({
  51675. panelId: 'geo--' + geoModel.id,
  51676. geoModel: geoModel,
  51677. coordSysModel: geoModel,
  51678. coordSys: coordSys,
  51679. coordSyses: [coordSys],
  51680. getPanelRect: panelRectBuilder.geo
  51681. });
  51682. });
  51683. }
  51684. };
  51685. var targetInfoMatchers = [
  51686. // grid
  51687. function (foundCpts, targetInfo) {
  51688. var xAxisModel = foundCpts.xAxisModel;
  51689. var yAxisModel = foundCpts.yAxisModel;
  51690. var gridModel = foundCpts.gridModel;
  51691. !gridModel && xAxisModel && (gridModel = xAxisModel.axis.grid.model);
  51692. !gridModel && yAxisModel && (gridModel = yAxisModel.axis.grid.model);
  51693. return gridModel && gridModel === targetInfo.gridModel;
  51694. },
  51695. // geo
  51696. function (foundCpts, targetInfo) {
  51697. var geoModel = foundCpts.geoModel;
  51698. return geoModel && geoModel === targetInfo.geoModel;
  51699. }
  51700. ];
  51701. var panelRectBuilder = {
  51702. grid: function () {
  51703. // grid is not Transformable.
  51704. return this.coordSys.grid.getRect().clone();
  51705. },
  51706. geo: function () {
  51707. var coordSys = this.coordSys;
  51708. var rect = coordSys.getBoundingRect().clone();
  51709. // geo roam and zoom transform
  51710. rect.applyTransform(graphic.getTransform(coordSys));
  51711. return rect;
  51712. }
  51713. };
  51714. var coordConvert = {
  51715. lineX: curry(axisConvert, 0),
  51716. lineY: curry(axisConvert, 1),
  51717. rect: function (to, coordSys, rangeOrCoordRange) {
  51718. var xminymin = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]]);
  51719. var xmaxymax = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]]);
  51720. var values = [
  51721. formatMinMax([xminymin[0], xmaxymax[0]]),
  51722. formatMinMax([xminymin[1], xmaxymax[1]])
  51723. ];
  51724. return {values: values, xyMinMax: values};
  51725. },
  51726. polygon: function (to, coordSys, rangeOrCoordRange) {
  51727. var xyMinMax = [[Infinity, -Infinity], [Infinity, -Infinity]];
  51728. var values = zrUtil.map(rangeOrCoordRange, function (item) {
  51729. var p = coordSys[COORD_CONVERTS[to]](item);
  51730. xyMinMax[0][0] = Math.min(xyMinMax[0][0], p[0]);
  51731. xyMinMax[1][0] = Math.min(xyMinMax[1][0], p[1]);
  51732. xyMinMax[0][1] = Math.max(xyMinMax[0][1], p[0]);
  51733. xyMinMax[1][1] = Math.max(xyMinMax[1][1], p[1]);
  51734. return p;
  51735. });
  51736. return {values: values, xyMinMax: xyMinMax};
  51737. }
  51738. };
  51739. function axisConvert(axisNameIndex, to, coordSys, rangeOrCoordRange) {
  51740. if (true) {
  51741. zrUtil.assert(
  51742. coordSys.type === 'cartesian2d',
  51743. 'lineX/lineY brush is available only in cartesian2d.'
  51744. );
  51745. }
  51746. var axis = coordSys.getAxis(['x', 'y'][axisNameIndex]);
  51747. var values = formatMinMax(zrUtil.map([0, 1], function (i) {
  51748. return to
  51749. ? axis.coordToData(axis.toLocalCoord(rangeOrCoordRange[i]))
  51750. : axis.toGlobalCoord(axis.dataToCoord(rangeOrCoordRange[i]));
  51751. }));
  51752. var xyMinMax = [];
  51753. xyMinMax[axisNameIndex] = values;
  51754. xyMinMax[1 - axisNameIndex] = [NaN, NaN];
  51755. return {values: values, xyMinMax: xyMinMax};
  51756. }
  51757. var diffProcessor = {
  51758. lineX: curry(axisDiffProcessor, 0),
  51759. lineY: curry(axisDiffProcessor, 1),
  51760. rect: function (values, refer, scales) {
  51761. return [
  51762. [values[0][0] - scales[0] * refer[0][0], values[0][1] - scales[0] * refer[0][1]],
  51763. [values[1][0] - scales[1] * refer[1][0], values[1][1] - scales[1] * refer[1][1]]
  51764. ];
  51765. },
  51766. polygon: function (values, refer, scales) {
  51767. return zrUtil.map(values, function (item, idx) {
  51768. return [item[0] - scales[0] * refer[idx][0], item[1] - scales[1] * refer[idx][1]];
  51769. });
  51770. }
  51771. };
  51772. function axisDiffProcessor(axisNameIndex, values, refer, scales) {
  51773. return [
  51774. values[0] - scales[axisNameIndex] * refer[0],
  51775. values[1] - scales[axisNameIndex] * refer[1]
  51776. ];
  51777. }
  51778. // We have to process scale caused by dataZoom manually,
  51779. // although it might be not accurate.
  51780. function getScales(xyMinMaxCurr, xyMinMaxOrigin) {
  51781. var sizeCurr = getSize(xyMinMaxCurr);
  51782. var sizeOrigin = getSize(xyMinMaxOrigin);
  51783. var scales = [sizeCurr[0] / sizeOrigin[0], sizeCurr[1] / sizeOrigin[1]];
  51784. isNaN(scales[0]) && (scales[0] = 1);
  51785. isNaN(scales[1]) && (scales[1] = 1);
  51786. return scales;
  51787. }
  51788. function getSize(xyMinMax) {
  51789. return xyMinMax
  51790. ? [xyMinMax[0][1] - xyMinMax[0][0], xyMinMax[1][1] - xyMinMax[1][0]]
  51791. : [NaN, NaN];
  51792. }
  51793. module.exports = BrushTargetManager;
  51794. /***/ },
  51795. /* 353 */
  51796. /***/ function(module, exports, __webpack_require__) {
  51797. /**
  51798. * @file Brush model
  51799. */
  51800. var echarts = __webpack_require__(1);
  51801. var zrUtil = __webpack_require__(4);
  51802. var visualSolution = __webpack_require__(350);
  51803. var Model = __webpack_require__(12);
  51804. var DEFAULT_OUT_OF_BRUSH_COLOR = ['#ddd'];
  51805. var BrushModel = echarts.extendComponentModel({
  51806. type: 'brush',
  51807. dependencies: ['geo', 'grid', 'xAxis', 'yAxis', 'parallel', 'series'],
  51808. /**
  51809. * @protected
  51810. */
  51811. defaultOption: {
  51812. // inBrush: null,
  51813. // outOfBrush: null,
  51814. toolbox: null, // Default value see preprocessor.
  51815. brushLink: null, // Series indices array, broadcast using dataIndex.
  51816. // or 'all', which means all series. 'none' or null means no series.
  51817. seriesIndex: 'all', // seriesIndex array, specify series controlled by this brush component.
  51818. geoIndex: null, //
  51819. xAxisIndex: null,
  51820. yAxisIndex: null,
  51821. brushType: 'rect', // Default brushType, see BrushController.
  51822. brushMode: 'single', // Default brushMode, 'single' or 'multiple'
  51823. transformable: true, // Default transformable.
  51824. brushStyle: { // Default brushStyle
  51825. borderWidth: 1,
  51826. color: 'rgba(120,140,180,0.3)',
  51827. borderColor: 'rgba(120,140,180,0.8)'
  51828. },
  51829. throttleType: 'fixRate',// Throttle in brushSelected event. 'fixRate' or 'debounce'.
  51830. // If null, no throttle. Valid only in the first brush component
  51831. throttleDelay: 0, // Unit: ms, 0 means every event will be triggered.
  51832. // FIXME
  51833. // 试验效果
  51834. removeOnClick: true,
  51835. z: 10000
  51836. },
  51837. /**
  51838. * @readOnly
  51839. * @type {Array.<Object>}
  51840. */
  51841. areas: [],
  51842. /**
  51843. * Current activated brush type.
  51844. * If null, brush is inactived.
  51845. * see module:echarts/component/helper/BrushController
  51846. * @readOnly
  51847. * @type {string}
  51848. */
  51849. brushType: null,
  51850. /**
  51851. * Current brush opt.
  51852. * see module:echarts/component/helper/BrushController
  51853. * @readOnly
  51854. * @type {Object}
  51855. */
  51856. brushOption: {},
  51857. /**
  51858. * @readOnly
  51859. * @type {Array.<Object>}
  51860. */
  51861. coordInfoList: [],
  51862. optionUpdated: function (newOption, isInit) {
  51863. var thisOption = this.option;
  51864. !isInit && visualSolution.replaceVisualOption(
  51865. thisOption, newOption, ['inBrush', 'outOfBrush']
  51866. );
  51867. thisOption.inBrush = thisOption.inBrush || {};
  51868. // Always give default visual, consider setOption at the second time.
  51869. thisOption.outOfBrush = thisOption.outOfBrush || {color: DEFAULT_OUT_OF_BRUSH_COLOR};
  51870. },
  51871. /**
  51872. * If ranges is null/undefined, range state remain.
  51873. *
  51874. * @param {Array.<Object>} [ranges]
  51875. */
  51876. setAreas: function (areas) {
  51877. if (true) {
  51878. zrUtil.assert(zrUtil.isArray(areas));
  51879. zrUtil.each(areas, function (area) {
  51880. zrUtil.assert(area.brushType, 'Illegal areas');
  51881. });
  51882. }
  51883. // If ranges is null/undefined, range state remain.
  51884. // This helps user to dispatchAction({type: 'brush'}) with no areas
  51885. // set but just want to get the current brush select info from a `brush` event.
  51886. if (!areas) {
  51887. return;
  51888. }
  51889. this.areas = zrUtil.map(areas, function (area) {
  51890. return generateBrushOption(this.option, area);
  51891. }, this);
  51892. },
  51893. /**
  51894. * see module:echarts/component/helper/BrushController
  51895. * @param {Object} brushOption
  51896. */
  51897. setBrushOption: function (brushOption) {
  51898. this.brushOption = generateBrushOption(this.option, brushOption);
  51899. this.brushType = this.brushOption.brushType;
  51900. }
  51901. });
  51902. function generateBrushOption(option, brushOption) {
  51903. return zrUtil.merge(
  51904. {
  51905. brushType: option.brushType,
  51906. brushMode: option.brushMode,
  51907. transformable: option.transformable,
  51908. brushStyle: new Model(option.brushStyle).getItemStyle(),
  51909. removeOnClick: option.removeOnClick,
  51910. z: option.z
  51911. },
  51912. brushOption,
  51913. true
  51914. );
  51915. }
  51916. module.exports = BrushModel;
  51917. /***/ },
  51918. /* 354 */
  51919. /***/ function(module, exports, __webpack_require__) {
  51920. var zrUtil = __webpack_require__(4);
  51921. var BrushController = __webpack_require__(245);
  51922. var echarts = __webpack_require__(1);
  51923. module.exports = echarts.extendComponentView({
  51924. type: 'brush',
  51925. init: function (ecModel, api) {
  51926. /**
  51927. * @readOnly
  51928. * @type {module:echarts/model/Global}
  51929. */
  51930. this.ecModel = ecModel;
  51931. /**
  51932. * @readOnly
  51933. * @type {module:echarts/ExtensionAPI}
  51934. */
  51935. this.api = api;
  51936. /**
  51937. * @readOnly
  51938. * @type {module:echarts/component/brush/BrushModel}
  51939. */
  51940. this.model;
  51941. /**
  51942. * @private
  51943. * @type {module:echarts/component/helper/BrushController}
  51944. */
  51945. (this._brushController = new BrushController(api.getZr()))
  51946. .on('brush', zrUtil.bind(this._onBrush, this))
  51947. .mount();
  51948. },
  51949. /**
  51950. * @override
  51951. */
  51952. render: function (brushModel) {
  51953. this.model = brushModel;
  51954. return updateController.apply(this, arguments);
  51955. },
  51956. /**
  51957. * @override
  51958. */
  51959. updateView: updateController,
  51960. /**
  51961. * @override
  51962. */
  51963. updateLayout: updateController,
  51964. /**
  51965. * @override
  51966. */
  51967. updateVisual: updateController,
  51968. /**
  51969. * @override
  51970. */
  51971. dispose: function () {
  51972. this._brushController.dispose();
  51973. },
  51974. /**
  51975. * @private
  51976. */
  51977. _onBrush: function (areas, opt) {
  51978. var modelId = this.model.id;
  51979. this.model.brushTargetManager.setOutputRanges(areas, this.ecModel);
  51980. // Action is not dispatched on drag end, because the drag end
  51981. // emits the same params with the last drag move event, and
  51982. // may have some delay when using touch pad, which makes
  51983. // animation not smooth (when using debounce).
  51984. (!opt.isEnd || opt.removeOnClick) && this.api.dispatchAction({
  51985. type: 'brush',
  51986. brushId: modelId,
  51987. areas: zrUtil.clone(areas),
  51988. $from: modelId
  51989. });
  51990. }
  51991. });
  51992. function updateController(brushModel, ecModel, api, payload) {
  51993. // Do not update controller when drawing.
  51994. (!payload || payload.$from !== brushModel.id) && this._brushController
  51995. .setPanels(brushModel.brushTargetManager.makePanelOpts(api))
  51996. .enableBrush(brushModel.brushOption)
  51997. .updateCovers(brushModel.areas.slice());
  51998. }
  51999. /***/ },
  52000. /* 355 */
  52001. /***/ function(module, exports, __webpack_require__) {
  52002. /**
  52003. * @file Brush action
  52004. */
  52005. var echarts = __webpack_require__(1);
  52006. /**
  52007. * payload: {
  52008. * brushIndex: number, or,
  52009. * brushId: string, or,
  52010. * brushName: string,
  52011. * globalRanges: Array
  52012. * }
  52013. */
  52014. echarts.registerAction(
  52015. {type: 'brush', event: 'brush', update: 'updateView'},
  52016. function (payload, ecModel) {
  52017. ecModel.eachComponent({mainType: 'brush', query: payload}, function (brushModel) {
  52018. brushModel.setAreas(payload.areas);
  52019. });
  52020. }
  52021. );
  52022. /**
  52023. * payload: {
  52024. * brushComponents: [
  52025. * {
  52026. * brushId,
  52027. * brushIndex,
  52028. * brushName,
  52029. * series: [
  52030. * {
  52031. * seriesId,
  52032. * seriesIndex,
  52033. * seriesName,
  52034. * rawIndices: [21, 34, ...]
  52035. * },
  52036. * ...
  52037. * ]
  52038. * },
  52039. * ...
  52040. * ]
  52041. * }
  52042. */
  52043. echarts.registerAction(
  52044. {type: 'brushSelect', event: 'brushSelected', update: 'none'},
  52045. function () {}
  52046. );
  52047. /***/ },
  52048. /* 356 */
  52049. /***/ function(module, exports, __webpack_require__) {
  52050. 'use strict';
  52051. var featureManager = __webpack_require__(357);
  52052. var zrUtil = __webpack_require__(4);
  52053. function Brush(model, ecModel, api) {
  52054. this.model = model;
  52055. this.ecModel = ecModel;
  52056. this.api = api;
  52057. /**
  52058. * @private
  52059. * @type {string}
  52060. */
  52061. this._brushType;
  52062. /**
  52063. * @private
  52064. * @type {string}
  52065. */
  52066. this._brushMode;
  52067. }
  52068. Brush.defaultOption = {
  52069. show: true,
  52070. type: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear'],
  52071. icon: {
  52072. 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
  52073. 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
  52074. 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
  52075. 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
  52076. 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
  52077. 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
  52078. },
  52079. title: {
  52080. rect: '矩形选择',
  52081. polygon: '圈选',
  52082. lineX: '横向选择',
  52083. lineY: '纵向选择',
  52084. keep: '保持选择',
  52085. clear: '清除选择'
  52086. }
  52087. };
  52088. var proto = Brush.prototype;
  52089. proto.render =
  52090. proto.updateView =
  52091. proto.updateLayout = function (featureModel, ecModel, api) {
  52092. var brushType;
  52093. var brushMode;
  52094. var isBrushed;
  52095. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  52096. brushType = brushModel.brushType;
  52097. brushMode = brushModel.brushOption.brushMode || 'single';
  52098. isBrushed |= brushModel.areas.length;
  52099. });
  52100. this._brushType = brushType;
  52101. this._brushMode = brushMode;
  52102. zrUtil.each(featureModel.get('type', true), function (type) {
  52103. featureModel.setIconStatus(
  52104. type,
  52105. (
  52106. type === 'keep'
  52107. ? brushMode === 'multiple'
  52108. : type === 'clear'
  52109. ? isBrushed
  52110. : type === brushType
  52111. ) ? 'emphasis' : 'normal'
  52112. );
  52113. });
  52114. };
  52115. proto.getIcons = function () {
  52116. var model = this.model;
  52117. var availableIcons = model.get('icon', true);
  52118. var icons = {};
  52119. zrUtil.each(model.get('type', true), function (type) {
  52120. if (availableIcons[type]) {
  52121. icons[type] = availableIcons[type];
  52122. }
  52123. });
  52124. return icons;
  52125. };
  52126. proto.onclick = function (ecModel, api, type) {
  52127. var api = this.api;
  52128. var brushType = this._brushType;
  52129. var brushMode = this._brushMode;
  52130. if (type === 'clear') {
  52131. // Trigger parallel action firstly
  52132. api.dispatchAction({
  52133. type: 'axisAreaSelect',
  52134. intervals: []
  52135. });
  52136. api.dispatchAction({
  52137. type: 'brush',
  52138. command: 'clear',
  52139. // Clear all areas of all brush components.
  52140. areas: []
  52141. });
  52142. }
  52143. else {
  52144. api.dispatchAction({
  52145. type: 'takeGlobalCursor',
  52146. key: 'brush',
  52147. brushOption: {
  52148. brushType: type === 'keep'
  52149. ? brushType
  52150. : (brushType === type ? false : type),
  52151. brushMode: type === 'keep'
  52152. ? (brushMode === 'multiple' ? 'single' : 'multiple')
  52153. : brushMode
  52154. }
  52155. });
  52156. }
  52157. };
  52158. featureManager.register('brush', Brush);
  52159. module.exports = Brush;
  52160. /***/ },
  52161. /* 357 */
  52162. /***/ function(module, exports) {
  52163. 'use strict';
  52164. var features = {};
  52165. module.exports = {
  52166. register: function (name, ctor) {
  52167. features[name] = ctor;
  52168. },
  52169. get: function (name) {
  52170. return features[name];
  52171. }
  52172. };
  52173. /***/ },
  52174. /* 358 */
  52175. /***/ function(module, exports, __webpack_require__) {
  52176. 'use strict';
  52177. /**
  52178. * @file calendar.js
  52179. * @author dxh
  52180. */
  52181. __webpack_require__(359);
  52182. __webpack_require__(360);
  52183. __webpack_require__(361);
  52184. /***/ },
  52185. /* 359 */
  52186. /***/ function(module, exports, __webpack_require__) {
  52187. 'use strict';
  52188. var layout = __webpack_require__(71);
  52189. var numberUtil = __webpack_require__(7);
  52190. var zrUtil = __webpack_require__(4);
  52191. // (24*60*60*1000)
  52192. var ONE_DAY = 86400000;
  52193. /**
  52194. * Calendar
  52195. *
  52196. * @constructor
  52197. *
  52198. * @param {Object} calendarModel calendarModel
  52199. * @param {Object} ecModel ecModel
  52200. * @param {Object} api api
  52201. */
  52202. function Calendar(calendarModel, ecModel, api) {
  52203. this._model = calendarModel;
  52204. }
  52205. Calendar.prototype = {
  52206. constructor: Calendar,
  52207. type: 'calendar',
  52208. dimensions: ['time', 'value'],
  52209. // Required in createListFromData
  52210. getDimensionsInfo: function () {
  52211. return [{name: 'time', type: 'time'}];
  52212. },
  52213. getRangeInfo: function () {
  52214. return this._rangeInfo;
  52215. },
  52216. getModel: function () {
  52217. return this._model;
  52218. },
  52219. getRect: function () {
  52220. return this._rect;
  52221. },
  52222. getCellWidth: function () {
  52223. return this._sw;
  52224. },
  52225. getCellHeight: function () {
  52226. return this._sh;
  52227. },
  52228. getOrient: function () {
  52229. return this._orient;
  52230. },
  52231. /**
  52232. * getFirstDayOfWeek
  52233. *
  52234. * @example
  52235. * 0 : start at Sunday
  52236. * 1 : start at Monday
  52237. *
  52238. * @return {number}
  52239. */
  52240. getFirstDayOfWeek: function () {
  52241. return this._firstDayOfWeek;
  52242. },
  52243. /**
  52244. * get date info
  52245. *
  52246. * @param {string|number} date date
  52247. * @return {Object} info
  52248. */
  52249. getDateInfo: function (date) {
  52250. date = numberUtil.parseDate(date);
  52251. var y = date.getFullYear();
  52252. var m = date.getMonth() + 1;
  52253. m = m < 10 ? '0' + m : m;
  52254. var d = date.getDate();
  52255. d = d < 10 ? '0' + d : d;
  52256. var day = date.getDay();
  52257. day = Math.abs((day + 7 - this.getFirstDayOfWeek()) % 7);
  52258. return {
  52259. y: y,
  52260. m: m,
  52261. d: d,
  52262. day: day,
  52263. time: date.getTime(),
  52264. formatedDate: y + '-' + m + '-' + d,
  52265. date: date
  52266. };
  52267. },
  52268. getNextNDay: function (date, n) {
  52269. n = n || 0;
  52270. if (n === 0) {
  52271. return this.getDateInfo(date);
  52272. }
  52273. var time = this.getDateInfo(date).time;
  52274. return this.getDateInfo(time + ONE_DAY * n);
  52275. },
  52276. update: function (ecModel, api) {
  52277. this._firstDayOfWeek = this._model.getModel('dayLabel').get('firstDay');
  52278. this._orient = this._model.get('orient');
  52279. this._lineWidth = this._model.getModel('itemStyle.normal').getItemStyle().lineWidth || 0;
  52280. this._rangeInfo = this._getRangeInfo(this._initRangeOption());
  52281. var weeks = this._rangeInfo.weeks || 1;
  52282. var whNames = ['width', 'height'];
  52283. var cellSize = this._model.get('cellSize').slice();
  52284. var layoutParams = this._model.getBoxLayoutParams();
  52285. var cellNumbers = this._orient === 'horizontal' ? [weeks, 7] : [7, weeks];
  52286. zrUtil.each([0, 1], function (idx) {
  52287. if (cellSizeSpecified(cellSize, idx)) {
  52288. layoutParams[whNames[idx]] = cellSize[idx] * cellNumbers[idx];
  52289. }
  52290. });
  52291. var whGlobal = {
  52292. width: api.getWidth(),
  52293. height: api.getHeight()
  52294. };
  52295. var calendarRect = this._rect = layout.getLayoutRect(layoutParams, whGlobal);
  52296. zrUtil.each([0, 1], function (idx) {
  52297. if (!cellSizeSpecified(cellSize, idx)) {
  52298. cellSize[idx] = calendarRect[whNames[idx]] / cellNumbers[idx];
  52299. }
  52300. });
  52301. function cellSizeSpecified(cellSize, idx) {
  52302. return cellSize[idx] != null && cellSize[idx] !== 'auto';
  52303. }
  52304. this._sw = cellSize[0];
  52305. this._sh = cellSize[1];
  52306. },
  52307. /**
  52308. * Convert a time data(time, value) item to (x, y) point.
  52309. *
  52310. * @override
  52311. * @param {Array|number} data data
  52312. * @param {boolean} [clamp=true] out of range
  52313. * @return {Array} point
  52314. */
  52315. dataToPoint: function (data, clamp) {
  52316. zrUtil.isArray(data) && (data = data[0]);
  52317. clamp == null && (clamp = true);
  52318. var dayInfo = this.getDateInfo(data);
  52319. var range = this._rangeInfo;
  52320. var date = dayInfo.formatedDate;
  52321. // if not in range return [NaN, NaN]
  52322. if (clamp && !(dayInfo.time >= range.start.time && dayInfo.time <= range.end.time)) {
  52323. return [NaN, NaN];
  52324. }
  52325. var week = dayInfo.day;
  52326. var nthWeek = this._getRangeInfo([range.start.time, date]).weeks;
  52327. if (this._orient === 'vertical') {
  52328. return [
  52329. this._rect.x + week * this._sw + this._sw / 2,
  52330. this._rect.y + (nthWeek - 1) * this._sh + this._sh / 2
  52331. ];
  52332. }
  52333. return [
  52334. this._rect.x + (nthWeek - 1) * this._sw + this._sw / 2,
  52335. this._rect.y + week * this._sh + this._sh / 2
  52336. ];
  52337. },
  52338. /**
  52339. * Convert a (x, y) point to time data
  52340. *
  52341. * @override
  52342. * @param {string} point point
  52343. * @return {string} data
  52344. */
  52345. pointToData: function (point) {
  52346. var date = this.pointToDate(point);
  52347. return date && date.time;
  52348. },
  52349. /**
  52350. * Convert a time date item to (x, y) four point.
  52351. *
  52352. * @param {Array} data date[0] is date
  52353. * @param {boolean} [clamp=true] out of range
  52354. * @return {Object} point
  52355. */
  52356. dataToRect: function (data, clamp) {
  52357. var point = this.dataToPoint(data, clamp);
  52358. return {
  52359. contentShape: {
  52360. x: point[0] - (this._sw - this._lineWidth) / 2,
  52361. y: point[1] - (this._sh - this._lineWidth) / 2,
  52362. width: this._sw - this._lineWidth,
  52363. height: this._sh - this._lineWidth
  52364. },
  52365. center: point,
  52366. tl: [
  52367. point[0] - this._sw / 2,
  52368. point[1] - this._sh / 2
  52369. ],
  52370. tr: [
  52371. point[0] + this._sw / 2,
  52372. point[1] - this._sh / 2
  52373. ],
  52374. br: [
  52375. point[0] + this._sw / 2,
  52376. point[1] + this._sh / 2
  52377. ],
  52378. bl: [
  52379. point[0] - this._sw / 2,
  52380. point[1] + this._sh / 2
  52381. ]
  52382. };
  52383. },
  52384. /**
  52385. * Convert a (x, y) point to time date
  52386. *
  52387. * @param {string} point point
  52388. * @return {Object} date
  52389. */
  52390. pointToDate: function (point) {
  52391. var nthX = Math.floor((point[0] - this._rect.x) / this._sw) + 1;
  52392. var nthY = Math.floor((point[1] - this._rect.y) / this._sh) + 1;
  52393. var range = this._rangeInfo.range;
  52394. if (this._orient === 'vertical') {
  52395. return this._getDateByWeeksAndDay(nthY, nthX - 1, range);
  52396. }
  52397. return this._getDateByWeeksAndDay(nthX, nthY - 1, range);
  52398. },
  52399. /**
  52400. * @inheritDoc
  52401. */
  52402. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  52403. /**
  52404. * @inheritDoc
  52405. */
  52406. convertFromPixel: zrUtil.curry(doConvert, 'pointToData'),
  52407. /**
  52408. * initRange
  52409. *
  52410. * @private
  52411. * @return {Array} [start, end]
  52412. */
  52413. _initRangeOption: function () {
  52414. var range = this._model.get('range');
  52415. var rg = range;
  52416. if (zrUtil.isArray(rg) && rg.length === 1) {
  52417. rg = rg[0];
  52418. }
  52419. if (/^\d{4}$/.test(rg)) {
  52420. range = [rg + '-01-01', rg + '-12-31'];
  52421. }
  52422. if (/^\d{4}[\/|-]\d{1,2}$/.test(rg)) {
  52423. var start = this.getDateInfo(rg);
  52424. var firstDay = start.date;
  52425. firstDay.setMonth(firstDay.getMonth() + 1);
  52426. var end = this.getNextNDay(firstDay, -1);
  52427. range = [start.formatedDate, end.formatedDate];
  52428. }
  52429. if (/^\d{4}[\/|-]\d{1,2}[\/|-]\d{1,2}$/.test(rg)) {
  52430. range = [rg, rg];
  52431. }
  52432. var tmp = this._getRangeInfo(range);
  52433. if (tmp.start.time > tmp.end.time) {
  52434. range.reverse();
  52435. }
  52436. return range;
  52437. },
  52438. /**
  52439. * range info
  52440. *
  52441. * @private
  52442. * @param {Array} range range ['2017-01-01', '2017-07-08']
  52443. * @return {Object} obj
  52444. */
  52445. _getRangeInfo: function (range) {
  52446. var start = this.getDateInfo(range[0]);
  52447. var end = this.getDateInfo(range[1]);
  52448. var allDay = Math.floor(end.time / ONE_DAY) - Math.floor(start.time / ONE_DAY) + 1;
  52449. var weeks = Math.floor((allDay + start.day + 6) / 7);
  52450. return {
  52451. range: [start.formatedDate, end.formatedDate],
  52452. start: start,
  52453. end: end,
  52454. allDay: allDay,
  52455. weeks: weeks,
  52456. fweek: start.day,
  52457. lweek: end.day
  52458. };
  52459. },
  52460. /**
  52461. * get date by nthWeeks and week day in range
  52462. *
  52463. * @private
  52464. * @param {number} nthWeek the week
  52465. * @param {number} day the week day
  52466. * @param {Array} range [d1, d2]
  52467. * @return {Object}
  52468. */
  52469. _getDateByWeeksAndDay: function (nthWeek, day, range) {
  52470. var rangeInfo = this._getRangeInfo(range);
  52471. if (nthWeek > rangeInfo.weeks
  52472. || (nthWeek === 0 && day < rangeInfo.fweek)
  52473. || (nthWeek === rangeInfo.weeks && day > rangeInfo.lweek)
  52474. ) {
  52475. return false;
  52476. }
  52477. var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
  52478. var time = rangeInfo.start.time + nthDay * ONE_DAY;
  52479. return this.getDateInfo(time);
  52480. }
  52481. };
  52482. Calendar.dimensions = Calendar.prototype.dimensions;
  52483. Calendar.getDimensionsInfo = Calendar.prototype.getDimensionsInfo;
  52484. Calendar.create = function (ecModel, api) {
  52485. var calendarList = [];
  52486. ecModel.eachComponent('calendar', function (calendarModel) {
  52487. var calendar = new Calendar(calendarModel, ecModel, api);
  52488. calendarList.push(calendar);
  52489. calendarModel.coordinateSystem = calendar;
  52490. });
  52491. ecModel.eachSeries(function (calendarSeries) {
  52492. if (calendarSeries.get('coordinateSystem') === 'calendar') {
  52493. // Inject coordinate system
  52494. calendarSeries.coordinateSystem = calendarList[calendarSeries.get('calendarIndex') || 0];
  52495. }
  52496. });
  52497. return calendarList;
  52498. };
  52499. function doConvert(methodName, ecModel, finder, value) {
  52500. var calendarModel = finder.calendarModel;
  52501. var seriesModel = finder.seriesModel;
  52502. var coordSys = calendarModel
  52503. ? calendarModel.coordinateSystem
  52504. : seriesModel
  52505. ? seriesModel.coordinateSystem
  52506. : null;
  52507. return coordSys === this ? coordSys[methodName](value) : null;
  52508. }
  52509. __webpack_require__(76).register('calendar', Calendar);
  52510. module.exports = Calendar;
  52511. /***/ },
  52512. /* 360 */
  52513. /***/ function(module, exports, __webpack_require__) {
  52514. 'use strict';
  52515. var ComponentModel = __webpack_require__(69);
  52516. var zrUtil = __webpack_require__(4);
  52517. var layout = __webpack_require__(71);
  52518. var CalendarModel = ComponentModel.extend({
  52519. type: 'calendar',
  52520. /**
  52521. * @type {module:echarts/coord/calendar/Calendar}
  52522. */
  52523. coordinateSystem: null,
  52524. defaultOption: {
  52525. zlevel: 0,
  52526. z: 2,
  52527. left: 80,
  52528. top: 60,
  52529. cellSize: 20,
  52530. // horizontal vertical
  52531. orient: 'horizontal',
  52532. // month separate line style
  52533. splitLine: {
  52534. show: true,
  52535. lineStyle: {
  52536. color: '#000',
  52537. width: 1,
  52538. type: 'solid'
  52539. }
  52540. },
  52541. // rect style temporarily unused emphasis
  52542. itemStyle: {
  52543. normal: {
  52544. color: '#fff',
  52545. borderWidth: 1,
  52546. borderColor: '#ccc'
  52547. }
  52548. },
  52549. // week text style
  52550. dayLabel: {
  52551. show: true,
  52552. // a week first day
  52553. firstDay: 0,
  52554. // start end
  52555. position: 'start',
  52556. margin: '50%', // 50% of cellSize
  52557. nameMap: 'en',
  52558. textStyle: {
  52559. color: '#000'
  52560. }
  52561. },
  52562. // month text style
  52563. monthLabel: {
  52564. show: true,
  52565. // start end
  52566. position: 'start',
  52567. margin: 5,
  52568. // center or left
  52569. align: 'center',
  52570. // cn en []
  52571. nameMap: 'en',
  52572. formatter: null,
  52573. textStyle: {
  52574. color: '#000'
  52575. }
  52576. },
  52577. // year text style
  52578. yearLabel: {
  52579. show: true,
  52580. // top bottom left right
  52581. position: null,
  52582. margin: 30,
  52583. formatter: null,
  52584. textStyle: {
  52585. color: '#ccc',
  52586. fontFamily: 'sans-serif',
  52587. fontWeight: 'bolder',
  52588. fontSize: 20
  52589. }
  52590. }
  52591. },
  52592. /**
  52593. * @override
  52594. */
  52595. init: function (option, parentModel, ecModel, extraOpt) {
  52596. var inputPositionParams = layout.getLayoutParams(option);
  52597. CalendarModel.superApply(this, 'init', arguments);
  52598. mergeAndNormalizeLayoutParams(option, inputPositionParams);
  52599. },
  52600. /**
  52601. * @override
  52602. */
  52603. mergeOption: function (option, extraOpt) {
  52604. CalendarModel.superApply(this, 'mergeOption', arguments);
  52605. mergeAndNormalizeLayoutParams(this.option, option);
  52606. }
  52607. });
  52608. function mergeAndNormalizeLayoutParams(target, raw) {
  52609. // Normalize cellSize
  52610. var cellSize = target.cellSize;
  52611. if (!zrUtil.isArray(cellSize)) {
  52612. cellSize = target.cellSize = [cellSize, cellSize];
  52613. }
  52614. else if (cellSize.length === 1) {
  52615. cellSize[1] = cellSize[0];
  52616. }
  52617. var ignoreSize = zrUtil.map([0, 1], function (hvIdx) {
  52618. // If user have set `width` or both `left` and `right`, cellSize
  52619. // will be automatically set to 'auto', otherwise the default
  52620. // setting of cellSize will make `width` setting not work.
  52621. if (layout.sizeCalculable(raw, hvIdx)) {
  52622. cellSize[hvIdx] = 'auto';
  52623. }
  52624. return cellSize[hvIdx] != null && cellSize[hvIdx] !== 'auto';
  52625. });
  52626. layout.mergeLayoutParam(target, raw, {
  52627. type: 'box', ignoreSize: ignoreSize
  52628. });
  52629. }
  52630. module.exports = CalendarModel;
  52631. /***/ },
  52632. /* 361 */
  52633. /***/ function(module, exports, __webpack_require__) {
  52634. 'use strict';
  52635. var zrUtil = __webpack_require__(4);
  52636. var graphic = __webpack_require__(18);
  52637. var formatUtil = __webpack_require__(6);
  52638. var numberUtil = __webpack_require__(7);
  52639. var MONTH_TEXT = {
  52640. EN: [
  52641. 'Jan', 'Feb', 'Mar',
  52642. 'Apr', 'May', 'Jun',
  52643. 'Jul', 'Aug', 'Sep',
  52644. 'Oct', 'Nov', 'Dec'
  52645. ],
  52646. CN: [
  52647. '一月', '二月', '三月',
  52648. '四月', '五月', '六月',
  52649. '七月', '八月', '九月',
  52650. '十月', '十一月', '十二月'
  52651. ]
  52652. };
  52653. var WEEK_TEXT = {
  52654. EN: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
  52655. CN: ['日', '一', '二', '三', '四', '五', '六']
  52656. };
  52657. module.exports = __webpack_require__(1).extendComponentView({
  52658. type: 'calendar',
  52659. /**
  52660. * top/left line points
  52661. * @private
  52662. */
  52663. _tlpoints: null,
  52664. /**
  52665. * bottom/right line points
  52666. * @private
  52667. */
  52668. _blpoints: null,
  52669. /**
  52670. * first day of month
  52671. * @private
  52672. */
  52673. _firstDayOfMonth: null,
  52674. /**
  52675. * first day point of month
  52676. * @private
  52677. */
  52678. _firstDayPoints: null,
  52679. render: function (calendarModel, ecModel, api) {
  52680. var group = this.group;
  52681. group.removeAll();
  52682. var coordSys = calendarModel.coordinateSystem;
  52683. // range info
  52684. var rangeData = coordSys.getRangeInfo();
  52685. var orient = coordSys.getOrient();
  52686. this._renderDayRect(calendarModel, rangeData, group);
  52687. // _renderLines must be called prior to following function
  52688. this._renderLines(calendarModel, rangeData, orient, group);
  52689. this._renderYearText(calendarModel, rangeData, orient, group);
  52690. this._renderMonthText(calendarModel, orient, group);
  52691. this._renderWeekText(calendarModel, rangeData, orient, group);
  52692. },
  52693. // render day rect
  52694. _renderDayRect: function (calendarModel, rangeData, group) {
  52695. var coordSys = calendarModel.coordinateSystem;
  52696. var itemRectStyleModel = calendarModel.getModel('itemStyle.normal').getItemStyle();
  52697. var sw = coordSys.getCellWidth();
  52698. var sh = coordSys.getCellHeight();
  52699. for (var i = rangeData.start.time;
  52700. i <= rangeData.end.time;
  52701. i = coordSys.getNextNDay(i, 1).time
  52702. ) {
  52703. var point = coordSys.dataToRect([i], false).tl;
  52704. // every rect
  52705. var rect = new graphic.Rect({
  52706. shape: {
  52707. x: point[0],
  52708. y: point[1],
  52709. width: sw,
  52710. height: sh
  52711. },
  52712. cursor: 'default',
  52713. style: itemRectStyleModel
  52714. });
  52715. group.add(rect);
  52716. }
  52717. },
  52718. // render separate line
  52719. _renderLines: function (calendarModel, rangeData, orient, group) {
  52720. var self = this;
  52721. var coordSys = calendarModel.coordinateSystem;
  52722. var lineStyleModel = calendarModel.getModel('splitLine.lineStyle').getLineStyle();
  52723. var show = calendarModel.get('splitLine.show');
  52724. var lineWidth = lineStyleModel.lineWidth;
  52725. this._tlpoints = [];
  52726. this._blpoints = [];
  52727. this._firstDayOfMonth = [];
  52728. this._firstDayPoints = [];
  52729. var firstDay = rangeData.start;
  52730. for (var i = 0; firstDay.time <= rangeData.end.time; i++) {
  52731. addPoints(firstDay.formatedDate);
  52732. if (i === 0) {
  52733. firstDay = coordSys.getDateInfo(rangeData.start.y + '-' + rangeData.start.m);
  52734. }
  52735. var date = firstDay.date;
  52736. date.setMonth(date.getMonth() + 1);
  52737. firstDay = coordSys.getDateInfo(date);
  52738. }
  52739. addPoints(coordSys.getNextNDay(rangeData.end.time, 1).formatedDate);
  52740. function addPoints(date) {
  52741. self._firstDayOfMonth.push(coordSys.getDateInfo(date));
  52742. self._firstDayPoints.push(coordSys.dataToRect([date], false).tl);
  52743. var points = self._getLinePointsOfOneWeek(calendarModel, date, orient);
  52744. self._tlpoints.push(points[0]);
  52745. self._blpoints.push(points[points.length - 1]);
  52746. show && self._drawSplitline(points, lineStyleModel, group);
  52747. }
  52748. // render top/left line
  52749. show && this._drawSplitline(self._getEdgesPoints(self._tlpoints, lineWidth, orient), lineStyleModel, group);
  52750. // render bottom/right line
  52751. show && this._drawSplitline(self._getEdgesPoints(self._blpoints, lineWidth, orient), lineStyleModel, group);
  52752. },
  52753. // get points at both ends
  52754. _getEdgesPoints: function (points, lineWidth, orient) {
  52755. var rs = [points[0].slice(), points[points.length - 1].slice()];
  52756. var idx = orient === 'horizontal' ? 0 : 1;
  52757. // both ends of the line are extend half lineWidth
  52758. rs[0][idx] = rs[0][idx] - lineWidth / 2;
  52759. rs[1][idx] = rs[1][idx] + lineWidth / 2;
  52760. return rs;
  52761. },
  52762. // render split line
  52763. _drawSplitline: function (points, lineStyleModel, group) {
  52764. var poyline = new graphic.Polyline({
  52765. z2: 20,
  52766. shape: {
  52767. points: points
  52768. },
  52769. style: lineStyleModel
  52770. });
  52771. group.add(poyline);
  52772. },
  52773. // render month line of one week points
  52774. _getLinePointsOfOneWeek: function (calendarModel, date, orient) {
  52775. var coordSys = calendarModel.coordinateSystem;
  52776. date = coordSys.getDateInfo(date);
  52777. var points = [];
  52778. for (var i = 0; i < 7; i++) {
  52779. var tmpD = coordSys.getNextNDay(date.time, i);
  52780. var point = coordSys.dataToRect([tmpD.time], false);
  52781. points[2 * tmpD.day] = point.tl;
  52782. points[2 * tmpD.day + 1] = point[orient === 'horizontal' ? 'bl' : 'tr'];
  52783. }
  52784. return points;
  52785. },
  52786. _formatterLabel: function (formatter, params) {
  52787. if (typeof formatter === 'string' && formatter) {
  52788. return formatUtil.formatTplSimple(formatter, params);
  52789. }
  52790. if (typeof formatter === 'function') {
  52791. return formatter(params);
  52792. }
  52793. return params.nameMap;
  52794. },
  52795. _yearTextPositionControl: function (point, orient, position, margin) {
  52796. point = point.slice();
  52797. var aligns = ['center', 'bottom'];
  52798. if (position === 'top') {
  52799. point[1] -= margin;
  52800. }
  52801. if (position === 'bottom') {
  52802. point[1] += margin;
  52803. aligns = ['center', 'top'];
  52804. }
  52805. if (position === 'left') {
  52806. point[0] -= margin;
  52807. }
  52808. if (position === 'right') {
  52809. point[0] += margin;
  52810. aligns = ['center', 'top'];
  52811. }
  52812. var rotate = 0;
  52813. if (position === 'left' || position === 'right') {
  52814. rotate = Math.PI / 2;
  52815. }
  52816. return {
  52817. rotation: rotate,
  52818. origin: point,
  52819. style: {
  52820. x: point[0],
  52821. y: point[1],
  52822. textAlign: aligns[0],
  52823. textVerticalAlign: aligns[1]
  52824. }
  52825. };
  52826. },
  52827. // render year
  52828. _renderYearText: function (calendarModel, rangeData, orient, group) {
  52829. var yearLabel = calendarModel.getModel('yearLabel');
  52830. if (!yearLabel.get('show')) {
  52831. return;
  52832. }
  52833. var yearLabelStyleModel = calendarModel.getModel('yearLabel.textStyle');
  52834. var margin = yearLabel.get('margin');
  52835. var pos = yearLabel.get('position');
  52836. if (!pos) {
  52837. pos = orient !== 'horizontal' ? 'top' : 'left';
  52838. }
  52839. var points = [this._tlpoints[this._tlpoints.length - 1], this._blpoints[0]];
  52840. var xc = (points[0][0] + points[1][0]) / 2;
  52841. var yc = (points[0][1] + points[1][1]) / 2;
  52842. var idx = orient === 'horizontal' ? 0 : 1;
  52843. var posPoints = {
  52844. top: [xc, points[idx][1]],
  52845. bottom: [xc, points[1 - idx][1]],
  52846. left: [points[1 - idx][0], yc],
  52847. right: [points[idx][0], yc]
  52848. };
  52849. var name = rangeData.start.y;
  52850. if (+rangeData.end.y > +rangeData.start.y) {
  52851. name = name + '-' + rangeData.end.y;
  52852. }
  52853. var formatter = yearLabel.get('formatter');
  52854. var params = {
  52855. start: rangeData.start.y,
  52856. end: rangeData.end.y,
  52857. nameMap: name
  52858. };
  52859. var content = this._formatterLabel(formatter, params);
  52860. var yearText = new graphic.Text(
  52861. zrUtil.merge({
  52862. z2: 30,
  52863. style: {
  52864. text: content,
  52865. font: yearLabelStyleModel.getFont(),
  52866. fill: yearLabelStyleModel.getTextColor()
  52867. }
  52868. }, this._yearTextPositionControl(posPoints[pos], orient, pos, margin))
  52869. );
  52870. group.add(yearText);
  52871. },
  52872. _monthTextPositionControl: function (point, isCenter, orient, position, margin) {
  52873. var align = 'left';
  52874. var vAlign = 'top';
  52875. var x = point[0];
  52876. var y = point[1];
  52877. if (orient === 'horizontal') {
  52878. y = y + margin;
  52879. if (isCenter) {
  52880. align = 'center';
  52881. }
  52882. if (position === 'start') {
  52883. vAlign = 'bottom';
  52884. }
  52885. }
  52886. else {
  52887. x = x + margin;
  52888. if (isCenter) {
  52889. vAlign = 'middle';
  52890. }
  52891. if (position === 'start') {
  52892. align = 'right';
  52893. }
  52894. }
  52895. return {
  52896. x: x,
  52897. y: y,
  52898. textAlign: align,
  52899. textVerticalAlign: vAlign
  52900. };
  52901. },
  52902. // render month and year text
  52903. _renderMonthText: function (calendarModel, orient, group) {
  52904. var monthLabel = calendarModel.getModel('monthLabel');
  52905. if (!monthLabel.get('show')) {
  52906. return;
  52907. }
  52908. var monthLabelStyleModel = calendarModel.getModel('monthLabel.textStyle');
  52909. var nameMap = monthLabel.get('nameMap');
  52910. var margin = monthLabel.get('margin');
  52911. var pos = monthLabel.get('position');
  52912. var align = monthLabel.get('align');
  52913. var termPoints = [this._tlpoints, this._blpoints];
  52914. if (zrUtil.isString(nameMap)) {
  52915. nameMap = MONTH_TEXT[nameMap.toUpperCase()] || [];
  52916. }
  52917. var idx = pos === 'start' ? 0 : 1;
  52918. var axis = orient === 'horizontal' ? 0 : 1;
  52919. margin = pos === 'start' ? -margin : margin;
  52920. var isCenter = (align === 'center');
  52921. for (var i = 0; i < termPoints[idx].length - 1; i++) {
  52922. var tmp = termPoints[idx][i].slice();
  52923. var firstDay = this._firstDayOfMonth[i];
  52924. if (isCenter) {
  52925. var firstDayPoints = this._firstDayPoints[i];
  52926. tmp[axis] = (firstDayPoints[axis] + termPoints[0][i + 1][axis]) / 2;
  52927. }
  52928. var formatter = monthLabel.get('formatter');
  52929. var name = nameMap[+firstDay.m - 1];
  52930. var params = {
  52931. yyyy: firstDay.y,
  52932. yy: (firstDay.y + '').slice(2),
  52933. MM: firstDay.m,
  52934. M: +firstDay.m,
  52935. nameMap: name
  52936. };
  52937. var content = this._formatterLabel(formatter, params);
  52938. var monthText = new graphic.Text({
  52939. z2: 30,
  52940. style: zrUtil.extend({
  52941. text: content,
  52942. font: monthLabelStyleModel.getFont(),
  52943. fill: monthLabelStyleModel.getTextColor()
  52944. }, this._monthTextPositionControl(tmp, isCenter, orient, pos, margin))
  52945. });
  52946. group.add(monthText);
  52947. }
  52948. },
  52949. _weekTextPositionControl: function (point, orient, position, margin, cellSize) {
  52950. var align = 'center';
  52951. var vAlign = 'middle';
  52952. var x = point[0];
  52953. var y = point[1];
  52954. var isStart = position === 'start';
  52955. if (orient === 'horizontal') {
  52956. x = x + margin + (isStart ? 1 : -1) * cellSize[0] / 2;
  52957. align = isStart ? 'right' : 'left';
  52958. }
  52959. else {
  52960. y = y + margin + (isStart ? 1 : -1) * cellSize[1] / 2;
  52961. vAlign = isStart ? 'bottom' : 'top';
  52962. }
  52963. return {
  52964. x: x,
  52965. y: y,
  52966. textAlign: align,
  52967. textVerticalAlign: vAlign
  52968. };
  52969. },
  52970. // render weeks
  52971. _renderWeekText: function (calendarModel, rangeData, orient, group) {
  52972. var dayLabel = calendarModel.getModel('dayLabel');
  52973. if (!dayLabel.get('show')) {
  52974. return;
  52975. }
  52976. var coordSys = calendarModel.coordinateSystem;
  52977. var dayLabelStyleModel = calendarModel.getModel('dayLabel.textStyle');
  52978. var pos = dayLabel.get('position');
  52979. var nameMap = dayLabel.get('nameMap');
  52980. var margin = dayLabel.get('margin');
  52981. var firstDayOfWeek = coordSys.getFirstDayOfWeek();
  52982. if (zrUtil.isString(nameMap)) {
  52983. nameMap = WEEK_TEXT[nameMap.toUpperCase()] || [];
  52984. }
  52985. var start = coordSys.getNextNDay(
  52986. rangeData.end.time, (7 - rangeData.lweek)
  52987. ).time;
  52988. var cellSize = [coordSys.getCellWidth(), coordSys.getCellHeight()];
  52989. margin = numberUtil.parsePercent(margin, cellSize[orient === 'horizontal' ? 0 : 1]);
  52990. if (pos === 'start') {
  52991. start = coordSys.getNextNDay(
  52992. rangeData.start.time, -(7 + rangeData.fweek)
  52993. ).time;
  52994. margin = -margin;
  52995. }
  52996. for (var i = 0; i < 7; i++) {
  52997. var tmpD = coordSys.getNextNDay(start, i);
  52998. var point = coordSys.dataToRect([tmpD.time], false).center;
  52999. var day = i;
  53000. day = Math.abs((i + firstDayOfWeek) % 7);
  53001. var weekText = new graphic.Text({
  53002. z2: 30,
  53003. style: zrUtil.extend({
  53004. text: nameMap[day],
  53005. font: dayLabelStyleModel.getFont(),
  53006. fill: dayLabelStyleModel.getTextColor()
  53007. }, this._weekTextPositionControl(point, orient, pos, margin, cellSize))
  53008. });
  53009. group.add(weekText);
  53010. }
  53011. }
  53012. });
  53013. /***/ },
  53014. /* 362 */
  53015. /***/ function(module, exports, __webpack_require__) {
  53016. 'use strict';
  53017. var echarts = __webpack_require__(1);
  53018. var graphic = __webpack_require__(18);
  53019. var layout = __webpack_require__(71);
  53020. // Model
  53021. echarts.extendComponentModel({
  53022. type: 'title',
  53023. layoutMode: {type: 'box', ignoreSize: true},
  53024. defaultOption: {
  53025. // 一级层叠
  53026. zlevel: 0,
  53027. // 二级层叠
  53028. z: 6,
  53029. show: true,
  53030. text: '',
  53031. // 超链接跳转
  53032. // link: null,
  53033. // 仅支持self | blank
  53034. target: 'blank',
  53035. subtext: '',
  53036. // 超链接跳转
  53037. // sublink: null,
  53038. // 仅支持self | blank
  53039. subtarget: 'blank',
  53040. // 'center' ¦ 'left' ¦ 'right'
  53041. // ¦ {number}(x坐标,单位px)
  53042. left: 0,
  53043. // 'top' ¦ 'bottom' ¦ 'center'
  53044. // ¦ {number}(y坐标,单位px)
  53045. top: 0,
  53046. // 水平对齐
  53047. // 'auto' | 'left' | 'right' | 'center'
  53048. // 默认根据 left 的位置判断是左对齐还是右对齐
  53049. // textAlign: null
  53050. //
  53051. // 垂直对齐
  53052. // 'auto' | 'top' | 'bottom' | 'middle'
  53053. // 默认根据 top 位置判断是上对齐还是下对齐
  53054. // textBaseline: null
  53055. backgroundColor: 'rgba(0,0,0,0)',
  53056. // 标题边框颜色
  53057. borderColor: '#ccc',
  53058. // 标题边框线宽,单位px,默认为0(无边框)
  53059. borderWidth: 0,
  53060. // 标题内边距,单位px,默认各方向内边距为5,
  53061. // 接受数组分别设定上右下左边距,同css
  53062. padding: 5,
  53063. // 主副标题纵向间隔,单位px,默认为10,
  53064. itemGap: 10,
  53065. textStyle: {
  53066. fontSize: 18,
  53067. fontWeight: 'bolder',
  53068. color: '#333'
  53069. },
  53070. subtextStyle: {
  53071. color: '#aaa'
  53072. }
  53073. }
  53074. });
  53075. // View
  53076. echarts.extendComponentView({
  53077. type: 'title',
  53078. render: function (titleModel, ecModel, api) {
  53079. this.group.removeAll();
  53080. if (!titleModel.get('show')) {
  53081. return;
  53082. }
  53083. var group = this.group;
  53084. var textStyleModel = titleModel.getModel('textStyle');
  53085. var subtextStyleModel = titleModel.getModel('subtextStyle');
  53086. var textAlign = titleModel.get('textAlign');
  53087. var textBaseline = titleModel.get('textBaseline');
  53088. var textEl = new graphic.Text({
  53089. style: {
  53090. text: titleModel.get('text'),
  53091. textFont: textStyleModel.getFont(),
  53092. fill: textStyleModel.getTextColor()
  53093. },
  53094. z2: 10
  53095. });
  53096. var textRect = textEl.getBoundingRect();
  53097. var subText = titleModel.get('subtext');
  53098. var subTextEl = new graphic.Text({
  53099. style: {
  53100. text: subText,
  53101. textFont: subtextStyleModel.getFont(),
  53102. fill: subtextStyleModel.getTextColor(),
  53103. y: textRect.height + titleModel.get('itemGap'),
  53104. textBaseline: 'top'
  53105. },
  53106. z2: 10
  53107. });
  53108. var link = titleModel.get('link');
  53109. var sublink = titleModel.get('sublink');
  53110. textEl.silent = !link;
  53111. subTextEl.silent = !sublink;
  53112. if (link) {
  53113. textEl.on('click', function () {
  53114. window.open(link, '_' + titleModel.get('target'));
  53115. });
  53116. }
  53117. if (sublink) {
  53118. subTextEl.on('click', function () {
  53119. window.open(sublink, '_' + titleModel.get('subtarget'));
  53120. });
  53121. }
  53122. group.add(textEl);
  53123. subText && group.add(subTextEl);
  53124. // If no subText, but add subTextEl, there will be an empty line.
  53125. var groupRect = group.getBoundingRect();
  53126. var layoutOption = titleModel.getBoxLayoutParams();
  53127. layoutOption.width = groupRect.width;
  53128. layoutOption.height = groupRect.height;
  53129. var layoutRect = layout.getLayoutRect(
  53130. layoutOption, {
  53131. width: api.getWidth(),
  53132. height: api.getHeight()
  53133. }, titleModel.get('padding')
  53134. );
  53135. // Adjust text align based on position
  53136. if (!textAlign) {
  53137. // Align left if title is on the left. center and right is same
  53138. textAlign = titleModel.get('left') || titleModel.get('right');
  53139. if (textAlign === 'middle') {
  53140. textAlign = 'center';
  53141. }
  53142. // Adjust layout by text align
  53143. if (textAlign === 'right') {
  53144. layoutRect.x += layoutRect.width;
  53145. }
  53146. else if (textAlign === 'center') {
  53147. layoutRect.x += layoutRect.width / 2;
  53148. }
  53149. }
  53150. if (!textBaseline) {
  53151. textBaseline = titleModel.get('top') || titleModel.get('bottom');
  53152. if (textBaseline === 'center') {
  53153. textBaseline = 'middle';
  53154. }
  53155. if (textBaseline === 'bottom') {
  53156. layoutRect.y += layoutRect.height;
  53157. }
  53158. else if (textBaseline === 'middle') {
  53159. layoutRect.y += layoutRect.height / 2;
  53160. }
  53161. textBaseline = textBaseline || 'top';
  53162. }
  53163. group.attr('position', [layoutRect.x, layoutRect.y]);
  53164. var alignStyle = {
  53165. textAlign: textAlign,
  53166. textVerticalAlign: textBaseline
  53167. };
  53168. textEl.setStyle(alignStyle);
  53169. subTextEl.setStyle(alignStyle);
  53170. // Render background
  53171. // Get groupRect again because textAlign has been changed
  53172. groupRect = group.getBoundingRect();
  53173. var padding = layoutRect.margin;
  53174. var style = titleModel.getItemStyle(['color', 'opacity']);
  53175. style.fill = titleModel.get('backgroundColor');
  53176. var rect = new graphic.Rect({
  53177. shape: {
  53178. x: groupRect.x - padding[3],
  53179. y: groupRect.y - padding[0],
  53180. width: groupRect.width + padding[1] + padding[3],
  53181. height: groupRect.height + padding[0] + padding[2]
  53182. },
  53183. style: style,
  53184. silent: true
  53185. });
  53186. graphic.subPixelOptimizeRect(rect);
  53187. group.add(rect);
  53188. }
  53189. });
  53190. /***/ },
  53191. /* 363 */
  53192. /***/ function(module, exports, __webpack_require__) {
  53193. /**
  53194. * DataZoom component entry
  53195. */
  53196. __webpack_require__(364);
  53197. __webpack_require__(365);
  53198. __webpack_require__(368);
  53199. __webpack_require__(369);
  53200. __webpack_require__(370);
  53201. __webpack_require__(371);
  53202. __webpack_require__(372);
  53203. __webpack_require__(374);
  53204. __webpack_require__(375);
  53205. /***/ },
  53206. /* 364 */
  53207. /***/ function(module, exports, __webpack_require__) {
  53208. __webpack_require__(69).registerSubTypeDefaulter('dataZoom', function (option) {
  53209. // Default 'slider' when no type specified.
  53210. return 'slider';
  53211. });
  53212. /***/ },
  53213. /* 365 */
  53214. /***/ function(module, exports, __webpack_require__) {
  53215. /**
  53216. * @file Data zoom model
  53217. */
  53218. var zrUtil = __webpack_require__(4);
  53219. var env = __webpack_require__(2);
  53220. var echarts = __webpack_require__(1);
  53221. var modelUtil = __webpack_require__(5);
  53222. var helper = __webpack_require__(366);
  53223. var AxisProxy = __webpack_require__(367);
  53224. var each = zrUtil.each;
  53225. var eachAxisDim = helper.eachAxisDim;
  53226. var DataZoomModel = echarts.extendComponentModel({
  53227. type: 'dataZoom',
  53228. dependencies: [
  53229. 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'singleAxis', 'series'
  53230. ],
  53231. /**
  53232. * @protected
  53233. */
  53234. defaultOption: {
  53235. zlevel: 0,
  53236. z: 4, // Higher than normal component (z: 2).
  53237. orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'.
  53238. xAxisIndex: null, // Default the first horizontal category axis.
  53239. yAxisIndex: null, // Default the first vertical category axis.
  53240. filterMode: 'filter', // Possible values: 'filter' or 'empty' or 'weakFilter'.
  53241. // 'filter': data items which are out of window will be removed. This option is
  53242. // applicable when filtering outliers. For each data item, it will be
  53243. // filtered if one of the relevant dimensions is out of the window.
  53244. // 'weakFilter': data items which are out of window will be removed. This option
  53245. // is applicable when filtering outliers. For each data item, it will be
  53246. // filtered only if all of the relevant dimensions are out of the same
  53247. // side of the window.
  53248. // 'empty': data items which are out of window will be set to empty.
  53249. // This option is applicable when user should not neglect
  53250. // that there are some data items out of window.
  53251. // 'none': Do not filter.
  53252. // Taking line chart as an example, line will be broken in
  53253. // the filtered points when filterModel is set to 'empty', but
  53254. // be connected when set to 'filter'.
  53255. throttle: null, // Dispatch action by the fixed rate, avoid frequency.
  53256. // default 100. Do not throttle when use null/undefined.
  53257. // If animation === true and animationDurationUpdate > 0,
  53258. // default value is 100, otherwise 20.
  53259. start: 0, // Start percent. 0 ~ 100
  53260. end: 100, // End percent. 0 ~ 100
  53261. startValue: null, // Start value. If startValue specified, start is ignored.
  53262. endValue: null, // End value. If endValue specified, end is ignored.
  53263. minSpan: null, // 0 ~ 100
  53264. maxSpan: null, // 0 ~ 100
  53265. minValueSpan: null, // The range of dataZoom can not be smaller than that.
  53266. maxValueSpan: null // The range of dataZoom can not be larger than that.
  53267. },
  53268. /**
  53269. * @override
  53270. */
  53271. init: function (option, parentModel, ecModel) {
  53272. /**
  53273. * key like x_0, y_1
  53274. * @private
  53275. * @type {Object}
  53276. */
  53277. this._dataIntervalByAxis = {};
  53278. /**
  53279. * @private
  53280. */
  53281. this._dataInfo = {};
  53282. /**
  53283. * key like x_0, y_1
  53284. * @private
  53285. */
  53286. this._axisProxies = {};
  53287. /**
  53288. * @readOnly
  53289. */
  53290. this.textStyleModel;
  53291. /**
  53292. * @private
  53293. */
  53294. this._autoThrottle = true;
  53295. /**
  53296. * 'percent' or 'value'
  53297. * @private
  53298. */
  53299. this._rangePropMode = ['percent', 'percent'];
  53300. var rawOption = retrieveRaw(option);
  53301. this.mergeDefaultAndTheme(option, ecModel);
  53302. this.doInit(rawOption);
  53303. },
  53304. /**
  53305. * @override
  53306. */
  53307. mergeOption: function (newOption) {
  53308. var rawOption = retrieveRaw(newOption);
  53309. //FIX #2591
  53310. zrUtil.merge(this.option, newOption, true);
  53311. this.doInit(rawOption);
  53312. },
  53313. /**
  53314. * @protected
  53315. */
  53316. doInit: function (rawOption) {
  53317. var thisOption = this.option;
  53318. // Disable realtime view update if canvas is not supported.
  53319. if (!env.canvasSupported) {
  53320. thisOption.realtime = false;
  53321. }
  53322. this._setDefaultThrottle(rawOption);
  53323. updateRangeUse(this, rawOption);
  53324. each([['start', 'startValue'], ['end', 'endValue']], function (names, index) {
  53325. // start/end has higher priority over startValue/endValue if they
  53326. // both set, but we should make chart.setOption({endValue: 1000})
  53327. // effective, rather than chart.setOption({endValue: 1000, end: null}).
  53328. if (this._rangePropMode[index] === 'value') {
  53329. thisOption[names[0]] = null;
  53330. }
  53331. // Otherwise do nothing and use the merge result.
  53332. }, this);
  53333. this.textStyleModel = this.getModel('textStyle');
  53334. this._resetTarget();
  53335. this._giveAxisProxies();
  53336. },
  53337. /**
  53338. * @private
  53339. */
  53340. _giveAxisProxies: function () {
  53341. var axisProxies = this._axisProxies;
  53342. this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) {
  53343. var axisModel = this.dependentModels[dimNames.axis][axisIndex];
  53344. // If exists, share axisProxy with other dataZoomModels.
  53345. var axisProxy = axisModel.__dzAxisProxy || (
  53346. // Use the first dataZoomModel as the main model of axisProxy.
  53347. axisModel.__dzAxisProxy = new AxisProxy(
  53348. dimNames.name, axisIndex, this, ecModel
  53349. )
  53350. );
  53351. // FIXME
  53352. // dispose __dzAxisProxy
  53353. axisProxies[dimNames.name + '_' + axisIndex] = axisProxy;
  53354. }, this);
  53355. },
  53356. /**
  53357. * @private
  53358. */
  53359. _resetTarget: function () {
  53360. var thisOption = this.option;
  53361. var autoMode = this._judgeAutoMode();
  53362. eachAxisDim(function (dimNames) {
  53363. var axisIndexName = dimNames.axisIndex;
  53364. thisOption[axisIndexName] = modelUtil.normalizeToArray(
  53365. thisOption[axisIndexName]
  53366. );
  53367. }, this);
  53368. if (autoMode === 'axisIndex') {
  53369. this._autoSetAxisIndex();
  53370. }
  53371. else if (autoMode === 'orient') {
  53372. this._autoSetOrient();
  53373. }
  53374. },
  53375. /**
  53376. * @private
  53377. */
  53378. _judgeAutoMode: function () {
  53379. // Auto set only works for setOption at the first time.
  53380. // The following is user's reponsibility. So using merged
  53381. // option is OK.
  53382. var thisOption = this.option;
  53383. var hasIndexSpecified = false;
  53384. eachAxisDim(function (dimNames) {
  53385. // When user set axisIndex as a empty array, we think that user specify axisIndex
  53386. // but do not want use auto mode. Because empty array may be encountered when
  53387. // some error occured.
  53388. if (thisOption[dimNames.axisIndex] != null) {
  53389. hasIndexSpecified = true;
  53390. }
  53391. }, this);
  53392. var orient = thisOption.orient;
  53393. if (orient == null && hasIndexSpecified) {
  53394. return 'orient';
  53395. }
  53396. else if (!hasIndexSpecified) {
  53397. if (orient == null) {
  53398. thisOption.orient = 'horizontal';
  53399. }
  53400. return 'axisIndex';
  53401. }
  53402. },
  53403. /**
  53404. * @private
  53405. */
  53406. _autoSetAxisIndex: function () {
  53407. var autoAxisIndex = true;
  53408. var orient = this.get('orient', true);
  53409. var thisOption = this.option;
  53410. var dependentModels = this.dependentModels;
  53411. if (autoAxisIndex) {
  53412. // Find axis that parallel to dataZoom as default.
  53413. var dimName = orient === 'vertical' ? 'y' : 'x';
  53414. if (dependentModels[dimName + 'Axis'].length) {
  53415. thisOption[dimName + 'AxisIndex'] = [0];
  53416. autoAxisIndex = false;
  53417. }
  53418. else {
  53419. each(dependentModels.singleAxis, function (singleAxisModel) {
  53420. if (autoAxisIndex && singleAxisModel.get('orient', true) === orient) {
  53421. thisOption.singleAxisIndex = [singleAxisModel.componentIndex];
  53422. autoAxisIndex = false;
  53423. }
  53424. });
  53425. }
  53426. }
  53427. if (autoAxisIndex) {
  53428. // Find the first category axis as default. (consider polar)
  53429. eachAxisDim(function (dimNames) {
  53430. if (!autoAxisIndex) {
  53431. return;
  53432. }
  53433. var axisIndices = [];
  53434. var axisModels = this.dependentModels[dimNames.axis];
  53435. if (axisModels.length && !axisIndices.length) {
  53436. for (var i = 0, len = axisModels.length; i < len; i++) {
  53437. if (axisModels[i].get('type') === 'category') {
  53438. axisIndices.push(i);
  53439. }
  53440. }
  53441. }
  53442. thisOption[dimNames.axisIndex] = axisIndices;
  53443. if (axisIndices.length) {
  53444. autoAxisIndex = false;
  53445. }
  53446. }, this);
  53447. }
  53448. if (autoAxisIndex) {
  53449. // FIXME
  53450. // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制),
  53451. // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)?
  53452. // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified,
  53453. // dataZoom component auto adopts series that reference to
  53454. // both xAxis and yAxis which type is 'value'.
  53455. this.ecModel.eachSeries(function (seriesModel) {
  53456. if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) {
  53457. eachAxisDim(function (dimNames) {
  53458. var axisIndices = thisOption[dimNames.axisIndex];
  53459. var axisIndex = seriesModel.get(dimNames.axisIndex);
  53460. var axisId = seriesModel.get(dimNames.axisId);
  53461. var axisModel = seriesModel.ecModel.queryComponents({
  53462. mainType: dimNames.axis,
  53463. index: axisIndex,
  53464. id: axisId
  53465. })[0];
  53466. if (true) {
  53467. if (!axisModel) {
  53468. throw new Error(
  53469. dimNames.axis + ' "' + zrUtil.retrieve(
  53470. axisIndex,
  53471. axisId,
  53472. 0
  53473. ) + '" not found'
  53474. );
  53475. }
  53476. }
  53477. axisIndex = axisModel.componentIndex;
  53478. if (zrUtil.indexOf(axisIndices, axisIndex) < 0) {
  53479. axisIndices.push(axisIndex);
  53480. }
  53481. });
  53482. }
  53483. }, this);
  53484. }
  53485. },
  53486. /**
  53487. * @private
  53488. */
  53489. _autoSetOrient: function () {
  53490. var dim;
  53491. // Find the first axis
  53492. this.eachTargetAxis(function (dimNames) {
  53493. !dim && (dim = dimNames.name);
  53494. }, this);
  53495. this.option.orient = dim === 'y' ? 'vertical' : 'horizontal';
  53496. },
  53497. /**
  53498. * @private
  53499. */
  53500. _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) {
  53501. // FIXME
  53502. // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。
  53503. // 例如series.type === scatter时。
  53504. var is = true;
  53505. eachAxisDim(function (dimNames) {
  53506. var seriesAxisIndex = seriesModel.get(dimNames.axisIndex);
  53507. var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex];
  53508. if (!axisModel || axisModel.get('type') !== axisType) {
  53509. is = false;
  53510. }
  53511. }, this);
  53512. return is;
  53513. },
  53514. /**
  53515. * @private
  53516. */
  53517. _setDefaultThrottle: function (rawOption) {
  53518. // When first time user set throttle, auto throttle ends.
  53519. if (rawOption.hasOwnProperty('throttle')) {
  53520. this._autoThrottle = false;
  53521. }
  53522. if (this._autoThrottle) {
  53523. var globalOption = this.ecModel.option;
  53524. this.option.throttle =
  53525. (globalOption.animation && globalOption.animationDurationUpdate > 0)
  53526. ? 100 : 20;
  53527. }
  53528. },
  53529. /**
  53530. * @public
  53531. */
  53532. getFirstTargetAxisModel: function () {
  53533. var firstAxisModel;
  53534. eachAxisDim(function (dimNames) {
  53535. if (firstAxisModel == null) {
  53536. var indices = this.get(dimNames.axisIndex);
  53537. if (indices.length) {
  53538. firstAxisModel = this.dependentModels[dimNames.axis][indices[0]];
  53539. }
  53540. }
  53541. }, this);
  53542. return firstAxisModel;
  53543. },
  53544. /**
  53545. * @public
  53546. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  53547. */
  53548. eachTargetAxis: function (callback, context) {
  53549. var ecModel = this.ecModel;
  53550. eachAxisDim(function (dimNames) {
  53551. each(
  53552. this.get(dimNames.axisIndex),
  53553. function (axisIndex) {
  53554. callback.call(context, dimNames, axisIndex, this, ecModel);
  53555. },
  53556. this
  53557. );
  53558. }, this);
  53559. },
  53560. /**
  53561. * @param {string} dimName
  53562. * @param {number} axisIndex
  53563. * @return {module:echarts/component/dataZoom/AxisProxy} If not found, return null/undefined.
  53564. */
  53565. getAxisProxy: function (dimName, axisIndex) {
  53566. return this._axisProxies[dimName + '_' + axisIndex];
  53567. },
  53568. /**
  53569. * @param {string} dimName
  53570. * @param {number} axisIndex
  53571. * @return {module:echarts/model/Model} If not found, return null/undefined.
  53572. */
  53573. getAxisModel: function (dimName, axisIndex) {
  53574. var axisProxy = this.getAxisProxy(dimName, axisIndex);
  53575. return axisProxy && axisProxy.getAxisModel();
  53576. },
  53577. /**
  53578. * If not specified, set to undefined.
  53579. *
  53580. * @public
  53581. * @param {Object} opt
  53582. * @param {number} [opt.start]
  53583. * @param {number} [opt.end]
  53584. * @param {number} [opt.startValue]
  53585. * @param {number} [opt.endValue]
  53586. * @param {boolean} [ignoreUpdateRangeUsg=false]
  53587. */
  53588. setRawRange: function (opt, ignoreUpdateRangeUsg) {
  53589. each(['start', 'end', 'startValue', 'endValue'], function (name) {
  53590. // If any of those prop is null/undefined, we should alos set
  53591. // them, because only one pair between start/end and
  53592. // startValue/endValue can work.
  53593. this.option[name] = opt[name];
  53594. }, this);
  53595. !ignoreUpdateRangeUsg && updateRangeUse(this, opt);
  53596. },
  53597. /**
  53598. * @public
  53599. * @return {Array.<number>} [startPercent, endPercent]
  53600. */
  53601. getPercentRange: function () {
  53602. var axisProxy = this.findRepresentativeAxisProxy();
  53603. if (axisProxy) {
  53604. return axisProxy.getDataPercentWindow();
  53605. }
  53606. },
  53607. /**
  53608. * @public
  53609. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  53610. *
  53611. * @param {string} [axisDimName]
  53612. * @param {number} [axisIndex]
  53613. * @return {Array.<number>} [startValue, endValue] value can only be '-' or finite number.
  53614. */
  53615. getValueRange: function (axisDimName, axisIndex) {
  53616. if (axisDimName == null && axisIndex == null) {
  53617. var axisProxy = this.findRepresentativeAxisProxy();
  53618. if (axisProxy) {
  53619. return axisProxy.getDataValueWindow();
  53620. }
  53621. }
  53622. else {
  53623. return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow();
  53624. }
  53625. },
  53626. /**
  53627. * @public
  53628. * @param {module:echarts/model/Model} [axisModel] If axisModel given, find axisProxy
  53629. * corresponding to the axisModel
  53630. * @return {module:echarts/component/dataZoom/AxisProxy}
  53631. */
  53632. findRepresentativeAxisProxy: function (axisModel) {
  53633. if (axisModel) {
  53634. return axisModel.__dzAxisProxy;
  53635. }
  53636. // Find the first hosted axisProxy
  53637. var axisProxies = this._axisProxies;
  53638. for (var key in axisProxies) {
  53639. if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) {
  53640. return axisProxies[key];
  53641. }
  53642. }
  53643. // If no hosted axis find not hosted axisProxy.
  53644. // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis,
  53645. // and the option.start or option.end settings are different. The percentRange
  53646. // should follow axisProxy.
  53647. // (We encounter this problem in toolbox data zoom.)
  53648. for (var key in axisProxies) {
  53649. if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) {
  53650. return axisProxies[key];
  53651. }
  53652. }
  53653. },
  53654. /**
  53655. * @return {Array.<string>}
  53656. */
  53657. getRangePropMode: function () {
  53658. return this._rangePropMode.slice();
  53659. }
  53660. });
  53661. function retrieveRaw(option) {
  53662. var ret = {};
  53663. each(
  53664. ['start', 'end', 'startValue', 'endValue', 'throttle'],
  53665. function (name) {
  53666. option.hasOwnProperty(name) && (ret[name] = option[name]);
  53667. }
  53668. );
  53669. return ret;
  53670. }
  53671. function updateRangeUse(dataZoomModel, rawOption) {
  53672. each([['start', 'startValue'], ['end', 'endValue']], function (names, index) {
  53673. var rangePropMode = dataZoomModel._rangePropMode;
  53674. if (rawOption[names[0]] != null) {
  53675. rangePropMode[index] = 'percent';
  53676. }
  53677. else if (rawOption[names[1]] != null) {
  53678. rangePropMode[index] = 'value';
  53679. }
  53680. // else remain its original setting.
  53681. });
  53682. }
  53683. module.exports = DataZoomModel;
  53684. /***/ },
  53685. /* 366 */
  53686. /***/ function(module, exports, __webpack_require__) {
  53687. var formatUtil = __webpack_require__(6);
  53688. var zrUtil = __webpack_require__(4);
  53689. var helper = {};
  53690. var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle', 'single'];
  53691. // Supported coords.
  53692. var COORDS = ['cartesian2d', 'polar', 'singleAxis'];
  53693. /**
  53694. * @param {string} coordType
  53695. * @return {boolean}
  53696. */
  53697. helper.isCoordSupported = function (coordType) {
  53698. return zrUtil.indexOf(COORDS, coordType) >= 0;
  53699. };
  53700. /**
  53701. * Create "each" method to iterate names.
  53702. *
  53703. * @pubilc
  53704. * @param {Array.<string>} names
  53705. * @param {Array.<string>=} attrs
  53706. * @return {Function}
  53707. */
  53708. helper.createNameEach = function (names, attrs) {
  53709. names = names.slice();
  53710. var capitalNames = zrUtil.map(names, formatUtil.capitalFirst);
  53711. attrs = (attrs || []).slice();
  53712. var capitalAttrs = zrUtil.map(attrs, formatUtil.capitalFirst);
  53713. return function (callback, context) {
  53714. zrUtil.each(names, function (name, index) {
  53715. var nameObj = {name: name, capital: capitalNames[index]};
  53716. for (var j = 0; j < attrs.length; j++) {
  53717. nameObj[attrs[j]] = name + capitalAttrs[j];
  53718. }
  53719. callback.call(context, nameObj);
  53720. });
  53721. };
  53722. };
  53723. /**
  53724. * Iterate each dimension name.
  53725. *
  53726. * @public
  53727. * @param {Function} callback The parameter is like:
  53728. * {
  53729. * name: 'angle',
  53730. * capital: 'Angle',
  53731. * axis: 'angleAxis',
  53732. * axisIndex: 'angleAixs',
  53733. * index: 'angleIndex'
  53734. * }
  53735. * @param {Object} context
  53736. */
  53737. helper.eachAxisDim = helper.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index', 'id']);
  53738. /**
  53739. * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'.
  53740. * dataZoomModels and 'links' make up one or more graphics.
  53741. * This function finds the graphic where the source dataZoomModel is in.
  53742. *
  53743. * @public
  53744. * @param {Function} forEachNode Node iterator.
  53745. * @param {Function} forEachEdgeType edgeType iterator
  53746. * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id.
  53747. * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}}
  53748. */
  53749. helper.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
  53750. return function (sourceNode) {
  53751. var result = {
  53752. nodes: [],
  53753. records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean).
  53754. };
  53755. forEachEdgeType(function (edgeType) {
  53756. result.records[edgeType.name] = {};
  53757. });
  53758. if (!sourceNode) {
  53759. return result;
  53760. }
  53761. absorb(sourceNode, result);
  53762. var existsLink;
  53763. do {
  53764. existsLink = false;
  53765. forEachNode(processSingleNode);
  53766. }
  53767. while (existsLink);
  53768. function processSingleNode(node) {
  53769. if (!isNodeAbsorded(node, result) && isLinked(node, result)) {
  53770. absorb(node, result);
  53771. existsLink = true;
  53772. }
  53773. }
  53774. return result;
  53775. };
  53776. function isNodeAbsorded(node, result) {
  53777. return zrUtil.indexOf(result.nodes, node) >= 0;
  53778. }
  53779. function isLinked(node, result) {
  53780. var hasLink = false;
  53781. forEachEdgeType(function (edgeType) {
  53782. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  53783. result.records[edgeType.name][edgeId] && (hasLink = true);
  53784. });
  53785. });
  53786. return hasLink;
  53787. }
  53788. function absorb(node, result) {
  53789. result.nodes.push(node);
  53790. forEachEdgeType(function (edgeType) {
  53791. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  53792. result.records[edgeType.name][edgeId] = true;
  53793. });
  53794. });
  53795. }
  53796. };
  53797. module.exports = helper;
  53798. /***/ },
  53799. /* 367 */
  53800. /***/ function(module, exports, __webpack_require__) {
  53801. /**
  53802. * @file Axis operator
  53803. */
  53804. var zrUtil = __webpack_require__(4);
  53805. var numberUtil = __webpack_require__(7);
  53806. var helper = __webpack_require__(366);
  53807. var each = zrUtil.each;
  53808. var asc = numberUtil.asc;
  53809. /**
  53810. * Operate single axis.
  53811. * One axis can only operated by one axis operator.
  53812. * Different dataZoomModels may be defined to operate the same axis.
  53813. * (i.e. 'inside' data zoom and 'slider' data zoom components)
  53814. * So dataZoomModels share one axisProxy in that case.
  53815. *
  53816. * @class
  53817. */
  53818. var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) {
  53819. /**
  53820. * @private
  53821. * @type {string}
  53822. */
  53823. this._dimName = dimName;
  53824. /**
  53825. * @private
  53826. */
  53827. this._axisIndex = axisIndex;
  53828. /**
  53829. * @private
  53830. * @type {Array.<number>}
  53831. */
  53832. this._valueWindow;
  53833. /**
  53834. * @private
  53835. * @type {Array.<number>}
  53836. */
  53837. this._percentWindow;
  53838. /**
  53839. * @private
  53840. * @type {Array.<number>}
  53841. */
  53842. this._dataExtent;
  53843. /**
  53844. * {minSpan, maxSpan, minValueSpan, maxValueSpan}
  53845. * @private
  53846. * @type {Object}
  53847. */
  53848. this._minMaxSpan;
  53849. /**
  53850. * @readOnly
  53851. * @type {module: echarts/model/Global}
  53852. */
  53853. this.ecModel = ecModel;
  53854. /**
  53855. * @private
  53856. * @type {module: echarts/component/dataZoom/DataZoomModel}
  53857. */
  53858. this._dataZoomModel = dataZoomModel;
  53859. };
  53860. AxisProxy.prototype = {
  53861. constructor: AxisProxy,
  53862. /**
  53863. * Whether the axisProxy is hosted by dataZoomModel.
  53864. *
  53865. * @public
  53866. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  53867. * @return {boolean}
  53868. */
  53869. hostedBy: function (dataZoomModel) {
  53870. return this._dataZoomModel === dataZoomModel;
  53871. },
  53872. /**
  53873. * @return {Array.<number>} Value can only be NaN or finite value.
  53874. */
  53875. getDataValueWindow: function () {
  53876. return this._valueWindow.slice();
  53877. },
  53878. /**
  53879. * @return {Array.<number>}
  53880. */
  53881. getDataPercentWindow: function () {
  53882. return this._percentWindow.slice();
  53883. },
  53884. /**
  53885. * @public
  53886. * @param {number} axisIndex
  53887. * @return {Array} seriesModels
  53888. */
  53889. getTargetSeriesModels: function () {
  53890. var seriesModels = [];
  53891. var ecModel = this.ecModel;
  53892. ecModel.eachSeries(function (seriesModel) {
  53893. if (helper.isCoordSupported(seriesModel.get('coordinateSystem'))) {
  53894. var dimName = this._dimName;
  53895. var axisModel = ecModel.queryComponents({
  53896. mainType: dimName + 'Axis',
  53897. index: seriesModel.get(dimName + 'AxisIndex'),
  53898. id: seriesModel.get(dimName + 'AxisId')
  53899. })[0];
  53900. if (this._axisIndex === (axisModel && axisModel.componentIndex)) {
  53901. seriesModels.push(seriesModel);
  53902. }
  53903. }
  53904. }, this);
  53905. return seriesModels;
  53906. },
  53907. getAxisModel: function () {
  53908. return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex);
  53909. },
  53910. getOtherAxisModel: function () {
  53911. var axisDim = this._dimName;
  53912. var ecModel = this.ecModel;
  53913. var axisModel = this.getAxisModel();
  53914. var isCartesian = axisDim === 'x' || axisDim === 'y';
  53915. var otherAxisDim;
  53916. var coordSysIndexName;
  53917. if (isCartesian) {
  53918. coordSysIndexName = 'gridIndex';
  53919. otherAxisDim = axisDim === 'x' ? 'y' : 'x';
  53920. }
  53921. else {
  53922. coordSysIndexName = 'polarIndex';
  53923. otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle';
  53924. }
  53925. var foundOtherAxisModel;
  53926. ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) {
  53927. if ((otherAxisModel.get(coordSysIndexName) || 0)
  53928. === (axisModel.get(coordSysIndexName) || 0)
  53929. ) {
  53930. foundOtherAxisModel = otherAxisModel;
  53931. }
  53932. });
  53933. return foundOtherAxisModel;
  53934. },
  53935. getMinMaxSpan: function () {
  53936. return zrUtil.clone(this._minMaxSpan);
  53937. },
  53938. /**
  53939. * Only calculate by given range and this._dataExtent, do not change anything.
  53940. *
  53941. * @param {Object} opt
  53942. * @param {number} [opt.start]
  53943. * @param {number} [opt.end]
  53944. * @param {number} [opt.startValue]
  53945. * @param {number} [opt.endValue]
  53946. */
  53947. calculateDataWindow: function (opt) {
  53948. var dataExtent = this._dataExtent;
  53949. var axisModel = this.getAxisModel();
  53950. var scale = axisModel.axis.scale;
  53951. var rangePropMode = this._dataZoomModel.getRangePropMode();
  53952. var percentExtent = [0, 100];
  53953. var percentWindow = [
  53954. opt.start,
  53955. opt.end
  53956. ];
  53957. var valueWindow = [];
  53958. each(['startValue', 'endValue'], function (prop) {
  53959. valueWindow.push(opt[prop] != null ? scale.parse(opt[prop]) : null);
  53960. });
  53961. // Normalize bound.
  53962. each([0, 1], function (idx) {
  53963. var boundValue = valueWindow[idx];
  53964. var boundPercent = percentWindow[idx];
  53965. // Notice: dataZoom is based either on `percentProp` ('start', 'end') or
  53966. // on `valueProp` ('startValue', 'endValue'). The former one is suitable
  53967. // for cases that a dataZoom component controls multiple axes with different
  53968. // unit or extent, and the latter one is suitable for accurate zoom by pixel
  53969. // (e.g., in dataZoomSelect). `valueProp` can be calculated from `percentProp`,
  53970. // but it is awkward that `percentProp` can not be obtained from `valueProp`
  53971. // accurately (because all of values that are overflow the `dataExtent` will
  53972. // be calculated to percent '100%'). So we have to use
  53973. // `dataZoom.getRangePropMode()` to mark which prop is used.
  53974. // `rangePropMode` is updated only when setOption or dispatchAction, otherwise
  53975. // it remains its original value.
  53976. if (rangePropMode[idx] === 'percent') {
  53977. if (boundPercent == null) {
  53978. boundPercent = percentExtent[idx];
  53979. }
  53980. // Use scale.parse to math round for category or time axis.
  53981. boundValue = scale.parse(numberUtil.linearMap(
  53982. boundPercent, percentExtent, dataExtent, true
  53983. ));
  53984. }
  53985. else {
  53986. // Calculating `percent` from `value` may be not accurate, because
  53987. // This calculation can not be inversed, because all of values that
  53988. // are overflow the `dataExtent` will be calculated to percent '100%'
  53989. boundPercent = numberUtil.linearMap(
  53990. boundValue, dataExtent, percentExtent, true
  53991. );
  53992. }
  53993. // valueWindow[idx] = round(boundValue);
  53994. // percentWindow[idx] = round(boundPercent);
  53995. valueWindow[idx] = boundValue;
  53996. percentWindow[idx] = boundPercent;
  53997. });
  53998. return {
  53999. valueWindow: asc(valueWindow),
  54000. percentWindow: asc(percentWindow)
  54001. };
  54002. },
  54003. /**
  54004. * Notice: reset should not be called before series.restoreData() called,
  54005. * so it is recommanded to be called in "process stage" but not "model init
  54006. * stage".
  54007. *
  54008. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  54009. */
  54010. reset: function (dataZoomModel) {
  54011. if (dataZoomModel !== this._dataZoomModel) {
  54012. return;
  54013. }
  54014. // Culculate data window and data extent, and record them.
  54015. this._dataExtent = calculateDataExtent(
  54016. this, this._dimName, this.getTargetSeriesModels()
  54017. );
  54018. var dataWindow = this.calculateDataWindow(dataZoomModel.option);
  54019. this._valueWindow = dataWindow.valueWindow;
  54020. this._percentWindow = dataWindow.percentWindow;
  54021. setMinMaxSpan(this);
  54022. // Update axis setting then.
  54023. setAxisModel(this);
  54024. },
  54025. /**
  54026. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  54027. */
  54028. restore: function (dataZoomModel) {
  54029. if (dataZoomModel !== this._dataZoomModel) {
  54030. return;
  54031. }
  54032. this._valueWindow = this._percentWindow = null;
  54033. setAxisModel(this, true);
  54034. },
  54035. /**
  54036. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  54037. */
  54038. filterData: function (dataZoomModel) {
  54039. if (dataZoomModel !== this._dataZoomModel) {
  54040. return;
  54041. }
  54042. var axisDim = this._dimName;
  54043. var seriesModels = this.getTargetSeriesModels();
  54044. var filterMode = dataZoomModel.get('filterMode');
  54045. var valueWindow = this._valueWindow;
  54046. if (filterMode === 'none') {
  54047. return;
  54048. }
  54049. // FIXME
  54050. // Toolbox may has dataZoom injected. And if there are stacked bar chart
  54051. // with NaN data, NaN will be filtered and stack will be wrong.
  54052. // So we need to force the mode to be set empty.
  54053. // In fect, it is not a big deal that do not support filterMode-'filter'
  54054. // when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
  54055. // selection" some day, which might need "adapt to data extent on the
  54056. // otherAxis", which is disabled by filterMode-'empty'.
  54057. var otherAxisModel = this.getOtherAxisModel();
  54058. if (dataZoomModel.get('$fromToolbox')
  54059. && otherAxisModel
  54060. && otherAxisModel.get('type') === 'category'
  54061. ) {
  54062. filterMode = 'empty';
  54063. }
  54064. // Process series data
  54065. each(seriesModels, function (seriesModel) {
  54066. var seriesData = seriesModel.getData();
  54067. var dataDims = seriesModel.coordDimToDataDim(axisDim);
  54068. if (filterMode === 'weakFilter') {
  54069. seriesData && seriesData.filterSelf(function (dataIndex) {
  54070. var leftOut;
  54071. var rightOut;
  54072. var hasValue;
  54073. for (var i = 0; i < dataDims.length; i++) {
  54074. var value = seriesData.get(dataDims[i], dataIndex);
  54075. var thisHasValue = !isNaN(value);
  54076. var thisLeftOut = value < valueWindow[0];
  54077. var thisRightOut = value > valueWindow[1];
  54078. if (thisHasValue && !thisLeftOut && !thisRightOut) {
  54079. return true;
  54080. }
  54081. thisHasValue && (hasValue = true);
  54082. thisLeftOut && (leftOut = true);
  54083. thisRightOut && (rightOut = true);
  54084. }
  54085. // If both left out and right out, do not filter.
  54086. return hasValue && leftOut && rightOut;
  54087. });
  54088. }
  54089. else {
  54090. seriesData && each(dataDims, function (dim) {
  54091. if (filterMode === 'empty') {
  54092. seriesModel.setData(
  54093. seriesData.map(dim, function (value) {
  54094. return !isInWindow(value) ? NaN : value;
  54095. })
  54096. );
  54097. }
  54098. else {
  54099. seriesData.filterSelf(dim, isInWindow);
  54100. }
  54101. });
  54102. }
  54103. });
  54104. function isInWindow(value) {
  54105. return value >= valueWindow[0] && value <= valueWindow[1];
  54106. }
  54107. }
  54108. };
  54109. function calculateDataExtent(axisProxy, axisDim, seriesModels) {
  54110. var dataExtent = [Infinity, -Infinity];
  54111. each(seriesModels, function (seriesModel) {
  54112. var seriesData = seriesModel.getData();
  54113. if (seriesData) {
  54114. each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  54115. var seriesExtent = seriesData.getDataExtent(dim);
  54116. seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]);
  54117. seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]);
  54118. });
  54119. }
  54120. });
  54121. if (dataExtent[1] < dataExtent[0]) {
  54122. dataExtent = [NaN, NaN];
  54123. }
  54124. // It is important to get "consistent" extent when more then one axes is
  54125. // controlled by a `dataZoom`, otherwise those axes will not be synchronized
  54126. // when zooming. But it is difficult to know what is "consistent", considering
  54127. // axes have different type or even different meanings (For example, two
  54128. // time axes are used to compare data of the same date in different years).
  54129. // So basically dataZoom just obtains extent by series.data (in category axis
  54130. // extent can be obtained from axis.data).
  54131. // Nevertheless, user can set min/max/scale on axes to make extent of axes
  54132. // consistent.
  54133. fixExtentByAxis(axisProxy, dataExtent);
  54134. return dataExtent;
  54135. }
  54136. function fixExtentByAxis(axisProxy, dataExtent) {
  54137. var axisModel = axisProxy.getAxisModel();
  54138. var min = axisModel.getMin(true);
  54139. // For category axis, if min/max/scale are not set, extent is determined
  54140. // by axis.data by default.
  54141. var isCategoryAxis = axisModel.get('type') === 'category';
  54142. var axisDataLen = isCategoryAxis && (axisModel.get('data') || []).length;
  54143. if (min != null && min !== 'dataMin') {
  54144. dataExtent[0] = min;
  54145. }
  54146. else if (isCategoryAxis) {
  54147. dataExtent[0] = axisDataLen > 0 ? 0 : NaN;
  54148. }
  54149. var max = axisModel.getMax(true);
  54150. if (max != null && max !== 'dataMax') {
  54151. dataExtent[1] = max;
  54152. }
  54153. else if (isCategoryAxis) {
  54154. dataExtent[1] = axisDataLen > 0 ? axisDataLen - 1 : NaN;
  54155. }
  54156. if (!axisModel.get('scale', true)) {
  54157. dataExtent[0] > 0 && (dataExtent[0] = 0);
  54158. dataExtent[1] < 0 && (dataExtent[1] = 0);
  54159. }
  54160. // For value axis, if min/max/scale are not set, we just use the extent obtained
  54161. // by series data, which may be a little different from the extent calculated by
  54162. // `axisHelper.getScaleExtent`. But the different just affects the experience a
  54163. // little when zooming. So it will not be fixed until some users require it strongly.
  54164. return dataExtent;
  54165. }
  54166. function setAxisModel(axisProxy, isRestore) {
  54167. var axisModel = axisProxy.getAxisModel();
  54168. var percentWindow = axisProxy._percentWindow;
  54169. var valueWindow = axisProxy._valueWindow;
  54170. if (!percentWindow) {
  54171. return;
  54172. }
  54173. // [0, 500]: arbitrary value, guess axis extent.
  54174. var precision = numberUtil.getPixelPrecision(valueWindow, [0, 500]);
  54175. // isRestore or isFull
  54176. var useOrigin = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100);
  54177. axisModel.setRange(
  54178. useOrigin ? null : +valueWindow[0].toFixed(precision),
  54179. useOrigin ? null : +valueWindow[1].toFixed(precision)
  54180. );
  54181. }
  54182. function setMinMaxSpan(axisProxy) {
  54183. var minMaxSpan = axisProxy._minMaxSpan = {};
  54184. var dataZoomModel = axisProxy._dataZoomModel;
  54185. each(['min', 'max'], function (minMax) {
  54186. minMaxSpan[minMax + 'Span'] = dataZoomModel.get(minMax + 'Span');
  54187. // minValueSpan and maxValueSpan has higher priority than minSpan and maxSpan
  54188. var valueSpan = dataZoomModel.get(minMax + 'ValueSpan');
  54189. if (valueSpan != null) {
  54190. minMaxSpan[minMax + 'ValueSpan'] = valueSpan;
  54191. valueSpan = axisProxy.getAxisModel().axis.scale.parse(valueSpan);
  54192. if (valueSpan != null) {
  54193. minMaxSpan[minMax + 'Span'] = numberUtil.linearMap(
  54194. valueSpan, axisProxy._dataExtent, [0, 100], true
  54195. );
  54196. }
  54197. }
  54198. });
  54199. }
  54200. module.exports = AxisProxy;
  54201. /***/ },
  54202. /* 368 */
  54203. /***/ function(module, exports, __webpack_require__) {
  54204. var ComponentView = __webpack_require__(79);
  54205. module.exports = ComponentView.extend({
  54206. type: 'dataZoom',
  54207. render: function (dataZoomModel, ecModel, api, payload) {
  54208. this.dataZoomModel = dataZoomModel;
  54209. this.ecModel = ecModel;
  54210. this.api = api;
  54211. },
  54212. /**
  54213. * Find the first target coordinate system.
  54214. *
  54215. * @protected
  54216. * @return {Object} {
  54217. * grid: [
  54218. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  54219. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  54220. * ...
  54221. * ], // cartesians must not be null/undefined.
  54222. * polar: [
  54223. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  54224. * ...
  54225. * ], // polars must not be null/undefined.
  54226. * singleAxis: [
  54227. * {model: coord0, axisModels: [], coordIndex: 0}
  54228. * ]
  54229. */
  54230. getTargetCoordInfo: function () {
  54231. var dataZoomModel = this.dataZoomModel;
  54232. var ecModel = this.ecModel;
  54233. var coordSysLists = {};
  54234. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  54235. var axisModel = ecModel.getComponent(dimNames.axis, axisIndex);
  54236. if (axisModel) {
  54237. var coordModel = axisModel.getCoordSysModel();
  54238. coordModel && save(
  54239. coordModel,
  54240. axisModel,
  54241. coordSysLists[coordModel.mainType] || (coordSysLists[coordModel.mainType] = []),
  54242. coordModel.componentIndex
  54243. );
  54244. }
  54245. }, this);
  54246. function save(coordModel, axisModel, store, coordIndex) {
  54247. var item;
  54248. for (var i = 0; i < store.length; i++) {
  54249. if (store[i].model === coordModel) {
  54250. item = store[i];
  54251. break;
  54252. }
  54253. }
  54254. if (!item) {
  54255. store.push(item = {
  54256. model: coordModel, axisModels: [], coordIndex: coordIndex
  54257. });
  54258. }
  54259. item.axisModels.push(axisModel);
  54260. }
  54261. return coordSysLists;
  54262. }
  54263. });
  54264. /***/ },
  54265. /* 369 */
  54266. /***/ function(module, exports, __webpack_require__) {
  54267. /**
  54268. * @file Data zoom model
  54269. */
  54270. var DataZoomModel = __webpack_require__(365);
  54271. var SliderZoomModel = DataZoomModel.extend({
  54272. type: 'dataZoom.slider',
  54273. layoutMode: 'box',
  54274. /**
  54275. * @protected
  54276. */
  54277. defaultOption: {
  54278. show: true,
  54279. // ph => placeholder. Using placehoder here because
  54280. // deault value can only be drived in view stage.
  54281. right: 'ph', // Default align to grid rect.
  54282. top: 'ph', // Default align to grid rect.
  54283. width: 'ph', // Default align to grid rect.
  54284. height: 'ph', // Default align to grid rect.
  54285. left: null, // Default align to grid rect.
  54286. bottom: null, // Default align to grid rect.
  54287. backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component.
  54288. // dataBackgroundColor: '#ddd', // Background coor of data shadow and border of box,
  54289. // highest priority, remain for compatibility of
  54290. // previous version, but not recommended any more.
  54291. dataBackground: {
  54292. lineStyle: {
  54293. color: '#2f4554',
  54294. width: 0.5,
  54295. opacity: 0.3
  54296. },
  54297. areaStyle: {
  54298. color: 'rgba(47,69,84,0.3)',
  54299. opacity: 0.3
  54300. }
  54301. },
  54302. borderColor: '#ddd', // border color of the box. For compatibility,
  54303. // if dataBackgroundColor is set, borderColor
  54304. // is ignored.
  54305. fillerColor: 'rgba(167,183,204,0.4)', // Color of selected area.
  54306. // handleColor: 'rgba(89,170,216,0.95)', // Color of handle.
  54307. // 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',
  54308. 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',
  54309. // Percent of the slider height
  54310. handleSize: '100%',
  54311. handleStyle: {
  54312. color: '#a7b7cc'
  54313. },
  54314. labelPrecision: null,
  54315. labelFormatter: null,
  54316. showDetail: true,
  54317. showDataShadow: 'auto', // Default auto decision.
  54318. realtime: true,
  54319. zoomLock: false, // Whether disable zoom.
  54320. textStyle: {
  54321. color: '#333'
  54322. }
  54323. }
  54324. });
  54325. module.exports = SliderZoomModel;
  54326. /***/ },
  54327. /* 370 */
  54328. /***/ function(module, exports, __webpack_require__) {
  54329. var zrUtil = __webpack_require__(4);
  54330. var graphic = __webpack_require__(18);
  54331. var throttle = __webpack_require__(81);
  54332. var DataZoomView = __webpack_require__(368);
  54333. var Rect = graphic.Rect;
  54334. var numberUtil = __webpack_require__(7);
  54335. var linearMap = numberUtil.linearMap;
  54336. var layout = __webpack_require__(71);
  54337. var sliderMove = __webpack_require__(239);
  54338. var eventTool = __webpack_require__(88);
  54339. var asc = numberUtil.asc;
  54340. var bind = zrUtil.bind;
  54341. // var mathMax = Math.max;
  54342. var each = zrUtil.each;
  54343. // Constants
  54344. var DEFAULT_LOCATION_EDGE_GAP = 7;
  54345. var DEFAULT_FRAME_BORDER_WIDTH = 1;
  54346. var DEFAULT_FILLER_SIZE = 30;
  54347. var HORIZONTAL = 'horizontal';
  54348. var VERTICAL = 'vertical';
  54349. var LABEL_GAP = 5;
  54350. var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter'];
  54351. var SliderZoomView = DataZoomView.extend({
  54352. type: 'dataZoom.slider',
  54353. init: function (ecModel, api) {
  54354. /**
  54355. * @private
  54356. * @type {Object}
  54357. */
  54358. this._displayables = {};
  54359. /**
  54360. * @private
  54361. * @type {string}
  54362. */
  54363. this._orient;
  54364. /**
  54365. * [0, 100]
  54366. * @private
  54367. */
  54368. this._range;
  54369. /**
  54370. * [coord of the first handle, coord of the second handle]
  54371. * @private
  54372. */
  54373. this._handleEnds;
  54374. /**
  54375. * [length, thick]
  54376. * @private
  54377. * @type {Array.<number>}
  54378. */
  54379. this._size;
  54380. /**
  54381. * @private
  54382. * @type {number}
  54383. */
  54384. this._handleWidth;
  54385. /**
  54386. * @private
  54387. * @type {number}
  54388. */
  54389. this._handleHeight;
  54390. /**
  54391. * @private
  54392. */
  54393. this._location;
  54394. /**
  54395. * @private
  54396. */
  54397. this._dragging;
  54398. /**
  54399. * @private
  54400. */
  54401. this._dataShadowInfo;
  54402. this.api = api;
  54403. },
  54404. /**
  54405. * @override
  54406. */
  54407. render: function (dataZoomModel, ecModel, api, payload) {
  54408. SliderZoomView.superApply(this, 'render', arguments);
  54409. throttle.createOrUpdate(
  54410. this,
  54411. '_dispatchZoomAction',
  54412. this.dataZoomModel.get('throttle'),
  54413. 'fixRate'
  54414. );
  54415. this._orient = dataZoomModel.get('orient');
  54416. if (this.dataZoomModel.get('show') === false) {
  54417. this.group.removeAll();
  54418. return;
  54419. }
  54420. // Notice: this._resetInterval() should not be executed when payload.type
  54421. // is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
  54422. // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
  54423. if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) {
  54424. this._buildView();
  54425. }
  54426. this._updateView();
  54427. },
  54428. /**
  54429. * @override
  54430. */
  54431. remove: function () {
  54432. SliderZoomView.superApply(this, 'remove', arguments);
  54433. throttle.clear(this, '_dispatchZoomAction');
  54434. },
  54435. /**
  54436. * @override
  54437. */
  54438. dispose: function () {
  54439. SliderZoomView.superApply(this, 'dispose', arguments);
  54440. throttle.clear(this, '_dispatchZoomAction');
  54441. },
  54442. _buildView: function () {
  54443. var thisGroup = this.group;
  54444. thisGroup.removeAll();
  54445. this._resetLocation();
  54446. this._resetInterval();
  54447. var barGroup = this._displayables.barGroup = new graphic.Group();
  54448. this._renderBackground();
  54449. this._renderHandle();
  54450. this._renderDataShadow();
  54451. thisGroup.add(barGroup);
  54452. this._positionGroup();
  54453. },
  54454. /**
  54455. * @private
  54456. */
  54457. _resetLocation: function () {
  54458. var dataZoomModel = this.dataZoomModel;
  54459. var api = this.api;
  54460. // If some of x/y/width/height are not specified,
  54461. // auto-adapt according to target grid.
  54462. var coordRect = this._findCoordRect();
  54463. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  54464. // Default align by coordinate system rect.
  54465. var positionInfo = this._orient === HORIZONTAL
  54466. ? {
  54467. // Why using 'right', because right should be used in vertical,
  54468. // and it is better to be consistent for dealing with position param merge.
  54469. right: ecSize.width - coordRect.x - coordRect.width,
  54470. top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP),
  54471. width: coordRect.width,
  54472. height: DEFAULT_FILLER_SIZE
  54473. }
  54474. : { // vertical
  54475. right: DEFAULT_LOCATION_EDGE_GAP,
  54476. top: coordRect.y,
  54477. width: DEFAULT_FILLER_SIZE,
  54478. height: coordRect.height
  54479. };
  54480. // Do not write back to option and replace value 'ph', because
  54481. // the 'ph' value should be recalculated when resize.
  54482. var layoutParams = layout.getLayoutParams(dataZoomModel.option);
  54483. // Replace the placeholder value.
  54484. zrUtil.each(['right', 'top', 'width', 'height'], function (name) {
  54485. if (layoutParams[name] === 'ph') {
  54486. layoutParams[name] = positionInfo[name];
  54487. }
  54488. });
  54489. var layoutRect = layout.getLayoutRect(
  54490. layoutParams,
  54491. ecSize,
  54492. dataZoomModel.padding
  54493. );
  54494. this._location = {x: layoutRect.x, y: layoutRect.y};
  54495. this._size = [layoutRect.width, layoutRect.height];
  54496. this._orient === VERTICAL && this._size.reverse();
  54497. },
  54498. /**
  54499. * @private
  54500. */
  54501. _positionGroup: function () {
  54502. var thisGroup = this.group;
  54503. var location = this._location;
  54504. var orient = this._orient;
  54505. // Just use the first axis to determine mapping.
  54506. var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel();
  54507. var inverse = targetAxisModel && targetAxisModel.get('inverse');
  54508. var barGroup = this._displayables.barGroup;
  54509. var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse;
  54510. // Transform barGroup.
  54511. barGroup.attr(
  54512. (orient === HORIZONTAL && !inverse)
  54513. ? {scale: otherAxisInverse ? [1, 1] : [1, -1]}
  54514. : (orient === HORIZONTAL && inverse)
  54515. ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]}
  54516. : (orient === VERTICAL && !inverse)
  54517. ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2}
  54518. // Dont use Math.PI, considering shadow direction.
  54519. : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2}
  54520. );
  54521. // Position barGroup
  54522. var rect = thisGroup.getBoundingRect([barGroup]);
  54523. thisGroup.attr('position', [location.x - rect.x, location.y - rect.y]);
  54524. },
  54525. /**
  54526. * @private
  54527. */
  54528. _getViewExtent: function () {
  54529. return [0, this._size[0]];
  54530. },
  54531. _renderBackground: function () {
  54532. var dataZoomModel = this.dataZoomModel;
  54533. var size = this._size;
  54534. var barGroup = this._displayables.barGroup;
  54535. barGroup.add(new Rect({
  54536. silent: true,
  54537. shape: {
  54538. x: 0, y: 0, width: size[0], height: size[1]
  54539. },
  54540. style: {
  54541. fill: dataZoomModel.get('backgroundColor')
  54542. },
  54543. z2: -40
  54544. }));
  54545. // Click panel, over shadow, below handles.
  54546. barGroup.add(new Rect({
  54547. shape: {
  54548. x: 0, y: 0, width: size[0], height: size[1]
  54549. },
  54550. style: {
  54551. fill: 'transparent'
  54552. },
  54553. z2: 0,
  54554. onclick: zrUtil.bind(this._onClickPanelClick, this)
  54555. }));
  54556. },
  54557. _renderDataShadow: function () {
  54558. var info = this._dataShadowInfo = this._prepareDataShadowInfo();
  54559. if (!info) {
  54560. return;
  54561. }
  54562. var size = this._size;
  54563. var seriesModel = info.series;
  54564. var data = seriesModel.getRawData();
  54565. var otherDim = seriesModel.getShadowDim
  54566. ? seriesModel.getShadowDim() // @see candlestick
  54567. : info.otherDim;
  54568. if (otherDim == null) {
  54569. return;
  54570. }
  54571. var otherDataExtent = data.getDataExtent(otherDim);
  54572. // Nice extent.
  54573. var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
  54574. otherDataExtent = [
  54575. otherDataExtent[0] - otherOffset,
  54576. otherDataExtent[1] + otherOffset
  54577. ];
  54578. var otherShadowExtent = [0, size[1]];
  54579. var thisShadowExtent = [0, size[0]];
  54580. var areaPoints = [[size[0], 0], [0, 0]];
  54581. var linePoints = [];
  54582. var step = thisShadowExtent[1] / (data.count() - 1);
  54583. var thisCoord = 0;
  54584. // Optimize for large data shadow
  54585. var stride = Math.round(data.count() / size[0]);
  54586. var lastIsEmpty;
  54587. data.each([otherDim], function (value, index) {
  54588. if (stride > 0 && (index % stride)) {
  54589. thisCoord += step;
  54590. return;
  54591. }
  54592. // FIXME
  54593. // Should consider axis.min/axis.max when drawing dataShadow.
  54594. // FIXME
  54595. // 应该使用统一的空判断?还是在list里进行空判断?
  54596. var isEmpty = value == null || isNaN(value) || value === '';
  54597. // See #4235.
  54598. var otherCoord = isEmpty
  54599. ? 0 : linearMap(value, otherDataExtent, otherShadowExtent, true);
  54600. // Attempt to draw data shadow precisely when there are empty value.
  54601. if (isEmpty && !lastIsEmpty && index) {
  54602. areaPoints.push([areaPoints[areaPoints.length - 1][0], 0]);
  54603. linePoints.push([linePoints[linePoints.length - 1][0], 0]);
  54604. }
  54605. else if (!isEmpty && lastIsEmpty) {
  54606. areaPoints.push([thisCoord, 0]);
  54607. linePoints.push([thisCoord, 0]);
  54608. }
  54609. areaPoints.push([thisCoord, otherCoord]);
  54610. linePoints.push([thisCoord, otherCoord]);
  54611. thisCoord += step;
  54612. lastIsEmpty = isEmpty;
  54613. });
  54614. var dataZoomModel = this.dataZoomModel;
  54615. // var dataBackgroundModel = dataZoomModel.getModel('dataBackground');
  54616. this._displayables.barGroup.add(new graphic.Polygon({
  54617. shape: {points: areaPoints},
  54618. style: zrUtil.defaults(
  54619. {fill: dataZoomModel.get('dataBackgroundColor')},
  54620. dataZoomModel.getModel('dataBackground.areaStyle').getAreaStyle()
  54621. ),
  54622. silent: true,
  54623. z2: -20
  54624. }));
  54625. this._displayables.barGroup.add(new graphic.Polyline({
  54626. shape: {points: linePoints},
  54627. style: dataZoomModel.getModel('dataBackground.lineStyle').getLineStyle(),
  54628. silent: true,
  54629. z2: -19
  54630. }));
  54631. },
  54632. _prepareDataShadowInfo: function () {
  54633. var dataZoomModel = this.dataZoomModel;
  54634. var showDataShadow = dataZoomModel.get('showDataShadow');
  54635. if (showDataShadow === false) {
  54636. return;
  54637. }
  54638. // Find a representative series.
  54639. var result;
  54640. var ecModel = this.ecModel;
  54641. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  54642. var seriesModels = dataZoomModel
  54643. .getAxisProxy(dimNames.name, axisIndex)
  54644. .getTargetSeriesModels();
  54645. zrUtil.each(seriesModels, function (seriesModel) {
  54646. if (result) {
  54647. return;
  54648. }
  54649. if (showDataShadow !== true && zrUtil.indexOf(
  54650. SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')
  54651. ) < 0
  54652. ) {
  54653. return;
  54654. }
  54655. var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis;
  54656. var otherDim = getOtherDim(dimNames.name);
  54657. var otherAxisInverse;
  54658. var coordSys = seriesModel.coordinateSystem;
  54659. if (otherDim != null && coordSys.getOtherAxis) {
  54660. otherAxisInverse = coordSys.getOtherAxis(thisAxis).inverse;
  54661. }
  54662. result = {
  54663. thisAxis: thisAxis,
  54664. series: seriesModel,
  54665. thisDim: dimNames.name,
  54666. otherDim: otherDim,
  54667. otherAxisInverse: otherAxisInverse
  54668. };
  54669. }, this);
  54670. }, this);
  54671. return result;
  54672. },
  54673. _renderHandle: function () {
  54674. var displaybles = this._displayables;
  54675. var handles = displaybles.handles = [];
  54676. var handleLabels = displaybles.handleLabels = [];
  54677. var barGroup = this._displayables.barGroup;
  54678. var size = this._size;
  54679. var dataZoomModel = this.dataZoomModel;
  54680. barGroup.add(displaybles.filler = new Rect({
  54681. draggable: true,
  54682. cursor: 'move',
  54683. drift: bind(this._onDragMove, this, 'all'),
  54684. onmousemove: function (e) {
  54685. // Fot mobile devicem, prevent screen slider on the button.
  54686. eventTool.stop(e.event);
  54687. },
  54688. ondragstart: bind(this._showDataInfo, this, true),
  54689. ondragend: bind(this._onDragEnd, this),
  54690. onmouseover: bind(this._showDataInfo, this, true),
  54691. onmouseout: bind(this._showDataInfo, this, false),
  54692. style: {
  54693. fill: dataZoomModel.get('fillerColor'),
  54694. textPosition : 'inside'
  54695. }
  54696. }));
  54697. // Frame border.
  54698. barGroup.add(new Rect(graphic.subPixelOptimizeRect({
  54699. silent: true,
  54700. shape: {
  54701. x: 0,
  54702. y: 0,
  54703. width: size[0],
  54704. height: size[1]
  54705. },
  54706. style: {
  54707. stroke: dataZoomModel.get('dataBackgroundColor')
  54708. || dataZoomModel.get('borderColor'),
  54709. lineWidth: DEFAULT_FRAME_BORDER_WIDTH,
  54710. fill: 'rgba(0,0,0,0)'
  54711. }
  54712. })));
  54713. var iconStr = dataZoomModel.get('handleIcon');
  54714. each([0, 1], function (handleIndex) {
  54715. var iconOpt = {
  54716. style: {
  54717. strokeNoScale: true
  54718. },
  54719. rectHover: true,
  54720. cursor: this._orient === 'vertical' ? 'ns-resize' : 'ew-resize',
  54721. draggable: true,
  54722. drift: bind(this._onDragMove, this, handleIndex),
  54723. onmousemove: function (e) {
  54724. // Fot mobile devicem, prevent screen slider on the button.
  54725. eventTool.stop(e.event);
  54726. },
  54727. ondragend: bind(this._onDragEnd, this),
  54728. onmouseover: bind(this._showDataInfo, this, true),
  54729. onmouseout: bind(this._showDataInfo, this, false)
  54730. };
  54731. var iconStyle = {x: -1, y: 0, width: 2, height: 2};
  54732. var path = iconStr.indexOf('image://') === 0
  54733. ? (
  54734. iconStyle.image = iconStr.slice(8),
  54735. iconOpt.style = iconStyle,
  54736. new graphic.Image(iconOpt)
  54737. )
  54738. : graphic.makePath(
  54739. iconStr.replace('path://', ''),
  54740. iconOpt,
  54741. iconStyle,
  54742. 'center'
  54743. );
  54744. var bRect = path.getBoundingRect();
  54745. this._handleHeight = numberUtil.parsePercent(dataZoomModel.get('handleSize'), this._size[1]);
  54746. this._handleWidth = bRect.width / bRect.height * this._handleHeight;
  54747. path.setStyle(dataZoomModel.getModel('handleStyle').getItemStyle());
  54748. var handleColor = dataZoomModel.get('handleColor');
  54749. // Compatitable with previous version
  54750. if (handleColor != null) {
  54751. path.style.fill = handleColor;
  54752. }
  54753. barGroup.add(handles[handleIndex] = path);
  54754. var textStyleModel = dataZoomModel.textStyleModel;
  54755. this.group.add(
  54756. handleLabels[handleIndex] = new graphic.Text({
  54757. silent: true,
  54758. invisible: true,
  54759. style: {
  54760. x: 0, y: 0, text: '',
  54761. textVerticalAlign: 'middle',
  54762. textAlign: 'center',
  54763. fill: textStyleModel.getTextColor(),
  54764. textFont: textStyleModel.getFont()
  54765. },
  54766. z2: 10
  54767. }));
  54768. }, this);
  54769. },
  54770. /**
  54771. * @private
  54772. */
  54773. _resetInterval: function () {
  54774. var range = this._range = this.dataZoomModel.getPercentRange();
  54775. var viewExtent = this._getViewExtent();
  54776. this._handleEnds = [
  54777. linearMap(range[0], [0, 100], viewExtent, true),
  54778. linearMap(range[1], [0, 100], viewExtent, true)
  54779. ];
  54780. },
  54781. /**
  54782. * @private
  54783. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  54784. * @param {number} delta
  54785. */
  54786. _updateInterval: function (handleIndex, delta) {
  54787. var dataZoomModel = this.dataZoomModel;
  54788. var handleEnds = this._handleEnds;
  54789. var viewExtend = this._getViewExtent();
  54790. var minMaxSpan = dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
  54791. var percentExtent = [0, 100];
  54792. sliderMove(
  54793. delta,
  54794. handleEnds,
  54795. viewExtend,
  54796. dataZoomModel.get('zoomLock') ? 'all' : handleIndex,
  54797. minMaxSpan.minSpan != null
  54798. ? linearMap(minMaxSpan.minSpan, percentExtent, viewExtend, true) : null,
  54799. minMaxSpan.maxSpan != null
  54800. ? linearMap(minMaxSpan.maxSpan, percentExtent, viewExtend, true) : null
  54801. );
  54802. this._range = asc([
  54803. linearMap(handleEnds[0], viewExtend, percentExtent, true),
  54804. linearMap(handleEnds[1], viewExtend, percentExtent, true)
  54805. ]);
  54806. },
  54807. /**
  54808. * @private
  54809. */
  54810. _updateView: function (nonRealtime) {
  54811. var displaybles = this._displayables;
  54812. var handleEnds = this._handleEnds;
  54813. var handleInterval = asc(handleEnds.slice());
  54814. var size = this._size;
  54815. each([0, 1], function (handleIndex) {
  54816. // Handles
  54817. var handle = displaybles.handles[handleIndex];
  54818. var handleHeight = this._handleHeight;
  54819. handle.attr({
  54820. scale: [handleHeight / 2, handleHeight / 2],
  54821. position: [handleEnds[handleIndex], size[1] / 2 - handleHeight / 2]
  54822. });
  54823. }, this);
  54824. // Filler
  54825. displaybles.filler.setShape({
  54826. x: handleInterval[0],
  54827. y: 0,
  54828. width: handleInterval[1] - handleInterval[0],
  54829. height: size[1]
  54830. });
  54831. this._updateDataInfo(nonRealtime);
  54832. },
  54833. /**
  54834. * @private
  54835. */
  54836. _updateDataInfo: function (nonRealtime) {
  54837. var dataZoomModel = this.dataZoomModel;
  54838. var displaybles = this._displayables;
  54839. var handleLabels = displaybles.handleLabels;
  54840. var orient = this._orient;
  54841. var labelTexts = ['', ''];
  54842. // FIXME
  54843. // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter)
  54844. if (dataZoomModel.get('showDetail')) {
  54845. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  54846. if (axisProxy) {
  54847. var axis = axisProxy.getAxisModel().axis;
  54848. var range = this._range;
  54849. var dataInterval = nonRealtime
  54850. // See #4434, data and axis are not processed and reset yet in non-realtime mode.
  54851. ? axisProxy.calculateDataWindow({
  54852. start: range[0], end: range[1]
  54853. }).valueWindow
  54854. : axisProxy.getDataValueWindow();
  54855. labelTexts = [
  54856. this._formatLabel(dataInterval[0], axis),
  54857. this._formatLabel(dataInterval[1], axis)
  54858. ];
  54859. }
  54860. }
  54861. var orderedHandleEnds = asc(this._handleEnds.slice());
  54862. setLabel.call(this, 0);
  54863. setLabel.call(this, 1);
  54864. function setLabel(handleIndex) {
  54865. // Label
  54866. // Text should not transform by barGroup.
  54867. // Ignore handlers transform
  54868. var barTransform = graphic.getTransform(
  54869. displaybles.handles[handleIndex].parent, this.group
  54870. );
  54871. var direction = graphic.transformDirection(
  54872. handleIndex === 0 ? 'right' : 'left', barTransform
  54873. );
  54874. var offset = this._handleWidth / 2 + LABEL_GAP;
  54875. var textPoint = graphic.applyTransform(
  54876. [
  54877. orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset),
  54878. this._size[1] / 2
  54879. ],
  54880. barTransform
  54881. );
  54882. handleLabels[handleIndex].setStyle({
  54883. x: textPoint[0],
  54884. y: textPoint[1],
  54885. textVerticalAlign: orient === HORIZONTAL ? 'middle' : direction,
  54886. textAlign: orient === HORIZONTAL ? direction : 'center',
  54887. text: labelTexts[handleIndex]
  54888. });
  54889. }
  54890. },
  54891. /**
  54892. * @private
  54893. */
  54894. _formatLabel: function (value, axis) {
  54895. var dataZoomModel = this.dataZoomModel;
  54896. var labelFormatter = dataZoomModel.get('labelFormatter');
  54897. var labelPrecision = dataZoomModel.get('labelPrecision');
  54898. if (labelPrecision == null || labelPrecision === 'auto') {
  54899. labelPrecision = axis.getPixelPrecision();
  54900. }
  54901. var valueStr = (value == null || isNaN(value))
  54902. ? ''
  54903. // FIXME Glue code
  54904. : (axis.type === 'category' || axis.type === 'time')
  54905. ? axis.scale.getLabel(Math.round(value))
  54906. // param of toFixed should less then 20.
  54907. : value.toFixed(Math.min(labelPrecision, 20));
  54908. return zrUtil.isFunction(labelFormatter)
  54909. ? labelFormatter(value, valueStr)
  54910. : zrUtil.isString(labelFormatter)
  54911. ? labelFormatter.replace('{value}', valueStr)
  54912. : valueStr;
  54913. },
  54914. /**
  54915. * @private
  54916. * @param {boolean} showOrHide true: show, false: hide
  54917. */
  54918. _showDataInfo: function (showOrHide) {
  54919. // Always show when drgging.
  54920. showOrHide = this._dragging || showOrHide;
  54921. var handleLabels = this._displayables.handleLabels;
  54922. handleLabels[0].attr('invisible', !showOrHide);
  54923. handleLabels[1].attr('invisible', !showOrHide);
  54924. },
  54925. _onDragMove: function (handleIndex, dx, dy) {
  54926. this._dragging = true;
  54927. // Transform dx, dy to bar coordination.
  54928. var barTransform = this._displayables.barGroup.getLocalTransform();
  54929. var vertex = graphic.applyTransform([dx, dy], barTransform, true);
  54930. this._updateInterval(handleIndex, vertex[0]);
  54931. var realtime = this.dataZoomModel.get('realtime');
  54932. this._updateView(!realtime);
  54933. if (realtime) {
  54934. realtime && this._dispatchZoomAction();
  54935. }
  54936. },
  54937. _onDragEnd: function () {
  54938. this._dragging = false;
  54939. this._showDataInfo(false);
  54940. this._dispatchZoomAction();
  54941. },
  54942. _onClickPanelClick: function (e) {
  54943. var size = this._size;
  54944. var localPoint = this._displayables.barGroup.transformCoordToLocal(e.offsetX, e.offsetY);
  54945. if (localPoint[0] < 0 || localPoint[0] > size[0]
  54946. || localPoint[1] < 0 || localPoint[1] > size[1]
  54947. ) {
  54948. return;
  54949. }
  54950. var handleEnds = this._handleEnds;
  54951. var center = (handleEnds[0] + handleEnds[1]) / 2;
  54952. this._updateInterval('all', localPoint[0] - center);
  54953. this._updateView();
  54954. this._dispatchZoomAction();
  54955. },
  54956. /**
  54957. * This action will be throttled.
  54958. * @private
  54959. */
  54960. _dispatchZoomAction: function () {
  54961. var range = this._range;
  54962. this.api.dispatchAction({
  54963. type: 'dataZoom',
  54964. from: this.uid,
  54965. dataZoomId: this.dataZoomModel.id,
  54966. start: range[0],
  54967. end: range[1]
  54968. });
  54969. },
  54970. /**
  54971. * @private
  54972. */
  54973. _findCoordRect: function () {
  54974. // Find the grid coresponding to the first axis referred by dataZoom.
  54975. var rect;
  54976. each(this.getTargetCoordInfo(), function (coordInfoList) {
  54977. if (!rect && coordInfoList.length) {
  54978. var coordSys = coordInfoList[0].model.coordinateSystem;
  54979. rect = coordSys.getRect && coordSys.getRect();
  54980. }
  54981. });
  54982. if (!rect) {
  54983. var width = this.api.getWidth();
  54984. var height = this.api.getHeight();
  54985. rect = {
  54986. x: width * 0.2,
  54987. y: height * 0.2,
  54988. width: width * 0.6,
  54989. height: height * 0.6
  54990. };
  54991. }
  54992. return rect;
  54993. }
  54994. });
  54995. function getOtherDim(thisDim) {
  54996. // FIXME
  54997. // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
  54998. var map = {x: 'y', y: 'x', radius: 'angle', angle: 'radius'};
  54999. return map[thisDim];
  55000. }
  55001. module.exports = SliderZoomView;
  55002. /***/ },
  55003. /* 371 */
  55004. /***/ function(module, exports, __webpack_require__) {
  55005. /**
  55006. * @file Data zoom model
  55007. */
  55008. module.exports = __webpack_require__(365).extend({
  55009. type: 'dataZoom.inside',
  55010. /**
  55011. * @protected
  55012. */
  55013. defaultOption: {
  55014. disabled: false, // Whether disable this inside zoom.
  55015. zoomLock: false, // Whether disable zoom but only pan.
  55016. zoomOnMouseWheel: true, // Can be: true / false / 'shift' / 'ctrl' / 'alt'.
  55017. moveOnMouseMove: true, // Can be: true / false / 'shift' / 'ctrl' / 'alt'.
  55018. preventDefaultMouseMove: true
  55019. }
  55020. });
  55021. /***/ },
  55022. /* 372 */
  55023. /***/ function(module, exports, __webpack_require__) {
  55024. var DataZoomView = __webpack_require__(368);
  55025. var zrUtil = __webpack_require__(4);
  55026. var sliderMove = __webpack_require__(239);
  55027. var roams = __webpack_require__(373);
  55028. var bind = zrUtil.bind;
  55029. var InsideZoomView = DataZoomView.extend({
  55030. type: 'dataZoom.inside',
  55031. /**
  55032. * @override
  55033. */
  55034. init: function (ecModel, api) {
  55035. /**
  55036. * 'throttle' is used in this.dispatchAction, so we save range
  55037. * to avoid missing some 'pan' info.
  55038. * @private
  55039. * @type {Array.<number>}
  55040. */
  55041. this._range;
  55042. },
  55043. /**
  55044. * @override
  55045. */
  55046. render: function (dataZoomModel, ecModel, api, payload) {
  55047. InsideZoomView.superApply(this, 'render', arguments);
  55048. // Notice: origin this._range should be maintained, and should not be re-fetched
  55049. // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom'
  55050. // info will be missed because of 'throttle' of this.dispatchAction.
  55051. if (roams.shouldRecordRange(payload, dataZoomModel.id)) {
  55052. this._range = dataZoomModel.getPercentRange();
  55053. }
  55054. // Reset controllers.
  55055. zrUtil.each(this.getTargetCoordInfo(), function (coordInfoList, coordSysName) {
  55056. var allCoordIds = zrUtil.map(coordInfoList, function (coordInfo) {
  55057. return roams.generateCoordId(coordInfo.model);
  55058. });
  55059. zrUtil.each(coordInfoList, function (coordInfo) {
  55060. var coordModel = coordInfo.model;
  55061. var dataZoomOption = dataZoomModel.option;
  55062. roams.register(
  55063. api,
  55064. {
  55065. coordId: roams.generateCoordId(coordModel),
  55066. allCoordIds: allCoordIds,
  55067. containsPoint: function (e, x, y) {
  55068. return coordModel.coordinateSystem.containPoint([x, y]);
  55069. },
  55070. dataZoomId: dataZoomModel.id,
  55071. throttleRate: dataZoomModel.get('throttle', true),
  55072. panGetRange: bind(this._onPan, this, coordInfo, coordSysName),
  55073. zoomGetRange: bind(this._onZoom, this, coordInfo, coordSysName),
  55074. zoomLock: dataZoomOption.zoomLock,
  55075. disabled: dataZoomOption.disabled,
  55076. roamControllerOpt: {
  55077. zoomOnMouseWheel: dataZoomOption.zoomOnMouseWheel,
  55078. moveOnMouseMove: dataZoomOption.moveOnMouseMove,
  55079. preventDefaultMouseMove: dataZoomOption.preventDefaultMouseMove
  55080. }
  55081. }
  55082. );
  55083. }, this);
  55084. }, this);
  55085. },
  55086. /**
  55087. * @override
  55088. */
  55089. dispose: function () {
  55090. roams.unregister(this.api, this.dataZoomModel.id);
  55091. InsideZoomView.superApply(this, 'dispose', arguments);
  55092. this._range = null;
  55093. },
  55094. /**
  55095. * @private
  55096. */
  55097. _onPan: function (coordInfo, coordSysName, controller, dx, dy, oldX, oldY, newX, newY) {
  55098. var range = this._range.slice();
  55099. // Calculate transform by the first axis.
  55100. var axisModel = coordInfo.axisModels[0];
  55101. if (!axisModel) {
  55102. return;
  55103. }
  55104. var directionInfo = getDirectionInfo[coordSysName](
  55105. [oldX, oldY], [newX, newY], axisModel, controller, coordInfo
  55106. );
  55107. var percentDelta = directionInfo.signal
  55108. * (range[1] - range[0])
  55109. * directionInfo.pixel / directionInfo.pixelLength;
  55110. sliderMove(percentDelta, range, [0, 100], 'all');
  55111. return (this._range = range);
  55112. },
  55113. /**
  55114. * @private
  55115. */
  55116. _onZoom: function (coordInfo, coordSysName, controller, scale, mouseX, mouseY) {
  55117. var range = this._range.slice();
  55118. // Calculate transform by the first axis.
  55119. var axisModel = coordInfo.axisModels[0];
  55120. if (!axisModel) {
  55121. return;
  55122. }
  55123. var directionInfo = getDirectionInfo[coordSysName](
  55124. null, [mouseX, mouseY], axisModel, controller, coordInfo
  55125. );
  55126. var percentPoint = (
  55127. directionInfo.signal > 0
  55128. ? (directionInfo.pixelStart + directionInfo.pixelLength - directionInfo.pixel)
  55129. : (directionInfo.pixel - directionInfo.pixelStart)
  55130. ) / directionInfo.pixelLength * (range[1] - range[0]) + range[0];
  55131. scale = Math.max(1 / scale, 0);
  55132. range[0] = (range[0] - percentPoint) * scale + percentPoint;
  55133. range[1] = (range[1] - percentPoint) * scale + percentPoint;
  55134. // Restrict range.
  55135. var minMaxSpan = this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
  55136. sliderMove(0, range, [0, 100], 0, minMaxSpan.minSpan, minMaxSpan.maxSpan);
  55137. return (this._range = range);
  55138. }
  55139. });
  55140. var getDirectionInfo = {
  55141. grid: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  55142. var axis = axisModel.axis;
  55143. var ret = {};
  55144. var rect = coordInfo.model.coordinateSystem.getRect();
  55145. oldPoint = oldPoint || [0, 0];
  55146. if (axis.dim === 'x') {
  55147. ret.pixel = newPoint[0] - oldPoint[0];
  55148. ret.pixelLength = rect.width;
  55149. ret.pixelStart = rect.x;
  55150. ret.signal = axis.inverse ? 1 : -1;
  55151. }
  55152. else { // axis.dim === 'y'
  55153. ret.pixel = newPoint[1] - oldPoint[1];
  55154. ret.pixelLength = rect.height;
  55155. ret.pixelStart = rect.y;
  55156. ret.signal = axis.inverse ? -1 : 1;
  55157. }
  55158. return ret;
  55159. },
  55160. polar: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  55161. var axis = axisModel.axis;
  55162. var ret = {};
  55163. var polar = coordInfo.model.coordinateSystem;
  55164. var radiusExtent = polar.getRadiusAxis().getExtent();
  55165. var angleExtent = polar.getAngleAxis().getExtent();
  55166. oldPoint = oldPoint ? polar.pointToCoord(oldPoint) : [0, 0];
  55167. newPoint = polar.pointToCoord(newPoint);
  55168. if (axisModel.mainType === 'radiusAxis') {
  55169. ret.pixel = newPoint[0] - oldPoint[0];
  55170. // ret.pixelLength = Math.abs(radiusExtent[1] - radiusExtent[0]);
  55171. // ret.pixelStart = Math.min(radiusExtent[0], radiusExtent[1]);
  55172. ret.pixelLength = radiusExtent[1] - radiusExtent[0];
  55173. ret.pixelStart = radiusExtent[0];
  55174. ret.signal = axis.inverse ? 1 : -1;
  55175. }
  55176. else { // 'angleAxis'
  55177. ret.pixel = newPoint[1] - oldPoint[1];
  55178. // ret.pixelLength = Math.abs(angleExtent[1] - angleExtent[0]);
  55179. // ret.pixelStart = Math.min(angleExtent[0], angleExtent[1]);
  55180. ret.pixelLength = angleExtent[1] - angleExtent[0];
  55181. ret.pixelStart = angleExtent[0];
  55182. ret.signal = axis.inverse ? -1 : 1;
  55183. }
  55184. return ret;
  55185. },
  55186. singleAxis: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  55187. var axis = axisModel.axis;
  55188. var rect = coordInfo.model.coordinateSystem.getRect();
  55189. var ret = {};
  55190. oldPoint = oldPoint || [0, 0];
  55191. if (axis.orient === 'horizontal') {
  55192. ret.pixel = newPoint[0] - oldPoint[0];
  55193. ret.pixelLength = rect.width;
  55194. ret.pixelStart = rect.x;
  55195. ret.signal = axis.inverse ? 1 : -1;
  55196. }
  55197. else { // 'vertical'
  55198. ret.pixel = newPoint[1] - oldPoint[1];
  55199. ret.pixelLength = rect.height;
  55200. ret.pixelStart = rect.y;
  55201. ret.signal = axis.inverse ? -1 : 1;
  55202. }
  55203. return ret;
  55204. }
  55205. };
  55206. module.exports = InsideZoomView;
  55207. /***/ },
  55208. /* 373 */
  55209. /***/ function(module, exports, __webpack_require__) {
  55210. /**
  55211. * @file Roam controller manager.
  55212. */
  55213. // Only create one roam controller for each coordinate system.
  55214. // one roam controller might be refered by two inside data zoom
  55215. // components (for example, one for x and one for y). When user
  55216. // pan or zoom, only dispatch one action for those data zoom
  55217. // components.
  55218. var zrUtil = __webpack_require__(4);
  55219. var RoamController = __webpack_require__(183);
  55220. var throttle = __webpack_require__(81);
  55221. var curry = zrUtil.curry;
  55222. var ATTR = '\0_ec_dataZoom_roams';
  55223. var roams = {
  55224. /**
  55225. * @public
  55226. * @param {module:echarts/ExtensionAPI} api
  55227. * @param {Object} dataZoomInfo
  55228. * @param {string} dataZoomInfo.coordId
  55229. * @param {Function} dataZoomInfo.containsPoint
  55230. * @param {Array.<string>} dataZoomInfo.allCoordIds
  55231. * @param {string} dataZoomInfo.dataZoomId
  55232. * @param {number} dataZoomInfo.throttleRate
  55233. * @param {Function} dataZoomInfo.panGetRange
  55234. * @param {Function} dataZoomInfo.zoomGetRange
  55235. * @param {boolean} [dataZoomInfo.zoomLock]
  55236. * @param {boolean} [dataZoomInfo.disabled]
  55237. */
  55238. register: function (api, dataZoomInfo) {
  55239. var store = giveStore(api);
  55240. var theDataZoomId = dataZoomInfo.dataZoomId;
  55241. var theCoordId = dataZoomInfo.coordId;
  55242. // Do clean when a dataZoom changes its target coordnate system.
  55243. // Avoid memory leak, dispose all not-used-registered.
  55244. zrUtil.each(store, function (record, coordId) {
  55245. var dataZoomInfos = record.dataZoomInfos;
  55246. if (dataZoomInfos[theDataZoomId]
  55247. && zrUtil.indexOf(dataZoomInfo.allCoordIds, theCoordId) < 0
  55248. ) {
  55249. delete dataZoomInfos[theDataZoomId];
  55250. record.count--;
  55251. }
  55252. });
  55253. cleanStore(store);
  55254. var record = store[theCoordId];
  55255. // Create if needed.
  55256. if (!record) {
  55257. record = store[theCoordId] = {
  55258. coordId: theCoordId,
  55259. dataZoomInfos: {},
  55260. count: 0
  55261. };
  55262. record.controller = createController(api, record);
  55263. record.dispatchAction = zrUtil.curry(dispatchAction, api);
  55264. }
  55265. // Update reference of dataZoom.
  55266. !(record.dataZoomInfos[theDataZoomId]) && record.count++;
  55267. record.dataZoomInfos[theDataZoomId] = dataZoomInfo;
  55268. var controllerParams = mergeControllerParams(record.dataZoomInfos);
  55269. record.controller.enable(controllerParams.controlType, controllerParams.opt);
  55270. // Consider resize, area should be always updated.
  55271. record.controller.setPointerChecker(dataZoomInfo.containsPoint);
  55272. // Update throttle.
  55273. throttle.createOrUpdate(
  55274. record,
  55275. 'dispatchAction',
  55276. dataZoomInfo.throttleRate,
  55277. 'fixRate'
  55278. );
  55279. },
  55280. /**
  55281. * @public
  55282. * @param {module:echarts/ExtensionAPI} api
  55283. * @param {string} dataZoomId
  55284. */
  55285. unregister: function (api, dataZoomId) {
  55286. var store = giveStore(api);
  55287. zrUtil.each(store, function (record) {
  55288. record.controller.dispose();
  55289. var dataZoomInfos = record.dataZoomInfos;
  55290. if (dataZoomInfos[dataZoomId]) {
  55291. delete dataZoomInfos[dataZoomId];
  55292. record.count--;
  55293. }
  55294. });
  55295. cleanStore(store);
  55296. },
  55297. /**
  55298. * @public
  55299. */
  55300. shouldRecordRange: function (payload, dataZoomId) {
  55301. if (payload && payload.type === 'dataZoom' && payload.batch) {
  55302. for (var i = 0, len = payload.batch.length; i < len; i++) {
  55303. if (payload.batch[i].dataZoomId === dataZoomId) {
  55304. return false;
  55305. }
  55306. }
  55307. }
  55308. return true;
  55309. },
  55310. /**
  55311. * @public
  55312. */
  55313. generateCoordId: function (coordModel) {
  55314. return coordModel.type + '\0_' + coordModel.id;
  55315. }
  55316. };
  55317. /**
  55318. * Key: coordId, value: {dataZoomInfos: [], count, controller}
  55319. * @type {Array.<Object>}
  55320. */
  55321. function giveStore(api) {
  55322. // Mount store on zrender instance, so that we do not
  55323. // need to worry about dispose.
  55324. var zr = api.getZr();
  55325. return zr[ATTR] || (zr[ATTR] = {});
  55326. }
  55327. function createController(api, newRecord) {
  55328. var controller = new RoamController(api.getZr());
  55329. controller.on('pan', curry(onPan, newRecord));
  55330. controller.on('zoom', curry(onZoom, newRecord));
  55331. return controller;
  55332. }
  55333. function cleanStore(store) {
  55334. zrUtil.each(store, function (record, coordId) {
  55335. if (!record.count) {
  55336. record.controller.dispose();
  55337. delete store[coordId];
  55338. }
  55339. });
  55340. }
  55341. function onPan(record, dx, dy, oldX, oldY, newX, newY) {
  55342. wrapAndDispatch(record, function (info) {
  55343. return info.panGetRange(record.controller, dx, dy, oldX, oldY, newX, newY);
  55344. });
  55345. }
  55346. function onZoom(record, scale, mouseX, mouseY) {
  55347. wrapAndDispatch(record, function (info) {
  55348. return info.zoomGetRange(record.controller, scale, mouseX, mouseY);
  55349. });
  55350. }
  55351. function wrapAndDispatch(record, getRange) {
  55352. var batch = [];
  55353. zrUtil.each(record.dataZoomInfos, function (info) {
  55354. var range = getRange(info);
  55355. !info.disabled && range && batch.push({
  55356. dataZoomId: info.dataZoomId,
  55357. start: range[0],
  55358. end: range[1]
  55359. });
  55360. });
  55361. record.dispatchAction(batch);
  55362. }
  55363. /**
  55364. * This action will be throttled.
  55365. */
  55366. function dispatchAction(api, batch) {
  55367. api.dispatchAction({
  55368. type: 'dataZoom',
  55369. batch: batch
  55370. });
  55371. }
  55372. /**
  55373. * Merge roamController settings when multiple dataZooms share one roamController.
  55374. */
  55375. function mergeControllerParams(dataZoomInfos) {
  55376. var controlType;
  55377. var opt = {};
  55378. var typePriority = {
  55379. 'true': 2,
  55380. 'move': 1,
  55381. 'false': 0,
  55382. 'undefined': -1
  55383. };
  55384. zrUtil.each(dataZoomInfos, function (dataZoomInfo) {
  55385. var oneType = dataZoomInfo.disabled ? false : dataZoomInfo.zoomLock ? 'move' : true;
  55386. typePriority[oneType] > typePriority[controlType] && (controlType = oneType);
  55387. // Do not support that different 'shift'/'ctrl'/'alt' setting used in one coord sys.
  55388. zrUtil.extend(opt, dataZoomInfo.roamControllerOpt);
  55389. });
  55390. return {
  55391. controlType: controlType,
  55392. opt: opt
  55393. };
  55394. }
  55395. module.exports = roams;
  55396. /***/ },
  55397. /* 374 */
  55398. /***/ function(module, exports, __webpack_require__) {
  55399. /**
  55400. * @file Data zoom processor
  55401. */
  55402. var echarts = __webpack_require__(1);
  55403. echarts.registerProcessor(function (ecModel, api) {
  55404. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  55405. // We calculate window and reset axis here but not in model
  55406. // init stage and not after action dispatch handler, because
  55407. // reset should be called after seriesData.restoreData.
  55408. dataZoomModel.eachTargetAxis(resetSingleAxis);
  55409. // Caution: data zoom filtering is order sensitive when using
  55410. // percent range and no min/max/scale set on axis.
  55411. // For example, we have dataZoom definition:
  55412. // [
  55413. // {xAxisIndex: 0, start: 30, end: 70},
  55414. // {yAxisIndex: 0, start: 20, end: 80}
  55415. // ]
  55416. // In this case, [20, 80] of y-dataZoom should be based on data
  55417. // that have filtered by x-dataZoom using range of [30, 70],
  55418. // but should not be based on full raw data. Thus sliding
  55419. // x-dataZoom will change both ranges of xAxis and yAxis,
  55420. // while sliding y-dataZoom will only change the range of yAxis.
  55421. // So we should filter x-axis after reset x-axis immediately,
  55422. // and then reset y-axis and filter y-axis.
  55423. dataZoomModel.eachTargetAxis(filterSingleAxis);
  55424. });
  55425. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  55426. // Fullfill all of the range props so that user
  55427. // is able to get them from chart.getOption().
  55428. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  55429. var percentRange = axisProxy.getDataPercentWindow();
  55430. var valueRange = axisProxy.getDataValueWindow();
  55431. dataZoomModel.setRawRange({
  55432. start: percentRange[0],
  55433. end: percentRange[1],
  55434. startValue: valueRange[0],
  55435. endValue: valueRange[1]
  55436. }, true);
  55437. });
  55438. });
  55439. function resetSingleAxis(dimNames, axisIndex, dataZoomModel) {
  55440. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel);
  55441. }
  55442. function filterSingleAxis(dimNames, axisIndex, dataZoomModel) {
  55443. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel);
  55444. }
  55445. /***/ },
  55446. /* 375 */
  55447. /***/ function(module, exports, __webpack_require__) {
  55448. /**
  55449. * @file Data zoom action
  55450. */
  55451. var zrUtil = __webpack_require__(4);
  55452. var helper = __webpack_require__(366);
  55453. var echarts = __webpack_require__(1);
  55454. echarts.registerAction('dataZoom', function (payload, ecModel) {
  55455. var linkedNodesFinder = helper.createLinkedNodesFinder(
  55456. zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'),
  55457. helper.eachAxisDim,
  55458. function (model, dimNames) {
  55459. return model.get(dimNames.axisIndex);
  55460. }
  55461. );
  55462. var effectedModels = [];
  55463. ecModel.eachComponent(
  55464. {mainType: 'dataZoom', query: payload},
  55465. function (model, index) {
  55466. effectedModels.push.apply(
  55467. effectedModels, linkedNodesFinder(model).nodes
  55468. );
  55469. }
  55470. );
  55471. zrUtil.each(effectedModels, function (dataZoomModel, index) {
  55472. dataZoomModel.setRawRange({
  55473. start: payload.start,
  55474. end: payload.end,
  55475. startValue: payload.startValue,
  55476. endValue: payload.endValue
  55477. });
  55478. });
  55479. });
  55480. /***/ },
  55481. /* 376 */
  55482. /***/ function(module, exports, __webpack_require__) {
  55483. /**
  55484. * visualMap component entry
  55485. */
  55486. __webpack_require__(377);
  55487. __webpack_require__(388);
  55488. /***/ },
  55489. /* 377 */
  55490. /***/ function(module, exports, __webpack_require__) {
  55491. /**
  55492. * DataZoom component entry
  55493. */
  55494. __webpack_require__(1).registerPreprocessor(
  55495. __webpack_require__(378)
  55496. );
  55497. __webpack_require__(379);
  55498. __webpack_require__(380);
  55499. __webpack_require__(381);
  55500. __webpack_require__(384);
  55501. __webpack_require__(387);
  55502. /***/ },
  55503. /* 378 */
  55504. /***/ function(module, exports, __webpack_require__) {
  55505. /**
  55506. * @file VisualMap preprocessor
  55507. */
  55508. var zrUtil = __webpack_require__(4);
  55509. var each = zrUtil.each;
  55510. module.exports = function (option) {
  55511. var visualMap = option && option.visualMap;
  55512. if (!zrUtil.isArray(visualMap)) {
  55513. visualMap = visualMap ? [visualMap] : [];
  55514. }
  55515. each(visualMap, function (opt) {
  55516. if (!opt) {
  55517. return;
  55518. }
  55519. // rename splitList to pieces
  55520. if (has(opt, 'splitList') && !has(opt, 'pieces')) {
  55521. opt.pieces = opt.splitList;
  55522. delete opt.splitList;
  55523. }
  55524. var pieces = opt.pieces;
  55525. if (pieces && zrUtil.isArray(pieces)) {
  55526. each(pieces, function (piece) {
  55527. if (zrUtil.isObject(piece)) {
  55528. if (has(piece, 'start') && !has(piece, 'min')) {
  55529. piece.min = piece.start;
  55530. }
  55531. if (has(piece, 'end') && !has(piece, 'max')) {
  55532. piece.max = piece.end;
  55533. }
  55534. }
  55535. });
  55536. }
  55537. });
  55538. };
  55539. function has(obj, name) {
  55540. return obj && obj.hasOwnProperty && obj.hasOwnProperty(name);
  55541. }
  55542. /***/ },
  55543. /* 379 */
  55544. /***/ function(module, exports, __webpack_require__) {
  55545. __webpack_require__(69).registerSubTypeDefaulter('visualMap', function (option) {
  55546. // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used.
  55547. return (
  55548. !option.categories
  55549. && (
  55550. !(
  55551. option.pieces
  55552. ? option.pieces.length > 0
  55553. : option.splitNumber > 0
  55554. )
  55555. || option.calculable
  55556. )
  55557. )
  55558. ? 'continuous' : 'piecewise';
  55559. });
  55560. /***/ },
  55561. /* 380 */
  55562. /***/ function(module, exports, __webpack_require__) {
  55563. /**
  55564. * @file Data range visual coding.
  55565. */
  55566. var echarts = __webpack_require__(1);
  55567. var visualSolution = __webpack_require__(350);
  55568. var VisualMapping = __webpack_require__(203);
  55569. var zrUtil = __webpack_require__(4);
  55570. echarts.registerVisual(echarts.PRIORITY.VISUAL.COMPONENT, function (ecModel) {
  55571. ecModel.eachComponent('visualMap', function (visualMapModel) {
  55572. processSingleVisualMap(visualMapModel, ecModel);
  55573. });
  55574. prepareVisualMeta(ecModel);
  55575. });
  55576. function processSingleVisualMap(visualMapModel, ecModel) {
  55577. visualMapModel.eachTargetSeries(function (seriesModel) {
  55578. var data = seriesModel.getData();
  55579. visualSolution.applyVisual(
  55580. visualMapModel.stateList,
  55581. visualMapModel.targetVisuals,
  55582. data,
  55583. visualMapModel.getValueState,
  55584. visualMapModel,
  55585. visualMapModel.getDataDimension(data)
  55586. );
  55587. });
  55588. }
  55589. // Only support color.
  55590. function prepareVisualMeta(ecModel) {
  55591. ecModel.eachSeries(function (seriesModel) {
  55592. var data = seriesModel.getData();
  55593. var visualMetaList = [];
  55594. ecModel.eachComponent('visualMap', function (visualMapModel) {
  55595. if (visualMapModel.isTargetSeries(seriesModel)) {
  55596. var visualMeta = visualMapModel.getVisualMeta(
  55597. zrUtil.bind(getColorVisual, null, seriesModel, visualMapModel)
  55598. ) || {stops: [], outerColors: []};
  55599. visualMeta.dimension = visualMapModel.getDataDimension(data);
  55600. visualMetaList.push(visualMeta);
  55601. }
  55602. });
  55603. // console.log(JSON.stringify(visualMetaList.map(a => a.stops)));
  55604. seriesModel.getData().setVisual('visualMeta', visualMetaList);
  55605. });
  55606. }
  55607. // FIXME
  55608. // performance and export for heatmap?
  55609. // value can be Infinity or -Infinity
  55610. function getColorVisual(seriesModel, visualMapModel, value, valueState) {
  55611. var mappings = visualMapModel.targetVisuals[valueState];
  55612. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  55613. var resultVisual = {
  55614. color: seriesModel.getData().getVisual('color') // default color.
  55615. };
  55616. for (var i = 0, len = visualTypes.length; i < len; i++) {
  55617. var type = visualTypes[i];
  55618. var mapping = mappings[
  55619. type === 'opacity' ? '__alphaForOpacity' : type
  55620. ];
  55621. mapping && mapping.applyVisual(value, getVisual, setVisual);
  55622. }
  55623. return resultVisual.color;
  55624. function getVisual(key) {
  55625. return resultVisual[key];
  55626. }
  55627. function setVisual(key, value) {
  55628. resultVisual[key] = value;
  55629. }
  55630. }
  55631. /***/ },
  55632. /* 381 */
  55633. /***/ function(module, exports, __webpack_require__) {
  55634. /**
  55635. * @file Data zoom model
  55636. */
  55637. var VisualMapModel = __webpack_require__(382);
  55638. var zrUtil = __webpack_require__(4);
  55639. var numberUtil = __webpack_require__(7);
  55640. // Constant
  55641. var DEFAULT_BAR_BOUND = [20, 140];
  55642. var ContinuousModel = VisualMapModel.extend({
  55643. type: 'visualMap.continuous',
  55644. /**
  55645. * @protected
  55646. */
  55647. defaultOption: {
  55648. align: 'auto', // 'auto', 'left', 'right', 'top', 'bottom'
  55649. calculable: false, // This prop effect default component type determine,
  55650. // See echarts/component/visualMap/typeDefaulter.
  55651. range: null, // selected range. In default case `range` is [min, max]
  55652. // and can auto change along with modification of min max,
  55653. // util use specifid a range.
  55654. realtime: true, // Whether realtime update.
  55655. itemHeight: null, // The length of the range control edge.
  55656. itemWidth: null, // The length of the other side.
  55657. hoverLink: true, // Enable hover highlight.
  55658. hoverLinkDataSize: null,// The size of hovered data.
  55659. hoverLinkOnHandle: true // Whether trigger hoverLink when hover handle.
  55660. },
  55661. /**
  55662. * @override
  55663. */
  55664. optionUpdated: function (newOption, isInit) {
  55665. ContinuousModel.superApply(this, 'optionUpdated', arguments);
  55666. this.resetTargetSeries();
  55667. this.resetExtent();
  55668. this.resetVisual(function (mappingOption) {
  55669. mappingOption.mappingMethod = 'linear';
  55670. mappingOption.dataExtent = this.getExtent();
  55671. });
  55672. this._resetRange();
  55673. },
  55674. /**
  55675. * @protected
  55676. * @override
  55677. */
  55678. resetItemSize: function () {
  55679. ContinuousModel.superApply(this, 'resetItemSize', arguments);
  55680. var itemSize = this.itemSize;
  55681. this._orient === 'horizontal' && itemSize.reverse();
  55682. (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]);
  55683. (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]);
  55684. },
  55685. /**
  55686. * @private
  55687. */
  55688. _resetRange: function () {
  55689. var dataExtent = this.getExtent();
  55690. var range = this.option.range;
  55691. if (!range || range.auto) {
  55692. // `range` should always be array (so we dont use other
  55693. // value like 'auto') for user-friend. (consider getOption).
  55694. dataExtent.auto = 1;
  55695. this.option.range = dataExtent;
  55696. }
  55697. else if (zrUtil.isArray(range)) {
  55698. if (range[0] > range[1]) {
  55699. range.reverse();
  55700. }
  55701. range[0] = Math.max(range[0], dataExtent[0]);
  55702. range[1] = Math.min(range[1], dataExtent[1]);
  55703. }
  55704. },
  55705. /**
  55706. * @protected
  55707. * @override
  55708. */
  55709. completeVisualOption: function () {
  55710. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  55711. zrUtil.each(this.stateList, function (state) {
  55712. var symbolSize = this.option.controller[state].symbolSize;
  55713. if (symbolSize && symbolSize[0] !== symbolSize[1]) {
  55714. symbolSize[0] = 0; // For good looking.
  55715. }
  55716. }, this);
  55717. },
  55718. /**
  55719. * @override
  55720. */
  55721. setSelected: function (selected) {
  55722. this.option.range = selected.slice();
  55723. this._resetRange();
  55724. },
  55725. /**
  55726. * @public
  55727. */
  55728. getSelected: function () {
  55729. var dataExtent = this.getExtent();
  55730. var dataInterval = numberUtil.asc(
  55731. (this.get('range') || []).slice()
  55732. );
  55733. // Clamp
  55734. dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]);
  55735. dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]);
  55736. dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]);
  55737. dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]);
  55738. return dataInterval;
  55739. },
  55740. /**
  55741. * @override
  55742. */
  55743. getValueState: function (value) {
  55744. var range = this.option.range;
  55745. var dataExtent = this.getExtent();
  55746. // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'.
  55747. // range[1] is processed likewise.
  55748. return (
  55749. (range[0] <= dataExtent[0] || range[0] <= value)
  55750. && (range[1] >= dataExtent[1] || value <= range[1])
  55751. ) ? 'inRange' : 'outOfRange';
  55752. },
  55753. /**
  55754. * @params {Array.<number>} range target value: range[0] <= value && value <= range[1]
  55755. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  55756. */
  55757. findTargetDataIndices: function (range) {
  55758. var result = [];
  55759. this.eachTargetSeries(function (seriesModel) {
  55760. var dataIndices = [];
  55761. var data = seriesModel.getData();
  55762. data.each(this.getDataDimension(data), function (value, dataIndex) {
  55763. range[0] <= value && value <= range[1] && dataIndices.push(dataIndex);
  55764. }, true, this);
  55765. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  55766. }, this);
  55767. return result;
  55768. },
  55769. /**
  55770. * @implement
  55771. */
  55772. getVisualMeta: function (getColorVisual) {
  55773. var oVals = getColorStopValues(this, 'outOfRange', this.getExtent());
  55774. var iVals = getColorStopValues(this, 'inRange', this.option.range.slice());
  55775. var stops = [];
  55776. function setStop(value, valueState) {
  55777. stops.push({
  55778. value: value,
  55779. color: getColorVisual(value, valueState)
  55780. });
  55781. }
  55782. // Format to: outOfRange -- inRange -- outOfRange.
  55783. var iIdx = 0;
  55784. var oIdx = 0;
  55785. var iLen = iVals.length;
  55786. var oLen = oVals.length;
  55787. for (; oIdx < oLen && (!iVals.length || oVals[oIdx] <= iVals[0]); oIdx++) {
  55788. // If oVal[oIdx] === iVals[iIdx], oVal[oIdx] should be ignored.
  55789. if (oVals[oIdx] < iVals[iIdx]) {
  55790. setStop(oVals[oIdx], 'outOfRange');
  55791. }
  55792. }
  55793. for (var first = 1; iIdx < iLen; iIdx++, first = 0) {
  55794. // If range is full, value beyond min, max will be clamped.
  55795. // make a singularity
  55796. first && stops.length && setStop(iVals[iIdx], 'outOfRange');
  55797. setStop(iVals[iIdx], 'inRange');
  55798. }
  55799. for (var first = 1; oIdx < oLen; oIdx++) {
  55800. if (!iVals.length || iVals[iVals.length - 1] < oVals[oIdx]) {
  55801. // make a singularity
  55802. if (first) {
  55803. stops.length && setStop(stops[stops.length - 1].value, 'outOfRange');
  55804. first = 0;
  55805. }
  55806. setStop(oVals[oIdx], 'outOfRange');
  55807. }
  55808. }
  55809. var stopsLen = stops.length;
  55810. return {
  55811. stops: stops,
  55812. outerColors: [
  55813. stopsLen ? stops[0].color : 'transparent',
  55814. stopsLen ? stops[stopsLen - 1].color : 'transparent'
  55815. ]
  55816. };
  55817. }
  55818. });
  55819. function getColorStopValues(visualMapModel, valueState, dataExtent) {
  55820. if (dataExtent[0] === dataExtent[1]) {
  55821. return dataExtent.slice();
  55822. }
  55823. // When using colorHue mapping, it is not linear color any more.
  55824. // Moreover, canvas gradient seems not to be accurate linear.
  55825. // FIXME
  55826. // Should be arbitrary value 100? or based on pixel size?
  55827. var count = 200;
  55828. var step = (dataExtent[1] - dataExtent[0]) / count;
  55829. var value = dataExtent[0];
  55830. var stopValues = [];
  55831. for (var i = 0; i <= count && value < dataExtent[1]; i++) {
  55832. stopValues.push(value);
  55833. value += step;
  55834. }
  55835. stopValues.push(dataExtent[1]);
  55836. return stopValues;
  55837. }
  55838. module.exports = ContinuousModel;
  55839. /***/ },
  55840. /* 382 */
  55841. /***/ function(module, exports, __webpack_require__) {
  55842. /**
  55843. * @file Controller visual map model
  55844. */
  55845. var echarts = __webpack_require__(1);
  55846. var zrUtil = __webpack_require__(4);
  55847. var env = __webpack_require__(2);
  55848. var visualDefault = __webpack_require__(383);
  55849. var VisualMapping = __webpack_require__(203);
  55850. var visualSolution = __webpack_require__(350);
  55851. var mapVisual = VisualMapping.mapVisual;
  55852. var modelUtil = __webpack_require__(5);
  55853. var eachVisual = VisualMapping.eachVisual;
  55854. var numberUtil = __webpack_require__(7);
  55855. var isArray = zrUtil.isArray;
  55856. var each = zrUtil.each;
  55857. var asc = numberUtil.asc;
  55858. var linearMap = numberUtil.linearMap;
  55859. var noop = zrUtil.noop;
  55860. var DEFAULT_COLOR = ['#f6efa6', '#d88273', '#bf444c'];
  55861. var VisualMapModel = echarts.extendComponentModel({
  55862. type: 'visualMap',
  55863. dependencies: ['series'],
  55864. /**
  55865. * @readOnly
  55866. * @type {Array.<string>}
  55867. */
  55868. stateList: ['inRange', 'outOfRange'],
  55869. /**
  55870. * @readOnly
  55871. * @type {Array.<string>}
  55872. */
  55873. replacableOptionKeys: [
  55874. 'inRange', 'outOfRange', 'target', 'controller', 'color'
  55875. ],
  55876. /**
  55877. * [lowerBound, upperBound]
  55878. *
  55879. * @readOnly
  55880. * @type {Array.<number>}
  55881. */
  55882. dataBound: [-Infinity, Infinity],
  55883. /**
  55884. * @readOnly
  55885. * @type {string|Object}
  55886. */
  55887. layoutMode: {type: 'box', ignoreSize: true},
  55888. /**
  55889. * @protected
  55890. */
  55891. defaultOption: {
  55892. show: true,
  55893. zlevel: 0,
  55894. z: 4,
  55895. seriesIndex: null, // 所控制的series indices,默认所有有value的series.
  55896. // set min: 0, max: 200, only for campatible with ec2.
  55897. // In fact min max should not have default value.
  55898. min: 0, // min value, must specified if pieces is not specified.
  55899. max: 200, // max value, must specified if pieces is not specified.
  55900. dimension: null,
  55901. inRange: null, // 'color', 'colorHue', 'colorSaturation', 'colorLightness', 'colorAlpha',
  55902. // 'symbol', 'symbolSize'
  55903. outOfRange: null, // 'color', 'colorHue', 'colorSaturation',
  55904. // 'colorLightness', 'colorAlpha',
  55905. // 'symbol', 'symbolSize'
  55906. left: 0, // 'center' ¦ 'left' ¦ 'right' ¦ {number} (px)
  55907. right: null, // The same as left.
  55908. top: null, // 'top' ¦ 'bottom' ¦ 'center' ¦ {number} (px)
  55909. bottom: 0, // The same as top.
  55910. itemWidth: null,
  55911. itemHeight: null,
  55912. inverse: false,
  55913. orient: 'vertical', // 'horizontal' ¦ 'vertical'
  55914. backgroundColor: 'rgba(0,0,0,0)',
  55915. borderColor: '#ccc', // 值域边框颜色
  55916. contentColor: '#5793f3',
  55917. inactiveColor: '#aaa',
  55918. borderWidth: 0, // 值域边框线宽,单位px,默认为0(无边框)
  55919. padding: 5, // 值域内边距,单位px,默认各方向内边距为5,
  55920. // 接受数组分别设定上右下左边距,同css
  55921. textGap: 10, //
  55922. precision: 0, // 小数精度,默认为0,无小数点
  55923. color: null, //颜色(deprecated,兼容ec2,顺序同pieces,不同于inRange/outOfRange)
  55924. formatter: null,
  55925. text: null, // 文本,如['高', '低'],兼容ec2,text[0]对应高值,text[1]对应低值
  55926. textStyle: {
  55927. color: '#333' // 值域文字颜色
  55928. }
  55929. },
  55930. /**
  55931. * @protected
  55932. */
  55933. init: function (option, parentModel, ecModel) {
  55934. /**
  55935. * @private
  55936. * @type {Array.<number>}
  55937. */
  55938. this._dataExtent;
  55939. /**
  55940. * @readOnly
  55941. */
  55942. this.targetVisuals = {};
  55943. /**
  55944. * @readOnly
  55945. */
  55946. this.controllerVisuals = {};
  55947. /**
  55948. * @readOnly
  55949. */
  55950. this.textStyleModel;
  55951. /**
  55952. * [width, height]
  55953. * @readOnly
  55954. * @type {Array.<number>}
  55955. */
  55956. this.itemSize;
  55957. this.mergeDefaultAndTheme(option, ecModel);
  55958. },
  55959. /**
  55960. * @protected
  55961. */
  55962. optionUpdated: function (newOption, isInit) {
  55963. var thisOption = this.option;
  55964. // FIXME
  55965. // necessary?
  55966. // Disable realtime view update if canvas is not supported.
  55967. if (!env.canvasSupported) {
  55968. thisOption.realtime = false;
  55969. }
  55970. !isInit && visualSolution.replaceVisualOption(
  55971. thisOption, newOption, this.replacableOptionKeys
  55972. );
  55973. this.textStyleModel = this.getModel('textStyle');
  55974. this.resetItemSize();
  55975. this.completeVisualOption();
  55976. },
  55977. /**
  55978. * @protected
  55979. */
  55980. resetVisual: function (supplementVisualOption) {
  55981. var stateList = this.stateList;
  55982. supplementVisualOption = zrUtil.bind(supplementVisualOption, this);
  55983. this.controllerVisuals = visualSolution.createVisualMappings(
  55984. this.option.controller, stateList, supplementVisualOption
  55985. );
  55986. this.targetVisuals = visualSolution.createVisualMappings(
  55987. this.option.target, stateList, supplementVisualOption
  55988. );
  55989. },
  55990. /**
  55991. * @protected
  55992. */
  55993. resetTargetSeries: function () {
  55994. var thisOption = this.option;
  55995. var allSeriesIndex = thisOption.seriesIndex == null;
  55996. thisOption.seriesIndex = allSeriesIndex
  55997. ? [] : modelUtil.normalizeToArray(thisOption.seriesIndex);
  55998. allSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) {
  55999. thisOption.seriesIndex.push(index);
  56000. });
  56001. },
  56002. /**
  56003. * @public
  56004. */
  56005. eachTargetSeries: function (callback, context) {
  56006. zrUtil.each(this.option.seriesIndex, function (seriesIndex) {
  56007. callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex));
  56008. }, this);
  56009. },
  56010. /**
  56011. * @pubilc
  56012. */
  56013. isTargetSeries: function (seriesModel) {
  56014. var is = false;
  56015. this.eachTargetSeries(function (model) {
  56016. model === seriesModel && (is = true);
  56017. });
  56018. return is;
  56019. },
  56020. /**
  56021. * @example
  56022. * this.formatValueText(someVal); // format single numeric value to text.
  56023. * this.formatValueText(someVal, true); // format single category value to text.
  56024. * this.formatValueText([min, max]); // format numeric min-max to text.
  56025. * this.formatValueText([this.dataBound[0], max]); // using data lower bound.
  56026. * this.formatValueText([min, this.dataBound[1]]); // using data upper bound.
  56027. *
  56028. * @param {number|Array.<number>} value Real value, or this.dataBound[0 or 1].
  56029. * @param {boolean} [isCategory=false] Only available when value is number.
  56030. * @param {Array.<string>} edgeSymbols Open-close symbol when value is interval.
  56031. * @return {string}
  56032. * @protected
  56033. */
  56034. formatValueText: function(value, isCategory, edgeSymbols) {
  56035. var option = this.option;
  56036. var precision = option.precision;
  56037. var dataBound = this.dataBound;
  56038. var formatter = option.formatter;
  56039. var isMinMax;
  56040. var textValue;
  56041. edgeSymbols = edgeSymbols || ['<', '>'];
  56042. if (zrUtil.isArray(value)) {
  56043. value = value.slice();
  56044. isMinMax = true;
  56045. }
  56046. textValue = isCategory
  56047. ? value
  56048. : (isMinMax
  56049. ? [toFixed(value[0]), toFixed(value[1])]
  56050. : toFixed(value)
  56051. );
  56052. if (zrUtil.isString(formatter)) {
  56053. return formatter
  56054. .replace('{value}', isMinMax ? textValue[0] : textValue)
  56055. .replace('{value2}', isMinMax ? textValue[1] : textValue);
  56056. }
  56057. else if (zrUtil.isFunction(formatter)) {
  56058. return isMinMax
  56059. ? formatter(value[0], value[1])
  56060. : formatter(value);
  56061. }
  56062. if (isMinMax) {
  56063. if (value[0] === dataBound[0]) {
  56064. return edgeSymbols[0] + ' ' + textValue[1];
  56065. }
  56066. else if (value[1] === dataBound[1]) {
  56067. return edgeSymbols[1] + ' ' + textValue[0];
  56068. }
  56069. else {
  56070. return textValue[0] + ' - ' + textValue[1];
  56071. }
  56072. }
  56073. else { // Format single value (includes category case).
  56074. return textValue;
  56075. }
  56076. function toFixed(val) {
  56077. return val === dataBound[0]
  56078. ? 'min'
  56079. : val === dataBound[1]
  56080. ? 'max'
  56081. : (+val).toFixed(precision);
  56082. }
  56083. },
  56084. /**
  56085. * @protected
  56086. */
  56087. resetExtent: function () {
  56088. var thisOption = this.option;
  56089. // Can not calculate data extent by data here.
  56090. // Because series and data may be modified in processing stage.
  56091. // So we do not support the feature "auto min/max".
  56092. var extent = asc([thisOption.min, thisOption.max]);
  56093. this._dataExtent = extent;
  56094. },
  56095. /**
  56096. * @public
  56097. * @param {module:echarts/data/List} list
  56098. * @return {string} Concrete dimention. If return null/undefined,
  56099. * no dimension used.
  56100. */
  56101. getDataDimension: function (list) {
  56102. var optDim = this.option.dimension;
  56103. return optDim != null
  56104. ? optDim : list.dimensions.length - 1;
  56105. },
  56106. /**
  56107. * @public
  56108. * @override
  56109. */
  56110. getExtent: function () {
  56111. return this._dataExtent.slice();
  56112. },
  56113. /**
  56114. * @protected
  56115. */
  56116. completeVisualOption: function () {
  56117. var thisOption = this.option;
  56118. var base = {inRange: thisOption.inRange, outOfRange: thisOption.outOfRange};
  56119. var target = thisOption.target || (thisOption.target = {});
  56120. var controller = thisOption.controller || (thisOption.controller = {});
  56121. zrUtil.merge(target, base); // Do not override
  56122. zrUtil.merge(controller, base); // Do not override
  56123. var isCategory = this.isCategory();
  56124. completeSingle.call(this, target);
  56125. completeSingle.call(this, controller);
  56126. completeInactive.call(this, target, 'inRange', 'outOfRange');
  56127. // completeInactive.call(this, target, 'outOfRange', 'inRange');
  56128. completeController.call(this, controller);
  56129. function completeSingle(base) {
  56130. // Compatible with ec2 dataRange.color.
  56131. // The mapping order of dataRange.color is: [high value, ..., low value]
  56132. // whereas inRange.color and outOfRange.color is [low value, ..., high value]
  56133. // Notice: ec2 has no inverse.
  56134. if (isArray(thisOption.color)
  56135. // If there has been inRange: {symbol: ...}, adding color is a mistake.
  56136. // So adding color only when no inRange defined.
  56137. && !base.inRange
  56138. ) {
  56139. base.inRange = {color: thisOption.color.slice().reverse()};
  56140. }
  56141. // Compatible with previous logic, always give a defautl color, otherwise
  56142. // simple config with no inRange and outOfRange will not work.
  56143. // Originally we use visualMap.color as the default color, but setOption at
  56144. // the second time the default color will be erased. So we change to use
  56145. // constant DEFAULT_COLOR.
  56146. // If user do not want the defualt color, set inRange: {color: null}.
  56147. base.inRange = base.inRange || {color: DEFAULT_COLOR};
  56148. // If using shortcut like: {inRange: 'symbol'}, complete default value.
  56149. each(this.stateList, function (state) {
  56150. var visualType = base[state];
  56151. if (zrUtil.isString(visualType)) {
  56152. var defa = visualDefault.get(visualType, 'active', isCategory);
  56153. if (defa) {
  56154. base[state] = {};
  56155. base[state][visualType] = defa;
  56156. }
  56157. else {
  56158. // Mark as not specified.
  56159. delete base[state];
  56160. }
  56161. }
  56162. }, this);
  56163. }
  56164. function completeInactive(base, stateExist, stateAbsent) {
  56165. var optExist = base[stateExist];
  56166. var optAbsent = base[stateAbsent];
  56167. if (optExist && !optAbsent) {
  56168. optAbsent = base[stateAbsent] = {};
  56169. each(optExist, function (visualData, visualType) {
  56170. if (!VisualMapping.isValidType(visualType)) {
  56171. return;
  56172. }
  56173. var defa = visualDefault.get(visualType, 'inactive', isCategory);
  56174. if (defa != null) {
  56175. optAbsent[visualType] = defa;
  56176. // Compatibable with ec2:
  56177. // Only inactive color to rgba(0,0,0,0) can not
  56178. // make label transparent, so use opacity also.
  56179. if (visualType === 'color'
  56180. && !optAbsent.hasOwnProperty('opacity')
  56181. && !optAbsent.hasOwnProperty('colorAlpha')
  56182. ) {
  56183. optAbsent.opacity = [0, 0];
  56184. }
  56185. }
  56186. });
  56187. }
  56188. }
  56189. function completeController(controller) {
  56190. var symbolExists = (controller.inRange || {}).symbol
  56191. || (controller.outOfRange || {}).symbol;
  56192. var symbolSizeExists = (controller.inRange || {}).symbolSize
  56193. || (controller.outOfRange || {}).symbolSize;
  56194. var inactiveColor = this.get('inactiveColor');
  56195. each(this.stateList, function (state) {
  56196. var itemSize = this.itemSize;
  56197. var visuals = controller[state];
  56198. // Set inactive color for controller if no other color
  56199. // attr (like colorAlpha) specified.
  56200. if (!visuals) {
  56201. visuals = controller[state] = {
  56202. color: isCategory ? inactiveColor : [inactiveColor]
  56203. };
  56204. }
  56205. // Consistent symbol and symbolSize if not specified.
  56206. if (visuals.symbol == null) {
  56207. visuals.symbol = symbolExists
  56208. && zrUtil.clone(symbolExists)
  56209. || (isCategory ? 'roundRect' : ['roundRect']);
  56210. }
  56211. if (visuals.symbolSize == null) {
  56212. visuals.symbolSize = symbolSizeExists
  56213. && zrUtil.clone(symbolSizeExists)
  56214. || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]);
  56215. }
  56216. // Filter square and none.
  56217. visuals.symbol = mapVisual(visuals.symbol, function (symbol) {
  56218. return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol;
  56219. });
  56220. // Normalize symbolSize
  56221. var symbolSize = visuals.symbolSize;
  56222. if (symbolSize != null) {
  56223. var max = -Infinity;
  56224. // symbolSize can be object when categories defined.
  56225. eachVisual(symbolSize, function (value) {
  56226. value > max && (max = value);
  56227. });
  56228. visuals.symbolSize = mapVisual(symbolSize, function (value) {
  56229. return linearMap(value, [0, max], [0, itemSize[0]], true);
  56230. });
  56231. }
  56232. }, this);
  56233. }
  56234. },
  56235. /**
  56236. * @protected
  56237. */
  56238. resetItemSize: function () {
  56239. this.itemSize = [
  56240. parseFloat(this.get('itemWidth')),
  56241. parseFloat(this.get('itemHeight'))
  56242. ];
  56243. },
  56244. /**
  56245. * @public
  56246. */
  56247. isCategory: function () {
  56248. return !!this.option.categories;
  56249. },
  56250. /**
  56251. * @public
  56252. * @abstract
  56253. */
  56254. setSelected: noop,
  56255. /**
  56256. * @public
  56257. * @abstract
  56258. * @param {*|module:echarts/data/List} valueOrData
  56259. * @param {number} dataIndex
  56260. * @return {string} state See this.stateList
  56261. */
  56262. getValueState: noop,
  56263. /**
  56264. * FIXME
  56265. * Do not publish to thirt-part-dev temporarily
  56266. * util the interface is stable. (Should it return
  56267. * a function but not visual meta?)
  56268. *
  56269. * @pubilc
  56270. * @abstract
  56271. * @param {Function} getColorVisual
  56272. * params: value, valueState
  56273. * return: color
  56274. * @return {Object} visualMeta
  56275. * should includes {stops, outerColors}
  56276. * outerColor means [colorBeyondMinValue, colorBeyondMaxValue]
  56277. */
  56278. getVisualMeta: noop
  56279. });
  56280. module.exports = VisualMapModel;
  56281. /***/ },
  56282. /* 383 */
  56283. /***/ function(module, exports, __webpack_require__) {
  56284. /**
  56285. * @file Visual mapping.
  56286. */
  56287. var zrUtil = __webpack_require__(4);
  56288. var visualDefault = {
  56289. /**
  56290. * @public
  56291. */
  56292. get: function (visualType, key, isCategory) {
  56293. var value = zrUtil.clone(
  56294. (defaultOption[visualType] || {})[key]
  56295. );
  56296. return isCategory
  56297. ? (zrUtil.isArray(value) ? value[value.length - 1] : value)
  56298. : value;
  56299. }
  56300. };
  56301. var defaultOption = {
  56302. color: {
  56303. active: ['#006edd', '#e0ffff'],
  56304. inactive: ['rgba(0,0,0,0)']
  56305. },
  56306. colorHue: {
  56307. active: [0, 360],
  56308. inactive: [0, 0]
  56309. },
  56310. colorSaturation: {
  56311. active: [0.3, 1],
  56312. inactive: [0, 0]
  56313. },
  56314. colorLightness: {
  56315. active: [0.9, 0.5],
  56316. inactive: [0, 0]
  56317. },
  56318. colorAlpha: {
  56319. active: [0.3, 1],
  56320. inactive: [0, 0]
  56321. },
  56322. opacity: {
  56323. active: [0.3, 1],
  56324. inactive: [0, 0]
  56325. },
  56326. symbol: {
  56327. active: ['circle', 'roundRect', 'diamond'],
  56328. inactive: ['none']
  56329. },
  56330. symbolSize: {
  56331. active: [10, 50],
  56332. inactive: [0, 0]
  56333. }
  56334. };
  56335. module.exports = visualDefault;
  56336. /***/ },
  56337. /* 384 */
  56338. /***/ function(module, exports, __webpack_require__) {
  56339. var VisualMapView = __webpack_require__(385);
  56340. var graphic = __webpack_require__(18);
  56341. var zrUtil = __webpack_require__(4);
  56342. var numberUtil = __webpack_require__(7);
  56343. var sliderMove = __webpack_require__(239);
  56344. var LinearGradient = __webpack_require__(65);
  56345. var helper = __webpack_require__(386);
  56346. var modelUtil = __webpack_require__(5);
  56347. var eventTool = __webpack_require__(88);
  56348. var linearMap = numberUtil.linearMap;
  56349. var each = zrUtil.each;
  56350. var mathMin = Math.min;
  56351. var mathMax = Math.max;
  56352. // Arbitrary value
  56353. var HOVER_LINK_SIZE = 12;
  56354. var HOVER_LINK_OUT = 6;
  56355. // Notice:
  56356. // Any "interval" should be by the order of [low, high].
  56357. // "handle0" (handleIndex === 0) maps to
  56358. // low data value: this._dataInterval[0] and has low coord.
  56359. // "handle1" (handleIndex === 1) maps to
  56360. // high data value: this._dataInterval[1] and has high coord.
  56361. // The logic of transform is implemented in this._createBarGroup.
  56362. var ContinuousView = VisualMapView.extend({
  56363. type: 'visualMap.continuous',
  56364. /**
  56365. * @override
  56366. */
  56367. init: function () {
  56368. ContinuousView.superApply(this, 'init', arguments);
  56369. /**
  56370. * @private
  56371. */
  56372. this._shapes = {};
  56373. /**
  56374. * @private
  56375. */
  56376. this._dataInterval = [];
  56377. /**
  56378. * @private
  56379. */
  56380. this._handleEnds = [];
  56381. /**
  56382. * @private
  56383. */
  56384. this._orient;
  56385. /**
  56386. * @private
  56387. */
  56388. this._useHandle;
  56389. /**
  56390. * @private
  56391. */
  56392. this._hoverLinkDataIndices = [];
  56393. /**
  56394. * @private
  56395. */
  56396. this._dragging;
  56397. /**
  56398. * @private
  56399. */
  56400. this._hovering;
  56401. },
  56402. /**
  56403. * @protected
  56404. * @override
  56405. */
  56406. doRender: function (visualMapModel, ecModel, api, payload) {
  56407. if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) {
  56408. this._buildView();
  56409. }
  56410. },
  56411. /**
  56412. * @private
  56413. */
  56414. _buildView: function () {
  56415. this.group.removeAll();
  56416. var visualMapModel = this.visualMapModel;
  56417. var thisGroup = this.group;
  56418. this._orient = visualMapModel.get('orient');
  56419. this._useHandle = visualMapModel.get('calculable');
  56420. this._resetInterval();
  56421. this._renderBar(thisGroup);
  56422. var dataRangeText = visualMapModel.get('text');
  56423. this._renderEndsText(thisGroup, dataRangeText, 0);
  56424. this._renderEndsText(thisGroup, dataRangeText, 1);
  56425. // Do this for background size calculation.
  56426. this._updateView(true);
  56427. // After updating view, inner shapes is built completely,
  56428. // and then background can be rendered.
  56429. this.renderBackground(thisGroup);
  56430. // Real update view
  56431. this._updateView();
  56432. this._enableHoverLinkToSeries();
  56433. this._enableHoverLinkFromSeries();
  56434. this.positionGroup(thisGroup);
  56435. },
  56436. /**
  56437. * @private
  56438. */
  56439. _renderEndsText: function (group, dataRangeText, endsIndex) {
  56440. if (!dataRangeText) {
  56441. return;
  56442. }
  56443. // Compatible with ec2, text[0] map to high value, text[1] map low value.
  56444. var text = dataRangeText[1 - endsIndex];
  56445. text = text != null ? text + '' : '';
  56446. var visualMapModel = this.visualMapModel;
  56447. var textGap = visualMapModel.get('textGap');
  56448. var itemSize = visualMapModel.itemSize;
  56449. var barGroup = this._shapes.barGroup;
  56450. var position = this._applyTransform(
  56451. [
  56452. itemSize[0] / 2,
  56453. endsIndex === 0 ? -textGap : itemSize[1] + textGap
  56454. ],
  56455. barGroup
  56456. );
  56457. var align = this._applyTransform(
  56458. endsIndex === 0 ? 'bottom' : 'top',
  56459. barGroup
  56460. );
  56461. var orient = this._orient;
  56462. var textStyleModel = this.visualMapModel.textStyleModel;
  56463. this.group.add(new graphic.Text({
  56464. style: {
  56465. x: position[0],
  56466. y: position[1],
  56467. textVerticalAlign: orient === 'horizontal' ? 'middle' : align,
  56468. textAlign: orient === 'horizontal' ? align : 'center',
  56469. text: text,
  56470. textFont: textStyleModel.getFont(),
  56471. fill: textStyleModel.getTextColor()
  56472. }
  56473. }));
  56474. },
  56475. /**
  56476. * @private
  56477. */
  56478. _renderBar: function (targetGroup) {
  56479. var visualMapModel = this.visualMapModel;
  56480. var shapes = this._shapes;
  56481. var itemSize = visualMapModel.itemSize;
  56482. var orient = this._orient;
  56483. var useHandle = this._useHandle;
  56484. var itemAlign = helper.getItemAlign(visualMapModel, this.api, itemSize);
  56485. var barGroup = shapes.barGroup = this._createBarGroup(itemAlign);
  56486. // Bar
  56487. barGroup.add(shapes.outOfRange = createPolygon());
  56488. barGroup.add(shapes.inRange = createPolygon(
  56489. null,
  56490. useHandle ? 'move' : null,
  56491. zrUtil.bind(this._dragHandle, this, 'all', false),
  56492. zrUtil.bind(this._dragHandle, this, 'all', true)
  56493. ));
  56494. var textRect = visualMapModel.textStyleModel.getTextRect('国');
  56495. var textSize = mathMax(textRect.width, textRect.height);
  56496. // Handle
  56497. if (useHandle) {
  56498. shapes.handleThumbs = [];
  56499. shapes.handleLabels = [];
  56500. shapes.handleLabelPoints = [];
  56501. this._createHandle(barGroup, 0, itemSize, textSize, orient, itemAlign);
  56502. this._createHandle(barGroup, 1, itemSize, textSize, orient, itemAlign);
  56503. }
  56504. this._createIndicator(barGroup, itemSize, textSize, orient);
  56505. targetGroup.add(barGroup);
  56506. },
  56507. /**
  56508. * @private
  56509. */
  56510. _createHandle: function (barGroup, handleIndex, itemSize, textSize, orient) {
  56511. var onDrift = zrUtil.bind(this._dragHandle, this, handleIndex, false);
  56512. var onDragEnd = zrUtil.bind(this._dragHandle, this, handleIndex, true);
  56513. var handleThumb = createPolygon(
  56514. createHandlePoints(handleIndex, textSize),
  56515. 'move',
  56516. onDrift,
  56517. onDragEnd
  56518. );
  56519. handleThumb.position[0] = itemSize[0];
  56520. barGroup.add(handleThumb);
  56521. // Text is always horizontal layout but should not be effected by
  56522. // transform (orient/inverse). So label is built separately but not
  56523. // use zrender/graphic/helper/RectText, and is located based on view
  56524. // group (according to handleLabelPoint) but not barGroup.
  56525. var textStyleModel = this.visualMapModel.textStyleModel;
  56526. var handleLabel = new graphic.Text({
  56527. draggable: true,
  56528. drift: onDrift,
  56529. onmousemove: function (e) {
  56530. // Fot mobile devicem, prevent screen slider on the button.
  56531. eventTool.stop(e.event);
  56532. },
  56533. ondragend: onDragEnd,
  56534. style: {
  56535. x: 0, y: 0, text: '',
  56536. textFont: textStyleModel.getFont(),
  56537. fill: textStyleModel.getTextColor()
  56538. }
  56539. });
  56540. this.group.add(handleLabel);
  56541. var handleLabelPoint = [
  56542. orient === 'horizontal'
  56543. ? textSize / 2
  56544. : textSize * 1.5,
  56545. orient === 'horizontal'
  56546. ? (handleIndex === 0 ? -(textSize * 1.5) : (textSize * 1.5))
  56547. : (handleIndex === 0 ? -textSize / 2 : textSize / 2)
  56548. ];
  56549. var shapes = this._shapes;
  56550. shapes.handleThumbs[handleIndex] = handleThumb;
  56551. shapes.handleLabelPoints[handleIndex] = handleLabelPoint;
  56552. shapes.handleLabels[handleIndex] = handleLabel;
  56553. },
  56554. /**
  56555. * @private
  56556. */
  56557. _createIndicator: function (barGroup, itemSize, textSize, orient) {
  56558. var indicator = createPolygon([[0, 0]], 'move');
  56559. indicator.position[0] = itemSize[0];
  56560. indicator.attr({invisible: true, silent: true});
  56561. barGroup.add(indicator);
  56562. var textStyleModel = this.visualMapModel.textStyleModel;
  56563. var indicatorLabel = new graphic.Text({
  56564. silent: true,
  56565. invisible: true,
  56566. style: {
  56567. x: 0, y: 0, text: '',
  56568. textFont: textStyleModel.getFont(),
  56569. fill: textStyleModel.getTextColor()
  56570. }
  56571. });
  56572. this.group.add(indicatorLabel);
  56573. var indicatorLabelPoint = [
  56574. orient === 'horizontal' ? textSize / 2 : HOVER_LINK_OUT + 3,
  56575. 0
  56576. ];
  56577. var shapes = this._shapes;
  56578. shapes.indicator = indicator;
  56579. shapes.indicatorLabel = indicatorLabel;
  56580. shapes.indicatorLabelPoint = indicatorLabelPoint;
  56581. },
  56582. /**
  56583. * @private
  56584. */
  56585. _dragHandle: function (handleIndex, isEnd, dx, dy) {
  56586. if (!this._useHandle) {
  56587. return;
  56588. }
  56589. this._dragging = !isEnd;
  56590. if (!isEnd) {
  56591. // Transform dx, dy to bar coordination.
  56592. var vertex = this._applyTransform([dx, dy], this._shapes.barGroup, true);
  56593. this._updateInterval(handleIndex, vertex[1]);
  56594. // Considering realtime, update view should be executed
  56595. // before dispatch action.
  56596. this._updateView();
  56597. }
  56598. // dragEnd do not dispatch action when realtime.
  56599. if (isEnd === !this.visualMapModel.get('realtime')) { // jshint ignore:line
  56600. this.api.dispatchAction({
  56601. type: 'selectDataRange',
  56602. from: this.uid,
  56603. visualMapId: this.visualMapModel.id,
  56604. selected: this._dataInterval.slice()
  56605. });
  56606. }
  56607. if (isEnd) {
  56608. !this._hovering && this._clearHoverLinkToSeries();
  56609. }
  56610. else if (useHoverLinkOnHandle(this.visualMapModel)) {
  56611. this._doHoverLinkToSeries(this._handleEnds[handleIndex], false);
  56612. }
  56613. },
  56614. /**
  56615. * @private
  56616. */
  56617. _resetInterval: function () {
  56618. var visualMapModel = this.visualMapModel;
  56619. var dataInterval = this._dataInterval = visualMapModel.getSelected();
  56620. var dataExtent = visualMapModel.getExtent();
  56621. var sizeExtent = [0, visualMapModel.itemSize[1]];
  56622. this._handleEnds = [
  56623. linearMap(dataInterval[0], dataExtent, sizeExtent, true),
  56624. linearMap(dataInterval[1], dataExtent, sizeExtent, true)
  56625. ];
  56626. },
  56627. /**
  56628. * @private
  56629. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  56630. * @param {number} dx
  56631. * @param {number} dy
  56632. */
  56633. _updateInterval: function (handleIndex, delta) {
  56634. delta = delta || 0;
  56635. var visualMapModel = this.visualMapModel;
  56636. var handleEnds = this._handleEnds;
  56637. var sizeExtent = [0, visualMapModel.itemSize[1]];
  56638. sliderMove(
  56639. delta,
  56640. handleEnds,
  56641. sizeExtent,
  56642. handleIndex,
  56643. // cross is forbiden
  56644. 0
  56645. );
  56646. var dataExtent = visualMapModel.getExtent();
  56647. // Update data interval.
  56648. this._dataInterval = [
  56649. linearMap(handleEnds[0], sizeExtent, dataExtent, true),
  56650. linearMap(handleEnds[1], sizeExtent, dataExtent, true)
  56651. ];
  56652. },
  56653. /**
  56654. * @private
  56655. */
  56656. _updateView: function (forSketch) {
  56657. var visualMapModel = this.visualMapModel;
  56658. var dataExtent = visualMapModel.getExtent();
  56659. var shapes = this._shapes;
  56660. var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]];
  56661. var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds;
  56662. var visualInRange = this._createBarVisual(
  56663. this._dataInterval, dataExtent, inRangeHandleEnds, 'inRange'
  56664. );
  56665. var visualOutOfRange = this._createBarVisual(
  56666. dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange'
  56667. );
  56668. shapes.inRange
  56669. .setStyle({
  56670. fill: visualInRange.barColor,
  56671. opacity: visualInRange.opacity
  56672. })
  56673. .setShape('points', visualInRange.barPoints);
  56674. shapes.outOfRange
  56675. .setStyle({
  56676. fill: visualOutOfRange.barColor,
  56677. opacity: visualOutOfRange.opacity
  56678. })
  56679. .setShape('points', visualOutOfRange.barPoints);
  56680. this._updateHandle(inRangeHandleEnds, visualInRange);
  56681. },
  56682. /**
  56683. * @private
  56684. */
  56685. _createBarVisual: function (dataInterval, dataExtent, handleEnds, forceState) {
  56686. var opts = {
  56687. forceState: forceState,
  56688. convertOpacityToAlpha: true
  56689. };
  56690. var colorStops = this._makeColorGradient(dataInterval, opts);
  56691. var symbolSizes = [
  56692. this.getControllerVisual(dataInterval[0], 'symbolSize', opts),
  56693. this.getControllerVisual(dataInterval[1], 'symbolSize', opts)
  56694. ];
  56695. var barPoints = this._createBarPoints(handleEnds, symbolSizes);
  56696. return {
  56697. barColor: new LinearGradient(0, 0, 0, 1, colorStops),
  56698. barPoints: barPoints,
  56699. handlesColor: [
  56700. colorStops[0].color,
  56701. colorStops[colorStops.length - 1].color
  56702. ]
  56703. };
  56704. },
  56705. /**
  56706. * @private
  56707. */
  56708. _makeColorGradient: function (dataInterval, opts) {
  56709. // Considering colorHue, which is not linear, so we have to sample
  56710. // to calculate gradient color stops, but not only caculate head
  56711. // and tail.
  56712. var sampleNumber = 100; // Arbitrary value.
  56713. var colorStops = [];
  56714. var step = (dataInterval[1] - dataInterval[0]) / sampleNumber;
  56715. colorStops.push({
  56716. color: this.getControllerVisual(dataInterval[0], 'color', opts),
  56717. offset: 0
  56718. });
  56719. for (var i = 1; i < sampleNumber; i++) {
  56720. var currValue = dataInterval[0] + step * i;
  56721. if (currValue > dataInterval[1]) {
  56722. break;
  56723. }
  56724. colorStops.push({
  56725. color: this.getControllerVisual(currValue, 'color', opts),
  56726. offset: i / sampleNumber
  56727. });
  56728. }
  56729. colorStops.push({
  56730. color: this.getControllerVisual(dataInterval[1], 'color', opts),
  56731. offset: 1
  56732. });
  56733. return colorStops;
  56734. },
  56735. /**
  56736. * @private
  56737. */
  56738. _createBarPoints: function (handleEnds, symbolSizes) {
  56739. var itemSize = this.visualMapModel.itemSize;
  56740. return [
  56741. [itemSize[0] - symbolSizes[0], handleEnds[0]],
  56742. [itemSize[0], handleEnds[0]],
  56743. [itemSize[0], handleEnds[1]],
  56744. [itemSize[0] - symbolSizes[1], handleEnds[1]]
  56745. ];
  56746. },
  56747. /**
  56748. * @private
  56749. */
  56750. _createBarGroup: function (itemAlign) {
  56751. var orient = this._orient;
  56752. var inverse = this.visualMapModel.get('inverse');
  56753. return new graphic.Group(
  56754. (orient === 'horizontal' && !inverse)
  56755. ? {scale: itemAlign === 'bottom' ? [1, 1] : [-1, 1], rotation: Math.PI / 2}
  56756. : (orient === 'horizontal' && inverse)
  56757. ? {scale: itemAlign === 'bottom' ? [-1, 1] : [1, 1], rotation: -Math.PI / 2}
  56758. : (orient === 'vertical' && !inverse)
  56759. ? {scale: itemAlign === 'left' ? [1, -1] : [-1, -1]}
  56760. : {scale: itemAlign === 'left' ? [1, 1] : [-1, 1]}
  56761. );
  56762. },
  56763. /**
  56764. * @private
  56765. */
  56766. _updateHandle: function (handleEnds, visualInRange) {
  56767. if (!this._useHandle) {
  56768. return;
  56769. }
  56770. var shapes = this._shapes;
  56771. var visualMapModel = this.visualMapModel;
  56772. var handleThumbs = shapes.handleThumbs;
  56773. var handleLabels = shapes.handleLabels;
  56774. each([0, 1], function (handleIndex) {
  56775. var handleThumb = handleThumbs[handleIndex];
  56776. handleThumb.setStyle('fill', visualInRange.handlesColor[handleIndex]);
  56777. handleThumb.position[1] = handleEnds[handleIndex];
  56778. // Update handle label position.
  56779. var textPoint = graphic.applyTransform(
  56780. shapes.handleLabelPoints[handleIndex],
  56781. graphic.getTransform(handleThumb, this.group)
  56782. );
  56783. handleLabels[handleIndex].setStyle({
  56784. x: textPoint[0],
  56785. y: textPoint[1],
  56786. text: visualMapModel.formatValueText(this._dataInterval[handleIndex]),
  56787. textVerticalAlign: 'middle',
  56788. textAlign: this._applyTransform(
  56789. this._orient === 'horizontal'
  56790. ? (handleIndex === 0 ? 'bottom' : 'top')
  56791. : 'left',
  56792. shapes.barGroup
  56793. )
  56794. });
  56795. }, this);
  56796. },
  56797. /**
  56798. * @private
  56799. * @param {number} cursorValue
  56800. * @param {number} textValue
  56801. * @param {string} [rangeSymbol]
  56802. * @param {number} [halfHoverLinkSize]
  56803. */
  56804. _showIndicator: function (cursorValue, textValue, rangeSymbol, halfHoverLinkSize) {
  56805. var visualMapModel = this.visualMapModel;
  56806. var dataExtent = visualMapModel.getExtent();
  56807. var itemSize = visualMapModel.itemSize;
  56808. var sizeExtent = [0, itemSize[1]];
  56809. var pos = linearMap(cursorValue, dataExtent, sizeExtent, true);
  56810. var shapes = this._shapes;
  56811. var indicator = shapes.indicator;
  56812. if (!indicator) {
  56813. return;
  56814. }
  56815. indicator.position[1] = pos;
  56816. indicator.attr('invisible', false);
  56817. indicator.setShape('points', createIndicatorPoints(
  56818. !!rangeSymbol, halfHoverLinkSize, pos, itemSize[1]
  56819. ));
  56820. var opts = {convertOpacityToAlpha: true};
  56821. var color = this.getControllerVisual(cursorValue, 'color', opts);
  56822. indicator.setStyle('fill', color);
  56823. // Update handle label position.
  56824. var textPoint = graphic.applyTransform(
  56825. shapes.indicatorLabelPoint,
  56826. graphic.getTransform(indicator, this.group)
  56827. );
  56828. var indicatorLabel = shapes.indicatorLabel;
  56829. indicatorLabel.attr('invisible', false);
  56830. var align = this._applyTransform('left', shapes.barGroup);
  56831. var orient = this._orient;
  56832. indicatorLabel.setStyle({
  56833. text: (rangeSymbol ? rangeSymbol : '') + visualMapModel.formatValueText(textValue),
  56834. textVerticalAlign: orient === 'horizontal' ? align : 'middle',
  56835. textAlign: orient === 'horizontal' ? 'center' : align,
  56836. x: textPoint[0],
  56837. y: textPoint[1]
  56838. });
  56839. },
  56840. /**
  56841. * @private
  56842. */
  56843. _enableHoverLinkToSeries: function () {
  56844. var self = this;
  56845. this._shapes.barGroup
  56846. .on('mousemove', function (e) {
  56847. self._hovering = true;
  56848. if (!self._dragging) {
  56849. var itemSize = self.visualMapModel.itemSize;
  56850. var pos = self._applyTransform(
  56851. [e.offsetX, e.offsetY], self._shapes.barGroup, true, true
  56852. );
  56853. // For hover link show when hover handle, which might be
  56854. // below or upper than sizeExtent.
  56855. pos[1] = mathMin(mathMax(0, pos[1]), itemSize[1]);
  56856. self._doHoverLinkToSeries(
  56857. pos[1],
  56858. 0 <= pos[0] && pos[0] <= itemSize[0]
  56859. );
  56860. }
  56861. })
  56862. .on('mouseout', function () {
  56863. // When mouse is out of handle, hoverLink still need
  56864. // to be displayed when realtime is set as false.
  56865. self._hovering = false;
  56866. !self._dragging && self._clearHoverLinkToSeries();
  56867. });
  56868. },
  56869. /**
  56870. * @private
  56871. */
  56872. _enableHoverLinkFromSeries: function () {
  56873. var zr = this.api.getZr();
  56874. if (this.visualMapModel.option.hoverLink) {
  56875. zr.on('mouseover', this._hoverLinkFromSeriesMouseOver, this);
  56876. zr.on('mouseout', this._hideIndicator, this);
  56877. }
  56878. else {
  56879. this._clearHoverLinkFromSeries();
  56880. }
  56881. },
  56882. /**
  56883. * @private
  56884. */
  56885. _doHoverLinkToSeries: function (cursorPos, hoverOnBar) {
  56886. var visualMapModel = this.visualMapModel;
  56887. var itemSize = visualMapModel.itemSize;
  56888. if (!visualMapModel.option.hoverLink) {
  56889. return;
  56890. }
  56891. var sizeExtent = [0, itemSize[1]];
  56892. var dataExtent = visualMapModel.getExtent();
  56893. // For hover link show when hover handle, which might be below or upper than sizeExtent.
  56894. cursorPos = mathMin(mathMax(sizeExtent[0], cursorPos), sizeExtent[1]);
  56895. var halfHoverLinkSize = getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent);
  56896. var hoverRange = [cursorPos - halfHoverLinkSize, cursorPos + halfHoverLinkSize];
  56897. var cursorValue = linearMap(cursorPos, sizeExtent, dataExtent, true);
  56898. var valueRange = [
  56899. linearMap(hoverRange[0], sizeExtent, dataExtent, true),
  56900. linearMap(hoverRange[1], sizeExtent, dataExtent, true)
  56901. ];
  56902. // Consider data range is out of visualMap range, see test/visualMap-continuous.html,
  56903. // where china and india has very large population.
  56904. hoverRange[0] < sizeExtent[0] && (valueRange[0] = -Infinity);
  56905. hoverRange[1] > sizeExtent[1] && (valueRange[1] = Infinity);
  56906. // Do not show indicator when mouse is over handle,
  56907. // otherwise labels overlap, especially when dragging.
  56908. if (hoverOnBar) {
  56909. if (valueRange[0] === -Infinity) {
  56910. this._showIndicator(cursorValue, valueRange[1], '< ', halfHoverLinkSize);
  56911. }
  56912. else if (valueRange[1] === Infinity) {
  56913. this._showIndicator(cursorValue, valueRange[0], '> ', halfHoverLinkSize);
  56914. }
  56915. else {
  56916. this._showIndicator(cursorValue, cursorValue, '≈ ', halfHoverLinkSize);
  56917. }
  56918. }
  56919. // When realtime is set as false, handles, which are in barGroup,
  56920. // also trigger hoverLink, which help user to realize where they
  56921. // focus on when dragging. (see test/heatmap-large.html)
  56922. // When realtime is set as true, highlight will not show when hover
  56923. // handle, because the label on handle, which displays a exact value
  56924. // but not range, might mislead users.
  56925. var oldBatch = this._hoverLinkDataIndices;
  56926. var newBatch = [];
  56927. if (hoverOnBar || useHoverLinkOnHandle(visualMapModel)) {
  56928. newBatch = this._hoverLinkDataIndices = visualMapModel.findTargetDataIndices(valueRange);
  56929. }
  56930. var resultBatches = modelUtil.compressBatches(oldBatch, newBatch);
  56931. this._dispatchHighDown('downplay', helper.convertDataIndex(resultBatches[0]));
  56932. this._dispatchHighDown('highlight', helper.convertDataIndex(resultBatches[1]));
  56933. },
  56934. /**
  56935. * @private
  56936. */
  56937. _hoverLinkFromSeriesMouseOver: function (e) {
  56938. var el = e.target;
  56939. var visualMapModel = this.visualMapModel;
  56940. if (!el || el.dataIndex == null) {
  56941. return;
  56942. }
  56943. var dataModel = this.ecModel.getSeriesByIndex(el.seriesIndex);
  56944. if (!visualMapModel.isTargetSeries(dataModel)) {
  56945. return;
  56946. }
  56947. var data = dataModel.getData(el.dataType);
  56948. var dim = data.getDimension(visualMapModel.getDataDimension(data));
  56949. var value = data.get(dim, el.dataIndex, true);
  56950. if (!isNaN(value)) {
  56951. this._showIndicator(value, value);
  56952. }
  56953. },
  56954. /**
  56955. * @private
  56956. */
  56957. _hideIndicator: function () {
  56958. var shapes = this._shapes;
  56959. shapes.indicator && shapes.indicator.attr('invisible', true);
  56960. shapes.indicatorLabel && shapes.indicatorLabel.attr('invisible', true);
  56961. },
  56962. /**
  56963. * @private
  56964. */
  56965. _clearHoverLinkToSeries: function () {
  56966. this._hideIndicator();
  56967. var indices = this._hoverLinkDataIndices;
  56968. this._dispatchHighDown('downplay', helper.convertDataIndex(indices));
  56969. indices.length = 0;
  56970. },
  56971. /**
  56972. * @private
  56973. */
  56974. _clearHoverLinkFromSeries: function () {
  56975. this._hideIndicator();
  56976. var zr = this.api.getZr();
  56977. zr.off('mouseover', this._hoverLinkFromSeriesMouseOver);
  56978. zr.off('mouseout', this._hideIndicator);
  56979. },
  56980. /**
  56981. * @private
  56982. */
  56983. _applyTransform: function (vertex, element, inverse, global) {
  56984. var transform = graphic.getTransform(element, global ? null : this.group);
  56985. return graphic[
  56986. zrUtil.isArray(vertex) ? 'applyTransform' : 'transformDirection'
  56987. ](vertex, transform, inverse);
  56988. },
  56989. /**
  56990. * @private
  56991. */
  56992. _dispatchHighDown: function (type, batch) {
  56993. batch && batch.length && this.api.dispatchAction({
  56994. type: type,
  56995. batch: batch
  56996. });
  56997. },
  56998. /**
  56999. * @override
  57000. */
  57001. dispose: function () {
  57002. this._clearHoverLinkFromSeries();
  57003. this._clearHoverLinkToSeries();
  57004. },
  57005. /**
  57006. * @override
  57007. */
  57008. remove: function () {
  57009. this._clearHoverLinkFromSeries();
  57010. this._clearHoverLinkToSeries();
  57011. }
  57012. });
  57013. function createPolygon(points, cursor, onDrift, onDragEnd) {
  57014. return new graphic.Polygon({
  57015. shape: {points: points},
  57016. draggable: !!onDrift,
  57017. cursor: cursor,
  57018. drift: onDrift,
  57019. onmousemove: function (e) {
  57020. // Fot mobile devicem, prevent screen slider on the button.
  57021. eventTool.stop(e.event);
  57022. },
  57023. ondragend: onDragEnd
  57024. });
  57025. }
  57026. function createHandlePoints(handleIndex, textSize) {
  57027. return handleIndex === 0
  57028. ? [[0, 0], [textSize, 0], [textSize, -textSize]]
  57029. : [[0, 0], [textSize, 0], [textSize, textSize]];
  57030. }
  57031. function createIndicatorPoints(isRange, halfHoverLinkSize, pos, extentMax) {
  57032. return isRange
  57033. ? [ // indicate range
  57034. [0, -mathMin(halfHoverLinkSize, mathMax(pos, 0))],
  57035. [HOVER_LINK_OUT, 0],
  57036. [0, mathMin(halfHoverLinkSize, mathMax(extentMax - pos, 0))]
  57037. ]
  57038. : [ // indicate single value
  57039. [0, 0], [5, -5], [5, 5]
  57040. ];
  57041. }
  57042. function getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent) {
  57043. var halfHoverLinkSize = HOVER_LINK_SIZE / 2;
  57044. var hoverLinkDataSize = visualMapModel.get('hoverLinkDataSize');
  57045. if (hoverLinkDataSize) {
  57046. halfHoverLinkSize = linearMap(hoverLinkDataSize, dataExtent, sizeExtent, true) / 2;
  57047. }
  57048. return halfHoverLinkSize;
  57049. }
  57050. function useHoverLinkOnHandle(visualMapModel) {
  57051. return !visualMapModel.get('realtime') && visualMapModel.get('hoverLinkOnHandle');
  57052. }
  57053. module.exports = ContinuousView;
  57054. /***/ },
  57055. /* 385 */
  57056. /***/ function(module, exports, __webpack_require__) {
  57057. var zrUtil = __webpack_require__(4);
  57058. var graphic = __webpack_require__(18);
  57059. var formatUtil = __webpack_require__(6);
  57060. var layout = __webpack_require__(71);
  57061. var echarts = __webpack_require__(1);
  57062. var VisualMapping = __webpack_require__(203);
  57063. module.exports = echarts.extendComponentView({
  57064. type: 'visualMap',
  57065. /**
  57066. * @readOnly
  57067. * @type {Object}
  57068. */
  57069. autoPositionValues: {left: 1, right: 1, top: 1, bottom: 1},
  57070. init: function (ecModel, api) {
  57071. /**
  57072. * @readOnly
  57073. * @type {module:echarts/model/Global}
  57074. */
  57075. this.ecModel = ecModel;
  57076. /**
  57077. * @readOnly
  57078. * @type {module:echarts/ExtensionAPI}
  57079. */
  57080. this.api = api;
  57081. /**
  57082. * @readOnly
  57083. * @type {module:echarts/component/visualMap/visualMapModel}
  57084. */
  57085. this.visualMapModel;
  57086. },
  57087. /**
  57088. * @protected
  57089. */
  57090. render: function (visualMapModel, ecModel, api, payload) {
  57091. this.visualMapModel = visualMapModel;
  57092. if (visualMapModel.get('show') === false) {
  57093. this.group.removeAll();
  57094. return;
  57095. }
  57096. this.doRender.apply(this, arguments);
  57097. },
  57098. /**
  57099. * @protected
  57100. */
  57101. renderBackground: function (group) {
  57102. var visualMapModel = this.visualMapModel;
  57103. var padding = formatUtil.normalizeCssArray(visualMapModel.get('padding') || 0);
  57104. var rect = group.getBoundingRect();
  57105. group.add(new graphic.Rect({
  57106. z2: -1, // Lay background rect on the lowest layer.
  57107. silent: true,
  57108. shape: {
  57109. x: rect.x - padding[3],
  57110. y: rect.y - padding[0],
  57111. width: rect.width + padding[3] + padding[1],
  57112. height: rect.height + padding[0] + padding[2]
  57113. },
  57114. style: {
  57115. fill: visualMapModel.get('backgroundColor'),
  57116. stroke: visualMapModel.get('borderColor'),
  57117. lineWidth: visualMapModel.get('borderWidth')
  57118. }
  57119. }));
  57120. },
  57121. /**
  57122. * @protected
  57123. * @param {number} targetValue can be Infinity or -Infinity
  57124. * @param {string=} visualCluster Only can be 'color' 'opacity' 'symbol' 'symbolSize'
  57125. * @param {Object} [opts]
  57126. * @param {string=} [opts.forceState] Specify state, instead of using getValueState method.
  57127. * @param {string=} [opts.convertOpacityToAlpha=false] For color gradient in controller widget.
  57128. * @return {*} Visual value.
  57129. */
  57130. getControllerVisual: function (targetValue, visualCluster, opts) {
  57131. opts = opts || {};
  57132. var forceState = opts.forceState;
  57133. var visualMapModel = this.visualMapModel;
  57134. var visualObj = {};
  57135. // Default values.
  57136. if (visualCluster === 'symbol') {
  57137. visualObj.symbol = visualMapModel.get('itemSymbol');
  57138. }
  57139. if (visualCluster === 'color') {
  57140. var defaultColor = visualMapModel.get('contentColor');
  57141. visualObj.color = defaultColor;
  57142. }
  57143. function getter(key) {
  57144. return visualObj[key];
  57145. }
  57146. function setter(key, value) {
  57147. visualObj[key] = value;
  57148. }
  57149. var mappings = visualMapModel.controllerVisuals[
  57150. forceState || visualMapModel.getValueState(targetValue)
  57151. ];
  57152. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  57153. zrUtil.each(visualTypes, function (type) {
  57154. var visualMapping = mappings[type];
  57155. if (opts.convertOpacityToAlpha && type === 'opacity') {
  57156. type = 'colorAlpha';
  57157. visualMapping = mappings.__alphaForOpacity;
  57158. }
  57159. if (VisualMapping.dependsOn(type, visualCluster)) {
  57160. visualMapping && visualMapping.applyVisual(
  57161. targetValue, getter, setter
  57162. );
  57163. }
  57164. });
  57165. return visualObj[visualCluster];
  57166. },
  57167. /**
  57168. * @protected
  57169. */
  57170. positionGroup: function (group) {
  57171. var model = this.visualMapModel;
  57172. var api = this.api;
  57173. layout.positionElement(
  57174. group,
  57175. model.getBoxLayoutParams(),
  57176. {width: api.getWidth(), height: api.getHeight()}
  57177. );
  57178. },
  57179. /**
  57180. * @protected
  57181. * @abstract
  57182. */
  57183. doRender: zrUtil.noop
  57184. });
  57185. /***/ },
  57186. /* 386 */
  57187. /***/ function(module, exports, __webpack_require__) {
  57188. var zrUtil = __webpack_require__(4);
  57189. var layout = __webpack_require__(71);
  57190. var helper = {
  57191. /**
  57192. * @param {module:echarts/component/visualMap/VisualMapModel} visualMapModel\
  57193. * @param {module:echarts/ExtensionAPI} api
  57194. * @param {Array.<number>} itemSize always [short, long]
  57195. * @return {string} 'left' or 'right' or 'top' or 'bottom'
  57196. */
  57197. getItemAlign: function (visualMapModel, api, itemSize) {
  57198. var modelOption = visualMapModel.option;
  57199. var itemAlign = modelOption.align;
  57200. if (itemAlign != null && itemAlign !== 'auto') {
  57201. return itemAlign;
  57202. }
  57203. // Auto decision align.
  57204. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  57205. var realIndex = modelOption.orient === 'horizontal' ? 1 : 0;
  57206. var paramsSet = [
  57207. ['left', 'right', 'width'],
  57208. ['top', 'bottom', 'height']
  57209. ];
  57210. var reals = paramsSet[realIndex];
  57211. var fakeValue = [0, null, 10];
  57212. var layoutInput = {};
  57213. for (var i = 0; i < 3; i++) {
  57214. layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i];
  57215. layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]];
  57216. }
  57217. var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex];
  57218. var rect = layout.getLayoutRect(layoutInput, ecSize, modelOption.padding);
  57219. return reals[
  57220. (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5
  57221. < ecSize[rParam[1]] * 0.5 ? 0 : 1
  57222. ];
  57223. },
  57224. /**
  57225. * Prepare dataIndex for outside usage, where dataIndex means rawIndex, and
  57226. * dataIndexInside means filtered index.
  57227. */
  57228. convertDataIndex: function (batch) {
  57229. zrUtil.each(batch || [], function (batchItem) {
  57230. if (batch.dataIndex != null) {
  57231. batch.dataIndexInside = batch.dataIndex;
  57232. batch.dataIndex = null;
  57233. }
  57234. });
  57235. return batch;
  57236. }
  57237. };
  57238. module.exports = helper;
  57239. /***/ },
  57240. /* 387 */
  57241. /***/ function(module, exports, __webpack_require__) {
  57242. /**
  57243. * @file Data range action
  57244. */
  57245. var echarts = __webpack_require__(1);
  57246. var actionInfo = {
  57247. type: 'selectDataRange',
  57248. event: 'dataRangeSelected',
  57249. // FIXME use updateView appears wrong
  57250. update: 'update'
  57251. };
  57252. echarts.registerAction(actionInfo, function (payload, ecModel) {
  57253. ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) {
  57254. model.setSelected(payload.selected);
  57255. });
  57256. });
  57257. /***/ },
  57258. /* 388 */
  57259. /***/ function(module, exports, __webpack_require__) {
  57260. /**
  57261. * DataZoom component entry
  57262. */
  57263. __webpack_require__(1).registerPreprocessor(
  57264. __webpack_require__(378)
  57265. );
  57266. __webpack_require__(379);
  57267. __webpack_require__(380);
  57268. __webpack_require__(389);
  57269. __webpack_require__(390);
  57270. __webpack_require__(387);
  57271. /***/ },
  57272. /* 389 */
  57273. /***/ function(module, exports, __webpack_require__) {
  57274. var VisualMapModel = __webpack_require__(382);
  57275. var zrUtil = __webpack_require__(4);
  57276. var VisualMapping = __webpack_require__(203);
  57277. var visualDefault = __webpack_require__(383);
  57278. var reformIntervals = __webpack_require__(7).reformIntervals;
  57279. var PiecewiseModel = VisualMapModel.extend({
  57280. type: 'visualMap.piecewise',
  57281. /**
  57282. * Order Rule:
  57283. *
  57284. * option.categories / option.pieces / option.text / option.selected:
  57285. * If !option.inverse,
  57286. * Order when vertical: ['top', ..., 'bottom'].
  57287. * Order when horizontal: ['left', ..., 'right'].
  57288. * If option.inverse, the meaning of
  57289. * the order should be reversed.
  57290. *
  57291. * this._pieceList:
  57292. * The order is always [low, ..., high].
  57293. *
  57294. * Mapping from location to low-high:
  57295. * If !option.inverse
  57296. * When vertical, top is high.
  57297. * When horizontal, right is high.
  57298. * If option.inverse, reverse.
  57299. */
  57300. /**
  57301. * @protected
  57302. */
  57303. defaultOption: {
  57304. selected: null, // Object. If not specified, means selected.
  57305. // When pieces and splitNumber: {'0': true, '5': true}
  57306. // When categories: {'cate1': false, 'cate3': true}
  57307. // When selected === false, means all unselected.
  57308. minOpen: false, // Whether include values that smaller than `min`.
  57309. maxOpen: false, // Whether include values that bigger than `max`.
  57310. align: 'auto', // 'auto', 'left', 'right'
  57311. itemWidth: 20, // When put the controller vertically, it is the length of
  57312. // horizontal side of each item. Otherwise, vertical side.
  57313. itemHeight: 14, // When put the controller vertically, it is the length of
  57314. // vertical side of each item. Otherwise, horizontal side.
  57315. itemSymbol: 'roundRect',
  57316. pieceList: null, // Each item is Object, with some of those attrs:
  57317. // {min, max, lt, gt, lte, gte, value,
  57318. // color, colorSaturation, colorAlpha, opacity,
  57319. // symbol, symbolSize}, which customize the range or visual
  57320. // coding of the certain piece. Besides, see "Order Rule".
  57321. categories: null, // category names, like: ['some1', 'some2', 'some3'].
  57322. // Attr min/max are ignored when categories set. See "Order Rule"
  57323. splitNumber: 5, // If set to 5, auto split five pieces equally.
  57324. // If set to 0 and component type not set, component type will be
  57325. // determined as "continuous". (It is less reasonable but for ec2
  57326. // compatibility, see echarts/component/visualMap/typeDefaulter)
  57327. selectedMode: 'multiple', // Can be 'multiple' or 'single'.
  57328. itemGap: 10, // The gap between two items, in px.
  57329. hoverLink: true, // Enable hover highlight.
  57330. showLabel: null // By default, when text is used, label will hide (the logic
  57331. // is remained for compatibility reason)
  57332. },
  57333. /**
  57334. * @override
  57335. */
  57336. optionUpdated: function (newOption, isInit) {
  57337. PiecewiseModel.superApply(this, 'optionUpdated', arguments);
  57338. /**
  57339. * The order is always [low, ..., high].
  57340. * [{text: string, interval: Array.<number>}, ...]
  57341. * @private
  57342. * @type {Array.<Object>}
  57343. */
  57344. this._pieceList = [];
  57345. this.resetTargetSeries();
  57346. this.resetExtent();
  57347. /**
  57348. * 'pieces', 'categories', 'splitNumber'
  57349. * @type {string}
  57350. */
  57351. var mode = this._mode = this._determineMode();
  57352. resetMethods[this._mode].call(this);
  57353. this._resetSelected(newOption, isInit);
  57354. var categories = this.option.categories;
  57355. this.resetVisual(function (mappingOption, state) {
  57356. if (mode === 'categories') {
  57357. mappingOption.mappingMethod = 'category';
  57358. mappingOption.categories = zrUtil.clone(categories);
  57359. }
  57360. else {
  57361. mappingOption.dataExtent = this.getExtent();
  57362. mappingOption.mappingMethod = 'piecewise';
  57363. mappingOption.pieceList = zrUtil.map(this._pieceList, function (piece) {
  57364. var piece = zrUtil.clone(piece);
  57365. if (state !== 'inRange') {
  57366. // FIXME
  57367. // outOfRange do not support special visual in pieces.
  57368. piece.visual = null;
  57369. }
  57370. return piece;
  57371. });
  57372. }
  57373. });
  57374. },
  57375. /**
  57376. * @protected
  57377. * @override
  57378. */
  57379. completeVisualOption: function () {
  57380. // Consider this case:
  57381. // visualMap: {
  57382. // pieces: [{symbol: 'circle', lt: 0}, {symbol: 'rect', gte: 0}]
  57383. // }
  57384. // where no inRange/outOfRange set but only pieces. So we should make
  57385. // default inRange/outOfRange for this case, otherwise visuals that only
  57386. // appear in `pieces` will not be taken into account in visual encoding.
  57387. var option = this.option;
  57388. var visualTypesInPieces = {};
  57389. var visualTypes = VisualMapping.listVisualTypes();
  57390. var isCategory = this.isCategory();
  57391. zrUtil.each(option.pieces, function (piece) {
  57392. zrUtil.each(visualTypes, function (visualType) {
  57393. if (piece.hasOwnProperty(visualType)) {
  57394. visualTypesInPieces[visualType] = 1;
  57395. }
  57396. });
  57397. });
  57398. zrUtil.each(visualTypesInPieces, function (v, visualType) {
  57399. var exists = 0;
  57400. zrUtil.each(this.stateList, function (state) {
  57401. exists |= has(option, state, visualType)
  57402. || has(option.target, state, visualType);
  57403. }, this);
  57404. !exists && zrUtil.each(this.stateList, function (state) {
  57405. (option[state] || (option[state] = {}))[visualType] = visualDefault.get(
  57406. visualType, state === 'inRange' ? 'active' : 'inactive', isCategory
  57407. );
  57408. });
  57409. }, this);
  57410. function has(obj, state, visualType) {
  57411. return obj && obj[state] && (
  57412. zrUtil.isObject(obj[state])
  57413. ? obj[state].hasOwnProperty(visualType)
  57414. : obj[state] === visualType // e.g., inRange: 'symbol'
  57415. );
  57416. }
  57417. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  57418. },
  57419. _resetSelected: function (newOption, isInit) {
  57420. var thisOption = this.option;
  57421. var pieceList = this._pieceList;
  57422. // Selected do not merge but all override.
  57423. var selected = (isInit ? thisOption : newOption).selected || {};
  57424. thisOption.selected = selected;
  57425. // Consider 'not specified' means true.
  57426. zrUtil.each(pieceList, function (piece, index) {
  57427. var key = this.getSelectedMapKey(piece);
  57428. if (!selected.hasOwnProperty(key)) {
  57429. selected[key] = true;
  57430. }
  57431. }, this);
  57432. if (thisOption.selectedMode === 'single') {
  57433. // Ensure there is only one selected.
  57434. var hasSel = false;
  57435. zrUtil.each(pieceList, function (piece, index) {
  57436. var key = this.getSelectedMapKey(piece);
  57437. if (selected[key]) {
  57438. hasSel
  57439. ? (selected[key] = false)
  57440. : (hasSel = true);
  57441. }
  57442. }, this);
  57443. }
  57444. // thisOption.selectedMode === 'multiple', default: all selected.
  57445. },
  57446. /**
  57447. * @public
  57448. */
  57449. getSelectedMapKey: function (piece) {
  57450. return this._mode === 'categories'
  57451. ? piece.value + '' : piece.index + '';
  57452. },
  57453. /**
  57454. * @public
  57455. */
  57456. getPieceList: function () {
  57457. return this._pieceList;
  57458. },
  57459. /**
  57460. * @private
  57461. * @return {string}
  57462. */
  57463. _determineMode: function () {
  57464. var option = this.option;
  57465. return option.pieces && option.pieces.length > 0
  57466. ? 'pieces'
  57467. : this.option.categories
  57468. ? 'categories'
  57469. : 'splitNumber';
  57470. },
  57471. /**
  57472. * @public
  57473. * @override
  57474. */
  57475. setSelected: function (selected) {
  57476. this.option.selected = zrUtil.clone(selected);
  57477. },
  57478. /**
  57479. * @public
  57480. * @override
  57481. */
  57482. getValueState: function (value) {
  57483. var index = VisualMapping.findPieceIndex(value, this._pieceList);
  57484. return index != null
  57485. ? (this.option.selected[this.getSelectedMapKey(this._pieceList[index])]
  57486. ? 'inRange' : 'outOfRange'
  57487. )
  57488. : 'outOfRange';
  57489. },
  57490. /**
  57491. * @public
  57492. * @params {number} pieceIndex piece index in visualMapModel.getPieceList()
  57493. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  57494. */
  57495. findTargetDataIndices: function (pieceIndex) {
  57496. var result = [];
  57497. this.eachTargetSeries(function (seriesModel) {
  57498. var dataIndices = [];
  57499. var data = seriesModel.getData();
  57500. data.each(this.getDataDimension(data), function (value, dataIndex) {
  57501. // Should always base on model pieceList, because it is order sensitive.
  57502. var pIdx = VisualMapping.findPieceIndex(value, this._pieceList);
  57503. pIdx === pieceIndex && dataIndices.push(dataIndex);
  57504. }, true, this);
  57505. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  57506. }, this);
  57507. return result;
  57508. },
  57509. /**
  57510. * @private
  57511. * @param {Object} piece piece.value or piece.interval is required.
  57512. * @return {number} Can be Infinity or -Infinity
  57513. */
  57514. getRepresentValue: function (piece) {
  57515. var representValue;
  57516. if (this.isCategory()) {
  57517. representValue = piece.value;
  57518. }
  57519. else {
  57520. if (piece.value != null) {
  57521. representValue = piece.value;
  57522. }
  57523. else {
  57524. var pieceInterval = piece.interval || [];
  57525. representValue = (pieceInterval[0] === -Infinity && pieceInterval[1] === Infinity)
  57526. ? 0
  57527. : (pieceInterval[0] + pieceInterval[1]) / 2;
  57528. }
  57529. }
  57530. return representValue;
  57531. },
  57532. getVisualMeta: function (getColorVisual) {
  57533. // Do not support category. (category axis is ordinal, numerical)
  57534. if (this.isCategory()) {
  57535. return;
  57536. }
  57537. var stops = [];
  57538. var outerColors = [];
  57539. var visualMapModel = this;
  57540. function setStop(interval, valueState) {
  57541. var representValue = visualMapModel.getRepresentValue({interval: interval});
  57542. if (!valueState) {
  57543. valueState = visualMapModel.getValueState(representValue);
  57544. }
  57545. var color = getColorVisual(representValue, valueState);
  57546. if (interval[0] === -Infinity) {
  57547. outerColors[0] = color;
  57548. }
  57549. else if (interval[1] === Infinity) {
  57550. outerColors[1] = color;
  57551. }
  57552. else {
  57553. stops.push(
  57554. {value: interval[0], color: color},
  57555. {value: interval[1], color: color}
  57556. );
  57557. }
  57558. }
  57559. // Suplement
  57560. var pieceList = this._pieceList.slice();
  57561. if (!pieceList.length) {
  57562. pieceList.push({interval: [-Infinity, Infinity]});
  57563. }
  57564. else {
  57565. var edge = pieceList[0].interval[0];
  57566. edge !== -Infinity && pieceList.unshift({interval: [-Infinity, edge]});
  57567. edge = pieceList[pieceList.length - 1].interval[1];
  57568. edge !== Infinity && pieceList.push({interval: [edge, Infinity]});
  57569. }
  57570. var curr = -Infinity;
  57571. zrUtil.each(pieceList, function (piece) {
  57572. var interval = piece.interval;
  57573. if (interval) {
  57574. // Fulfill gap.
  57575. interval[0] > curr && setStop([curr, interval[0]], 'outOfRange');
  57576. setStop(interval.slice());
  57577. curr = interval[1];
  57578. }
  57579. }, this);
  57580. return {stops: stops, outerColors: outerColors};
  57581. }
  57582. });
  57583. /**
  57584. * Key is this._mode
  57585. * @type {Object}
  57586. * @this {module:echarts/component/viusalMap/PiecewiseMode}
  57587. */
  57588. var resetMethods = {
  57589. splitNumber: function () {
  57590. var thisOption = this.option;
  57591. var pieceList = this._pieceList;
  57592. var precision = thisOption.precision;
  57593. var dataExtent = this.getExtent();
  57594. var splitNumber = thisOption.splitNumber;
  57595. splitNumber = Math.max(parseInt(splitNumber, 10), 1);
  57596. thisOption.splitNumber = splitNumber;
  57597. var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber;
  57598. // Precision auto-adaption
  57599. while (+splitStep.toFixed(precision) !== splitStep && precision < 5) {
  57600. precision++;
  57601. }
  57602. thisOption.precision = precision;
  57603. splitStep = +splitStep.toFixed(precision);
  57604. var index = 0;
  57605. if (thisOption.minOpen) {
  57606. pieceList.push({
  57607. index: index++,
  57608. interval: [-Infinity, dataExtent[0]],
  57609. close: [0, 0]
  57610. });
  57611. }
  57612. for (
  57613. var curr = dataExtent[0], len = index + splitNumber;
  57614. index < len;
  57615. curr += splitStep
  57616. ) {
  57617. var max = index === splitNumber - 1 ? dataExtent[1] : (curr + splitStep);
  57618. pieceList.push({
  57619. index: index++,
  57620. interval: [curr, max],
  57621. close: [1, 1]
  57622. });
  57623. }
  57624. if (thisOption.maxOpen) {
  57625. pieceList.push({
  57626. index: index++,
  57627. interval: [dataExtent[1], Infinity],
  57628. close: [0, 0]
  57629. });
  57630. }
  57631. reformIntervals(pieceList);
  57632. zrUtil.each(pieceList, function (piece) {
  57633. piece.text = this.formatValueText(piece.interval);
  57634. }, this);
  57635. },
  57636. categories: function () {
  57637. var thisOption = this.option;
  57638. zrUtil.each(thisOption.categories, function (cate) {
  57639. // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。
  57640. // 是否改一致。
  57641. this._pieceList.push({
  57642. text: this.formatValueText(cate, true),
  57643. value: cate
  57644. });
  57645. }, this);
  57646. // See "Order Rule".
  57647. normalizeReverse(thisOption, this._pieceList);
  57648. },
  57649. pieces: function () {
  57650. var thisOption = this.option;
  57651. var pieceList = this._pieceList;
  57652. zrUtil.each(thisOption.pieces, function (pieceListItem, index) {
  57653. if (!zrUtil.isObject(pieceListItem)) {
  57654. pieceListItem = {value: pieceListItem};
  57655. }
  57656. var item = {text: '', index: index};
  57657. if (pieceListItem.label != null) {
  57658. item.text = pieceListItem.label;
  57659. }
  57660. if (pieceListItem.hasOwnProperty('value')) {
  57661. var value = item.value = pieceListItem.value;
  57662. item.interval = [value, value];
  57663. item.close = [1, 1];
  57664. }
  57665. else {
  57666. // `min` `max` is legacy option.
  57667. // `lt` `gt` `lte` `gte` is recommanded.
  57668. var interval = item.interval = [];
  57669. var close = item.close = [0, 0];
  57670. var closeList = [1, 0, 1];
  57671. var infinityList = [-Infinity, Infinity];
  57672. var useMinMax = [];
  57673. for (var lg = 0; lg < 2; lg++) {
  57674. var names = [['gte', 'gt', 'min'], ['lte', 'lt', 'max']][lg];
  57675. for (var i = 0; i < 3 && interval[lg] == null; i++) {
  57676. interval[lg] = pieceListItem[names[i]];
  57677. close[lg] = closeList[i];
  57678. useMinMax[lg] = i === 2;
  57679. }
  57680. interval[lg] == null && (interval[lg] = infinityList[lg]);
  57681. }
  57682. useMinMax[0] && interval[1] === Infinity && (close[0] = 0);
  57683. useMinMax[1] && interval[0] === -Infinity && (close[1] = 0);
  57684. if (true) {
  57685. if (interval[0] > interval[1]) {
  57686. console.warn(
  57687. 'Piece ' + index + 'is illegal: ' + interval
  57688. + ' lower bound should not greater then uppper bound.'
  57689. );
  57690. }
  57691. }
  57692. if (interval[0] === interval[1] && close[0] && close[1]) {
  57693. // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}],
  57694. // we use value to lift the priority when min === max
  57695. item.value = interval[0];
  57696. }
  57697. }
  57698. item.visual = VisualMapping.retrieveVisuals(pieceListItem);
  57699. pieceList.push(item);
  57700. }, this);
  57701. // See "Order Rule".
  57702. normalizeReverse(thisOption, pieceList);
  57703. // Only pieces
  57704. reformIntervals(pieceList);
  57705. zrUtil.each(pieceList, function (piece) {
  57706. var close = piece.close;
  57707. var edgeSymbols = [['<', '≤'][close[1]], ['>', '≥'][close[0]]];
  57708. piece.text = piece.text || this.formatValueText(
  57709. piece.value != null ? piece.value : piece.interval,
  57710. false,
  57711. edgeSymbols
  57712. );
  57713. }, this);
  57714. }
  57715. };
  57716. function normalizeReverse(thisOption, pieceList) {
  57717. var inverse = thisOption.inverse;
  57718. if (thisOption.orient === 'vertical' ? !inverse : inverse) {
  57719. pieceList.reverse();
  57720. }
  57721. }
  57722. module.exports = PiecewiseModel;
  57723. /***/ },
  57724. /* 390 */
  57725. /***/ function(module, exports, __webpack_require__) {
  57726. var VisualMapView = __webpack_require__(385);
  57727. var zrUtil = __webpack_require__(4);
  57728. var graphic = __webpack_require__(18);
  57729. var symbolCreators = __webpack_require__(111);
  57730. var layout = __webpack_require__(71);
  57731. var helper = __webpack_require__(386);
  57732. var PiecewiseVisualMapView = VisualMapView.extend({
  57733. type: 'visualMap.piecewise',
  57734. /**
  57735. * @protected
  57736. * @override
  57737. */
  57738. doRender: function () {
  57739. var thisGroup = this.group;
  57740. thisGroup.removeAll();
  57741. var visualMapModel = this.visualMapModel;
  57742. var textGap = visualMapModel.get('textGap');
  57743. var textStyleModel = visualMapModel.textStyleModel;
  57744. var textFont = textStyleModel.getFont();
  57745. var textFill = textStyleModel.getTextColor();
  57746. var itemAlign = this._getItemAlign();
  57747. var itemSize = visualMapModel.itemSize;
  57748. var viewData = this._getViewData();
  57749. var endsText = viewData.endsText;
  57750. var showLabel = zrUtil.retrieve(visualMapModel.get('showLabel', true), !endsText);
  57751. endsText && this._renderEndsText(
  57752. thisGroup, endsText[0], itemSize, showLabel, itemAlign
  57753. );
  57754. zrUtil.each(viewData.viewPieceList, renderItem, this);
  57755. endsText && this._renderEndsText(
  57756. thisGroup, endsText[1], itemSize, showLabel, itemAlign
  57757. );
  57758. layout.box(
  57759. visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap')
  57760. );
  57761. this.renderBackground(thisGroup);
  57762. this.positionGroup(thisGroup);
  57763. function renderItem(item) {
  57764. var piece = item.piece;
  57765. var itemGroup = new graphic.Group();
  57766. itemGroup.onclick = zrUtil.bind(this._onItemClick, this, piece);
  57767. this._enableHoverLink(itemGroup, item.indexInModelPieceList);
  57768. var representValue = visualMapModel.getRepresentValue(piece);
  57769. this._createItemSymbol(
  57770. itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]]
  57771. );
  57772. if (showLabel) {
  57773. var visualState = this.visualMapModel.getValueState(representValue);
  57774. itemGroup.add(new graphic.Text({
  57775. style: {
  57776. x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
  57777. y: itemSize[1] / 2,
  57778. text: piece.text,
  57779. textVerticalAlign: 'middle',
  57780. textAlign: itemAlign,
  57781. textFont: textFont,
  57782. fill: textFill,
  57783. opacity: visualState === 'outOfRange' ? 0.5 : 1
  57784. }
  57785. }));
  57786. }
  57787. thisGroup.add(itemGroup);
  57788. }
  57789. },
  57790. /**
  57791. * @private
  57792. */
  57793. _enableHoverLink: function (itemGroup, pieceIndex) {
  57794. itemGroup
  57795. .on('mouseover', zrUtil.bind(onHoverLink, this, 'highlight'))
  57796. .on('mouseout', zrUtil.bind(onHoverLink, this, 'downplay'));
  57797. function onHoverLink(method) {
  57798. var visualMapModel = this.visualMapModel;
  57799. visualMapModel.option.hoverLink && this.api.dispatchAction({
  57800. type: method,
  57801. batch: helper.convertDataIndex(
  57802. visualMapModel.findTargetDataIndices(pieceIndex)
  57803. )
  57804. });
  57805. }
  57806. },
  57807. /**
  57808. * @private
  57809. */
  57810. _getItemAlign: function () {
  57811. var visualMapModel = this.visualMapModel;
  57812. var modelOption = visualMapModel.option;
  57813. if (modelOption.orient === 'vertical') {
  57814. return helper.getItemAlign(
  57815. visualMapModel, this.api, visualMapModel.itemSize
  57816. );
  57817. }
  57818. else { // horizontal, most case left unless specifying right.
  57819. var align = modelOption.align;
  57820. if (!align || align === 'auto') {
  57821. align = 'left';
  57822. }
  57823. return align;
  57824. }
  57825. },
  57826. /**
  57827. * @private
  57828. */
  57829. _renderEndsText: function (group, text, itemSize, showLabel, itemAlign) {
  57830. if (!text) {
  57831. return;
  57832. }
  57833. var itemGroup = new graphic.Group();
  57834. var textStyleModel = this.visualMapModel.textStyleModel;
  57835. itemGroup.add(new graphic.Text({
  57836. style: {
  57837. x: showLabel ? (itemAlign === 'right' ? itemSize[0] : 0) : itemSize[0] / 2,
  57838. y: itemSize[1] / 2,
  57839. textVerticalAlign: 'middle',
  57840. textAlign: showLabel ? itemAlign : 'center',
  57841. text: text,
  57842. textFont: textStyleModel.getFont(),
  57843. fill: textStyleModel.getTextColor()
  57844. }
  57845. }));
  57846. group.add(itemGroup);
  57847. },
  57848. /**
  57849. * @private
  57850. * @return {Object} {peiceList, endsText} The order is the same as screen pixel order.
  57851. */
  57852. _getViewData: function () {
  57853. var visualMapModel = this.visualMapModel;
  57854. var viewPieceList = zrUtil.map(visualMapModel.getPieceList(), function (piece, index) {
  57855. return {piece: piece, indexInModelPieceList: index};
  57856. });
  57857. var endsText = visualMapModel.get('text');
  57858. // Consider orient and inverse.
  57859. var orient = visualMapModel.get('orient');
  57860. var inverse = visualMapModel.get('inverse');
  57861. // Order of model pieceList is always [low, ..., high]
  57862. if (orient === 'horizontal' ? inverse : !inverse) {
  57863. viewPieceList.reverse();
  57864. }
  57865. // Origin order of endsText is [high, low]
  57866. else if (endsText) {
  57867. endsText = endsText.slice().reverse();
  57868. }
  57869. return {viewPieceList: viewPieceList, endsText: endsText};
  57870. },
  57871. /**
  57872. * @private
  57873. */
  57874. _createItemSymbol: function (group, representValue, shapeParam) {
  57875. group.add(symbolCreators.createSymbol(
  57876. this.getControllerVisual(representValue, 'symbol'),
  57877. shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3],
  57878. this.getControllerVisual(representValue, 'color')
  57879. ));
  57880. },
  57881. /**
  57882. * @private
  57883. */
  57884. _onItemClick: function (piece) {
  57885. var visualMapModel = this.visualMapModel;
  57886. var option = visualMapModel.option;
  57887. var selected = zrUtil.clone(option.selected);
  57888. var newKey = visualMapModel.getSelectedMapKey(piece);
  57889. if (option.selectedMode === 'single') {
  57890. selected[newKey] = true;
  57891. zrUtil.each(selected, function (o, key) {
  57892. selected[key] = key === newKey;
  57893. });
  57894. }
  57895. else {
  57896. selected[newKey] = !selected[newKey];
  57897. }
  57898. this.api.dispatchAction({
  57899. type: 'selectDataRange',
  57900. from: this.uid,
  57901. visualMapId: this.visualMapModel.id,
  57902. selected: selected
  57903. });
  57904. }
  57905. });
  57906. module.exports = PiecewiseVisualMapView;
  57907. /***/ },
  57908. /* 391 */
  57909. /***/ function(module, exports, __webpack_require__) {
  57910. // HINT Markpoint can't be used too much
  57911. __webpack_require__(392);
  57912. __webpack_require__(394);
  57913. __webpack_require__(1).registerPreprocessor(function (opt) {
  57914. // Make sure markPoint component is enabled
  57915. opt.markPoint = opt.markPoint || {};
  57916. });
  57917. /***/ },
  57918. /* 392 */
  57919. /***/ function(module, exports, __webpack_require__) {
  57920. module.exports = __webpack_require__(393).extend({
  57921. type: 'markPoint',
  57922. defaultOption: {
  57923. zlevel: 0,
  57924. z: 5,
  57925. symbol: 'pin',
  57926. symbolSize: 50,
  57927. //symbolRotate: 0,
  57928. //symbolOffset: [0, 0]
  57929. tooltip: {
  57930. trigger: 'item'
  57931. },
  57932. label: {
  57933. normal: {
  57934. show: true,
  57935. position: 'inside'
  57936. },
  57937. emphasis: {
  57938. show: true
  57939. }
  57940. },
  57941. itemStyle: {
  57942. normal: {
  57943. borderWidth: 2
  57944. }
  57945. }
  57946. }
  57947. });
  57948. /***/ },
  57949. /* 393 */
  57950. /***/ function(module, exports, __webpack_require__) {
  57951. var modelUtil = __webpack_require__(5);
  57952. var zrUtil = __webpack_require__(4);
  57953. var env = __webpack_require__(2);
  57954. var formatUtil = __webpack_require__(6);
  57955. var addCommas = formatUtil.addCommas;
  57956. var encodeHTML = formatUtil.encodeHTML;
  57957. function fillLabel(opt) {
  57958. modelUtil.defaultEmphasis(
  57959. opt.label,
  57960. modelUtil.LABEL_OPTIONS
  57961. );
  57962. }
  57963. var MarkerModel = __webpack_require__(1).extendComponentModel({
  57964. type: 'marker',
  57965. dependencies: ['series', 'grid', 'polar', 'geo'],
  57966. /**
  57967. * @overrite
  57968. */
  57969. init: function (option, parentModel, ecModel, extraOpt) {
  57970. if (true) {
  57971. if (this.type === 'marker') {
  57972. throw new Error('Marker component is abstract component. Use markLine, markPoint, markArea instead.');
  57973. }
  57974. }
  57975. this.mergeDefaultAndTheme(option, ecModel);
  57976. this.mergeOption(option, ecModel, extraOpt.createdBySelf, true);
  57977. },
  57978. /**
  57979. * @return {boolean}
  57980. */
  57981. isAnimationEnabled: function () {
  57982. if (env.node) {
  57983. return false;
  57984. }
  57985. var hostSeries = this.__hostSeries;
  57986. return this.getShallow('animation') && hostSeries && hostSeries.isAnimationEnabled();
  57987. },
  57988. mergeOption: function (newOpt, ecModel, createdBySelf, isInit) {
  57989. var MarkerModel = this.constructor;
  57990. var modelPropName = this.mainType + 'Model';
  57991. if (!createdBySelf) {
  57992. ecModel.eachSeries(function (seriesModel) {
  57993. var markerOpt = seriesModel.get(this.mainType);
  57994. var markerModel = seriesModel[modelPropName];
  57995. if (!markerOpt || !markerOpt.data) {
  57996. seriesModel[modelPropName] = null;
  57997. return;
  57998. }
  57999. if (!markerModel) {
  58000. if (isInit) {
  58001. // Default label emphasis `position` and `show`
  58002. fillLabel(markerOpt);
  58003. }
  58004. zrUtil.each(markerOpt.data, function (item) {
  58005. // FIXME Overwrite fillLabel method ?
  58006. if (item instanceof Array) {
  58007. fillLabel(item[0]);
  58008. fillLabel(item[1]);
  58009. }
  58010. else {
  58011. fillLabel(item);
  58012. }
  58013. });
  58014. markerModel = new MarkerModel(
  58015. markerOpt, this, ecModel
  58016. );
  58017. zrUtil.extend(markerModel, {
  58018. mainType: this.mainType,
  58019. // Use the same series index and name
  58020. seriesIndex: seriesModel.seriesIndex,
  58021. name: seriesModel.name,
  58022. createdBySelf: true
  58023. });
  58024. markerModel.__hostSeries = seriesModel;
  58025. }
  58026. else {
  58027. markerModel.mergeOption(markerOpt, ecModel, true);
  58028. }
  58029. seriesModel[modelPropName] = markerModel;
  58030. }, this);
  58031. }
  58032. },
  58033. formatTooltip: function (dataIndex) {
  58034. var data = this.getData();
  58035. var value = this.getRawValue(dataIndex);
  58036. var formattedValue = zrUtil.isArray(value)
  58037. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  58038. var name = data.getName(dataIndex);
  58039. var html = encodeHTML(this.name);
  58040. if (value != null || name) {
  58041. html += '<br />';
  58042. }
  58043. if (name) {
  58044. html += encodeHTML(name);
  58045. if (value != null) {
  58046. html += ' : ';
  58047. }
  58048. }
  58049. if (value != null) {
  58050. html += encodeHTML(formattedValue);
  58051. }
  58052. return html;
  58053. },
  58054. getData: function () {
  58055. return this._data;
  58056. },
  58057. setData: function (data) {
  58058. this._data = data;
  58059. }
  58060. });
  58061. zrUtil.mixin(MarkerModel, modelUtil.dataFormatMixin);
  58062. module.exports = MarkerModel;
  58063. /***/ },
  58064. /* 394 */
  58065. /***/ function(module, exports, __webpack_require__) {
  58066. var SymbolDraw = __webpack_require__(116);
  58067. var zrUtil = __webpack_require__(4);
  58068. var numberUtil = __webpack_require__(7);
  58069. var List = __webpack_require__(98);
  58070. var markerHelper = __webpack_require__(395);
  58071. function updateMarkerLayout(mpData, seriesModel, api) {
  58072. var coordSys = seriesModel.coordinateSystem;
  58073. mpData.each(function (idx) {
  58074. var itemModel = mpData.getItemModel(idx);
  58075. var point;
  58076. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  58077. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  58078. if (!isNaN(xPx) && !isNaN(yPx)) {
  58079. point = [xPx, yPx];
  58080. }
  58081. // Chart like bar may have there own marker positioning logic
  58082. else if (seriesModel.getMarkerPosition) {
  58083. // Use the getMarkerPoisition
  58084. point = seriesModel.getMarkerPosition(
  58085. mpData.getValues(mpData.dimensions, idx)
  58086. );
  58087. }
  58088. else if (coordSys) {
  58089. var x = mpData.get(coordSys.dimensions[0], idx);
  58090. var y = mpData.get(coordSys.dimensions[1], idx);
  58091. point = coordSys.dataToPoint([x, y]);
  58092. }
  58093. // Use x, y if has any
  58094. if (!isNaN(xPx)) {
  58095. point[0] = xPx;
  58096. }
  58097. if (!isNaN(yPx)) {
  58098. point[1] = yPx;
  58099. }
  58100. mpData.setItemLayout(idx, point);
  58101. });
  58102. }
  58103. __webpack_require__(396).extend({
  58104. type: 'markPoint',
  58105. updateLayout: function (markPointModel, ecModel, api) {
  58106. ecModel.eachSeries(function (seriesModel) {
  58107. var mpModel = seriesModel.markPointModel;
  58108. if (mpModel) {
  58109. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  58110. this.markerGroupMap.get(seriesModel.id).updateLayout(mpModel);
  58111. }
  58112. }, this);
  58113. },
  58114. renderSeries: function (seriesModel, mpModel, ecModel, api) {
  58115. var coordSys = seriesModel.coordinateSystem;
  58116. var seriesId = seriesModel.id;
  58117. var seriesData = seriesModel.getData();
  58118. var symbolDrawMap = this.markerGroupMap;
  58119. var symbolDraw = symbolDrawMap.get(seriesId)
  58120. || symbolDrawMap.set(seriesId, new SymbolDraw());
  58121. var mpData = createList(coordSys, seriesModel, mpModel);
  58122. // FIXME
  58123. mpModel.setData(mpData);
  58124. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  58125. mpData.each(function (idx) {
  58126. var itemModel = mpData.getItemModel(idx);
  58127. var symbolSize = itemModel.getShallow('symbolSize');
  58128. if (typeof symbolSize === 'function') {
  58129. // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据?
  58130. symbolSize = symbolSize(
  58131. mpModel.getRawValue(idx), mpModel.getDataParams(idx)
  58132. );
  58133. }
  58134. mpData.setItemVisual(idx, {
  58135. symbolSize: symbolSize,
  58136. color: itemModel.get('itemStyle.normal.color')
  58137. || seriesData.getVisual('color'),
  58138. symbol: itemModel.getShallow('symbol')
  58139. });
  58140. });
  58141. // TODO Text are wrong
  58142. symbolDraw.updateData(mpData);
  58143. this.group.add(symbolDraw.group);
  58144. // Set host model for tooltip
  58145. // FIXME
  58146. mpData.eachItemGraphicEl(function (el) {
  58147. el.traverse(function (child) {
  58148. child.dataModel = mpModel;
  58149. });
  58150. });
  58151. symbolDraw.__keep = true;
  58152. symbolDraw.group.silent = mpModel.get('silent') || seriesModel.get('silent');
  58153. }
  58154. });
  58155. /**
  58156. * @inner
  58157. * @param {module:echarts/coord/*} [coordSys]
  58158. * @param {module:echarts/model/Series} seriesModel
  58159. * @param {module:echarts/model/Model} mpModel
  58160. */
  58161. function createList(coordSys, seriesModel, mpModel) {
  58162. var coordDimsInfos;
  58163. if (coordSys) {
  58164. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  58165. var info = seriesModel.getData().getDimensionInfo(
  58166. seriesModel.coordDimToDataDim(coordDim)[0]
  58167. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  58168. info.name = coordDim;
  58169. return info;
  58170. });
  58171. }
  58172. else {
  58173. coordDimsInfos =[{
  58174. name: 'value',
  58175. type: 'float'
  58176. }];
  58177. }
  58178. var mpData = new List(coordDimsInfos, mpModel);
  58179. var dataOpt = zrUtil.map(mpModel.get('data'), zrUtil.curry(
  58180. markerHelper.dataTransform, seriesModel
  58181. ));
  58182. if (coordSys) {
  58183. dataOpt = zrUtil.filter(
  58184. dataOpt, zrUtil.curry(markerHelper.dataFilter, coordSys)
  58185. );
  58186. }
  58187. mpData.initData(dataOpt, null,
  58188. coordSys ? markerHelper.dimValueGetter : function (item) {
  58189. return item.value;
  58190. }
  58191. );
  58192. return mpData;
  58193. }
  58194. /***/ },
  58195. /* 395 */
  58196. /***/ function(module, exports, __webpack_require__) {
  58197. var zrUtil = __webpack_require__(4);
  58198. var numberUtil = __webpack_require__(7);
  58199. var indexOf = zrUtil.indexOf;
  58200. function hasXOrY(item) {
  58201. return !(isNaN(parseFloat(item.x)) && isNaN(parseFloat(item.y)));
  58202. }
  58203. function hasXAndY(item) {
  58204. return !isNaN(parseFloat(item.x)) && !isNaN(parseFloat(item.y));
  58205. }
  58206. function getPrecision(data, valueAxisDim, dataIndex) {
  58207. var precision = -1;
  58208. do {
  58209. precision = Math.max(
  58210. numberUtil.getPrecision(data.get(
  58211. valueAxisDim, dataIndex
  58212. )),
  58213. precision
  58214. );
  58215. data = data.stackedOn;
  58216. } while (data);
  58217. return precision;
  58218. }
  58219. function markerTypeCalculatorWithExtent(
  58220. mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
  58221. ) {
  58222. var coordArr = [];
  58223. var value = numCalculate(data, targetDataDim, mlType);
  58224. var dataIndex = data.indicesOfNearest(targetDataDim, value, true)[0];
  58225. coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex, true);
  58226. coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex, true);
  58227. var precision = getPrecision(data, targetDataDim, dataIndex);
  58228. if (precision >= 0) {
  58229. coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
  58230. }
  58231. return coordArr;
  58232. }
  58233. var curry = zrUtil.curry;
  58234. // TODO Specified percent
  58235. var markerTypeCalculator = {
  58236. /**
  58237. * @method
  58238. * @param {module:echarts/data/List} data
  58239. * @param {string} baseAxisDim
  58240. * @param {string} valueAxisDim
  58241. */
  58242. min: curry(markerTypeCalculatorWithExtent, 'min'),
  58243. /**
  58244. * @method
  58245. * @param {module:echarts/data/List} data
  58246. * @param {string} baseAxisDim
  58247. * @param {string} valueAxisDim
  58248. */
  58249. max: curry(markerTypeCalculatorWithExtent, 'max'),
  58250. /**
  58251. * @method
  58252. * @param {module:echarts/data/List} data
  58253. * @param {string} baseAxisDim
  58254. * @param {string} valueAxisDim
  58255. */
  58256. average: curry(markerTypeCalculatorWithExtent, 'average')
  58257. };
  58258. /**
  58259. * Transform markPoint data item to format used in List by do the following
  58260. * 1. Calculate statistic like `max`, `min`, `average`
  58261. * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
  58262. * @param {module:echarts/model/Series} seriesModel
  58263. * @param {module:echarts/coord/*} [coordSys]
  58264. * @param {Object} item
  58265. * @return {Object}
  58266. */
  58267. var dataTransform = function (seriesModel, item) {
  58268. var data = seriesModel.getData();
  58269. var coordSys = seriesModel.coordinateSystem;
  58270. // 1. If not specify the position with pixel directly
  58271. // 2. If `coord` is not a data array. Which uses `xAxis`,
  58272. // `yAxis` to specify the coord on each dimension
  58273. // parseFloat first because item.x and item.y can be percent string like '20%'
  58274. if (item && !hasXAndY(item) && !zrUtil.isArray(item.coord) && coordSys) {
  58275. var dims = coordSys.dimensions;
  58276. var axisInfo = getAxisInfo(item, data, coordSys, seriesModel);
  58277. // Clone the option
  58278. // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
  58279. item = zrUtil.clone(item);
  58280. if (item.type
  58281. && markerTypeCalculator[item.type]
  58282. && axisInfo.baseAxis && axisInfo.valueAxis
  58283. ) {
  58284. var otherCoordIndex = indexOf(dims, axisInfo.baseAxis.dim);
  58285. var targetCoordIndex = indexOf(dims, axisInfo.valueAxis.dim);
  58286. item.coord = markerTypeCalculator[item.type](
  58287. data, axisInfo.baseDataDim, axisInfo.valueDataDim,
  58288. otherCoordIndex, targetCoordIndex
  58289. );
  58290. // Force to use the value of calculated value.
  58291. item.value = item.coord[targetCoordIndex];
  58292. }
  58293. else {
  58294. // FIXME Only has one of xAxis and yAxis.
  58295. var coord = [
  58296. item.xAxis != null ? item.xAxis : item.radiusAxis,
  58297. item.yAxis != null ? item.yAxis : item.angleAxis
  58298. ];
  58299. // Each coord support max, min, average
  58300. for (var i = 0; i < 2; i++) {
  58301. if (markerTypeCalculator[coord[i]]) {
  58302. var dataDim = seriesModel.coordDimToDataDim(dims[i])[0];
  58303. coord[i] = numCalculate(data, dataDim, coord[i]);
  58304. }
  58305. }
  58306. item.coord = coord;
  58307. }
  58308. }
  58309. return item;
  58310. };
  58311. var getAxisInfo = function (item, data, coordSys, seriesModel) {
  58312. var ret = {};
  58313. if (item.valueIndex != null || item.valueDim != null) {
  58314. ret.valueDataDim = item.valueIndex != null
  58315. ? data.getDimension(item.valueIndex) : item.valueDim;
  58316. ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim));
  58317. ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis);
  58318. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  58319. }
  58320. else {
  58321. ret.baseAxis = seriesModel.getBaseAxis();
  58322. ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis);
  58323. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  58324. ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0];
  58325. }
  58326. return ret;
  58327. };
  58328. /**
  58329. * Filter data which is out of coordinateSystem range
  58330. * [dataFilter description]
  58331. * @param {module:echarts/coord/*} [coordSys]
  58332. * @param {Object} item
  58333. * @return {boolean}
  58334. */
  58335. var dataFilter = function (coordSys, item) {
  58336. // Alwalys return true if there is no coordSys
  58337. return (coordSys && coordSys.containData && item.coord && !hasXOrY(item))
  58338. ? coordSys.containData(item.coord) : true;
  58339. };
  58340. var dimValueGetter = function (item, dimName, dataIndex, dimIndex) {
  58341. // x, y, radius, angle
  58342. if (dimIndex < 2) {
  58343. return item.coord && item.coord[dimIndex];
  58344. }
  58345. return item.value;
  58346. };
  58347. var numCalculate = function (data, valueDataDim, type) {
  58348. if (type === 'average') {
  58349. var sum = 0;
  58350. var count = 0;
  58351. data.each(valueDataDim, function (val, idx) {
  58352. if (!isNaN(val)) {
  58353. sum += val;
  58354. count++;
  58355. }
  58356. }, true);
  58357. return sum / count;
  58358. }
  58359. else {
  58360. return data.getDataExtent(valueDataDim, true)[type === 'max' ? 1 : 0];
  58361. }
  58362. };
  58363. module.exports = {
  58364. dataTransform: dataTransform,
  58365. dataFilter: dataFilter,
  58366. dimValueGetter: dimValueGetter,
  58367. getAxisInfo: getAxisInfo,
  58368. numCalculate: numCalculate
  58369. };
  58370. /***/ },
  58371. /* 396 */
  58372. /***/ function(module, exports, __webpack_require__) {
  58373. var zrUtil = __webpack_require__(4);
  58374. module.exports = __webpack_require__(1).extendComponentView({
  58375. type: 'marker',
  58376. init: function () {
  58377. /**
  58378. * Markline grouped by series
  58379. * @private
  58380. * @type {module:zrender/core/util.HashMap}
  58381. */
  58382. this.markerGroupMap = zrUtil.createHashMap();
  58383. },
  58384. render: function (markerModel, ecModel, api) {
  58385. var markerGroupMap = this.markerGroupMap;
  58386. markerGroupMap.each(function (item) {
  58387. item.__keep = false;
  58388. });
  58389. var markerModelKey = this.type + 'Model';
  58390. ecModel.eachSeries(function (seriesModel) {
  58391. var markerModel = seriesModel[markerModelKey];
  58392. markerModel && this.renderSeries(seriesModel, markerModel, ecModel, api);
  58393. }, this);
  58394. markerGroupMap.each(function (item) {
  58395. !item.__keep && this.group.remove(item.group);
  58396. }, this);
  58397. },
  58398. renderSeries: function () {}
  58399. });
  58400. /***/ },
  58401. /* 397 */
  58402. /***/ function(module, exports, __webpack_require__) {
  58403. __webpack_require__(398);
  58404. __webpack_require__(399);
  58405. __webpack_require__(1).registerPreprocessor(function (opt) {
  58406. // Make sure markLine component is enabled
  58407. opt.markLine = opt.markLine || {};
  58408. });
  58409. /***/ },
  58410. /* 398 */
  58411. /***/ function(module, exports, __webpack_require__) {
  58412. module.exports = __webpack_require__(393).extend({
  58413. type: 'markLine',
  58414. defaultOption: {
  58415. zlevel: 0,
  58416. z: 5,
  58417. symbol: ['circle', 'arrow'],
  58418. symbolSize: [8, 16],
  58419. //symbolRotate: 0,
  58420. precision: 2,
  58421. tooltip: {
  58422. trigger: 'item'
  58423. },
  58424. label: {
  58425. normal: {
  58426. show: true,
  58427. position: 'end'
  58428. },
  58429. emphasis: {
  58430. show: true
  58431. }
  58432. },
  58433. lineStyle: {
  58434. normal: {
  58435. type: 'dashed'
  58436. },
  58437. emphasis: {
  58438. width: 3
  58439. }
  58440. },
  58441. animationEasing: 'linear'
  58442. }
  58443. });
  58444. /***/ },
  58445. /* 399 */
  58446. /***/ function(module, exports, __webpack_require__) {
  58447. var zrUtil = __webpack_require__(4);
  58448. var List = __webpack_require__(98);
  58449. var numberUtil = __webpack_require__(7);
  58450. var markerHelper = __webpack_require__(395);
  58451. var LineDraw = __webpack_require__(210);
  58452. var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
  58453. var data = seriesModel.getData();
  58454. // Special type markLine like 'min', 'max', 'average'
  58455. var mlType = item.type;
  58456. if (!zrUtil.isArray(item)
  58457. && (
  58458. mlType === 'min' || mlType === 'max' || mlType === 'average'
  58459. // In case
  58460. // data: [{
  58461. // yAxis: 10
  58462. // }]
  58463. || (item.xAxis != null || item.yAxis != null)
  58464. )
  58465. ) {
  58466. var valueAxis;
  58467. var valueDataDim;
  58468. var value;
  58469. if (item.yAxis != null || item.xAxis != null) {
  58470. valueDataDim = item.yAxis != null ? 'y' : 'x';
  58471. valueAxis = coordSys.getAxis(valueDataDim);
  58472. value = zrUtil.retrieve(item.yAxis, item.xAxis);
  58473. }
  58474. else {
  58475. var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);
  58476. valueDataDim = axisInfo.valueDataDim;
  58477. valueAxis = axisInfo.valueAxis;
  58478. value = markerHelper.numCalculate(data, valueDataDim, mlType);
  58479. }
  58480. var valueIndex = valueDataDim === 'x' ? 0 : 1;
  58481. var baseIndex = 1 - valueIndex;
  58482. var mlFrom = zrUtil.clone(item);
  58483. var mlTo = {};
  58484. mlFrom.type = null;
  58485. mlFrom.coord = [];
  58486. mlTo.coord = [];
  58487. mlFrom.coord[baseIndex] = -Infinity;
  58488. mlTo.coord[baseIndex] = Infinity;
  58489. var precision = mlModel.get('precision');
  58490. if (precision >= 0 && typeof value === 'number') {
  58491. value = +value.toFixed(precision);
  58492. }
  58493. mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
  58494. item = [mlFrom, mlTo, { // Extra option for tooltip and label
  58495. type: mlType,
  58496. valueIndex: item.valueIndex,
  58497. // Force to use the value of calculated value.
  58498. value: value
  58499. }];
  58500. }
  58501. item = [
  58502. markerHelper.dataTransform(seriesModel, item[0]),
  58503. markerHelper.dataTransform(seriesModel, item[1]),
  58504. zrUtil.extend({}, item[2])
  58505. ];
  58506. // Avoid line data type is extended by from(to) data type
  58507. item[2].type = item[2].type || '';
  58508. // Merge from option and to option into line option
  58509. zrUtil.merge(item[2], item[0]);
  58510. zrUtil.merge(item[2], item[1]);
  58511. return item;
  58512. };
  58513. function isInifinity(val) {
  58514. return !isNaN(val) && !isFinite(val);
  58515. }
  58516. // If a markLine has one dim
  58517. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  58518. var otherDimIndex = 1 - dimIndex;
  58519. var dimName = coordSys.dimensions[dimIndex];
  58520. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
  58521. && fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
  58522. }
  58523. function markLineFilter(coordSys, item) {
  58524. if (coordSys.type === 'cartesian2d') {
  58525. var fromCoord = item[0].coord;
  58526. var toCoord = item[1].coord;
  58527. // In case
  58528. // {
  58529. // markLine: {
  58530. // data: [{ yAxis: 2 }]
  58531. // }
  58532. // }
  58533. if (
  58534. fromCoord && toCoord &&
  58535. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  58536. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  58537. ) {
  58538. return true;
  58539. }
  58540. }
  58541. return markerHelper.dataFilter(coordSys, item[0])
  58542. && markerHelper.dataFilter(coordSys, item[1]);
  58543. }
  58544. function updateSingleMarkerEndLayout(
  58545. data, idx, isFrom, seriesModel, api
  58546. ) {
  58547. var coordSys = seriesModel.coordinateSystem;
  58548. var itemModel = data.getItemModel(idx);
  58549. var point;
  58550. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  58551. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  58552. if (!isNaN(xPx) && !isNaN(yPx)) {
  58553. point = [xPx, yPx];
  58554. }
  58555. else {
  58556. // Chart like bar may have there own marker positioning logic
  58557. if (seriesModel.getMarkerPosition) {
  58558. // Use the getMarkerPoisition
  58559. point = seriesModel.getMarkerPosition(
  58560. data.getValues(data.dimensions, idx)
  58561. );
  58562. }
  58563. else {
  58564. var dims = coordSys.dimensions;
  58565. var x = data.get(dims[0], idx);
  58566. var y = data.get(dims[1], idx);
  58567. point = coordSys.dataToPoint([x, y]);
  58568. }
  58569. // Expand line to the edge of grid if value on one axis is Inifnity
  58570. // In case
  58571. // markLine: {
  58572. // data: [{
  58573. // yAxis: 2
  58574. // // or
  58575. // type: 'average'
  58576. // }]
  58577. // }
  58578. if (coordSys.type === 'cartesian2d') {
  58579. var xAxis = coordSys.getAxis('x');
  58580. var yAxis = coordSys.getAxis('y');
  58581. var dims = coordSys.dimensions;
  58582. if (isInifinity(data.get(dims[0], idx))) {
  58583. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
  58584. }
  58585. else if (isInifinity(data.get(dims[1], idx))) {
  58586. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
  58587. }
  58588. }
  58589. // Use x, y if has any
  58590. if (!isNaN(xPx)) {
  58591. point[0] = xPx;
  58592. }
  58593. if (!isNaN(yPx)) {
  58594. point[1] = yPx;
  58595. }
  58596. }
  58597. data.setItemLayout(idx, point);
  58598. }
  58599. __webpack_require__(396).extend({
  58600. type: 'markLine',
  58601. updateLayout: function (markLineModel, ecModel, api) {
  58602. ecModel.eachSeries(function (seriesModel) {
  58603. var mlModel = seriesModel.markLineModel;
  58604. if (mlModel) {
  58605. var mlData = mlModel.getData();
  58606. var fromData = mlModel.__from;
  58607. var toData = mlModel.__to;
  58608. // Update visual and layout of from symbol and to symbol
  58609. fromData.each(function (idx) {
  58610. updateSingleMarkerEndLayout(fromData, idx, true, seriesModel, api);
  58611. updateSingleMarkerEndLayout(toData, idx, false, seriesModel, api);
  58612. });
  58613. // Update layout of line
  58614. mlData.each(function (idx) {
  58615. mlData.setItemLayout(idx, [
  58616. fromData.getItemLayout(idx),
  58617. toData.getItemLayout(idx)
  58618. ]);
  58619. });
  58620. this.markerGroupMap.get(seriesModel.id).updateLayout();
  58621. }
  58622. }, this);
  58623. },
  58624. renderSeries: function (seriesModel, mlModel, ecModel, api) {
  58625. var coordSys = seriesModel.coordinateSystem;
  58626. var seriesId = seriesModel.id;
  58627. var seriesData = seriesModel.getData();
  58628. var lineDrawMap = this.markerGroupMap;
  58629. var lineDraw = lineDrawMap.get(seriesId)
  58630. || lineDrawMap.set(seriesId, new LineDraw());
  58631. this.group.add(lineDraw.group);
  58632. var mlData = createList(coordSys, seriesModel, mlModel);
  58633. var fromData = mlData.from;
  58634. var toData = mlData.to;
  58635. var lineData = mlData.line;
  58636. mlModel.__from = fromData;
  58637. mlModel.__to = toData;
  58638. // Line data for tooltip and formatter
  58639. mlModel.setData(lineData);
  58640. var symbolType = mlModel.get('symbol');
  58641. var symbolSize = mlModel.get('symbolSize');
  58642. if (!zrUtil.isArray(symbolType)) {
  58643. symbolType = [symbolType, symbolType];
  58644. }
  58645. if (typeof symbolSize === 'number') {
  58646. symbolSize = [symbolSize, symbolSize];
  58647. }
  58648. // Update visual and layout of from symbol and to symbol
  58649. mlData.from.each(function (idx) {
  58650. updateDataVisualAndLayout(fromData, idx, true);
  58651. updateDataVisualAndLayout(toData, idx, false);
  58652. });
  58653. // Update visual and layout of line
  58654. lineData.each(function (idx) {
  58655. var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color');
  58656. lineData.setItemVisual(idx, {
  58657. color: lineColor || fromData.getItemVisual(idx, 'color')
  58658. });
  58659. lineData.setItemLayout(idx, [
  58660. fromData.getItemLayout(idx),
  58661. toData.getItemLayout(idx)
  58662. ]);
  58663. lineData.setItemVisual(idx, {
  58664. 'fromSymbolSize': fromData.getItemVisual(idx, 'symbolSize'),
  58665. 'fromSymbol': fromData.getItemVisual(idx, 'symbol'),
  58666. 'toSymbolSize': toData.getItemVisual(idx, 'symbolSize'),
  58667. 'toSymbol': toData.getItemVisual(idx, 'symbol')
  58668. });
  58669. });
  58670. lineDraw.updateData(lineData);
  58671. // Set host model for tooltip
  58672. // FIXME
  58673. mlData.line.eachItemGraphicEl(function (el, idx) {
  58674. el.traverse(function (child) {
  58675. child.dataModel = mlModel;
  58676. });
  58677. });
  58678. function updateDataVisualAndLayout(data, idx, isFrom) {
  58679. var itemModel = data.getItemModel(idx);
  58680. updateSingleMarkerEndLayout(
  58681. data, idx, isFrom, seriesModel, api
  58682. );
  58683. data.setItemVisual(idx, {
  58684. symbolSize: itemModel.get('symbolSize') || symbolSize[isFrom ? 0 : 1],
  58685. symbol: itemModel.get('symbol', true) || symbolType[isFrom ? 0 : 1],
  58686. color: itemModel.get('itemStyle.normal.color') || seriesData.getVisual('color')
  58687. });
  58688. }
  58689. lineDraw.__keep = true;
  58690. lineDraw.group.silent = mlModel.get('silent') || seriesModel.get('silent');
  58691. }
  58692. });
  58693. /**
  58694. * @inner
  58695. * @param {module:echarts/coord/*} coordSys
  58696. * @param {module:echarts/model/Series} seriesModel
  58697. * @param {module:echarts/model/Model} mpModel
  58698. */
  58699. function createList(coordSys, seriesModel, mlModel) {
  58700. var coordDimsInfos;
  58701. if (coordSys) {
  58702. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  58703. var info = seriesModel.getData().getDimensionInfo(
  58704. seriesModel.coordDimToDataDim(coordDim)[0]
  58705. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  58706. info.name = coordDim;
  58707. return info;
  58708. });
  58709. }
  58710. else {
  58711. coordDimsInfos =[{
  58712. name: 'value',
  58713. type: 'float'
  58714. }];
  58715. }
  58716. var fromData = new List(coordDimsInfos, mlModel);
  58717. var toData = new List(coordDimsInfos, mlModel);
  58718. // No dimensions
  58719. var lineData = new List([], mlModel);
  58720. var optData = zrUtil.map(mlModel.get('data'), zrUtil.curry(
  58721. markLineTransform, seriesModel, coordSys, mlModel
  58722. ));
  58723. if (coordSys) {
  58724. optData = zrUtil.filter(
  58725. optData, zrUtil.curry(markLineFilter, coordSys)
  58726. );
  58727. }
  58728. var dimValueGetter = coordSys ? markerHelper.dimValueGetter : function (item) {
  58729. return item.value;
  58730. };
  58731. fromData.initData(
  58732. zrUtil.map(optData, function (item) { return item[0]; }),
  58733. null, dimValueGetter
  58734. );
  58735. toData.initData(
  58736. zrUtil.map(optData, function (item) { return item[1]; }),
  58737. null, dimValueGetter
  58738. );
  58739. lineData.initData(
  58740. zrUtil.map(optData, function (item) { return item[2]; })
  58741. );
  58742. lineData.hasItemOption = true;
  58743. return {
  58744. from: fromData,
  58745. to: toData,
  58746. line: lineData
  58747. };
  58748. }
  58749. /***/ },
  58750. /* 400 */
  58751. /***/ function(module, exports, __webpack_require__) {
  58752. __webpack_require__(401);
  58753. __webpack_require__(402);
  58754. __webpack_require__(1).registerPreprocessor(function (opt) {
  58755. // Make sure markArea component is enabled
  58756. opt.markArea = opt.markArea || {};
  58757. });
  58758. /***/ },
  58759. /* 401 */
  58760. /***/ function(module, exports, __webpack_require__) {
  58761. module.exports = __webpack_require__(393).extend({
  58762. type: 'markArea',
  58763. defaultOption: {
  58764. zlevel: 0,
  58765. // PENDING
  58766. z: 1,
  58767. tooltip: {
  58768. trigger: 'item'
  58769. },
  58770. // markArea should fixed on the coordinate system
  58771. animation: false,
  58772. label: {
  58773. normal: {
  58774. show: true,
  58775. position: 'top'
  58776. },
  58777. emphasis: {
  58778. show: true,
  58779. position: 'top'
  58780. }
  58781. },
  58782. itemStyle: {
  58783. normal: {
  58784. // color and borderColor default to use color from series
  58785. // color: 'auto'
  58786. // borderColor: 'auto'
  58787. borderWidth: 0
  58788. }
  58789. }
  58790. }
  58791. });
  58792. /***/ },
  58793. /* 402 */
  58794. /***/ function(module, exports, __webpack_require__) {
  58795. // TODO Better on polar
  58796. var zrUtil = __webpack_require__(4);
  58797. var List = __webpack_require__(98);
  58798. var numberUtil = __webpack_require__(7);
  58799. var graphic = __webpack_require__(18);
  58800. var colorUtil = __webpack_require__(31);
  58801. var markerHelper = __webpack_require__(395);
  58802. var markAreaTransform = function (seriesModel, coordSys, maModel, item) {
  58803. var lt = markerHelper.dataTransform(seriesModel, item[0]);
  58804. var rb = markerHelper.dataTransform(seriesModel, item[1]);
  58805. var retrieve = zrUtil.retrieve;
  58806. // FIXME make sure lt is less than rb
  58807. var ltCoord = lt.coord;
  58808. var rbCoord = rb.coord;
  58809. ltCoord[0] = retrieve(ltCoord[0], -Infinity);
  58810. ltCoord[1] = retrieve(ltCoord[1], -Infinity);
  58811. rbCoord[0] = retrieve(rbCoord[0], Infinity);
  58812. rbCoord[1] = retrieve(rbCoord[1], Infinity);
  58813. // Merge option into one
  58814. var result = zrUtil.mergeAll([{}, lt, rb]);
  58815. result.coord = [
  58816. lt.coord, rb.coord
  58817. ];
  58818. result.x0 = lt.x;
  58819. result.y0 = lt.y;
  58820. result.x1 = rb.x;
  58821. result.y1 = rb.y;
  58822. return result;
  58823. };
  58824. function isInifinity(val) {
  58825. return !isNaN(val) && !isFinite(val);
  58826. }
  58827. // If a markArea has one dim
  58828. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  58829. var otherDimIndex = 1 - dimIndex;
  58830. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
  58831. }
  58832. function markAreaFilter(coordSys, item) {
  58833. var fromCoord = item.coord[0];
  58834. var toCoord = item.coord[1];
  58835. if (coordSys.type === 'cartesian2d') {
  58836. // In case
  58837. // {
  58838. // markArea: {
  58839. // data: [{ yAxis: 2 }]
  58840. // }
  58841. // }
  58842. if (
  58843. fromCoord && toCoord &&
  58844. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  58845. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  58846. ) {
  58847. return true;
  58848. }
  58849. }
  58850. return markerHelper.dataFilter(coordSys, {
  58851. coord: fromCoord,
  58852. x: item.x0,
  58853. y: item.y0
  58854. })
  58855. || markerHelper.dataFilter(coordSys, {
  58856. coord: toCoord,
  58857. x: item.x1,
  58858. y: item.y1
  58859. });
  58860. }
  58861. // dims can be ['x0', 'y0'], ['x1', 'y1'], ['x0', 'y1'], ['x1', 'y0']
  58862. function getSingleMarkerEndPoint(data, idx, dims, seriesModel, api) {
  58863. var coordSys = seriesModel.coordinateSystem;
  58864. var itemModel = data.getItemModel(idx);
  58865. var point;
  58866. var xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
  58867. var yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
  58868. if (!isNaN(xPx) && !isNaN(yPx)) {
  58869. point = [xPx, yPx];
  58870. }
  58871. else {
  58872. // Chart like bar may have there own marker positioning logic
  58873. if (seriesModel.getMarkerPosition) {
  58874. // Use the getMarkerPoisition
  58875. point = seriesModel.getMarkerPosition(
  58876. data.getValues(dims, idx)
  58877. );
  58878. }
  58879. else {
  58880. var x = data.get(dims[0], idx);
  58881. var y = data.get(dims[1], idx);
  58882. point = coordSys.dataToPoint([x, y], true);
  58883. }
  58884. if (coordSys.type === 'cartesian2d') {
  58885. var xAxis = coordSys.getAxis('x');
  58886. var yAxis = coordSys.getAxis('y');
  58887. var x = data.get(dims[0], idx);
  58888. var y = data.get(dims[1], idx);
  58889. if (isInifinity(x)) {
  58890. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
  58891. }
  58892. else if (isInifinity(y)) {
  58893. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
  58894. }
  58895. }
  58896. // Use x, y if has any
  58897. if (!isNaN(xPx)) {
  58898. point[0] = xPx;
  58899. }
  58900. if (!isNaN(yPx)) {
  58901. point[1] = yPx;
  58902. }
  58903. }
  58904. return point;
  58905. }
  58906. var dimPermutations = [['x0', 'y0'], ['x1', 'y0'], ['x1', 'y1'], ['x0', 'y1']];
  58907. __webpack_require__(396).extend({
  58908. type: 'markArea',
  58909. updateLayout: function (markAreaModel, ecModel, api) {
  58910. ecModel.eachSeries(function (seriesModel) {
  58911. var maModel = seriesModel.markAreaModel;
  58912. if (maModel) {
  58913. var areaData = maModel.getData();
  58914. areaData.each(function (idx) {
  58915. var points = zrUtil.map(dimPermutations, function (dim) {
  58916. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  58917. });
  58918. // Layout
  58919. areaData.setItemLayout(idx, points);
  58920. var el = areaData.getItemGraphicEl(idx);
  58921. el.setShape('points', points);
  58922. });
  58923. }
  58924. }, this);
  58925. },
  58926. renderSeries: function (seriesModel, maModel, ecModel, api) {
  58927. var coordSys = seriesModel.coordinateSystem;
  58928. var seriesName = seriesModel.name;
  58929. var seriesData = seriesModel.getData();
  58930. var areaGroupMap = this.markerGroupMap;
  58931. var polygonGroup = areaGroupMap.get(seriesName)
  58932. || areaGroupMap.set(seriesName, {group: new graphic.Group()});
  58933. this.group.add(polygonGroup.group);
  58934. polygonGroup.__keep = true;
  58935. var areaData = createList(coordSys, seriesModel, maModel);
  58936. // Line data for tooltip and formatter
  58937. maModel.setData(areaData);
  58938. // Update visual and layout of line
  58939. areaData.each(function (idx) {
  58940. // Layout
  58941. areaData.setItemLayout(idx, zrUtil.map(dimPermutations, function (dim) {
  58942. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  58943. }));
  58944. // Visual
  58945. areaData.setItemVisual(idx, {
  58946. color: seriesData.getVisual('color')
  58947. });
  58948. });
  58949. areaData.diff(polygonGroup.__data)
  58950. .add(function (idx) {
  58951. var polygon = new graphic.Polygon({
  58952. shape: {
  58953. points: areaData.getItemLayout(idx)
  58954. }
  58955. });
  58956. areaData.setItemGraphicEl(idx, polygon);
  58957. polygonGroup.group.add(polygon);
  58958. })
  58959. .update(function (newIdx, oldIdx) {
  58960. var polygon = polygonGroup.__data.getItemGraphicEl(oldIdx);
  58961. graphic.updateProps(polygon, {
  58962. shape: {
  58963. points: areaData.getItemLayout(newIdx)
  58964. }
  58965. }, maModel, newIdx);
  58966. polygonGroup.group.add(polygon);
  58967. areaData.setItemGraphicEl(newIdx, polygon);
  58968. })
  58969. .remove(function (idx) {
  58970. var polygon = polygonGroup.__data.getItemGraphicEl(idx);
  58971. polygonGroup.group.remove(polygon);
  58972. })
  58973. .execute();
  58974. areaData.eachItemGraphicEl(function (polygon, idx) {
  58975. var itemModel = areaData.getItemModel(idx);
  58976. var labelModel = itemModel.getModel('label.normal');
  58977. var labelHoverModel = itemModel.getModel('label.emphasis');
  58978. var color = areaData.getItemVisual(idx, 'color');
  58979. polygon.useStyle(
  58980. zrUtil.defaults(
  58981. itemModel.getModel('itemStyle.normal').getItemStyle(),
  58982. {
  58983. fill: colorUtil.modifyAlpha(color, 0.4),
  58984. stroke: color
  58985. }
  58986. )
  58987. );
  58988. polygon.hoverStyle = itemModel.getModel('itemStyle.normal').getItemStyle();
  58989. var defaultValue = areaData.getName(idx) || '';
  58990. var textColor = color || polygon.style.fill;
  58991. if (labelModel.getShallow('show')) {
  58992. graphic.setText(polygon.style, labelModel, textColor);
  58993. polygon.style.text = zrUtil.retrieve(
  58994. maModel.getFormattedLabel(idx, 'normal'),
  58995. defaultValue
  58996. );
  58997. }
  58998. else {
  58999. polygon.style.text = '';
  59000. }
  59001. if (labelHoverModel.getShallow('show')) {
  59002. graphic.setText(polygon.hoverStyle, labelHoverModel, textColor);
  59003. polygon.hoverStyle.text = zrUtil.retrieve(
  59004. maModel.getFormattedLabel(idx, 'emphasis'),
  59005. defaultValue
  59006. );
  59007. }
  59008. else {
  59009. polygon.hoverStyle.text = '';
  59010. }
  59011. graphic.setHoverStyle(polygon, {});
  59012. polygon.dataModel = maModel;
  59013. });
  59014. polygonGroup.__data = areaData;
  59015. polygonGroup.group.silent = maModel.get('silent') || seriesModel.get('silent');
  59016. }
  59017. });
  59018. /**
  59019. * @inner
  59020. * @param {module:echarts/coord/*} coordSys
  59021. * @param {module:echarts/model/Series} seriesModel
  59022. * @param {module:echarts/model/Model} mpModel
  59023. */
  59024. function createList(coordSys, seriesModel, maModel) {
  59025. var coordDimsInfos;
  59026. var areaData;
  59027. var dims = ['x0', 'y0', 'x1', 'y1'];
  59028. if (coordSys) {
  59029. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  59030. var info = seriesModel.getData().getDimensionInfo(
  59031. seriesModel.coordDimToDataDim(coordDim)[0]
  59032. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  59033. info.name = coordDim;
  59034. return info;
  59035. });
  59036. areaData = new List(zrUtil.map(dims, function (dim, idx) {
  59037. return {
  59038. name: dim,
  59039. type: coordDimsInfos[idx % 2].type
  59040. };
  59041. }), maModel);
  59042. }
  59043. else {
  59044. coordDimsInfos =[{
  59045. name: 'value',
  59046. type: 'float'
  59047. }];
  59048. areaData = new List(coordDimsInfos, maModel);
  59049. }
  59050. var optData = zrUtil.map(maModel.get('data'), zrUtil.curry(
  59051. markAreaTransform, seriesModel, coordSys, maModel
  59052. ));
  59053. if (coordSys) {
  59054. optData = zrUtil.filter(
  59055. optData, zrUtil.curry(markAreaFilter, coordSys)
  59056. );
  59057. }
  59058. var dimValueGetter = coordSys ? function (item, dimName, dataIndex, dimIndex) {
  59059. return item.coord[Math.floor(dimIndex / 2)][dimIndex % 2];
  59060. } : function (item) {
  59061. return item.value;
  59062. };
  59063. areaData.initData(optData, null, dimValueGetter);
  59064. areaData.hasItemOption = true;
  59065. return areaData;
  59066. }
  59067. /***/ },
  59068. /* 403 */
  59069. /***/ function(module, exports, __webpack_require__) {
  59070. /**
  59071. * DataZoom component entry
  59072. */
  59073. var echarts = __webpack_require__(1);
  59074. echarts.registerPreprocessor(__webpack_require__(404));
  59075. __webpack_require__(405);
  59076. __webpack_require__(406);
  59077. __webpack_require__(407);
  59078. __webpack_require__(409);
  59079. /***/ },
  59080. /* 404 */
  59081. /***/ function(module, exports, __webpack_require__) {
  59082. /**
  59083. * @file Timeline preprocessor
  59084. */
  59085. var zrUtil = __webpack_require__(4);
  59086. module.exports = function (option) {
  59087. var timelineOpt = option && option.timeline;
  59088. if (!zrUtil.isArray(timelineOpt)) {
  59089. timelineOpt = timelineOpt ? [timelineOpt] : [];
  59090. }
  59091. zrUtil.each(timelineOpt, function (opt) {
  59092. if (!opt) {
  59093. return;
  59094. }
  59095. compatibleEC2(opt);
  59096. });
  59097. };
  59098. function compatibleEC2(opt) {
  59099. var type = opt.type;
  59100. var ec2Types = {'number': 'value', 'time': 'time'};
  59101. // Compatible with ec2
  59102. if (ec2Types[type]) {
  59103. opt.axisType = ec2Types[type];
  59104. delete opt.type;
  59105. }
  59106. transferItem(opt);
  59107. if (has(opt, 'controlPosition')) {
  59108. var controlStyle = opt.controlStyle || (opt.controlStyle = {});
  59109. if (!has(controlStyle, 'position')) {
  59110. controlStyle.position = opt.controlPosition;
  59111. }
  59112. if (controlStyle.position === 'none' && !has(controlStyle, 'show')) {
  59113. controlStyle.show = false;
  59114. delete controlStyle.position;
  59115. }
  59116. delete opt.controlPosition;
  59117. }
  59118. zrUtil.each(opt.data || [], function (dataItem) {
  59119. if (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) {
  59120. if (!has(dataItem, 'value') && has(dataItem, 'name')) {
  59121. // In ec2, using name as value.
  59122. dataItem.value = dataItem.name;
  59123. }
  59124. transferItem(dataItem);
  59125. }
  59126. });
  59127. }
  59128. function transferItem(opt) {
  59129. var itemStyle = opt.itemStyle || (opt.itemStyle = {});
  59130. var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {});
  59131. // Transfer label out
  59132. var label = opt.label || (opt.label || {});
  59133. var labelNormal = label.normal || (label.normal = {});
  59134. var excludeLabelAttr = {normal: 1, emphasis: 1};
  59135. zrUtil.each(label, function (value, name) {
  59136. if (!excludeLabelAttr[name] && !has(labelNormal, name)) {
  59137. labelNormal[name] = value;
  59138. }
  59139. });
  59140. if (itemStyleEmphasis.label && !has(label, 'emphasis')) {
  59141. label.emphasis = itemStyleEmphasis.label;
  59142. delete itemStyleEmphasis.label;
  59143. }
  59144. }
  59145. function has(obj, attr) {
  59146. return obj.hasOwnProperty(attr);
  59147. }
  59148. /***/ },
  59149. /* 405 */
  59150. /***/ function(module, exports, __webpack_require__) {
  59151. __webpack_require__(69).registerSubTypeDefaulter('timeline', function () {
  59152. // Only slider now.
  59153. return 'slider';
  59154. });
  59155. /***/ },
  59156. /* 406 */
  59157. /***/ function(module, exports, __webpack_require__) {
  59158. /**
  59159. * @file Timeilne action
  59160. */
  59161. var echarts = __webpack_require__(1);
  59162. var zrUtil = __webpack_require__(4);
  59163. echarts.registerAction(
  59164. {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'},
  59165. function (payload, ecModel) {
  59166. var timelineModel = ecModel.getComponent('timeline');
  59167. if (timelineModel && payload.currentIndex != null) {
  59168. timelineModel.setCurrentIndex(payload.currentIndex);
  59169. if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) {
  59170. timelineModel.setPlayState(false);
  59171. }
  59172. }
  59173. // Set normalized currentIndex to payload.
  59174. ecModel.resetOption('timeline');
  59175. return zrUtil.defaults({
  59176. currentIndex: timelineModel.option.currentIndex
  59177. }, payload);
  59178. }
  59179. );
  59180. echarts.registerAction(
  59181. {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'},
  59182. function (payload, ecModel) {
  59183. var timelineModel = ecModel.getComponent('timeline');
  59184. if (timelineModel && payload.playState != null) {
  59185. timelineModel.setPlayState(payload.playState);
  59186. }
  59187. }
  59188. );
  59189. /***/ },
  59190. /* 407 */
  59191. /***/ function(module, exports, __webpack_require__) {
  59192. /**
  59193. * @file Silder timeline model
  59194. */
  59195. var TimelineModel = __webpack_require__(408);
  59196. var zrUtil = __webpack_require__(4);
  59197. var modelUtil = __webpack_require__(5);
  59198. var SliderTimelineModel = TimelineModel.extend({
  59199. type: 'timeline.slider',
  59200. /**
  59201. * @protected
  59202. */
  59203. defaultOption: {
  59204. backgroundColor: 'rgba(0,0,0,0)', // 时间轴背景颜色
  59205. borderColor: '#ccc', // 时间轴边框颜色
  59206. borderWidth: 0, // 时间轴边框线宽,单位px,默认为0(无边框)
  59207. orient: 'horizontal', // 'vertical'
  59208. inverse: false,
  59209. tooltip: { // boolean or Object
  59210. trigger: 'item' // data item may also have tootip attr.
  59211. },
  59212. symbol: 'emptyCircle',
  59213. symbolSize: 10,
  59214. lineStyle: {
  59215. show: true,
  59216. width: 2,
  59217. color: '#304654'
  59218. },
  59219. label: { // 文本标签
  59220. position: 'auto', // auto left right top bottom
  59221. // When using number, label position is not
  59222. // restricted by viewRect.
  59223. // positive: right/bottom, negative: left/top
  59224. normal: {
  59225. show: true,
  59226. interval: 'auto',
  59227. rotate: 0,
  59228. // formatter: null,
  59229. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  59230. color: '#304654'
  59231. }
  59232. },
  59233. emphasis: {
  59234. show: true,
  59235. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  59236. color: '#c23531'
  59237. }
  59238. }
  59239. },
  59240. itemStyle: {
  59241. normal: {
  59242. color: '#304654',
  59243. borderWidth: 1
  59244. },
  59245. emphasis: {
  59246. color: '#c23531'
  59247. }
  59248. },
  59249. checkpointStyle: {
  59250. symbol: 'circle',
  59251. symbolSize: 13,
  59252. color: '#c23531',
  59253. borderWidth: 5,
  59254. borderColor: 'rgba(194,53,49, 0.5)',
  59255. animation: true,
  59256. animationDuration: 300,
  59257. animationEasing: 'quinticInOut'
  59258. },
  59259. controlStyle: {
  59260. show: true,
  59261. showPlayBtn: true,
  59262. showPrevBtn: true,
  59263. showNextBtn: true,
  59264. itemSize: 22,
  59265. itemGap: 12,
  59266. position: 'left', // 'left' 'right' 'top' 'bottom'
  59267. 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
  59268. 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
  59269. 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
  59270. 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
  59271. normal: {
  59272. color: '#304654',
  59273. borderColor: '#304654',
  59274. borderWidth: 1
  59275. },
  59276. emphasis: {
  59277. color: '#c23531',
  59278. borderColor: '#c23531',
  59279. borderWidth: 2
  59280. }
  59281. },
  59282. data: []
  59283. }
  59284. });
  59285. zrUtil.mixin(SliderTimelineModel, modelUtil.dataFormatMixin);
  59286. module.exports = SliderTimelineModel;
  59287. /***/ },
  59288. /* 408 */
  59289. /***/ function(module, exports, __webpack_require__) {
  59290. /**
  59291. * @file Timeline model
  59292. */
  59293. var ComponentModel = __webpack_require__(69);
  59294. var List = __webpack_require__(98);
  59295. var zrUtil = __webpack_require__(4);
  59296. var modelUtil = __webpack_require__(5);
  59297. var TimelineModel = ComponentModel.extend({
  59298. type: 'timeline',
  59299. layoutMode: 'box',
  59300. /**
  59301. * @protected
  59302. */
  59303. defaultOption: {
  59304. zlevel: 0, // 一级层叠
  59305. z: 4, // 二级层叠
  59306. show: true,
  59307. axisType: 'time', // 模式是时间类型,支持 value, category
  59308. realtime: true,
  59309. left: '20%',
  59310. top: null,
  59311. right: '20%',
  59312. bottom: 0,
  59313. width: null,
  59314. height: 40,
  59315. padding: 5,
  59316. controlPosition: 'left', // 'left' 'right' 'top' 'bottom' 'none'
  59317. autoPlay: false,
  59318. rewind: false, // 反向播放
  59319. loop: true,
  59320. playInterval: 2000, // 播放时间间隔,单位ms
  59321. currentIndex: 0,
  59322. itemStyle: {
  59323. normal: {},
  59324. emphasis: {}
  59325. },
  59326. label: {
  59327. normal: {
  59328. textStyle: {
  59329. color: '#000'
  59330. }
  59331. },
  59332. emphasis: {}
  59333. },
  59334. data: []
  59335. },
  59336. /**
  59337. * @override
  59338. */
  59339. init: function (option, parentModel, ecModel) {
  59340. /**
  59341. * @private
  59342. * @type {module:echarts/data/List}
  59343. */
  59344. this._data;
  59345. /**
  59346. * @private
  59347. * @type {Array.<string>}
  59348. */
  59349. this._names;
  59350. this.mergeDefaultAndTheme(option, ecModel);
  59351. this._initData();
  59352. },
  59353. /**
  59354. * @override
  59355. */
  59356. mergeOption: function (option) {
  59357. TimelineModel.superApply(this, 'mergeOption', arguments);
  59358. this._initData();
  59359. },
  59360. /**
  59361. * @param {number} [currentIndex]
  59362. */
  59363. setCurrentIndex: function (currentIndex) {
  59364. if (currentIndex == null) {
  59365. currentIndex = this.option.currentIndex;
  59366. }
  59367. var count = this._data.count();
  59368. if (this.option.loop) {
  59369. currentIndex = (currentIndex % count + count) % count;
  59370. }
  59371. else {
  59372. currentIndex >= count && (currentIndex = count - 1);
  59373. currentIndex < 0 && (currentIndex = 0);
  59374. }
  59375. this.option.currentIndex = currentIndex;
  59376. },
  59377. /**
  59378. * @return {number} currentIndex
  59379. */
  59380. getCurrentIndex: function () {
  59381. return this.option.currentIndex;
  59382. },
  59383. /**
  59384. * @return {boolean}
  59385. */
  59386. isIndexMax: function () {
  59387. return this.getCurrentIndex() >= this._data.count() - 1;
  59388. },
  59389. /**
  59390. * @param {boolean} state true: play, false: stop
  59391. */
  59392. setPlayState: function (state) {
  59393. this.option.autoPlay = !!state;
  59394. },
  59395. /**
  59396. * @return {boolean} true: play, false: stop
  59397. */
  59398. getPlayState: function () {
  59399. return !!this.option.autoPlay;
  59400. },
  59401. /**
  59402. * @private
  59403. */
  59404. _initData: function () {
  59405. var thisOption = this.option;
  59406. var dataArr = thisOption.data || [];
  59407. var axisType = thisOption.axisType;
  59408. var names = this._names = [];
  59409. if (axisType === 'category') {
  59410. var idxArr = [];
  59411. zrUtil.each(dataArr, function (item, index) {
  59412. var value = modelUtil.getDataItemValue(item);
  59413. var newItem;
  59414. if (zrUtil.isObject(item)) {
  59415. newItem = zrUtil.clone(item);
  59416. newItem.value = index;
  59417. }
  59418. else {
  59419. newItem = index;
  59420. }
  59421. idxArr.push(newItem);
  59422. if (!zrUtil.isString(value) && (value == null || isNaN(value))) {
  59423. value = '';
  59424. }
  59425. names.push(value + '');
  59426. });
  59427. dataArr = idxArr;
  59428. }
  59429. var dimType = ({category: 'ordinal', time: 'time'})[axisType] || 'number';
  59430. var data = this._data = new List([{name: 'value', type: dimType}], this);
  59431. data.initData(dataArr, names);
  59432. },
  59433. getData: function () {
  59434. return this._data;
  59435. },
  59436. /**
  59437. * @public
  59438. * @return {Array.<string>} categoreis
  59439. */
  59440. getCategories: function () {
  59441. if (this.get('axisType') === 'category') {
  59442. return this._names.slice();
  59443. }
  59444. }
  59445. });
  59446. module.exports = TimelineModel;
  59447. /***/ },
  59448. /* 409 */
  59449. /***/ function(module, exports, __webpack_require__) {
  59450. /**
  59451. * @file Silder timeline view
  59452. */
  59453. var zrUtil = __webpack_require__(4);
  59454. var graphic = __webpack_require__(18);
  59455. var layout = __webpack_require__(71);
  59456. var TimelineView = __webpack_require__(410);
  59457. var TimelineAxis = __webpack_require__(411);
  59458. var symbolUtil = __webpack_require__(111);
  59459. var axisHelper = __webpack_require__(101);
  59460. var BoundingRect = __webpack_require__(9);
  59461. var matrix = __webpack_require__(11);
  59462. var numberUtil = __webpack_require__(7);
  59463. var formatUtil = __webpack_require__(6);
  59464. var encodeHTML = formatUtil.encodeHTML;
  59465. var bind = zrUtil.bind;
  59466. var each = zrUtil.each;
  59467. var PI = Math.PI;
  59468. module.exports = TimelineView.extend({
  59469. type: 'timeline.slider',
  59470. init: function (ecModel, api) {
  59471. this.api = api;
  59472. /**
  59473. * @private
  59474. * @type {module:echarts/component/timeline/TimelineAxis}
  59475. */
  59476. this._axis;
  59477. /**
  59478. * @private
  59479. * @type {module:zrender/core/BoundingRect}
  59480. */
  59481. this._viewRect;
  59482. /**
  59483. * @type {number}
  59484. */
  59485. this._timer;
  59486. /**
  59487. * @type {module:zrender/Element}
  59488. */
  59489. this._currentPointer;
  59490. /**
  59491. * @type {module:zrender/container/Group}
  59492. */
  59493. this._mainGroup;
  59494. /**
  59495. * @type {module:zrender/container/Group}
  59496. */
  59497. this._labelGroup;
  59498. },
  59499. /**
  59500. * @override
  59501. */
  59502. render: function (timelineModel, ecModel, api, payload) {
  59503. this.model = timelineModel;
  59504. this.api = api;
  59505. this.ecModel = ecModel;
  59506. this.group.removeAll();
  59507. if (timelineModel.get('show', true)) {
  59508. var layoutInfo = this._layout(timelineModel, api);
  59509. var mainGroup = this._createGroup('mainGroup');
  59510. var labelGroup = this._createGroup('labelGroup');
  59511. /**
  59512. * @private
  59513. * @type {module:echarts/component/timeline/TimelineAxis}
  59514. */
  59515. var axis = this._axis = this._createAxis(layoutInfo, timelineModel);
  59516. timelineModel.formatTooltip = function (dataIndex) {
  59517. return encodeHTML(axis.scale.getLabel(dataIndex));
  59518. };
  59519. each(
  59520. ['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'],
  59521. function (name) {
  59522. this['_render' + name](layoutInfo, mainGroup, axis, timelineModel);
  59523. },
  59524. this
  59525. );
  59526. this._renderAxisLabel(layoutInfo, labelGroup, axis, timelineModel);
  59527. this._position(layoutInfo, timelineModel);
  59528. }
  59529. this._doPlayStop();
  59530. },
  59531. /**
  59532. * @override
  59533. */
  59534. remove: function () {
  59535. this._clearTimer();
  59536. this.group.removeAll();
  59537. },
  59538. /**
  59539. * @override
  59540. */
  59541. dispose: function () {
  59542. this._clearTimer();
  59543. },
  59544. _layout: function (timelineModel, api) {
  59545. var labelPosOpt = timelineModel.get('label.normal.position');
  59546. var orient = timelineModel.get('orient');
  59547. var viewRect = getViewRect(timelineModel, api);
  59548. // Auto label offset.
  59549. if (labelPosOpt == null || labelPosOpt === 'auto') {
  59550. labelPosOpt = orient === 'horizontal'
  59551. ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+')
  59552. : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-');
  59553. }
  59554. else if (isNaN(labelPosOpt)) {
  59555. labelPosOpt = ({
  59556. horizontal: {top: '-', bottom: '+'},
  59557. vertical: {left: '-', right: '+'}
  59558. })[orient][labelPosOpt];
  59559. }
  59560. var labelAlignMap = {
  59561. horizontal: 'center',
  59562. vertical: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'left' : 'right'
  59563. };
  59564. var labelBaselineMap = {
  59565. horizontal: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'top' : 'bottom',
  59566. vertical: 'middle'
  59567. };
  59568. var rotationMap = {
  59569. horizontal: 0,
  59570. vertical: PI / 2
  59571. };
  59572. // Position
  59573. var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width;
  59574. var controlModel = timelineModel.getModel('controlStyle');
  59575. var showControl = controlModel.get('show');
  59576. var controlSize = showControl ? controlModel.get('itemSize') : 0;
  59577. var controlGap = showControl ? controlModel.get('itemGap') : 0;
  59578. var sizePlusGap = controlSize + controlGap;
  59579. // Special label rotate.
  59580. var labelRotation = timelineModel.get('label.normal.rotate') || 0;
  59581. labelRotation = labelRotation * PI / 180; // To radian.
  59582. var playPosition;
  59583. var prevBtnPosition;
  59584. var nextBtnPosition;
  59585. var axisExtent;
  59586. var controlPosition = controlModel.get('position', true);
  59587. var showControl = controlModel.get('show', true);
  59588. var showPlayBtn = showControl && controlModel.get('showPlayBtn', true);
  59589. var showPrevBtn = showControl && controlModel.get('showPrevBtn', true);
  59590. var showNextBtn = showControl && controlModel.get('showNextBtn', true);
  59591. var xLeft = 0;
  59592. var xRight = mainLength;
  59593. // position[0] means left, position[1] means middle.
  59594. if (controlPosition === 'left' || controlPosition === 'bottom') {
  59595. showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap);
  59596. showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap);
  59597. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  59598. }
  59599. else { // 'top' 'right'
  59600. showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  59601. showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap);
  59602. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  59603. }
  59604. axisExtent = [xLeft, xRight];
  59605. if (timelineModel.get('inverse')) {
  59606. axisExtent.reverse();
  59607. }
  59608. return {
  59609. viewRect: viewRect,
  59610. mainLength: mainLength,
  59611. orient: orient,
  59612. rotation: rotationMap[orient],
  59613. labelRotation: labelRotation,
  59614. labelPosOpt: labelPosOpt,
  59615. labelAlign: timelineModel.get('label.normal.textStyle.align') || labelAlignMap[orient],
  59616. labelBaseline: timelineModel.get('label.normal.textStyle.baseline') || labelBaselineMap[orient],
  59617. // Based on mainGroup.
  59618. playPosition: playPosition,
  59619. prevBtnPosition: prevBtnPosition,
  59620. nextBtnPosition: nextBtnPosition,
  59621. axisExtent: axisExtent,
  59622. controlSize: controlSize,
  59623. controlGap: controlGap
  59624. };
  59625. },
  59626. _position: function (layoutInfo, timelineModel) {
  59627. // Position is be called finally, because bounding rect is needed for
  59628. // adapt content to fill viewRect (auto adapt offset).
  59629. // Timeline may be not all in the viewRect when 'offset' is specified
  59630. // as a number, because it is more appropriate that label aligns at
  59631. // 'offset' but not the other edge defined by viewRect.
  59632. var mainGroup = this._mainGroup;
  59633. var labelGroup = this._labelGroup;
  59634. var viewRect = layoutInfo.viewRect;
  59635. if (layoutInfo.orient === 'vertical') {
  59636. // transfrom to horizontal, inverse rotate by left-top point.
  59637. var m = matrix.create();
  59638. var rotateOriginX = viewRect.x;
  59639. var rotateOriginY = viewRect.y + viewRect.height;
  59640. matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]);
  59641. matrix.rotate(m, m, -PI / 2);
  59642. matrix.translate(m, m, [rotateOriginX, rotateOriginY]);
  59643. viewRect = viewRect.clone();
  59644. viewRect.applyTransform(m);
  59645. }
  59646. var viewBound = getBound(viewRect);
  59647. var mainBound = getBound(mainGroup.getBoundingRect());
  59648. var labelBound = getBound(labelGroup.getBoundingRect());
  59649. var mainPosition = mainGroup.position;
  59650. var labelsPosition = labelGroup.position;
  59651. labelsPosition[0] = mainPosition[0] = viewBound[0][0];
  59652. var labelPosOpt = layoutInfo.labelPosOpt;
  59653. if (isNaN(labelPosOpt)) { // '+' or '-'
  59654. var mainBoundIdx = labelPosOpt === '+' ? 0 : 1;
  59655. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  59656. toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx);
  59657. }
  59658. else {
  59659. var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1;
  59660. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  59661. labelsPosition[1] = mainPosition[1] + labelPosOpt;
  59662. }
  59663. mainGroup.attr('position', mainPosition);
  59664. labelGroup.attr('position', labelsPosition);
  59665. mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation;
  59666. setOrigin(mainGroup);
  59667. setOrigin(labelGroup);
  59668. function setOrigin(targetGroup) {
  59669. var pos = targetGroup.position;
  59670. targetGroup.origin = [
  59671. viewBound[0][0] - pos[0],
  59672. viewBound[1][0] - pos[1]
  59673. ];
  59674. }
  59675. function getBound(rect) {
  59676. // [[xmin, xmax], [ymin, ymax]]
  59677. return [
  59678. [rect.x, rect.x + rect.width],
  59679. [rect.y, rect.y + rect.height]
  59680. ];
  59681. }
  59682. function toBound(fromPos, from, to, dimIdx, boundIdx) {
  59683. fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx];
  59684. }
  59685. },
  59686. _createAxis: function (layoutInfo, timelineModel) {
  59687. var data = timelineModel.getData();
  59688. var axisType = timelineModel.get('axisType');
  59689. var scale = axisHelper.createScaleByModel(timelineModel, axisType);
  59690. var dataExtent = data.getDataExtent('value');
  59691. scale.setExtent(dataExtent[0], dataExtent[1]);
  59692. this._customizeScale(scale, data);
  59693. scale.niceTicks();
  59694. var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType);
  59695. axis.model = timelineModel;
  59696. return axis;
  59697. },
  59698. _customizeScale: function (scale, data) {
  59699. scale.getTicks = function () {
  59700. return data.mapArray(['value'], function (value) {
  59701. return value;
  59702. });
  59703. };
  59704. scale.getTicksLabels = function () {
  59705. return zrUtil.map(this.getTicks(), scale.getLabel, scale);
  59706. };
  59707. },
  59708. _createGroup: function (name) {
  59709. var newGroup = this['_' + name] = new graphic.Group();
  59710. this.group.add(newGroup);
  59711. return newGroup;
  59712. },
  59713. _renderAxisLine: function (layoutInfo, group, axis, timelineModel) {
  59714. var axisExtent = axis.getExtent();
  59715. if (!timelineModel.get('lineStyle.show')) {
  59716. return;
  59717. }
  59718. group.add(new graphic.Line({
  59719. shape: {
  59720. x1: axisExtent[0], y1: 0,
  59721. x2: axisExtent[1], y2: 0
  59722. },
  59723. style: zrUtil.extend(
  59724. {lineCap: 'round'},
  59725. timelineModel.getModel('lineStyle').getLineStyle()
  59726. ),
  59727. silent: true,
  59728. z2: 1
  59729. }));
  59730. },
  59731. /**
  59732. * @private
  59733. */
  59734. _renderAxisTick: function (layoutInfo, group, axis, timelineModel) {
  59735. var data = timelineModel.getData();
  59736. var ticks = axis.scale.getTicks();
  59737. each(ticks, function (value, dataIndex) {
  59738. var tickCoord = axis.dataToCoord(value);
  59739. var itemModel = data.getItemModel(dataIndex);
  59740. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  59741. var hoverStyleModel = itemModel.getModel('itemStyle.emphasis');
  59742. var symbolOpt = {
  59743. position: [tickCoord, 0],
  59744. onclick: bind(this._changeTimeline, this, dataIndex)
  59745. };
  59746. var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt);
  59747. graphic.setHoverStyle(el, hoverStyleModel.getItemStyle());
  59748. if (itemModel.get('tooltip')) {
  59749. el.dataIndex = dataIndex;
  59750. el.dataModel = timelineModel;
  59751. }
  59752. else {
  59753. el.dataIndex = el.dataModel = null;
  59754. }
  59755. }, this);
  59756. },
  59757. /**
  59758. * @private
  59759. */
  59760. _renderAxisLabel: function (layoutInfo, group, axis, timelineModel) {
  59761. var labelModel = timelineModel.getModel('label.normal');
  59762. if (!labelModel.get('show')) {
  59763. return;
  59764. }
  59765. var data = timelineModel.getData();
  59766. var ticks = axis.scale.getTicks();
  59767. var labels = axisHelper.getFormattedLabels(
  59768. axis, labelModel.get('formatter')
  59769. );
  59770. var labelInterval = axis.getLabelInterval();
  59771. each(ticks, function (tick, dataIndex) {
  59772. if (axis.isLabelIgnored(dataIndex, labelInterval)) {
  59773. return;
  59774. }
  59775. var itemModel = data.getItemModel(dataIndex);
  59776. var itemTextStyleModel = itemModel.getModel('label.normal.textStyle');
  59777. var hoverTextStyleModel = itemModel.getModel('label.emphasis.textStyle');
  59778. var tickCoord = axis.dataToCoord(tick);
  59779. var textEl = new graphic.Text({
  59780. style: {
  59781. text: labels[dataIndex],
  59782. textAlign: layoutInfo.labelAlign,
  59783. textVerticalAlign: layoutInfo.labelBaseline,
  59784. textFont: itemTextStyleModel.getFont(),
  59785. fill: itemTextStyleModel.getTextColor()
  59786. },
  59787. position: [tickCoord, 0],
  59788. rotation: layoutInfo.labelRotation - layoutInfo.rotation,
  59789. onclick: bind(this._changeTimeline, this, dataIndex),
  59790. silent: false
  59791. });
  59792. group.add(textEl);
  59793. graphic.setHoverStyle(textEl, hoverTextStyleModel.getItemStyle());
  59794. }, this);
  59795. },
  59796. /**
  59797. * @private
  59798. */
  59799. _renderControl: function (layoutInfo, group, axis, timelineModel) {
  59800. var controlSize = layoutInfo.controlSize;
  59801. var rotation = layoutInfo.rotation;
  59802. var itemStyle = timelineModel.getModel('controlStyle.normal').getItemStyle();
  59803. var hoverStyle = timelineModel.getModel('controlStyle.emphasis').getItemStyle();
  59804. var rect = [0, -controlSize / 2, controlSize, controlSize];
  59805. var playState = timelineModel.getPlayState();
  59806. var inverse = timelineModel.get('inverse', true);
  59807. makeBtn(
  59808. layoutInfo.nextBtnPosition,
  59809. 'controlStyle.nextIcon',
  59810. bind(this._changeTimeline, this, inverse ? '-' : '+')
  59811. );
  59812. makeBtn(
  59813. layoutInfo.prevBtnPosition,
  59814. 'controlStyle.prevIcon',
  59815. bind(this._changeTimeline, this, inverse ? '+' : '-')
  59816. );
  59817. makeBtn(
  59818. layoutInfo.playPosition,
  59819. 'controlStyle.' + (playState ? 'stopIcon' : 'playIcon'),
  59820. bind(this._handlePlayClick, this, !playState),
  59821. true
  59822. );
  59823. function makeBtn(position, iconPath, onclick, willRotate) {
  59824. if (!position) {
  59825. return;
  59826. }
  59827. var opt = {
  59828. position: position,
  59829. origin: [controlSize / 2, 0],
  59830. rotation: willRotate ? -rotation : 0,
  59831. rectHover: true,
  59832. style: itemStyle,
  59833. onclick: onclick
  59834. };
  59835. var btn = makeIcon(timelineModel, iconPath, rect, opt);
  59836. group.add(btn);
  59837. graphic.setHoverStyle(btn, hoverStyle);
  59838. }
  59839. },
  59840. _renderCurrentPointer: function (layoutInfo, group, axis, timelineModel) {
  59841. var data = timelineModel.getData();
  59842. var currentIndex = timelineModel.getCurrentIndex();
  59843. var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle');
  59844. var me = this;
  59845. var callback = {
  59846. onCreate: function (pointer) {
  59847. pointer.draggable = true;
  59848. pointer.drift = bind(me._handlePointerDrag, me);
  59849. pointer.ondragend = bind(me._handlePointerDragend, me);
  59850. pointerMoveTo(pointer, currentIndex, axis, timelineModel, true);
  59851. },
  59852. onUpdate: function (pointer) {
  59853. pointerMoveTo(pointer, currentIndex, axis, timelineModel);
  59854. }
  59855. };
  59856. // Reuse when exists, for animation and drag.
  59857. this._currentPointer = giveSymbol(
  59858. pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback
  59859. );
  59860. },
  59861. _handlePlayClick: function (nextState) {
  59862. this._clearTimer();
  59863. this.api.dispatchAction({
  59864. type: 'timelinePlayChange',
  59865. playState: nextState,
  59866. from: this.uid
  59867. });
  59868. },
  59869. _handlePointerDrag: function (dx, dy, e) {
  59870. this._clearTimer();
  59871. this._pointerChangeTimeline([e.offsetX, e.offsetY]);
  59872. },
  59873. _handlePointerDragend: function (e) {
  59874. this._pointerChangeTimeline([e.offsetX, e.offsetY], true);
  59875. },
  59876. _pointerChangeTimeline: function (mousePos, trigger) {
  59877. var toCoord = this._toAxisCoord(mousePos)[0];
  59878. var axis = this._axis;
  59879. var axisExtent = numberUtil.asc(axis.getExtent().slice());
  59880. toCoord > axisExtent[1] && (toCoord = axisExtent[1]);
  59881. toCoord < axisExtent[0] && (toCoord = axisExtent[0]);
  59882. this._currentPointer.position[0] = toCoord;
  59883. this._currentPointer.dirty();
  59884. var targetDataIndex = this._findNearestTick(toCoord);
  59885. var timelineModel = this.model;
  59886. if (trigger || (
  59887. targetDataIndex !== timelineModel.getCurrentIndex()
  59888. && timelineModel.get('realtime')
  59889. )) {
  59890. this._changeTimeline(targetDataIndex);
  59891. }
  59892. },
  59893. _doPlayStop: function () {
  59894. this._clearTimer();
  59895. if (this.model.getPlayState()) {
  59896. this._timer = setTimeout(
  59897. bind(handleFrame, this),
  59898. this.model.get('playInterval')
  59899. );
  59900. }
  59901. function handleFrame() {
  59902. // Do not cache
  59903. var timelineModel = this.model;
  59904. this._changeTimeline(
  59905. timelineModel.getCurrentIndex()
  59906. + (timelineModel.get('rewind', true) ? -1 : 1)
  59907. );
  59908. }
  59909. },
  59910. _toAxisCoord: function (vertex) {
  59911. var trans = this._mainGroup.getLocalTransform();
  59912. return graphic.applyTransform(vertex, trans, true);
  59913. },
  59914. _findNearestTick: function (axisCoord) {
  59915. var data = this.model.getData();
  59916. var dist = Infinity;
  59917. var targetDataIndex;
  59918. var axis = this._axis;
  59919. data.each(['value'], function (value, dataIndex) {
  59920. var coord = axis.dataToCoord(value);
  59921. var d = Math.abs(coord - axisCoord);
  59922. if (d < dist) {
  59923. dist = d;
  59924. targetDataIndex = dataIndex;
  59925. }
  59926. });
  59927. return targetDataIndex;
  59928. },
  59929. _clearTimer: function () {
  59930. if (this._timer) {
  59931. clearTimeout(this._timer);
  59932. this._timer = null;
  59933. }
  59934. },
  59935. _changeTimeline: function (nextIndex) {
  59936. var currentIndex = this.model.getCurrentIndex();
  59937. if (nextIndex === '+') {
  59938. nextIndex = currentIndex + 1;
  59939. }
  59940. else if (nextIndex === '-') {
  59941. nextIndex = currentIndex - 1;
  59942. }
  59943. this.api.dispatchAction({
  59944. type: 'timelineChange',
  59945. currentIndex: nextIndex,
  59946. from: this.uid
  59947. });
  59948. }
  59949. });
  59950. function getViewRect(model, api) {
  59951. return layout.getLayoutRect(
  59952. model.getBoxLayoutParams(),
  59953. {
  59954. width: api.getWidth(),
  59955. height: api.getHeight()
  59956. },
  59957. model.get('padding')
  59958. );
  59959. }
  59960. function makeIcon(timelineModel, objPath, rect, opts) {
  59961. var icon = graphic.makePath(
  59962. timelineModel.get(objPath).replace(/^path:\/\//, ''),
  59963. zrUtil.clone(opts || {}),
  59964. new BoundingRect(rect[0], rect[1], rect[2], rect[3]),
  59965. 'center'
  59966. );
  59967. return icon;
  59968. }
  59969. /**
  59970. * Create symbol or update symbol
  59971. * opt: basic position and event handlers
  59972. */
  59973. function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
  59974. var color = itemStyleModel.get('color');
  59975. if (!symbol) {
  59976. var symbolType = hostModel.get('symbol');
  59977. symbol = symbolUtil.createSymbol(symbolType, -1, -1, 2, 2, color);
  59978. symbol.setStyle('strokeNoScale', true);
  59979. group.add(symbol);
  59980. callback && callback.onCreate(symbol);
  59981. }
  59982. else {
  59983. symbol.setColor(color);
  59984. group.add(symbol); // Group may be new, also need to add.
  59985. callback && callback.onUpdate(symbol);
  59986. }
  59987. // Style
  59988. var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']);
  59989. symbol.setStyle(itemStyle);
  59990. // Transform and events.
  59991. opt = zrUtil.merge({
  59992. rectHover: true,
  59993. z2: 100
  59994. }, opt, true);
  59995. var symbolSize = hostModel.get('symbolSize');
  59996. symbolSize = symbolSize instanceof Array
  59997. ? symbolSize.slice()
  59998. : [+symbolSize, +symbolSize];
  59999. symbolSize[0] /= 2;
  60000. symbolSize[1] /= 2;
  60001. opt.scale = symbolSize;
  60002. var symbolOffset = hostModel.get('symbolOffset');
  60003. if (symbolOffset) {
  60004. var pos = opt.position = opt.position || [0, 0];
  60005. pos[0] += numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  60006. pos[1] += numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  60007. }
  60008. var symbolRotate = hostModel.get('symbolRotate');
  60009. opt.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  60010. symbol.attr(opt);
  60011. // FIXME
  60012. // (1) When symbol.style.strokeNoScale is true and updateTransform is not performed,
  60013. // getBoundingRect will return wrong result.
  60014. // (This is supposed to be resolved in zrender, but it is a little difficult to
  60015. // leverage performance and auto updateTransform)
  60016. // (2) All of ancesters of symbol do not scale, so we can just updateTransform symbol.
  60017. symbol.updateTransform();
  60018. return symbol;
  60019. }
  60020. function pointerMoveTo(pointer, dataIndex, axis, timelineModel, noAnimation) {
  60021. if (pointer.dragging) {
  60022. return;
  60023. }
  60024. var pointerModel = timelineModel.getModel('checkpointStyle');
  60025. var toCoord = axis.dataToCoord(timelineModel.getData().get(['value'], dataIndex));
  60026. if (noAnimation || !pointerModel.get('animation', true)) {
  60027. pointer.attr({position: [toCoord, 0]});
  60028. }
  60029. else {
  60030. pointer.stopAnimation(true);
  60031. pointer.animateTo(
  60032. {position: [toCoord, 0]},
  60033. pointerModel.get('animationDuration', true),
  60034. pointerModel.get('animationEasing', true)
  60035. );
  60036. }
  60037. }
  60038. /***/ },
  60039. /* 410 */
  60040. /***/ function(module, exports, __webpack_require__) {
  60041. /**
  60042. * @file Timeline view
  60043. */
  60044. // var zrUtil = require('zrender/lib/core/util');
  60045. // var graphic = require('../../util/graphic');
  60046. var ComponentView = __webpack_require__(79);
  60047. module.exports = ComponentView.extend({
  60048. type: 'timeline'
  60049. });
  60050. /***/ },
  60051. /* 411 */
  60052. /***/ function(module, exports, __webpack_require__) {
  60053. var zrUtil = __webpack_require__(4);
  60054. var Axis = __webpack_require__(100);
  60055. var axisHelper = __webpack_require__(101);
  60056. /**
  60057. * Extend axis 2d
  60058. * @constructor module:echarts/coord/cartesian/Axis2D
  60059. * @extends {module:echarts/coord/cartesian/Axis}
  60060. * @param {string} dim
  60061. * @param {*} scale
  60062. * @param {Array.<number>} coordExtent
  60063. * @param {string} axisType
  60064. * @param {string} position
  60065. */
  60066. var TimelineAxis = function (dim, scale, coordExtent, axisType) {
  60067. Axis.call(this, dim, scale, coordExtent);
  60068. /**
  60069. * Axis type
  60070. * - 'category'
  60071. * - 'value'
  60072. * - 'time'
  60073. * - 'log'
  60074. * @type {string}
  60075. */
  60076. this.type = axisType || 'value';
  60077. /**
  60078. * @private
  60079. * @type {number}
  60080. */
  60081. this._autoLabelInterval;
  60082. /**
  60083. * Axis model
  60084. * @param {module:echarts/component/TimelineModel}
  60085. */
  60086. this.model = null;
  60087. };
  60088. TimelineAxis.prototype = {
  60089. constructor: TimelineAxis,
  60090. /**
  60091. * @public
  60092. * @return {number}
  60093. */
  60094. getLabelInterval: function () {
  60095. var timelineModel = this.model;
  60096. var labelModel = timelineModel.getModel('label.normal');
  60097. var labelInterval = labelModel.get('interval');
  60098. if (labelInterval != null && labelInterval != 'auto') {
  60099. return labelInterval;
  60100. }
  60101. var labelInterval = this._autoLabelInterval;
  60102. if (!labelInterval) {
  60103. labelInterval = this._autoLabelInterval = axisHelper.getAxisLabelInterval(
  60104. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  60105. axisHelper.getFormattedLabels(this, labelModel.get('formatter')),
  60106. labelModel.getModel('textStyle').getFont(),
  60107. timelineModel.get('orient') === 'horizontal'
  60108. );
  60109. }
  60110. return labelInterval;
  60111. },
  60112. /**
  60113. * If label is ignored.
  60114. * Automatically used when axis is category and label can not be all shown
  60115. * @public
  60116. * @param {number} idx
  60117. * @return {boolean}
  60118. */
  60119. isLabelIgnored: function (idx) {
  60120. if (this.type === 'category') {
  60121. var labelInterval = this.getLabelInterval();
  60122. return ((typeof labelInterval === 'function')
  60123. && !labelInterval(idx, this.scale.getLabel(idx)))
  60124. || idx % (labelInterval + 1);
  60125. }
  60126. }
  60127. };
  60128. zrUtil.inherits(TimelineAxis, Axis);
  60129. module.exports = TimelineAxis;
  60130. /***/ },
  60131. /* 412 */
  60132. /***/ function(module, exports, __webpack_require__) {
  60133. __webpack_require__(413);
  60134. __webpack_require__(414);
  60135. __webpack_require__(415);
  60136. __webpack_require__(416);
  60137. __webpack_require__(417);
  60138. __webpack_require__(418);
  60139. __webpack_require__(423);
  60140. /***/ },
  60141. /* 413 */
  60142. /***/ function(module, exports, __webpack_require__) {
  60143. var featureManager = __webpack_require__(357);
  60144. var zrUtil = __webpack_require__(4);
  60145. var ToolboxModel = __webpack_require__(1).extendComponentModel({
  60146. type: 'toolbox',
  60147. layoutMode: {
  60148. type: 'box',
  60149. ignoreSize: true
  60150. },
  60151. mergeDefaultAndTheme: function (option) {
  60152. ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments);
  60153. zrUtil.each(this.option.feature, function (featureOpt, featureName) {
  60154. var Feature = featureManager.get(featureName);
  60155. Feature && zrUtil.merge(featureOpt, Feature.defaultOption);
  60156. });
  60157. },
  60158. defaultOption: {
  60159. show: true,
  60160. z: 6,
  60161. zlevel: 0,
  60162. orient: 'horizontal',
  60163. left: 'right',
  60164. top: 'top',
  60165. // right
  60166. // bottom
  60167. backgroundColor: 'transparent',
  60168. borderColor: '#ccc',
  60169. borderWidth: 0,
  60170. padding: 5,
  60171. itemSize: 15,
  60172. itemGap: 8,
  60173. showTitle: true,
  60174. iconStyle: {
  60175. normal: {
  60176. borderColor: '#666',
  60177. color: 'none'
  60178. },
  60179. emphasis: {
  60180. borderColor: '#3E98C5'
  60181. }
  60182. }
  60183. // textStyle: {},
  60184. // feature
  60185. }
  60186. });
  60187. module.exports = ToolboxModel;
  60188. /***/ },
  60189. /* 414 */
  60190. /***/ function(module, exports, __webpack_require__) {
  60191. /* WEBPACK VAR INJECTION */(function(process) {
  60192. var featureManager = __webpack_require__(357);
  60193. var zrUtil = __webpack_require__(4);
  60194. var graphic = __webpack_require__(18);
  60195. var Model = __webpack_require__(12);
  60196. var DataDiffer = __webpack_require__(99);
  60197. var listComponentHelper = __webpack_require__(325);
  60198. var textContain = __webpack_require__(8);
  60199. module.exports = __webpack_require__(1).extendComponentView({
  60200. type: 'toolbox',
  60201. render: function (toolboxModel, ecModel, api, payload) {
  60202. var group = this.group;
  60203. group.removeAll();
  60204. if (!toolboxModel.get('show')) {
  60205. return;
  60206. }
  60207. var itemSize = +toolboxModel.get('itemSize');
  60208. var featureOpts = toolboxModel.get('feature') || {};
  60209. var features = this._features || (this._features = {});
  60210. var featureNames = [];
  60211. zrUtil.each(featureOpts, function (opt, name) {
  60212. featureNames.push(name);
  60213. });
  60214. (new DataDiffer(this._featureNames || [], featureNames))
  60215. .add(process)
  60216. .update(process)
  60217. .remove(zrUtil.curry(process, null))
  60218. .execute();
  60219. // Keep for diff.
  60220. this._featureNames = featureNames;
  60221. function process(newIndex, oldIndex) {
  60222. var featureName = featureNames[newIndex];
  60223. var oldName = featureNames[oldIndex];
  60224. var featureOpt = featureOpts[featureName];
  60225. var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
  60226. var feature;
  60227. if (featureName && !oldName) { // Create
  60228. if (isUserFeatureName(featureName)) {
  60229. feature = {
  60230. model: featureModel,
  60231. onclick: featureModel.option.onclick,
  60232. featureName: featureName
  60233. };
  60234. }
  60235. else {
  60236. var Feature = featureManager.get(featureName);
  60237. if (!Feature) {
  60238. return;
  60239. }
  60240. feature = new Feature(featureModel, ecModel, api);
  60241. }
  60242. features[featureName] = feature;
  60243. }
  60244. else {
  60245. feature = features[oldName];
  60246. // If feature does not exsit.
  60247. if (!feature) {
  60248. return;
  60249. }
  60250. feature.model = featureModel;
  60251. feature.ecModel = ecModel;
  60252. feature.api = api;
  60253. }
  60254. if (!featureName && oldName) {
  60255. feature.dispose && feature.dispose(ecModel, api);
  60256. return;
  60257. }
  60258. if (!featureModel.get('show') || feature.unusable) {
  60259. feature.remove && feature.remove(ecModel, api);
  60260. return;
  60261. }
  60262. createIconPaths(featureModel, feature, featureName);
  60263. featureModel.setIconStatus = function (iconName, status) {
  60264. var option = this.option;
  60265. var iconPaths = this.iconPaths;
  60266. option.iconStatus = option.iconStatus || {};
  60267. option.iconStatus[iconName] = status;
  60268. // FIXME
  60269. iconPaths[iconName] && iconPaths[iconName].trigger(status);
  60270. };
  60271. if (feature.render) {
  60272. feature.render(featureModel, ecModel, api, payload);
  60273. }
  60274. }
  60275. function createIconPaths(featureModel, feature, featureName) {
  60276. var iconStyleModel = featureModel.getModel('iconStyle');
  60277. // If one feature has mutiple icon. they are orginaized as
  60278. // {
  60279. // icon: {
  60280. // foo: '',
  60281. // bar: ''
  60282. // },
  60283. // title: {
  60284. // foo: '',
  60285. // bar: ''
  60286. // }
  60287. // }
  60288. var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon');
  60289. var titles = featureModel.get('title') || {};
  60290. if (typeof icons === 'string') {
  60291. var icon = icons;
  60292. var title = titles;
  60293. icons = {};
  60294. titles = {};
  60295. icons[featureName] = icon;
  60296. titles[featureName] = title;
  60297. }
  60298. var iconPaths = featureModel.iconPaths = {};
  60299. zrUtil.each(icons, function (icon, iconName) {
  60300. var normalStyle = iconStyleModel.getModel('normal').getItemStyle();
  60301. var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  60302. var style = {
  60303. x: -itemSize / 2,
  60304. y: -itemSize / 2,
  60305. width: itemSize,
  60306. height: itemSize
  60307. };
  60308. var path = icon.indexOf('image://') === 0
  60309. ? (
  60310. style.image = icon.slice(8),
  60311. new graphic.Image({style: style})
  60312. )
  60313. : graphic.makePath(
  60314. icon.replace('path://', ''),
  60315. {
  60316. style: normalStyle,
  60317. hoverStyle: hoverStyle,
  60318. rectHover: true
  60319. },
  60320. style,
  60321. 'center'
  60322. );
  60323. graphic.setHoverStyle(path);
  60324. if (toolboxModel.get('showTitle')) {
  60325. path.__title = titles[iconName];
  60326. path.on('mouseover', function () {
  60327. // Should not reuse above hoverStyle, which might be modified.
  60328. var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  60329. path.setStyle({
  60330. text: titles[iconName],
  60331. textPosition: hoverStyle.textPosition || 'bottom',
  60332. textFill: hoverStyle.fill || hoverStyle.stroke || '#000',
  60333. textAlign: hoverStyle.textAlign || 'center'
  60334. });
  60335. })
  60336. .on('mouseout', function () {
  60337. path.setStyle({
  60338. textFill: null
  60339. });
  60340. });
  60341. }
  60342. path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal');
  60343. group.add(path);
  60344. path.on('click', zrUtil.bind(
  60345. feature.onclick, feature, ecModel, api, iconName
  60346. ));
  60347. iconPaths[iconName] = path;
  60348. });
  60349. }
  60350. listComponentHelper.layout(group, toolboxModel, api);
  60351. // Render background after group is layout
  60352. // FIXME
  60353. listComponentHelper.addBackground(group, toolboxModel);
  60354. // Adjust icon title positions to avoid them out of screen
  60355. group.eachChild(function (icon) {
  60356. var titleText = icon.__title;
  60357. var hoverStyle = icon.hoverStyle;
  60358. // May be background element
  60359. if (hoverStyle && titleText) {
  60360. var rect = textContain.getBoundingRect(
  60361. titleText, hoverStyle.font
  60362. );
  60363. var offsetX = icon.position[0] + group.position[0];
  60364. var offsetY = icon.position[1] + group.position[1] + itemSize;
  60365. var needPutOnTop = false;
  60366. if (offsetY + rect.height > api.getHeight()) {
  60367. hoverStyle.textPosition = 'top';
  60368. needPutOnTop = true;
  60369. }
  60370. var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8);
  60371. if (offsetX + rect.width / 2 > api.getWidth()) {
  60372. hoverStyle.textPosition = ['100%', topOffset];
  60373. hoverStyle.textAlign = 'right';
  60374. }
  60375. else if (offsetX - rect.width / 2 < 0) {
  60376. hoverStyle.textPosition = [0, topOffset];
  60377. hoverStyle.textAlign = 'left';
  60378. }
  60379. }
  60380. });
  60381. },
  60382. updateView: function (toolboxModel, ecModel, api, payload) {
  60383. zrUtil.each(this._features, function (feature) {
  60384. feature.updateView && feature.updateView(feature.model, ecModel, api, payload);
  60385. });
  60386. },
  60387. updateLayout: function (toolboxModel, ecModel, api, payload) {
  60388. zrUtil.each(this._features, function (feature) {
  60389. feature.updateLayout && feature.updateLayout(feature.model, ecModel, api, payload);
  60390. });
  60391. },
  60392. remove: function (ecModel, api) {
  60393. zrUtil.each(this._features, function (feature) {
  60394. feature.remove && feature.remove(ecModel, api);
  60395. });
  60396. this.group.removeAll();
  60397. },
  60398. dispose: function (ecModel, api) {
  60399. zrUtil.each(this._features, function (feature) {
  60400. feature.dispose && feature.dispose(ecModel, api);
  60401. });
  60402. }
  60403. });
  60404. function isUserFeatureName(featureName) {
  60405. return featureName.indexOf('my') === 0;
  60406. }
  60407. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(310)))
  60408. /***/ },
  60409. /* 415 */
  60410. /***/ function(module, exports, __webpack_require__) {
  60411. var env = __webpack_require__(2);
  60412. function SaveAsImage (model) {
  60413. this.model = model;
  60414. }
  60415. SaveAsImage.defaultOption = {
  60416. show: true,
  60417. 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',
  60418. title: '保存为图片',
  60419. type: 'png',
  60420. // Default use option.backgroundColor
  60421. // backgroundColor: '#fff',
  60422. name: '',
  60423. excludeComponents: ['toolbox'],
  60424. pixelRatio: 1,
  60425. lang: ['右键另存为图片']
  60426. };
  60427. SaveAsImage.prototype.unusable = !env.canvasSupported;
  60428. var proto = SaveAsImage.prototype;
  60429. proto.onclick = function (ecModel, api) {
  60430. var model = this.model;
  60431. var title = model.get('name') || ecModel.get('title.0.text') || 'echarts';
  60432. var $a = document.createElement('a');
  60433. var type = model.get('type', true) || 'png';
  60434. $a.download = title + '.' + type;
  60435. $a.target = '_blank';
  60436. var url = api.getConnectedDataURL({
  60437. type: type,
  60438. backgroundColor: model.get('backgroundColor', true)
  60439. || ecModel.get('backgroundColor') || '#fff',
  60440. excludeComponents: model.get('excludeComponents'),
  60441. pixelRatio: model.get('pixelRatio')
  60442. });
  60443. $a.href = url;
  60444. // Chrome and Firefox
  60445. if (typeof MouseEvent === 'function' && !env.browser.ie && !env.browser.edge) {
  60446. var evt = new MouseEvent('click', {
  60447. view: window,
  60448. bubbles: true,
  60449. cancelable: false
  60450. });
  60451. $a.dispatchEvent(evt);
  60452. }
  60453. // IE
  60454. else {
  60455. var lang = model.get('lang');
  60456. var html = ''
  60457. + '<body style="margin:0;">'
  60458. + '<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />'
  60459. + '</body>';
  60460. var tab = window.open();
  60461. tab.document.write(html);
  60462. }
  60463. };
  60464. __webpack_require__(357).register(
  60465. 'saveAsImage', SaveAsImage
  60466. );
  60467. module.exports = SaveAsImage;
  60468. /***/ },
  60469. /* 416 */
  60470. /***/ function(module, exports, __webpack_require__) {
  60471. 'use strict';
  60472. var zrUtil = __webpack_require__(4);
  60473. function MagicType(model) {
  60474. this.model = model;
  60475. }
  60476. MagicType.defaultOption = {
  60477. show: true,
  60478. type: [],
  60479. // Icon group
  60480. icon: {
  60481. line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
  60482. bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
  60483. 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
  60484. tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
  60485. },
  60486. title: {
  60487. line: '切换为折线图',
  60488. bar: '切换为柱状图',
  60489. stack: '切换为堆叠',
  60490. tiled: '切换为平铺'
  60491. },
  60492. option: {},
  60493. seriesIndex: {}
  60494. };
  60495. var proto = MagicType.prototype;
  60496. proto.getIcons = function () {
  60497. var model = this.model;
  60498. var availableIcons = model.get('icon');
  60499. var icons = {};
  60500. zrUtil.each(model.get('type'), function (type) {
  60501. if (availableIcons[type]) {
  60502. icons[type] = availableIcons[type];
  60503. }
  60504. });
  60505. return icons;
  60506. };
  60507. var seriesOptGenreator = {
  60508. 'line': function (seriesType, seriesId, seriesModel, model) {
  60509. if (seriesType === 'bar') {
  60510. return zrUtil.merge({
  60511. id: seriesId,
  60512. type: 'line',
  60513. // Preserve data related option
  60514. data: seriesModel.get('data'),
  60515. stack: seriesModel.get('stack'),
  60516. markPoint: seriesModel.get('markPoint'),
  60517. markLine: seriesModel.get('markLine')
  60518. }, model.get('option.line') || {}, true);
  60519. }
  60520. },
  60521. 'bar': function (seriesType, seriesId, seriesModel, model) {
  60522. if (seriesType === 'line') {
  60523. return zrUtil.merge({
  60524. id: seriesId,
  60525. type: 'bar',
  60526. // Preserve data related option
  60527. data: seriesModel.get('data'),
  60528. stack: seriesModel.get('stack'),
  60529. markPoint: seriesModel.get('markPoint'),
  60530. markLine: seriesModel.get('markLine')
  60531. }, model.get('option.bar') || {}, true);
  60532. }
  60533. },
  60534. 'stack': function (seriesType, seriesId, seriesModel, model) {
  60535. if (seriesType === 'line' || seriesType === 'bar') {
  60536. return zrUtil.merge({
  60537. id: seriesId,
  60538. stack: '__ec_magicType_stack__'
  60539. }, model.get('option.stack') || {}, true);
  60540. }
  60541. },
  60542. 'tiled': function (seriesType, seriesId, seriesModel, model) {
  60543. if (seriesType === 'line' || seriesType === 'bar') {
  60544. return zrUtil.merge({
  60545. id: seriesId,
  60546. stack: ''
  60547. }, model.get('option.tiled') || {}, true);
  60548. }
  60549. }
  60550. };
  60551. var radioTypes = [
  60552. ['line', 'bar'],
  60553. ['stack', 'tiled']
  60554. ];
  60555. proto.onclick = function (ecModel, api, type) {
  60556. var model = this.model;
  60557. var seriesIndex = model.get('seriesIndex.' + type);
  60558. // Not supported magicType
  60559. if (!seriesOptGenreator[type]) {
  60560. return;
  60561. }
  60562. var newOption = {
  60563. series: []
  60564. };
  60565. var generateNewSeriesTypes = function (seriesModel) {
  60566. var seriesType = seriesModel.subType;
  60567. var seriesId = seriesModel.id;
  60568. var newSeriesOpt = seriesOptGenreator[type](
  60569. seriesType, seriesId, seriesModel, model
  60570. );
  60571. if (newSeriesOpt) {
  60572. // PENDING If merge original option?
  60573. zrUtil.defaults(newSeriesOpt, seriesModel.option);
  60574. newOption.series.push(newSeriesOpt);
  60575. }
  60576. // Modify boundaryGap
  60577. var coordSys = seriesModel.coordinateSystem;
  60578. if (coordSys && coordSys.type === 'cartesian2d' && (type === 'line' || type === 'bar')) {
  60579. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  60580. if (categoryAxis) {
  60581. var axisDim = categoryAxis.dim;
  60582. var axisType = axisDim + 'Axis';
  60583. var axisModel = ecModel.queryComponents({
  60584. mainType: axisType,
  60585. index: seriesModel.get(name + 'Index'),
  60586. id: seriesModel.get(name + 'Id')
  60587. })[0];
  60588. var axisIndex = axisModel.componentIndex;
  60589. newOption[axisType] = newOption[axisType] || [];
  60590. for (var i = 0; i <= axisIndex; i++) {
  60591. newOption[axisType][axisIndex] = newOption[axisType][axisIndex] || {};
  60592. }
  60593. newOption[axisType][axisIndex].boundaryGap = type === 'bar' ? true : false;
  60594. }
  60595. }
  60596. };
  60597. zrUtil.each(radioTypes, function (radio) {
  60598. if (zrUtil.indexOf(radio, type) >= 0) {
  60599. zrUtil.each(radio, function (item) {
  60600. model.setIconStatus(item, 'normal');
  60601. });
  60602. }
  60603. });
  60604. model.setIconStatus(type, 'emphasis');
  60605. ecModel.eachComponent(
  60606. {
  60607. mainType: 'series',
  60608. query: seriesIndex == null ? null : {
  60609. seriesIndex: seriesIndex
  60610. }
  60611. }, generateNewSeriesTypes
  60612. );
  60613. api.dispatchAction({
  60614. type: 'changeMagicType',
  60615. currentType: type,
  60616. newOption: newOption
  60617. });
  60618. };
  60619. var echarts = __webpack_require__(1);
  60620. echarts.registerAction({
  60621. type: 'changeMagicType',
  60622. event: 'magicTypeChanged',
  60623. update: 'prepareAndUpdate'
  60624. }, function (payload, ecModel) {
  60625. ecModel.mergeOption(payload.newOption);
  60626. });
  60627. __webpack_require__(357).register('magicType', MagicType);
  60628. module.exports = MagicType;
  60629. /***/ },
  60630. /* 417 */
  60631. /***/ function(module, exports, __webpack_require__) {
  60632. /**
  60633. * @module echarts/component/toolbox/feature/DataView
  60634. */
  60635. var zrUtil = __webpack_require__(4);
  60636. var eventTool = __webpack_require__(88);
  60637. var BLOCK_SPLITER = new Array(60).join('-');
  60638. var ITEM_SPLITER = '\t';
  60639. /**
  60640. * Group series into two types
  60641. * 1. on category axis, like line, bar
  60642. * 2. others, like scatter, pie
  60643. * @param {module:echarts/model/Global} ecModel
  60644. * @return {Object}
  60645. * @inner
  60646. */
  60647. function groupSeries(ecModel) {
  60648. var seriesGroupByCategoryAxis = {};
  60649. var otherSeries = [];
  60650. var meta = [];
  60651. ecModel.eachRawSeries(function (seriesModel) {
  60652. var coordSys = seriesModel.coordinateSystem;
  60653. if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
  60654. var baseAxis = coordSys.getBaseAxis();
  60655. if (baseAxis.type === 'category') {
  60656. var key = baseAxis.dim + '_' + baseAxis.index;
  60657. if (!seriesGroupByCategoryAxis[key]) {
  60658. seriesGroupByCategoryAxis[key] = {
  60659. categoryAxis: baseAxis,
  60660. valueAxis: coordSys.getOtherAxis(baseAxis),
  60661. series: []
  60662. };
  60663. meta.push({
  60664. axisDim: baseAxis.dim,
  60665. axisIndex: baseAxis.index
  60666. });
  60667. }
  60668. seriesGroupByCategoryAxis[key].series.push(seriesModel);
  60669. }
  60670. else {
  60671. otherSeries.push(seriesModel);
  60672. }
  60673. }
  60674. else {
  60675. otherSeries.push(seriesModel);
  60676. }
  60677. });
  60678. return {
  60679. seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
  60680. other: otherSeries,
  60681. meta: meta
  60682. };
  60683. }
  60684. /**
  60685. * Assemble content of series on cateogory axis
  60686. * @param {Array.<module:echarts/model/Series>} series
  60687. * @return {string}
  60688. * @inner
  60689. */
  60690. function assembleSeriesWithCategoryAxis(series) {
  60691. var tables = [];
  60692. zrUtil.each(series, function (group, key) {
  60693. var categoryAxis = group.categoryAxis;
  60694. var valueAxis = group.valueAxis;
  60695. var valueAxisDim = valueAxis.dim;
  60696. var headers = [' '].concat(zrUtil.map(group.series, function (series) {
  60697. return series.name;
  60698. }));
  60699. var columns = [categoryAxis.model.getCategories()];
  60700. zrUtil.each(group.series, function (series) {
  60701. columns.push(series.getRawData().mapArray(valueAxisDim, function (val) {
  60702. return val;
  60703. }));
  60704. });
  60705. // Assemble table content
  60706. var lines = [headers.join(ITEM_SPLITER)];
  60707. for (var i = 0; i < columns[0].length; i++) {
  60708. var items = [];
  60709. for (var j = 0; j < columns.length; j++) {
  60710. items.push(columns[j][i]);
  60711. }
  60712. lines.push(items.join(ITEM_SPLITER));
  60713. }
  60714. tables.push(lines.join('\n'));
  60715. });
  60716. return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
  60717. }
  60718. /**
  60719. * Assemble content of other series
  60720. * @param {Array.<module:echarts/model/Series>} series
  60721. * @return {string}
  60722. * @inner
  60723. */
  60724. function assembleOtherSeries(series) {
  60725. return zrUtil.map(series, function (series) {
  60726. var data = series.getRawData();
  60727. var lines = [series.name];
  60728. var vals = [];
  60729. data.each(data.dimensions, function () {
  60730. var argLen = arguments.length;
  60731. var dataIndex = arguments[argLen - 1];
  60732. var name = data.getName(dataIndex);
  60733. for (var i = 0; i < argLen - 1; i++) {
  60734. vals[i] = arguments[i];
  60735. }
  60736. lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
  60737. });
  60738. return lines.join('\n');
  60739. }).join('\n\n' + BLOCK_SPLITER + '\n\n');
  60740. }
  60741. /**
  60742. * @param {module:echarts/model/Global}
  60743. * @return {string}
  60744. * @inner
  60745. */
  60746. function getContentFromModel(ecModel) {
  60747. var result = groupSeries(ecModel);
  60748. return {
  60749. value: zrUtil.filter([
  60750. assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis),
  60751. assembleOtherSeries(result.other)
  60752. ], function (str) {
  60753. return str.replace(/[\n\t\s]/g, '');
  60754. }).join('\n\n' + BLOCK_SPLITER + '\n\n'),
  60755. meta: result.meta
  60756. };
  60757. }
  60758. function trim(str) {
  60759. return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  60760. }
  60761. /**
  60762. * If a block is tsv format
  60763. */
  60764. function isTSVFormat(block) {
  60765. // Simple method to find out if a block is tsv format
  60766. var firstLine = block.slice(0, block.indexOf('\n'));
  60767. if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
  60768. return true;
  60769. }
  60770. }
  60771. var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g');
  60772. /**
  60773. * @param {string} tsv
  60774. * @return {Array.<Object>}
  60775. */
  60776. function parseTSVContents(tsv) {
  60777. var tsvLines = tsv.split(/\n+/g);
  60778. var headers = trim(tsvLines.shift()).split(itemSplitRegex);
  60779. var categories = [];
  60780. var series = zrUtil.map(headers, function (header) {
  60781. return {
  60782. name: header,
  60783. data: []
  60784. };
  60785. });
  60786. for (var i = 0; i < tsvLines.length; i++) {
  60787. var items = trim(tsvLines[i]).split(itemSplitRegex);
  60788. categories.push(items.shift());
  60789. for (var j = 0; j < items.length; j++) {
  60790. series[j] && (series[j].data[i] = items[j]);
  60791. }
  60792. }
  60793. return {
  60794. series: series,
  60795. categories: categories
  60796. };
  60797. }
  60798. /**
  60799. * @param {string} str
  60800. * @return {Array.<Object>}
  60801. * @inner
  60802. */
  60803. function parseListContents(str) {
  60804. var lines = str.split(/\n+/g);
  60805. var seriesName = trim(lines.shift());
  60806. var data = [];
  60807. for (var i = 0; i < lines.length; i++) {
  60808. var items = trim(lines[i]).split(itemSplitRegex);
  60809. var name = '';
  60810. var value;
  60811. var hasName = false;
  60812. if (isNaN(items[0])) { // First item is name
  60813. hasName = true;
  60814. name = items[0];
  60815. items = items.slice(1);
  60816. data[i] = {
  60817. name: name,
  60818. value: []
  60819. };
  60820. value = data[i].value;
  60821. }
  60822. else {
  60823. value = data[i] = [];
  60824. }
  60825. for (var j = 0; j < items.length; j++) {
  60826. value.push(+items[j]);
  60827. }
  60828. if (value.length === 1) {
  60829. hasName ? (data[i].value = value[0]) : (data[i] = value[0]);
  60830. }
  60831. }
  60832. return {
  60833. name: seriesName,
  60834. data: data
  60835. };
  60836. }
  60837. /**
  60838. * @param {string} str
  60839. * @param {Array.<Object>} blockMetaList
  60840. * @return {Object}
  60841. * @inner
  60842. */
  60843. function parseContents(str, blockMetaList) {
  60844. var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g'));
  60845. var newOption = {
  60846. series: []
  60847. };
  60848. zrUtil.each(blocks, function (block, idx) {
  60849. if (isTSVFormat(block)) {
  60850. var result = parseTSVContents(block);
  60851. var blockMeta = blockMetaList[idx];
  60852. var axisKey = blockMeta.axisDim + 'Axis';
  60853. if (blockMeta) {
  60854. newOption[axisKey] = newOption[axisKey] || [];
  60855. newOption[axisKey][blockMeta.axisIndex] = {
  60856. data: result.categories
  60857. };
  60858. newOption.series = newOption.series.concat(result.series);
  60859. }
  60860. }
  60861. else {
  60862. var result = parseListContents(block);
  60863. newOption.series.push(result);
  60864. }
  60865. });
  60866. return newOption;
  60867. }
  60868. /**
  60869. * @alias {module:echarts/component/toolbox/feature/DataView}
  60870. * @constructor
  60871. * @param {module:echarts/model/Model} model
  60872. */
  60873. function DataView(model) {
  60874. this._dom = null;
  60875. this.model = model;
  60876. }
  60877. DataView.defaultOption = {
  60878. show: true,
  60879. readOnly: false,
  60880. optionToContent: null,
  60881. contentToOption: null,
  60882. 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',
  60883. title: '数据视图',
  60884. lang: ['数据视图', '关闭', '刷新'],
  60885. backgroundColor: '#fff',
  60886. textColor: '#000',
  60887. textareaColor: '#fff',
  60888. textareaBorderColor: '#333',
  60889. buttonColor: '#c23531',
  60890. buttonTextColor: '#fff'
  60891. };
  60892. DataView.prototype.onclick = function (ecModel, api) {
  60893. var container = api.getDom();
  60894. var model = this.model;
  60895. if (this._dom) {
  60896. container.removeChild(this._dom);
  60897. }
  60898. var root = document.createElement('div');
  60899. root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;';
  60900. root.style.backgroundColor = model.get('backgroundColor') || '#fff';
  60901. // Create elements
  60902. var header = document.createElement('h4');
  60903. var lang = model.get('lang') || [];
  60904. header.innerHTML = lang[0] || model.get('title');
  60905. header.style.cssText = 'margin: 10px 20px;';
  60906. header.style.color = model.get('textColor');
  60907. var viewMain = document.createElement('div');
  60908. var textarea = document.createElement('textarea');
  60909. viewMain.style.cssText = 'display:block;width:100%;overflow:auto;';
  60910. var optionToContent = model.get('optionToContent');
  60911. var contentToOption = model.get('contentToOption');
  60912. var result = getContentFromModel(ecModel);
  60913. if (typeof optionToContent === 'function') {
  60914. var htmlOrDom = optionToContent(api.getOption());
  60915. if (typeof htmlOrDom === 'string') {
  60916. viewMain.innerHTML = htmlOrDom;
  60917. }
  60918. else if (zrUtil.isDom(htmlOrDom)) {
  60919. viewMain.appendChild(htmlOrDom);
  60920. }
  60921. }
  60922. else {
  60923. // Use default textarea
  60924. viewMain.appendChild(textarea);
  60925. textarea.readOnly = model.get('readOnly');
  60926. textarea.style.cssText = 'width:100%;height:100%;font-family:monospace;font-size:14px;line-height:1.6rem;';
  60927. textarea.style.color = model.get('textColor');
  60928. textarea.style.borderColor = model.get('textareaBorderColor');
  60929. textarea.style.backgroundColor = model.get('textareaColor');
  60930. textarea.value = result.value;
  60931. }
  60932. var blockMetaList = result.meta;
  60933. var buttonContainer = document.createElement('div');
  60934. buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;';
  60935. var buttonStyle = 'float:right;margin-right:20px;border:none;'
  60936. + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px';
  60937. var closeButton = document.createElement('div');
  60938. var refreshButton = document.createElement('div');
  60939. buttonStyle += ';background-color:' + model.get('buttonColor');
  60940. buttonStyle += ';color:' + model.get('buttonTextColor');
  60941. var self = this;
  60942. function close() {
  60943. container.removeChild(root);
  60944. self._dom = null;
  60945. }
  60946. eventTool.addEventListener(closeButton, 'click', close);
  60947. eventTool.addEventListener(refreshButton, 'click', function () {
  60948. var newOption;
  60949. try {
  60950. if (typeof contentToOption === 'function') {
  60951. newOption = contentToOption(viewMain, api.getOption());
  60952. }
  60953. else {
  60954. newOption = parseContents(textarea.value, blockMetaList);
  60955. }
  60956. }
  60957. catch (e) {
  60958. close();
  60959. throw new Error('Data view format error ' + e);
  60960. }
  60961. if (newOption) {
  60962. api.dispatchAction({
  60963. type: 'changeDataView',
  60964. newOption: newOption
  60965. });
  60966. }
  60967. close();
  60968. });
  60969. closeButton.innerHTML = lang[1];
  60970. refreshButton.innerHTML = lang[2];
  60971. refreshButton.style.cssText = buttonStyle;
  60972. closeButton.style.cssText = buttonStyle;
  60973. !model.get('readOnly') && buttonContainer.appendChild(refreshButton);
  60974. buttonContainer.appendChild(closeButton);
  60975. // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea
  60976. eventTool.addEventListener(textarea, 'keydown', function (e) {
  60977. if ((e.keyCode || e.which) === 9) {
  60978. // get caret position/selection
  60979. var val = this.value;
  60980. var start = this.selectionStart;
  60981. var end = this.selectionEnd;
  60982. // set textarea value to: text before caret + tab + text after caret
  60983. this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end);
  60984. // put caret at right position again
  60985. this.selectionStart = this.selectionEnd = start + 1;
  60986. // prevent the focus lose
  60987. eventTool.stop(e);
  60988. }
  60989. });
  60990. root.appendChild(header);
  60991. root.appendChild(viewMain);
  60992. root.appendChild(buttonContainer);
  60993. viewMain.style.height = (container.clientHeight - 80) + 'px';
  60994. container.appendChild(root);
  60995. this._dom = root;
  60996. };
  60997. DataView.prototype.remove = function (ecModel, api) {
  60998. this._dom && api.getDom().removeChild(this._dom);
  60999. };
  61000. DataView.prototype.dispose = function (ecModel, api) {
  61001. this.remove(ecModel, api);
  61002. };
  61003. /**
  61004. * @inner
  61005. */
  61006. function tryMergeDataOption(newData, originalData) {
  61007. return zrUtil.map(newData, function (newVal, idx) {
  61008. var original = originalData && originalData[idx];
  61009. if (zrUtil.isObject(original) && !zrUtil.isArray(original)) {
  61010. if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) {
  61011. newVal = newVal.value;
  61012. }
  61013. // Original data has option
  61014. return zrUtil.defaults({
  61015. value: newVal
  61016. }, original);
  61017. }
  61018. else {
  61019. return newVal;
  61020. }
  61021. });
  61022. }
  61023. __webpack_require__(357).register('dataView', DataView);
  61024. __webpack_require__(1).registerAction({
  61025. type: 'changeDataView',
  61026. event: 'dataViewChanged',
  61027. update: 'prepareAndUpdate'
  61028. }, function (payload, ecModel) {
  61029. var newSeriesOptList = [];
  61030. zrUtil.each(payload.newOption.series, function (seriesOpt) {
  61031. var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0];
  61032. if (!seriesModel) {
  61033. // New created series
  61034. // Geuss the series type
  61035. newSeriesOptList.push(zrUtil.extend({
  61036. // Default is scatter
  61037. type: 'scatter'
  61038. }, seriesOpt));
  61039. }
  61040. else {
  61041. var originalData = seriesModel.get('data');
  61042. newSeriesOptList.push({
  61043. name: seriesOpt.name,
  61044. data: tryMergeDataOption(seriesOpt.data, originalData)
  61045. });
  61046. }
  61047. });
  61048. ecModel.mergeOption(zrUtil.defaults({
  61049. series: newSeriesOptList
  61050. }, payload.newOption));
  61051. });
  61052. module.exports = DataView;
  61053. /***/ },
  61054. /* 418 */
  61055. /***/ function(module, exports, __webpack_require__) {
  61056. 'use strict';
  61057. var zrUtil = __webpack_require__(4);
  61058. var BrushController = __webpack_require__(245);
  61059. var BrushTargetManager = __webpack_require__(352);
  61060. var history = __webpack_require__(419);
  61061. var sliderMove = __webpack_require__(239);
  61062. var each = zrUtil.each;
  61063. // Use dataZoomSelect
  61064. __webpack_require__(420);
  61065. // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId
  61066. var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_';
  61067. function DataZoom(model, ecModel, api) {
  61068. /**
  61069. * @private
  61070. * @type {module:echarts/component/helper/BrushController}
  61071. */
  61072. (this._brushController = new BrushController(api.getZr()))
  61073. .on('brush', zrUtil.bind(this._onBrush, this))
  61074. .mount();
  61075. /**
  61076. * @private
  61077. * @type {boolean}
  61078. */
  61079. this._isZoomActive;
  61080. }
  61081. DataZoom.defaultOption = {
  61082. show: true,
  61083. // Icon group
  61084. icon: {
  61085. zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
  61086. back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
  61087. },
  61088. title: {
  61089. zoom: '区域缩放',
  61090. back: '区域缩放还原'
  61091. }
  61092. };
  61093. var proto = DataZoom.prototype;
  61094. proto.render = function (featureModel, ecModel, api, payload) {
  61095. this.model = featureModel;
  61096. this.ecModel = ecModel;
  61097. this.api = api;
  61098. updateZoomBtnStatus(featureModel, ecModel, this, payload, api);
  61099. updateBackBtnStatus(featureModel, ecModel);
  61100. };
  61101. proto.onclick = function (ecModel, api, type) {
  61102. handlers[type].call(this);
  61103. };
  61104. proto.remove = function (ecModel, api) {
  61105. this._brushController.unmount();
  61106. };
  61107. proto.dispose = function (ecModel, api) {
  61108. this._brushController.dispose();
  61109. };
  61110. /**
  61111. * @private
  61112. */
  61113. var handlers = {
  61114. zoom: function () {
  61115. var nextActive = !this._isZoomActive;
  61116. this.api.dispatchAction({
  61117. type: 'takeGlobalCursor',
  61118. key: 'dataZoomSelect',
  61119. dataZoomSelectActive: nextActive
  61120. });
  61121. },
  61122. back: function () {
  61123. this._dispatchZoomAction(history.pop(this.ecModel));
  61124. }
  61125. };
  61126. /**
  61127. * @private
  61128. */
  61129. proto._onBrush = function (areas, opt) {
  61130. if (!opt.isEnd || !areas.length) {
  61131. return;
  61132. }
  61133. var snapshot = {};
  61134. var ecModel = this.ecModel;
  61135. this._brushController.updateCovers([]); // remove cover
  61136. var brushTargetManager = new BrushTargetManager(
  61137. retrieveAxisSetting(this.model.option), ecModel, {include: ['grid']}
  61138. );
  61139. brushTargetManager.matchOutputRanges(areas, ecModel, function (area, coordRange, coordSys) {
  61140. if (coordSys.type !== 'cartesian2d') {
  61141. return;
  61142. }
  61143. var brushType = area.brushType;
  61144. if (brushType === 'rect') {
  61145. setBatch('x', coordSys, coordRange[0]);
  61146. setBatch('y', coordSys, coordRange[1]);
  61147. }
  61148. else {
  61149. setBatch(({lineX: 'x', lineY: 'y'})[brushType], coordSys, coordRange);
  61150. }
  61151. });
  61152. history.push(ecModel, snapshot);
  61153. this._dispatchZoomAction(snapshot);
  61154. function setBatch(dimName, coordSys, minMax) {
  61155. var axis = coordSys.getAxis(dimName);
  61156. var axisModel = axis.model;
  61157. var dataZoomModel = findDataZoom(dimName, axisModel, ecModel);
  61158. // Restrict range.
  61159. var minMaxSpan = dataZoomModel.findRepresentativeAxisProxy(axisModel).getMinMaxSpan();
  61160. if (minMaxSpan.minValueSpan != null || minMaxSpan.maxValueSpan != null) {
  61161. minMax = sliderMove(
  61162. 0, minMax.slice(), axis.scale.getExtent(), 0,
  61163. minMaxSpan.minValueSpan, minMaxSpan.maxValueSpan
  61164. );
  61165. }
  61166. dataZoomModel && (snapshot[dataZoomModel.id] = {
  61167. dataZoomId: dataZoomModel.id,
  61168. startValue: minMax[0],
  61169. endValue: minMax[1]
  61170. });
  61171. }
  61172. function findDataZoom(dimName, axisModel, ecModel) {
  61173. var found;
  61174. ecModel.eachComponent({mainType: 'dataZoom', subType: 'select'}, function (dzModel) {
  61175. var has = dzModel.getAxisModel(dimName, axisModel.componentIndex);
  61176. has && (found = dzModel);
  61177. });
  61178. return found;
  61179. }
  61180. };
  61181. /**
  61182. * @private
  61183. */
  61184. proto._dispatchZoomAction = function (snapshot) {
  61185. var batch = [];
  61186. // Convert from hash map to array.
  61187. each(snapshot, function (batchItem, dataZoomId) {
  61188. batch.push(zrUtil.clone(batchItem));
  61189. });
  61190. batch.length && this.api.dispatchAction({
  61191. type: 'dataZoom',
  61192. from: this.uid,
  61193. batch: batch
  61194. });
  61195. };
  61196. function retrieveAxisSetting(option) {
  61197. var setting = {};
  61198. // Compatible with previous setting: null => all axis, false => no axis.
  61199. zrUtil.each(['xAxisIndex', 'yAxisIndex'], function (name) {
  61200. setting[name] = option[name];
  61201. setting[name] == null && (setting[name] = 'all');
  61202. (setting[name] === false || setting[name] === 'none') && (setting[name] = []);
  61203. });
  61204. return setting;
  61205. }
  61206. function updateBackBtnStatus(featureModel, ecModel) {
  61207. featureModel.setIconStatus(
  61208. 'back',
  61209. history.count(ecModel) > 1 ? 'emphasis' : 'normal'
  61210. );
  61211. }
  61212. function updateZoomBtnStatus(featureModel, ecModel, view, payload, api) {
  61213. var zoomActive = view._isZoomActive;
  61214. if (payload && payload.type === 'takeGlobalCursor') {
  61215. zoomActive = payload.key === 'dataZoomSelect'
  61216. ? payload.dataZoomSelectActive : false;
  61217. }
  61218. view._isZoomActive = zoomActive;
  61219. featureModel.setIconStatus('zoom', zoomActive ? 'emphasis' : 'normal');
  61220. var brushTargetManager = new BrushTargetManager(
  61221. retrieveAxisSetting(featureModel.option), ecModel, {include: ['grid']}
  61222. );
  61223. view._brushController
  61224. .setPanels(brushTargetManager.makePanelOpts(api, function (targetInfo) {
  61225. return (targetInfo.xAxisDeclared && !targetInfo.yAxisDeclared)
  61226. ? 'lineX'
  61227. : (!targetInfo.xAxisDeclared && targetInfo.yAxisDeclared)
  61228. ? 'lineY'
  61229. : 'rect';
  61230. }))
  61231. .enableBrush(
  61232. zoomActive
  61233. ? {
  61234. brushType: 'auto',
  61235. brushStyle: {
  61236. // FIXME user customized?
  61237. lineWidth: 0,
  61238. fill: 'rgba(0,0,0,0.2)'
  61239. }
  61240. }
  61241. : false
  61242. );
  61243. }
  61244. __webpack_require__(357).register('dataZoom', DataZoom);
  61245. // Create special dataZoom option for select
  61246. __webpack_require__(1).registerPreprocessor(function (option) {
  61247. if (!option) {
  61248. return;
  61249. }
  61250. var dataZoomOpts = option.dataZoom || (option.dataZoom = []);
  61251. if (!zrUtil.isArray(dataZoomOpts)) {
  61252. option.dataZoom = dataZoomOpts = [dataZoomOpts];
  61253. }
  61254. var toolboxOpt = option.toolbox;
  61255. if (toolboxOpt) {
  61256. // Assume there is only one toolbox
  61257. if (zrUtil.isArray(toolboxOpt)) {
  61258. toolboxOpt = toolboxOpt[0];
  61259. }
  61260. if (toolboxOpt && toolboxOpt.feature) {
  61261. var dataZoomOpt = toolboxOpt.feature.dataZoom;
  61262. addForAxis('xAxis', dataZoomOpt);
  61263. addForAxis('yAxis', dataZoomOpt);
  61264. }
  61265. }
  61266. function addForAxis(axisName, dataZoomOpt) {
  61267. if (!dataZoomOpt) {
  61268. return;
  61269. }
  61270. // Try not to modify model, because it is not merged yet.
  61271. var axisIndicesName = axisName + 'Index';
  61272. var givenAxisIndices = dataZoomOpt[axisIndicesName];
  61273. if (givenAxisIndices != null
  61274. && givenAxisIndices != 'all'
  61275. && !zrUtil.isArray(givenAxisIndices)
  61276. ) {
  61277. givenAxisIndices = (givenAxisIndices === false || givenAxisIndices === 'none') ? [] : [givenAxisIndices];
  61278. }
  61279. forEachComponent(axisName, function (axisOpt, axisIndex) {
  61280. if (givenAxisIndices != null
  61281. && givenAxisIndices != 'all'
  61282. && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1
  61283. ) {
  61284. return;
  61285. }
  61286. var newOpt = {
  61287. type: 'select',
  61288. $fromToolbox: true,
  61289. // Id for merge mapping.
  61290. id: DATA_ZOOM_ID_BASE + axisName + axisIndex
  61291. };
  61292. // FIXME
  61293. // Only support one axis now.
  61294. newOpt[axisIndicesName] = axisIndex;
  61295. dataZoomOpts.push(newOpt);
  61296. });
  61297. }
  61298. function forEachComponent(mainType, cb) {
  61299. var opts = option[mainType];
  61300. if (!zrUtil.isArray(opts)) {
  61301. opts = opts ? [opts] : [];
  61302. }
  61303. each(opts, cb);
  61304. }
  61305. });
  61306. module.exports = DataZoom;
  61307. /***/ },
  61308. /* 419 */
  61309. /***/ function(module, exports, __webpack_require__) {
  61310. /**
  61311. * @file History manager.
  61312. */
  61313. var zrUtil = __webpack_require__(4);
  61314. var each = zrUtil.each;
  61315. var ATTR = '\0_ec_hist_store';
  61316. var history = {
  61317. /**
  61318. * @public
  61319. * @param {module:echarts/model/Global} ecModel
  61320. * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]}
  61321. */
  61322. push: function (ecModel, newSnapshot) {
  61323. var store = giveStore(ecModel);
  61324. // If previous dataZoom can not be found,
  61325. // complete an range with current range.
  61326. each(newSnapshot, function (batchItem, dataZoomId) {
  61327. var i = store.length - 1;
  61328. for (; i >= 0; i--) {
  61329. var snapshot = store[i];
  61330. if (snapshot[dataZoomId]) {
  61331. break;
  61332. }
  61333. }
  61334. if (i < 0) {
  61335. // No origin range set, create one by current range.
  61336. var dataZoomModel = ecModel.queryComponents(
  61337. {mainType: 'dataZoom', subType: 'select', id: dataZoomId}
  61338. )[0];
  61339. if (dataZoomModel) {
  61340. var percentRange = dataZoomModel.getPercentRange();
  61341. store[0][dataZoomId] = {
  61342. dataZoomId: dataZoomId,
  61343. start: percentRange[0],
  61344. end: percentRange[1]
  61345. };
  61346. }
  61347. }
  61348. });
  61349. store.push(newSnapshot);
  61350. },
  61351. /**
  61352. * @public
  61353. * @param {module:echarts/model/Global} ecModel
  61354. * @return {Object} snapshot
  61355. */
  61356. pop: function (ecModel) {
  61357. var store = giveStore(ecModel);
  61358. var head = store[store.length - 1];
  61359. store.length > 1 && store.pop();
  61360. // Find top for all dataZoom.
  61361. var snapshot = {};
  61362. each(head, function (batchItem, dataZoomId) {
  61363. for (var i = store.length - 1; i >= 0; i--) {
  61364. var batchItem = store[i][dataZoomId];
  61365. if (batchItem) {
  61366. snapshot[dataZoomId] = batchItem;
  61367. break;
  61368. }
  61369. }
  61370. });
  61371. return snapshot;
  61372. },
  61373. /**
  61374. * @public
  61375. */
  61376. clear: function (ecModel) {
  61377. ecModel[ATTR] = null;
  61378. },
  61379. /**
  61380. * @public
  61381. * @param {module:echarts/model/Global} ecModel
  61382. * @return {number} records. always >= 1.
  61383. */
  61384. count: function (ecModel) {
  61385. return giveStore(ecModel).length;
  61386. }
  61387. };
  61388. /**
  61389. * [{key: dataZoomId, value: {dataZoomId, range}}, ...]
  61390. * History length of each dataZoom may be different.
  61391. * this._history[0] is used to store origin range.
  61392. * @type {Array.<Object>}
  61393. */
  61394. function giveStore(ecModel) {
  61395. var store = ecModel[ATTR];
  61396. if (!store) {
  61397. store = ecModel[ATTR] = [{}];
  61398. }
  61399. return store;
  61400. }
  61401. module.exports = history;
  61402. /***/ },
  61403. /* 420 */
  61404. /***/ function(module, exports, __webpack_require__) {
  61405. /**
  61406. * DataZoom component entry
  61407. */
  61408. __webpack_require__(364);
  61409. __webpack_require__(365);
  61410. __webpack_require__(368);
  61411. __webpack_require__(421);
  61412. __webpack_require__(422);
  61413. __webpack_require__(374);
  61414. __webpack_require__(375);
  61415. /***/ },
  61416. /* 421 */
  61417. /***/ function(module, exports, __webpack_require__) {
  61418. /**
  61419. * @file Data zoom model
  61420. */
  61421. var DataZoomModel = __webpack_require__(365);
  61422. module.exports = DataZoomModel.extend({
  61423. type: 'dataZoom.select'
  61424. });
  61425. /***/ },
  61426. /* 422 */
  61427. /***/ function(module, exports, __webpack_require__) {
  61428. module.exports = __webpack_require__(368).extend({
  61429. type: 'dataZoom.select'
  61430. });
  61431. /***/ },
  61432. /* 423 */
  61433. /***/ function(module, exports, __webpack_require__) {
  61434. 'use strict';
  61435. var history = __webpack_require__(419);
  61436. function Restore(model) {
  61437. this.model = model;
  61438. }
  61439. Restore.defaultOption = {
  61440. show: true,
  61441. 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',
  61442. title: '还原'
  61443. };
  61444. var proto = Restore.prototype;
  61445. proto.onclick = function (ecModel, api, type) {
  61446. history.clear(ecModel);
  61447. api.dispatchAction({
  61448. type: 'restore',
  61449. from: this.uid
  61450. });
  61451. };
  61452. __webpack_require__(357).register('restore', Restore);
  61453. __webpack_require__(1).registerAction(
  61454. {type: 'restore', event: 'restore', update: 'prepareAndUpdate'},
  61455. function (payload, ecModel) {
  61456. ecModel.resetOption('recreate');
  61457. }
  61458. );
  61459. module.exports = Restore;
  61460. /***/ },
  61461. /* 424 */
  61462. /***/ function(module, exports, __webpack_require__) {
  61463. __webpack_require__(425);
  61464. __webpack_require__(82).registerPainter('vml', __webpack_require__(427));
  61465. /***/ },
  61466. /* 425 */
  61467. /***/ function(module, exports, __webpack_require__) {
  61468. // http://www.w3.org/TR/NOTE-VML
  61469. // TODO Use proxy like svg instead of overwrite brush methods
  61470. if (!__webpack_require__(2).canvasSupported) {
  61471. var vec2 = __webpack_require__(10);
  61472. var BoundingRect = __webpack_require__(9);
  61473. var CMD = __webpack_require__(36).CMD;
  61474. var colorTool = __webpack_require__(31);
  61475. var textContain = __webpack_require__(8);
  61476. var RectText = __webpack_require__(35);
  61477. var Displayable = __webpack_require__(21);
  61478. var ZImage = __webpack_require__(49);
  61479. var Text = __webpack_require__(50);
  61480. var Path = __webpack_require__(20);
  61481. var PathProxy = __webpack_require__(36);
  61482. var Gradient = __webpack_require__(66);
  61483. var vmlCore = __webpack_require__(426);
  61484. var round = Math.round;
  61485. var sqrt = Math.sqrt;
  61486. var abs = Math.abs;
  61487. var cos = Math.cos;
  61488. var sin = Math.sin;
  61489. var mathMax = Math.max;
  61490. var applyTransform = vec2.applyTransform;
  61491. var comma = ',';
  61492. var imageTransformPrefix = 'progid:DXImageTransform.Microsoft';
  61493. var Z = 21600;
  61494. var Z2 = Z / 2;
  61495. var ZLEVEL_BASE = 100000;
  61496. var Z_BASE = 1000;
  61497. var initRootElStyle = function (el) {
  61498. el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;';
  61499. el.coordsize = Z + ',' + Z;
  61500. el.coordorigin = '0,0';
  61501. };
  61502. var encodeHtmlAttribute = function (s) {
  61503. return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
  61504. };
  61505. var rgb2Str = function (r, g, b) {
  61506. return 'rgb(' + [r, g, b].join(',') + ')';
  61507. };
  61508. var append = function (parent, child) {
  61509. if (child && parent && child.parentNode !== parent) {
  61510. parent.appendChild(child);
  61511. }
  61512. };
  61513. var remove = function (parent, child) {
  61514. if (child && parent && child.parentNode === parent) {
  61515. parent.removeChild(child);
  61516. }
  61517. };
  61518. var getZIndex = function (zlevel, z, z2) {
  61519. // z 的取值范围为 [0, 1000]
  61520. return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2;
  61521. };
  61522. var parsePercent = function (value, maxValue) {
  61523. if (typeof value === 'string') {
  61524. if (value.lastIndexOf('%') >= 0) {
  61525. return parseFloat(value) / 100 * maxValue;
  61526. }
  61527. return parseFloat(value);
  61528. }
  61529. return value;
  61530. };
  61531. /***************************************************
  61532. * PATH
  61533. **************************************************/
  61534. var setColorAndOpacity = function (el, color, opacity) {
  61535. var colorArr = colorTool.parse(color);
  61536. opacity = +opacity;
  61537. if (isNaN(opacity)) {
  61538. opacity = 1;
  61539. }
  61540. if (colorArr) {
  61541. el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]);
  61542. el.opacity = opacity * colorArr[3];
  61543. }
  61544. };
  61545. var getColorAndAlpha = function (color) {
  61546. var colorArr = colorTool.parse(color);
  61547. return [
  61548. rgb2Str(colorArr[0], colorArr[1], colorArr[2]),
  61549. colorArr[3]
  61550. ];
  61551. };
  61552. var updateFillNode = function (el, style, zrEl) {
  61553. // TODO pattern
  61554. var fill = style.fill;
  61555. if (fill != null) {
  61556. // Modified from excanvas
  61557. if (fill instanceof Gradient) {
  61558. var gradientType;
  61559. var angle = 0;
  61560. var focus = [0, 0];
  61561. // additional offset
  61562. var shift = 0;
  61563. // scale factor for offset
  61564. var expansion = 1;
  61565. var rect = zrEl.getBoundingRect();
  61566. var rectWidth = rect.width;
  61567. var rectHeight = rect.height;
  61568. if (fill.type === 'linear') {
  61569. gradientType = 'gradient';
  61570. var transform = zrEl.transform;
  61571. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  61572. var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight];
  61573. if (transform) {
  61574. applyTransform(p0, p0, transform);
  61575. applyTransform(p1, p1, transform);
  61576. }
  61577. var dx = p1[0] - p0[0];
  61578. var dy = p1[1] - p0[1];
  61579. angle = Math.atan2(dx, dy) * 180 / Math.PI;
  61580. // The angle should be a non-negative number.
  61581. if (angle < 0) {
  61582. angle += 360;
  61583. }
  61584. // Very small angles produce an unexpected result because they are
  61585. // converted to a scientific notation string.
  61586. if (angle < 1e-6) {
  61587. angle = 0;
  61588. }
  61589. }
  61590. else {
  61591. gradientType = 'gradientradial';
  61592. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  61593. var transform = zrEl.transform;
  61594. var scale = zrEl.scale;
  61595. var width = rectWidth;
  61596. var height = rectHeight;
  61597. focus = [
  61598. // Percent in bounding rect
  61599. (p0[0] - rect.x) / width,
  61600. (p0[1] - rect.y) / height
  61601. ];
  61602. if (transform) {
  61603. applyTransform(p0, p0, transform);
  61604. }
  61605. width /= scale[0] * Z;
  61606. height /= scale[1] * Z;
  61607. var dimension = mathMax(width, height);
  61608. shift = 2 * 0 / dimension;
  61609. expansion = 2 * fill.r / dimension - shift;
  61610. }
  61611. // We need to sort the color stops in ascending order by offset,
  61612. // otherwise IE won't interpret it correctly.
  61613. var stops = fill.colorStops.slice();
  61614. stops.sort(function(cs1, cs2) {
  61615. return cs1.offset - cs2.offset;
  61616. });
  61617. var length = stops.length;
  61618. // Color and alpha list of first and last stop
  61619. var colorAndAlphaList = [];
  61620. var colors = [];
  61621. for (var i = 0; i < length; i++) {
  61622. var stop = stops[i];
  61623. var colorAndAlpha = getColorAndAlpha(stop.color);
  61624. colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]);
  61625. if (i === 0 || i === length - 1) {
  61626. colorAndAlphaList.push(colorAndAlpha);
  61627. }
  61628. }
  61629. if (length >= 2) {
  61630. var color1 = colorAndAlphaList[0][0];
  61631. var color2 = colorAndAlphaList[1][0];
  61632. var opacity1 = colorAndAlphaList[0][1] * style.opacity;
  61633. var opacity2 = colorAndAlphaList[1][1] * style.opacity;
  61634. el.type = gradientType;
  61635. el.method = 'none';
  61636. el.focus = '100%';
  61637. el.angle = angle;
  61638. el.color = color1;
  61639. el.color2 = color2;
  61640. el.colors = colors.join(',');
  61641. // When colors attribute is used, the meanings of opacity and o:opacity2
  61642. // are reversed.
  61643. el.opacity = opacity2;
  61644. // FIXME g_o_:opacity ?
  61645. el.opacity2 = opacity1;
  61646. }
  61647. if (gradientType === 'radial') {
  61648. el.focusposition = focus.join(',');
  61649. }
  61650. }
  61651. else {
  61652. // FIXME Change from Gradient fill to color fill
  61653. setColorAndOpacity(el, fill, style.opacity);
  61654. }
  61655. }
  61656. };
  61657. var updateStrokeNode = function (el, style) {
  61658. // if (style.lineJoin != null) {
  61659. // el.joinstyle = style.lineJoin;
  61660. // }
  61661. // if (style.miterLimit != null) {
  61662. // el.miterlimit = style.miterLimit * Z;
  61663. // }
  61664. // if (style.lineCap != null) {
  61665. // el.endcap = style.lineCap;
  61666. // }
  61667. if (style.lineDash != null) {
  61668. el.dashstyle = style.lineDash.join(' ');
  61669. }
  61670. if (style.stroke != null && !(style.stroke instanceof Gradient)) {
  61671. setColorAndOpacity(el, style.stroke, style.opacity);
  61672. }
  61673. };
  61674. var updateFillAndStroke = function (vmlEl, type, style, zrEl) {
  61675. var isFill = type == 'fill';
  61676. var el = vmlEl.getElementsByTagName(type)[0];
  61677. // Stroke must have lineWidth
  61678. if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) {
  61679. vmlEl[isFill ? 'filled' : 'stroked'] = 'true';
  61680. // FIXME Remove before updating, or set `colors` will throw error
  61681. if (style[type] instanceof Gradient) {
  61682. remove(vmlEl, el);
  61683. }
  61684. if (!el) {
  61685. el = vmlCore.createNode(type);
  61686. }
  61687. isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style);
  61688. append(vmlEl, el);
  61689. }
  61690. else {
  61691. vmlEl[isFill ? 'filled' : 'stroked'] = 'false';
  61692. remove(vmlEl, el);
  61693. }
  61694. };
  61695. var points = [[], [], []];
  61696. var pathDataToString = function (data, m) {
  61697. var M = CMD.M;
  61698. var C = CMD.C;
  61699. var L = CMD.L;
  61700. var A = CMD.A;
  61701. var Q = CMD.Q;
  61702. var str = [];
  61703. var nPoint;
  61704. var cmdStr;
  61705. var cmd;
  61706. var i;
  61707. var xi;
  61708. var yi;
  61709. for (i = 0; i < data.length;) {
  61710. cmd = data[i++];
  61711. cmdStr = '';
  61712. nPoint = 0;
  61713. switch (cmd) {
  61714. case M:
  61715. cmdStr = ' m ';
  61716. nPoint = 1;
  61717. xi = data[i++];
  61718. yi = data[i++];
  61719. points[0][0] = xi;
  61720. points[0][1] = yi;
  61721. break;
  61722. case L:
  61723. cmdStr = ' l ';
  61724. nPoint = 1;
  61725. xi = data[i++];
  61726. yi = data[i++];
  61727. points[0][0] = xi;
  61728. points[0][1] = yi;
  61729. break;
  61730. case Q:
  61731. case C:
  61732. cmdStr = ' c ';
  61733. nPoint = 3;
  61734. var x1 = data[i++];
  61735. var y1 = data[i++];
  61736. var x2 = data[i++];
  61737. var y2 = data[i++];
  61738. var x3;
  61739. var y3;
  61740. if (cmd === Q) {
  61741. // Convert quadratic to cubic using degree elevation
  61742. x3 = x2;
  61743. y3 = y2;
  61744. x2 = (x2 + 2 * x1) / 3;
  61745. y2 = (y2 + 2 * y1) / 3;
  61746. x1 = (xi + 2 * x1) / 3;
  61747. y1 = (yi + 2 * y1) / 3;
  61748. }
  61749. else {
  61750. x3 = data[i++];
  61751. y3 = data[i++];
  61752. }
  61753. points[0][0] = x1;
  61754. points[0][1] = y1;
  61755. points[1][0] = x2;
  61756. points[1][1] = y2;
  61757. points[2][0] = x3;
  61758. points[2][1] = y3;
  61759. xi = x3;
  61760. yi = y3;
  61761. break;
  61762. case A:
  61763. var x = 0;
  61764. var y = 0;
  61765. var sx = 1;
  61766. var sy = 1;
  61767. var angle = 0;
  61768. if (m) {
  61769. // Extract SRT from matrix
  61770. x = m[4];
  61771. y = m[5];
  61772. sx = sqrt(m[0] * m[0] + m[1] * m[1]);
  61773. sy = sqrt(m[2] * m[2] + m[3] * m[3]);
  61774. angle = Math.atan2(-m[1] / sy, m[0] / sx);
  61775. }
  61776. var cx = data[i++];
  61777. var cy = data[i++];
  61778. var rx = data[i++];
  61779. var ry = data[i++];
  61780. var startAngle = data[i++] + angle;
  61781. var endAngle = data[i++] + startAngle + angle;
  61782. // FIXME
  61783. // var psi = data[i++];
  61784. i++;
  61785. var clockwise = data[i++];
  61786. var x0 = cx + cos(startAngle) * rx;
  61787. var y0 = cy + sin(startAngle) * ry;
  61788. var x1 = cx + cos(endAngle) * rx;
  61789. var y1 = cy + sin(endAngle) * ry;
  61790. var type = clockwise ? ' wa ' : ' at ';
  61791. if (Math.abs(x0 - x1) < 1e-4) {
  61792. // IE won't render arches drawn counter clockwise if x0 == x1.
  61793. if (Math.abs(endAngle - startAngle) > 1e-2) {
  61794. // Offset x0 by 1/80 of a pixel. Use something
  61795. // that can be represented in binary
  61796. if (clockwise) {
  61797. x0 += 270 / Z;
  61798. }
  61799. }
  61800. else {
  61801. // Avoid case draw full circle
  61802. if (Math.abs(y0 - cy) < 1e-4) {
  61803. if ((clockwise && x0 < cx) || (!clockwise && x0 > cx)) {
  61804. y1 -= 270 / Z;
  61805. }
  61806. else {
  61807. y1 += 270 / Z;
  61808. }
  61809. }
  61810. else if ((clockwise && y0 < cy) || (!clockwise && y0 > cy)) {
  61811. x1 += 270 / Z;
  61812. }
  61813. else {
  61814. x1 -= 270 / Z;
  61815. }
  61816. }
  61817. }
  61818. str.push(
  61819. type,
  61820. round(((cx - rx) * sx + x) * Z - Z2), comma,
  61821. round(((cy - ry) * sy + y) * Z - Z2), comma,
  61822. round(((cx + rx) * sx + x) * Z - Z2), comma,
  61823. round(((cy + ry) * sy + y) * Z - Z2), comma,
  61824. round((x0 * sx + x) * Z - Z2), comma,
  61825. round((y0 * sy + y) * Z - Z2), comma,
  61826. round((x1 * sx + x) * Z - Z2), comma,
  61827. round((y1 * sy + y) * Z - Z2)
  61828. );
  61829. xi = x1;
  61830. yi = y1;
  61831. break;
  61832. case CMD.R:
  61833. var p0 = points[0];
  61834. var p1 = points[1];
  61835. // x0, y0
  61836. p0[0] = data[i++];
  61837. p0[1] = data[i++];
  61838. // x1, y1
  61839. p1[0] = p0[0] + data[i++];
  61840. p1[1] = p0[1] + data[i++];
  61841. if (m) {
  61842. applyTransform(p0, p0, m);
  61843. applyTransform(p1, p1, m);
  61844. }
  61845. p0[0] = round(p0[0] * Z - Z2);
  61846. p1[0] = round(p1[0] * Z - Z2);
  61847. p0[1] = round(p0[1] * Z - Z2);
  61848. p1[1] = round(p1[1] * Z - Z2);
  61849. str.push(
  61850. // x0, y0
  61851. ' m ', p0[0], comma, p0[1],
  61852. // x1, y0
  61853. ' l ', p1[0], comma, p0[1],
  61854. // x1, y1
  61855. ' l ', p1[0], comma, p1[1],
  61856. // x0, y1
  61857. ' l ', p0[0], comma, p1[1]
  61858. );
  61859. break;
  61860. case CMD.Z:
  61861. // FIXME Update xi, yi
  61862. str.push(' x ');
  61863. }
  61864. if (nPoint > 0) {
  61865. str.push(cmdStr);
  61866. for (var k = 0; k < nPoint; k++) {
  61867. var p = points[k];
  61868. m && applyTransform(p, p, m);
  61869. // 不 round 会非常慢
  61870. str.push(
  61871. round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2),
  61872. k < nPoint - 1 ? comma : ''
  61873. );
  61874. }
  61875. }
  61876. }
  61877. return str.join('');
  61878. };
  61879. // Rewrite the original path method
  61880. Path.prototype.brushVML = function (vmlRoot) {
  61881. var style = this.style;
  61882. var vmlEl = this._vmlEl;
  61883. if (!vmlEl) {
  61884. vmlEl = vmlCore.createNode('shape');
  61885. initRootElStyle(vmlEl);
  61886. this._vmlEl = vmlEl;
  61887. }
  61888. updateFillAndStroke(vmlEl, 'fill', style, this);
  61889. updateFillAndStroke(vmlEl, 'stroke', style, this);
  61890. var m = this.transform;
  61891. var needTransform = m != null;
  61892. var strokeEl = vmlEl.getElementsByTagName('stroke')[0];
  61893. if (strokeEl) {
  61894. var lineWidth = style.lineWidth;
  61895. // Get the line scale.
  61896. // Determinant of this.m_ means how much the area is enlarged by the
  61897. // transformation. So its square root can be used as a scale factor
  61898. // for width.
  61899. if (needTransform && !style.strokeNoScale) {
  61900. var det = m[0] * m[3] - m[1] * m[2];
  61901. lineWidth *= sqrt(abs(det));
  61902. }
  61903. strokeEl.weight = lineWidth + 'px';
  61904. }
  61905. var path = this.path || (this.path = new PathProxy());
  61906. if (this.__dirtyPath) {
  61907. path.beginPath();
  61908. this.buildPath(path, this.shape);
  61909. path.toStatic();
  61910. this.__dirtyPath = false;
  61911. }
  61912. vmlEl.path = pathDataToString(path.data, this.transform);
  61913. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  61914. // Append to root
  61915. append(vmlRoot, vmlEl);
  61916. // Text
  61917. if (style.text != null) {
  61918. this.drawRectText(vmlRoot, this.getBoundingRect());
  61919. }
  61920. else {
  61921. this.removeRectText(vmlRoot);
  61922. }
  61923. };
  61924. Path.prototype.onRemove = function (vmlRoot) {
  61925. remove(vmlRoot, this._vmlEl);
  61926. this.removeRectText(vmlRoot);
  61927. };
  61928. Path.prototype.onAdd = function (vmlRoot) {
  61929. append(vmlRoot, this._vmlEl);
  61930. this.appendRectText(vmlRoot);
  61931. };
  61932. /***************************************************
  61933. * IMAGE
  61934. **************************************************/
  61935. var isImage = function (img) {
  61936. // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错
  61937. return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG';
  61938. // return img instanceof Image;
  61939. };
  61940. // Rewrite the original path method
  61941. ZImage.prototype.brushVML = function (vmlRoot) {
  61942. var style = this.style;
  61943. var image = style.image;
  61944. // Image original width, height
  61945. var ow;
  61946. var oh;
  61947. if (isImage(image)) {
  61948. var src = image.src;
  61949. if (src === this._imageSrc) {
  61950. ow = this._imageWidth;
  61951. oh = this._imageHeight;
  61952. }
  61953. else {
  61954. var imageRuntimeStyle = image.runtimeStyle;
  61955. var oldRuntimeWidth = imageRuntimeStyle.width;
  61956. var oldRuntimeHeight = imageRuntimeStyle.height;
  61957. imageRuntimeStyle.width = 'auto';
  61958. imageRuntimeStyle.height = 'auto';
  61959. // get the original size
  61960. ow = image.width;
  61961. oh = image.height;
  61962. // and remove overides
  61963. imageRuntimeStyle.width = oldRuntimeWidth;
  61964. imageRuntimeStyle.height = oldRuntimeHeight;
  61965. // Caching image original width, height and src
  61966. this._imageSrc = src;
  61967. this._imageWidth = ow;
  61968. this._imageHeight = oh;
  61969. }
  61970. image = src;
  61971. }
  61972. else {
  61973. if (image === this._imageSrc) {
  61974. ow = this._imageWidth;
  61975. oh = this._imageHeight;
  61976. }
  61977. }
  61978. if (!image) {
  61979. return;
  61980. }
  61981. var x = style.x || 0;
  61982. var y = style.y || 0;
  61983. var dw = style.width;
  61984. var dh = style.height;
  61985. var sw = style.sWidth;
  61986. var sh = style.sHeight;
  61987. var sx = style.sx || 0;
  61988. var sy = style.sy || 0;
  61989. var hasCrop = sw && sh;
  61990. var vmlEl = this._vmlEl;
  61991. if (!vmlEl) {
  61992. // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。
  61993. // vmlEl = vmlCore.createNode('group');
  61994. vmlEl = vmlCore.doc.createElement('div');
  61995. initRootElStyle(vmlEl);
  61996. this._vmlEl = vmlEl;
  61997. }
  61998. var vmlElStyle = vmlEl.style;
  61999. var hasRotation = false;
  62000. var m;
  62001. var scaleX = 1;
  62002. var scaleY = 1;
  62003. if (this.transform) {
  62004. m = this.transform;
  62005. scaleX = sqrt(m[0] * m[0] + m[1] * m[1]);
  62006. scaleY = sqrt(m[2] * m[2] + m[3] * m[3]);
  62007. hasRotation = m[1] || m[2];
  62008. }
  62009. if (hasRotation) {
  62010. // If filters are necessary (rotation exists), create them
  62011. // filters are bog-slow, so only create them if abbsolutely necessary
  62012. // The following check doesn't account for skews (which don't exist
  62013. // in the canvas spec (yet) anyway.
  62014. // From excanvas
  62015. var p0 = [x, y];
  62016. var p1 = [x + dw, y];
  62017. var p2 = [x, y + dh];
  62018. var p3 = [x + dw, y + dh];
  62019. applyTransform(p0, p0, m);
  62020. applyTransform(p1, p1, m);
  62021. applyTransform(p2, p2, m);
  62022. applyTransform(p3, p3, m);
  62023. var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]);
  62024. var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]);
  62025. var transformFilter = [];
  62026. transformFilter.push('M11=', m[0] / scaleX, comma,
  62027. 'M12=', m[2] / scaleY, comma,
  62028. 'M21=', m[1] / scaleX, comma,
  62029. 'M22=', m[3] / scaleY, comma,
  62030. 'Dx=', round(x * scaleX + m[4]), comma,
  62031. 'Dy=', round(y * scaleY + m[5]));
  62032. vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0';
  62033. // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用
  62034. vmlElStyle.filter = imageTransformPrefix + '.Matrix('
  62035. + transformFilter.join('') + ', SizingMethod=clip)';
  62036. }
  62037. else {
  62038. if (m) {
  62039. x = x * scaleX + m[4];
  62040. y = y * scaleY + m[5];
  62041. }
  62042. vmlElStyle.filter = '';
  62043. vmlElStyle.left = round(x) + 'px';
  62044. vmlElStyle.top = round(y) + 'px';
  62045. }
  62046. var imageEl = this._imageEl;
  62047. var cropEl = this._cropEl;
  62048. if (!imageEl) {
  62049. imageEl = vmlCore.doc.createElement('div');
  62050. this._imageEl = imageEl;
  62051. }
  62052. var imageELStyle = imageEl.style;
  62053. if (hasCrop) {
  62054. // Needs know image original width and height
  62055. if (! (ow && oh)) {
  62056. var tmpImage = new Image();
  62057. var self = this;
  62058. tmpImage.onload = function () {
  62059. tmpImage.onload = null;
  62060. ow = tmpImage.width;
  62061. oh = tmpImage.height;
  62062. // Adjust image width and height to fit the ratio destinationSize / sourceSize
  62063. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  62064. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  62065. // Caching image original width, height and src
  62066. self._imageWidth = ow;
  62067. self._imageHeight = oh;
  62068. self._imageSrc = image;
  62069. };
  62070. tmpImage.src = image;
  62071. }
  62072. else {
  62073. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  62074. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  62075. }
  62076. if (! cropEl) {
  62077. cropEl = vmlCore.doc.createElement('div');
  62078. cropEl.style.overflow = 'hidden';
  62079. this._cropEl = cropEl;
  62080. }
  62081. var cropElStyle = cropEl.style;
  62082. cropElStyle.width = round((dw + sx * dw / sw) * scaleX);
  62083. cropElStyle.height = round((dh + sy * dh / sh) * scaleY);
  62084. cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx='
  62085. + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')';
  62086. if (! cropEl.parentNode) {
  62087. vmlEl.appendChild(cropEl);
  62088. }
  62089. if (imageEl.parentNode != cropEl) {
  62090. cropEl.appendChild(imageEl);
  62091. }
  62092. }
  62093. else {
  62094. imageELStyle.width = round(scaleX * dw) + 'px';
  62095. imageELStyle.height = round(scaleY * dh) + 'px';
  62096. vmlEl.appendChild(imageEl);
  62097. if (cropEl && cropEl.parentNode) {
  62098. vmlEl.removeChild(cropEl);
  62099. this._cropEl = null;
  62100. }
  62101. }
  62102. var filterStr = '';
  62103. var alpha = style.opacity;
  62104. if (alpha < 1) {
  62105. filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') ';
  62106. }
  62107. filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)';
  62108. imageELStyle.filter = filterStr;
  62109. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  62110. // Append to root
  62111. append(vmlRoot, vmlEl);
  62112. // Text
  62113. if (style.text != null) {
  62114. this.drawRectText(vmlRoot, this.getBoundingRect());
  62115. }
  62116. };
  62117. ZImage.prototype.onRemove = function (vmlRoot) {
  62118. remove(vmlRoot, this._vmlEl);
  62119. this._vmlEl = null;
  62120. this._cropEl = null;
  62121. this._imageEl = null;
  62122. this.removeRectText(vmlRoot);
  62123. };
  62124. ZImage.prototype.onAdd = function (vmlRoot) {
  62125. append(vmlRoot, this._vmlEl);
  62126. this.appendRectText(vmlRoot);
  62127. };
  62128. /***************************************************
  62129. * TEXT
  62130. **************************************************/
  62131. var DEFAULT_STYLE_NORMAL = 'normal';
  62132. var fontStyleCache = {};
  62133. var fontStyleCacheCount = 0;
  62134. var MAX_FONT_CACHE_SIZE = 100;
  62135. var fontEl = document.createElement('div');
  62136. var getFontStyle = function (fontString) {
  62137. var fontStyle = fontStyleCache[fontString];
  62138. if (!fontStyle) {
  62139. // Clear cache
  62140. if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) {
  62141. fontStyleCacheCount = 0;
  62142. fontStyleCache = {};
  62143. }
  62144. var style = fontEl.style;
  62145. var fontFamily;
  62146. try {
  62147. style.font = fontString;
  62148. fontFamily = style.fontFamily.split(',')[0];
  62149. }
  62150. catch (e) {
  62151. }
  62152. fontStyle = {
  62153. style: style.fontStyle || DEFAULT_STYLE_NORMAL,
  62154. variant: style.fontVariant || DEFAULT_STYLE_NORMAL,
  62155. weight: style.fontWeight || DEFAULT_STYLE_NORMAL,
  62156. size: parseFloat(style.fontSize || 12) | 0,
  62157. family: fontFamily || 'Microsoft YaHei'
  62158. };
  62159. fontStyleCache[fontString] = fontStyle;
  62160. fontStyleCacheCount++;
  62161. }
  62162. return fontStyle;
  62163. };
  62164. var textMeasureEl;
  62165. // Overwrite measure text method
  62166. textContain.measureText = function (text, textFont) {
  62167. var doc = vmlCore.doc;
  62168. if (!textMeasureEl) {
  62169. textMeasureEl = doc.createElement('div');
  62170. textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;'
  62171. + 'padding:0;margin:0;border:none;white-space:pre;';
  62172. vmlCore.doc.body.appendChild(textMeasureEl);
  62173. }
  62174. try {
  62175. textMeasureEl.style.font = textFont;
  62176. } catch (ex) {
  62177. // Ignore failures to set to invalid font.
  62178. }
  62179. textMeasureEl.innerHTML = '';
  62180. // Don't use innerHTML or innerText because they allow markup/whitespace.
  62181. textMeasureEl.appendChild(doc.createTextNode(text));
  62182. return {
  62183. width: textMeasureEl.offsetWidth
  62184. };
  62185. };
  62186. var tmpRect = new BoundingRect();
  62187. var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) {
  62188. var style = this.style;
  62189. var text = style.text;
  62190. // Convert to string
  62191. text != null && (text += '');
  62192. if (!text) {
  62193. return;
  62194. }
  62195. var x;
  62196. var y;
  62197. var align = style.textAlign;
  62198. var fontStyle = getFontStyle(style.textFont);
  62199. // FIXME encodeHtmlAttribute ?
  62200. var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' '
  62201. + fontStyle.size + 'px "' + fontStyle.family + '"';
  62202. var baseline = style.textBaseline;
  62203. var verticalAlign = style.textVerticalAlign;
  62204. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  62205. // Transform rect to view space
  62206. var m = this.transform;
  62207. // Ignore transform for text in other element
  62208. if (m && !fromTextEl) {
  62209. tmpRect.copy(rect);
  62210. tmpRect.applyTransform(m);
  62211. rect = tmpRect;
  62212. }
  62213. if (!fromTextEl) {
  62214. var textPosition = style.textPosition;
  62215. var distance = style.textDistance;
  62216. // Text position represented by coord
  62217. if (textPosition instanceof Array) {
  62218. x = rect.x + parsePercent(textPosition[0], rect.width);
  62219. y = rect.y + parsePercent(textPosition[1], rect.height);
  62220. align = align || 'left';
  62221. baseline = baseline || 'top';
  62222. }
  62223. else {
  62224. var res = textContain.adjustTextPositionOnRect(
  62225. textPosition, rect, textRect, distance
  62226. );
  62227. x = res.x;
  62228. y = res.y;
  62229. // Default align and baseline when has textPosition
  62230. align = align || res.textAlign;
  62231. baseline = baseline || res.textBaseline;
  62232. }
  62233. }
  62234. else {
  62235. x = rect.x;
  62236. y = rect.y;
  62237. }
  62238. if (verticalAlign) {
  62239. switch (verticalAlign) {
  62240. case 'middle':
  62241. y -= textRect.height / 2;
  62242. break;
  62243. case 'bottom':
  62244. y -= textRect.height;
  62245. break;
  62246. // 'top'
  62247. }
  62248. // Ignore baseline
  62249. baseline = 'top';
  62250. }
  62251. var fontSize = fontStyle.size;
  62252. // 1.75 is an arbitrary number, as there is no info about the text baseline
  62253. switch (baseline) {
  62254. case 'hanging':
  62255. case 'top':
  62256. y += fontSize / 1.75;
  62257. break;
  62258. case 'middle':
  62259. break;
  62260. default:
  62261. // case null:
  62262. // case 'alphabetic':
  62263. // case 'ideographic':
  62264. // case 'bottom':
  62265. y -= fontSize / 2.25;
  62266. break;
  62267. }
  62268. switch (align) {
  62269. case 'left':
  62270. break;
  62271. case 'center':
  62272. x -= textRect.width / 2;
  62273. break;
  62274. case 'right':
  62275. x -= textRect.width;
  62276. break;
  62277. // case 'end':
  62278. // align = elementStyle.direction == 'ltr' ? 'right' : 'left';
  62279. // break;
  62280. // case 'start':
  62281. // align = elementStyle.direction == 'rtl' ? 'right' : 'left';
  62282. // break;
  62283. // default:
  62284. // align = 'left';
  62285. }
  62286. var createNode = vmlCore.createNode;
  62287. var textVmlEl = this._textVmlEl;
  62288. var pathEl;
  62289. var textPathEl;
  62290. var skewEl;
  62291. if (!textVmlEl) {
  62292. textVmlEl = createNode('line');
  62293. pathEl = createNode('path');
  62294. textPathEl = createNode('textpath');
  62295. skewEl = createNode('skew');
  62296. // FIXME Why here is not cammel case
  62297. // Align 'center' seems wrong
  62298. textPathEl.style['v-text-align'] = 'left';
  62299. initRootElStyle(textVmlEl);
  62300. pathEl.textpathok = true;
  62301. textPathEl.on = true;
  62302. textVmlEl.from = '0 0';
  62303. textVmlEl.to = '1000 0.05';
  62304. append(textVmlEl, skewEl);
  62305. append(textVmlEl, pathEl);
  62306. append(textVmlEl, textPathEl);
  62307. this._textVmlEl = textVmlEl;
  62308. }
  62309. else {
  62310. // 这里是在前面 appendChild 保证顺序的前提下
  62311. skewEl = textVmlEl.firstChild;
  62312. pathEl = skewEl.nextSibling;
  62313. textPathEl = pathEl.nextSibling;
  62314. }
  62315. var coords = [x, y];
  62316. var textVmlElStyle = textVmlEl.style;
  62317. // Ignore transform for text in other element
  62318. if (m && fromTextEl) {
  62319. applyTransform(coords, coords, m);
  62320. skewEl.on = true;
  62321. skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma +
  62322. m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0';
  62323. // Text position
  62324. skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0);
  62325. // Left top point as origin
  62326. skewEl.origin = '0 0';
  62327. textVmlElStyle.left = '0px';
  62328. textVmlElStyle.top = '0px';
  62329. }
  62330. else {
  62331. skewEl.on = false;
  62332. textVmlElStyle.left = round(x) + 'px';
  62333. textVmlElStyle.top = round(y) + 'px';
  62334. }
  62335. textPathEl.string = encodeHtmlAttribute(text);
  62336. // TODO
  62337. try {
  62338. textPathEl.style.font = font;
  62339. }
  62340. // Error font format
  62341. catch (e) {}
  62342. updateFillAndStroke(textVmlEl, 'fill', {
  62343. fill: fromTextEl ? style.fill : style.textFill,
  62344. opacity: style.opacity
  62345. }, this);
  62346. updateFillAndStroke(textVmlEl, 'stroke', {
  62347. stroke: fromTextEl ? style.stroke : style.textStroke,
  62348. opacity: style.opacity,
  62349. lineDash: style.lineDash
  62350. }, this);
  62351. textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  62352. // Attached to root
  62353. append(vmlRoot, textVmlEl);
  62354. };
  62355. var removeRectText = function (vmlRoot) {
  62356. remove(vmlRoot, this._textVmlEl);
  62357. this._textVmlEl = null;
  62358. };
  62359. var appendRectText = function (vmlRoot) {
  62360. append(vmlRoot, this._textVmlEl);
  62361. };
  62362. var list = [RectText, Displayable, ZImage, Path, Text];
  62363. // In case Displayable has been mixed in RectText
  62364. for (var i = 0; i < list.length; i++) {
  62365. var proto = list[i].prototype;
  62366. proto.drawRectText = drawRectText;
  62367. proto.removeRectText = removeRectText;
  62368. proto.appendRectText = appendRectText;
  62369. }
  62370. Text.prototype.brushVML = function (vmlRoot) {
  62371. var style = this.style;
  62372. if (style.text != null) {
  62373. this.drawRectText(vmlRoot, {
  62374. x: style.x || 0, y: style.y || 0,
  62375. width: 0, height: 0
  62376. }, this.getBoundingRect(), true);
  62377. }
  62378. else {
  62379. this.removeRectText(vmlRoot);
  62380. }
  62381. };
  62382. Text.prototype.onRemove = function (vmlRoot) {
  62383. this.removeRectText(vmlRoot);
  62384. };
  62385. Text.prototype.onAdd = function (vmlRoot) {
  62386. this.appendRectText(vmlRoot);
  62387. };
  62388. }
  62389. /***/ },
  62390. /* 426 */
  62391. /***/ function(module, exports, __webpack_require__) {
  62392. if (!__webpack_require__(2).canvasSupported) {
  62393. var urn = 'urn:schemas-microsoft-com:vml';
  62394. var createNode;
  62395. var win = window;
  62396. var doc = win.document;
  62397. var vmlInited = false;
  62398. try {
  62399. !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn);
  62400. createNode = function (tagName) {
  62401. return doc.createElement('<zrvml:' + tagName + ' class="zrvml">');
  62402. };
  62403. }
  62404. catch (e) {
  62405. createNode = function (tagName) {
  62406. return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">');
  62407. };
  62408. }
  62409. // From raphael
  62410. var initVML = function () {
  62411. if (vmlInited) {
  62412. return;
  62413. }
  62414. vmlInited = true;
  62415. var styleSheets = doc.styleSheets;
  62416. if (styleSheets.length < 31) {
  62417. doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)');
  62418. }
  62419. else {
  62420. // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx
  62421. styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)');
  62422. }
  62423. };
  62424. // Not useing return to avoid error when converting to CommonJS module
  62425. module.exports = {
  62426. doc: doc,
  62427. initVML: initVML,
  62428. createNode: createNode
  62429. };
  62430. }
  62431. /***/ },
  62432. /* 427 */
  62433. /***/ function(module, exports, __webpack_require__) {
  62434. /**
  62435. * VML Painter.
  62436. *
  62437. * @module zrender/vml/Painter
  62438. */
  62439. var zrLog = __webpack_require__(33);
  62440. var vmlCore = __webpack_require__(426);
  62441. function parseInt10(val) {
  62442. return parseInt(val, 10);
  62443. }
  62444. /**
  62445. * @alias module:zrender/vml/Painter
  62446. */
  62447. function VMLPainter(root, storage) {
  62448. vmlCore.initVML();
  62449. this.root = root;
  62450. this.storage = storage;
  62451. var vmlViewport = document.createElement('div');
  62452. var vmlRoot = document.createElement('div');
  62453. vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;';
  62454. vmlRoot.style.cssText = 'position:absolute;left:0;top:0;';
  62455. root.appendChild(vmlViewport);
  62456. this._vmlRoot = vmlRoot;
  62457. this._vmlViewport = vmlViewport;
  62458. this.resize();
  62459. // Modify storage
  62460. var oldDelFromStorage = storage.delFromStorage;
  62461. var oldAddToStorage = storage.addToStorage;
  62462. storage.delFromStorage = function (el) {
  62463. oldDelFromStorage.call(storage, el);
  62464. if (el) {
  62465. el.onRemove && el.onRemove(vmlRoot);
  62466. }
  62467. };
  62468. storage.addToStorage = function (el) {
  62469. // Displayable already has a vml node
  62470. el.onAdd && el.onAdd(vmlRoot);
  62471. oldAddToStorage.call(storage, el);
  62472. };
  62473. this._firstPaint = true;
  62474. }
  62475. VMLPainter.prototype = {
  62476. constructor: VMLPainter,
  62477. /**
  62478. * @return {HTMLDivElement}
  62479. */
  62480. getViewportRoot: function () {
  62481. return this._vmlViewport;
  62482. },
  62483. /**
  62484. * 刷新
  62485. */
  62486. refresh: function () {
  62487. var list = this.storage.getDisplayList(true, true);
  62488. this._paintList(list);
  62489. },
  62490. _paintList: function (list) {
  62491. var vmlRoot = this._vmlRoot;
  62492. for (var i = 0; i < list.length; i++) {
  62493. var el = list[i];
  62494. if (el.invisible || el.ignore) {
  62495. if (!el.__alreadyNotVisible) {
  62496. el.onRemove(vmlRoot);
  62497. }
  62498. // Set as already invisible
  62499. el.__alreadyNotVisible = true;
  62500. }
  62501. else {
  62502. if (el.__alreadyNotVisible) {
  62503. el.onAdd(vmlRoot);
  62504. }
  62505. el.__alreadyNotVisible = false;
  62506. if (el.__dirty) {
  62507. el.beforeBrush && el.beforeBrush();
  62508. (el.brushVML || el.brush).call(el, vmlRoot);
  62509. el.afterBrush && el.afterBrush();
  62510. }
  62511. }
  62512. el.__dirty = false;
  62513. }
  62514. if (this._firstPaint) {
  62515. // Detached from document at first time
  62516. // to avoid page refreshing too many times
  62517. // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变
  62518. this._vmlViewport.appendChild(vmlRoot);
  62519. this._firstPaint = false;
  62520. }
  62521. },
  62522. resize: function (width, height) {
  62523. var width = width == null ? this._getWidth() : width;
  62524. var height = height == null ? this._getHeight() : height;
  62525. if (this._width != width || this._height != height) {
  62526. this._width = width;
  62527. this._height = height;
  62528. var vmlViewportStyle = this._vmlViewport.style;
  62529. vmlViewportStyle.width = width + 'px';
  62530. vmlViewportStyle.height = height + 'px';
  62531. }
  62532. },
  62533. dispose: function () {
  62534. this.root.innerHTML = '';
  62535. this._vmlRoot =
  62536. this._vmlViewport =
  62537. this.storage = null;
  62538. },
  62539. getWidth: function () {
  62540. return this._width;
  62541. },
  62542. getHeight: function () {
  62543. return this._height;
  62544. },
  62545. clear: function () {
  62546. if (this._vmlViewport) {
  62547. this.root.removeChild(this._vmlViewport);
  62548. }
  62549. },
  62550. _getWidth: function () {
  62551. var root = this.root;
  62552. var stl = root.currentStyle;
  62553. return ((root.clientWidth || parseInt10(stl.width))
  62554. - parseInt10(stl.paddingLeft)
  62555. - parseInt10(stl.paddingRight)) | 0;
  62556. },
  62557. _getHeight: function () {
  62558. var root = this.root;
  62559. var stl = root.currentStyle;
  62560. return ((root.clientHeight || parseInt10(stl.height))
  62561. - parseInt10(stl.paddingTop)
  62562. - parseInt10(stl.paddingBottom)) | 0;
  62563. }
  62564. };
  62565. // Not supported methods
  62566. function createMethodNotSupport(method) {
  62567. return function () {
  62568. zrLog('In IE8.0 VML mode painter not support method "' + method + '"');
  62569. };
  62570. }
  62571. var notSupportedMethods = [
  62572. 'getLayer', 'insertLayer', 'eachLayer', 'eachBuiltinLayer', 'eachOtherLayer', 'getLayers',
  62573. 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage'
  62574. ];
  62575. for (var i = 0; i < notSupportedMethods.length; i++) {
  62576. var name = notSupportedMethods[i];
  62577. VMLPainter.prototype[name] = createMethodNotSupport(name);
  62578. }
  62579. module.exports = VMLPainter;
  62580. /***/ }
  62581. /******/ ])
  62582. });
  62583. ;